babylon.module.d.ts 6.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static get LogCache(): string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static set LogLevels(level: number);
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/stringTools" {
  378. /**
  379. * Helper to manipulate strings
  380. */
  381. export class StringTools {
  382. /**
  383. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  384. * @param str Source string
  385. * @param suffix Suffix to search for in the source string
  386. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  387. */
  388. static EndsWith(str: string, suffix: string): boolean;
  389. /**
  390. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  391. * @param str Source string
  392. * @param suffix Suffix to search for in the source string
  393. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  394. */
  395. static StartsWith(str: string, suffix: string): boolean;
  396. /**
  397. * Decodes a buffer into a string
  398. * @param buffer The buffer to decode
  399. * @returns The decoded string
  400. */
  401. static Decode(buffer: Uint8Array | Uint16Array): string;
  402. /**
  403. * Encode a buffer to a base64 string
  404. * @param buffer defines the buffer to encode
  405. * @returns the encoded string
  406. */
  407. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  408. }
  409. }
  410. declare module "babylonjs/Misc/deepCopier" {
  411. /**
  412. * Class containing a set of static utilities functions for deep copy.
  413. */
  414. export class DeepCopier {
  415. /**
  416. * Tries to copy an object by duplicating every property
  417. * @param source defines the source object
  418. * @param destination defines the target object
  419. * @param doNotCopyList defines a list of properties to avoid
  420. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  421. */
  422. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  423. }
  424. }
  425. declare module "babylonjs/Misc/precisionDate" {
  426. /**
  427. * Class containing a set of static utilities functions for precision date
  428. */
  429. export class PrecisionDate {
  430. /**
  431. * Gets either window.performance.now() if supported or Date.now() else
  432. */
  433. static get Now(): number;
  434. }
  435. }
  436. declare module "babylonjs/Misc/devTools" {
  437. /** @hidden */
  438. export class _DevTools {
  439. static WarnImport(name: string): string;
  440. }
  441. }
  442. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  443. /**
  444. * Interface used to define the mechanism to get data from the network
  445. */
  446. export interface IWebRequest {
  447. /**
  448. * Returns client's response url
  449. */
  450. responseURL: string;
  451. /**
  452. * Returns client's status
  453. */
  454. status: number;
  455. /**
  456. * Returns client's status as a text
  457. */
  458. statusText: string;
  459. }
  460. }
  461. declare module "babylonjs/Misc/webRequest" {
  462. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  463. import { Nullable } from "babylonjs/types";
  464. /**
  465. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  466. */
  467. export class WebRequest implements IWebRequest {
  468. private _xhr;
  469. /**
  470. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  471. * i.e. when loading files, where the server/service expects an Authorization header
  472. */
  473. static CustomRequestHeaders: {
  474. [key: string]: string;
  475. };
  476. /**
  477. * Add callback functions in this array to update all the requests before they get sent to the network
  478. */
  479. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  480. private _injectCustomRequestHeaders;
  481. /**
  482. * Gets or sets a function to be called when loading progress changes
  483. */
  484. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  485. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  486. /**
  487. * Returns client's state
  488. */
  489. get readyState(): number;
  490. /**
  491. * Returns client's status
  492. */
  493. get status(): number;
  494. /**
  495. * Returns client's status as a text
  496. */
  497. get statusText(): string;
  498. /**
  499. * Returns client's response
  500. */
  501. get response(): any;
  502. /**
  503. * Returns client's response url
  504. */
  505. get responseURL(): string;
  506. /**
  507. * Returns client's response as text
  508. */
  509. get responseText(): string;
  510. /**
  511. * Gets or sets the expected response type
  512. */
  513. get responseType(): XMLHttpRequestResponseType;
  514. set responseType(value: XMLHttpRequestResponseType);
  515. /** @hidden */
  516. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  517. /** @hidden */
  518. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  519. /**
  520. * Cancels any network activity
  521. */
  522. abort(): void;
  523. /**
  524. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  525. * @param body defines an optional request body
  526. */
  527. send(body?: Document | BodyInit | null): void;
  528. /**
  529. * Sets the request method, request URL
  530. * @param method defines the method to use (GET, POST, etc..)
  531. * @param url defines the url to connect with
  532. */
  533. open(method: string, url: string): void;
  534. /**
  535. * Sets the value of a request header.
  536. * @param name The name of the header whose value is to be set
  537. * @param value The value to set as the body of the header
  538. */
  539. setRequestHeader(name: string, value: string): void;
  540. /**
  541. * Get the string containing the text of a particular header's value.
  542. * @param name The name of the header
  543. * @returns The string containing the text of the given header name
  544. */
  545. getResponseHeader(name: string): Nullable<string>;
  546. }
  547. }
  548. declare module "babylonjs/Misc/fileRequest" {
  549. import { Observable } from "babylonjs/Misc/observable";
  550. /**
  551. * File request interface
  552. */
  553. export interface IFileRequest {
  554. /**
  555. * Raised when the request is complete (success or error).
  556. */
  557. onCompleteObservable: Observable<IFileRequest>;
  558. /**
  559. * Aborts the request for a file.
  560. */
  561. abort: () => void;
  562. }
  563. }
  564. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  565. /**
  566. * Define options used to create a render target texture
  567. */
  568. export class RenderTargetCreationOptions {
  569. /**
  570. * Specifies is mipmaps must be generated
  571. */
  572. generateMipMaps?: boolean;
  573. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  574. generateDepthBuffer?: boolean;
  575. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  576. generateStencilBuffer?: boolean;
  577. /** Defines texture type (int by default) */
  578. type?: number;
  579. /** Defines sampling mode (trilinear by default) */
  580. samplingMode?: number;
  581. /** Defines format (RGBA by default) */
  582. format?: number;
  583. }
  584. }
  585. declare module "babylonjs/Instrumentation/timeToken" {
  586. import { Nullable } from "babylonjs/types";
  587. /**
  588. * @hidden
  589. **/
  590. export class _TimeToken {
  591. _startTimeQuery: Nullable<WebGLQuery>;
  592. _endTimeQuery: Nullable<WebGLQuery>;
  593. _timeElapsedQuery: Nullable<WebGLQuery>;
  594. _timeElapsedQueryEnded: boolean;
  595. }
  596. }
  597. declare module "babylonjs/Engines/constants" {
  598. /** Defines the cross module used constants to avoid circular dependncies */
  599. export class Constants {
  600. /** Defines that alpha blending is disabled */
  601. static readonly ALPHA_DISABLE: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  603. static readonly ALPHA_ADD: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  605. static readonly ALPHA_COMBINE: number;
  606. /** Defines that alpha blending is DEST - SRC * DEST */
  607. static readonly ALPHA_SUBTRACT: number;
  608. /** Defines that alpha blending is SRC * DEST */
  609. static readonly ALPHA_MULTIPLY: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  611. static readonly ALPHA_MAXIMIZED: number;
  612. /** Defines that alpha blending is SRC + DEST */
  613. static readonly ALPHA_ONEONE: number;
  614. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  615. static readonly ALPHA_PREMULTIPLIED: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  618. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  621. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  622. static readonly ALPHA_INTERPOLATE: number;
  623. /**
  624. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  625. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  626. */
  627. static readonly ALPHA_SCREENMODE: number;
  628. /**
  629. * Defines that alpha blending is SRC + DST
  630. * Alpha will be set to SRC ALPHA + DST ALPHA
  631. */
  632. static readonly ALPHA_ONEONE_ONEONE: number;
  633. /**
  634. * Defines that alpha blending is SRC * DST ALPHA + DST
  635. * Alpha will be set to 0
  636. */
  637. static readonly ALPHA_ALPHATOCOLOR: number;
  638. /**
  639. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  640. */
  641. static readonly ALPHA_REVERSEONEMINUS: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  644. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  645. */
  646. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEZERO: number;
  652. /**
  653. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  654. * Alpha will be set to DST ALPHA
  655. */
  656. static readonly ALPHA_EXCLUSION: number;
  657. /** Defines that alpha blending equation a SUM */
  658. static readonly ALPHA_EQUATION_ADD: number;
  659. /** Defines that alpha blending equation a SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  661. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  663. /** Defines that alpha blending equation a MAX operation */
  664. static readonly ALPHA_EQUATION_MAX: number;
  665. /** Defines that alpha blending equation a MIN operation */
  666. static readonly ALPHA_EQUATION_MIN: number;
  667. /**
  668. * Defines that alpha blending equation a DARKEN operation:
  669. * It takes the min of the src and sums the alpha channels.
  670. */
  671. static readonly ALPHA_EQUATION_DARKEN: number;
  672. /** Defines that the ressource is not delayed*/
  673. static readonly DELAYLOADSTATE_NONE: number;
  674. /** Defines that the ressource was successfully delay loaded */
  675. static readonly DELAYLOADSTATE_LOADED: number;
  676. /** Defines that the ressource is currently delay loading */
  677. static readonly DELAYLOADSTATE_LOADING: number;
  678. /** Defines that the ressource is delayed and has not started loading */
  679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  681. static readonly NEVER: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  683. static readonly ALWAYS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  685. static readonly LESS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  687. static readonly EQUAL: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  689. static readonly LEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  691. static readonly GREATER: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  693. static readonly GEQUAL: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  695. static readonly NOTEQUAL: number;
  696. /** Passed to stencilOperation to specify that stencil value must be kept */
  697. static readonly KEEP: number;
  698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  699. static readonly REPLACE: number;
  700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  701. static readonly INCR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  703. static readonly DECR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  705. static readonly INVERT: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  707. static readonly INCR_WRAP: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  709. static readonly DECR_WRAP: number;
  710. /** Texture is not repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  712. /** Texture is repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  714. /** Texture is repeating and mirrored */
  715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  716. /** ALPHA */
  717. static readonly TEXTUREFORMAT_ALPHA: number;
  718. /** LUMINANCE */
  719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  720. /** LUMINANCE_ALPHA */
  721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  722. /** RGB */
  723. static readonly TEXTUREFORMAT_RGB: number;
  724. /** RGBA */
  725. static readonly TEXTUREFORMAT_RGBA: number;
  726. /** RED */
  727. static readonly TEXTUREFORMAT_RED: number;
  728. /** RED (2nd reference) */
  729. static readonly TEXTUREFORMAT_R: number;
  730. /** RG */
  731. static readonly TEXTUREFORMAT_RG: number;
  732. /** RED_INTEGER */
  733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  734. /** RED_INTEGER (2nd reference) */
  735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  736. /** RG_INTEGER */
  737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  738. /** RGB_INTEGER */
  739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  740. /** RGBA_INTEGER */
  741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  742. /** UNSIGNED_BYTE */
  743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  744. /** UNSIGNED_BYTE (2nd reference) */
  745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  746. /** FLOAT */
  747. static readonly TEXTURETYPE_FLOAT: number;
  748. /** HALF_FLOAT */
  749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  750. /** BYTE */
  751. static readonly TEXTURETYPE_BYTE: number;
  752. /** SHORT */
  753. static readonly TEXTURETYPE_SHORT: number;
  754. /** UNSIGNED_SHORT */
  755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  756. /** INT */
  757. static readonly TEXTURETYPE_INT: number;
  758. /** UNSIGNED_INT */
  759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  760. /** UNSIGNED_SHORT_4_4_4_4 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  762. /** UNSIGNED_SHORT_5_5_5_1 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  764. /** UNSIGNED_SHORT_5_6_5 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  766. /** UNSIGNED_INT_2_10_10_10_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  768. /** UNSIGNED_INT_24_8 */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  770. /** UNSIGNED_INT_10F_11F_11F_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  772. /** UNSIGNED_INT_5_9_9_9_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  776. /** nearest is mag = nearest and min = nearest and no mip */
  777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  778. /** mag = nearest and min = nearest and mip = none */
  779. static readonly TEXTURE_NEAREST_NEAREST: number;
  780. /** Bilinear is mag = linear and min = linear and no mip */
  781. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  782. /** mag = linear and min = linear and mip = none */
  783. static readonly TEXTURE_LINEAR_LINEAR: number;
  784. /** Trilinear is mag = linear and min = linear and mip = linear */
  785. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  788. /** mag = nearest and min = nearest and mip = nearest */
  789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = nearest */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = linear */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = linear and mip = none */
  795. static readonly TEXTURE_NEAREST_LINEAR: number;
  796. /** nearest is mag = nearest and min = nearest and mip = linear */
  797. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  798. /** mag = linear and min = nearest and mip = nearest */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = linear */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  802. /** Bilinear is mag = linear and min = linear and mip = nearest */
  803. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  804. /** mag = linear and min = nearest and mip = none */
  805. static readonly TEXTURE_LINEAR_NEAREST: number;
  806. /** Explicit coordinates mode */
  807. static readonly TEXTURE_EXPLICIT_MODE: number;
  808. /** Spherical coordinates mode */
  809. static readonly TEXTURE_SPHERICAL_MODE: number;
  810. /** Planar coordinates mode */
  811. static readonly TEXTURE_PLANAR_MODE: number;
  812. /** Cubic coordinates mode */
  813. static readonly TEXTURE_CUBIC_MODE: number;
  814. /** Projection coordinates mode */
  815. static readonly TEXTURE_PROJECTION_MODE: number;
  816. /** Skybox coordinates mode */
  817. static readonly TEXTURE_SKYBOX_MODE: number;
  818. /** Inverse Cubic coordinates mode */
  819. static readonly TEXTURE_INVCUBIC_MODE: number;
  820. /** Equirectangular coordinates mode */
  821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed Mirrored coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  826. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  827. static readonly SCALEMODE_FLOOR: number;
  828. /** Defines that texture rescaling will look for the nearest power of 2 size */
  829. static readonly SCALEMODE_NEAREST: number;
  830. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  831. static readonly SCALEMODE_CEILING: number;
  832. /**
  833. * The dirty texture flag value
  834. */
  835. static readonly MATERIAL_TextureDirtyFlag: number;
  836. /**
  837. * The dirty light flag value
  838. */
  839. static readonly MATERIAL_LightDirtyFlag: number;
  840. /**
  841. * The dirty fresnel flag value
  842. */
  843. static readonly MATERIAL_FresnelDirtyFlag: number;
  844. /**
  845. * The dirty attribute flag value
  846. */
  847. static readonly MATERIAL_AttributesDirtyFlag: number;
  848. /**
  849. * The dirty misc flag value
  850. */
  851. static readonly MATERIAL_MiscDirtyFlag: number;
  852. /**
  853. * The all dirty flag value
  854. */
  855. static readonly MATERIAL_AllDirtyFlag: number;
  856. /**
  857. * Returns the triangle fill mode
  858. */
  859. static readonly MATERIAL_TriangleFillMode: number;
  860. /**
  861. * Returns the wireframe mode
  862. */
  863. static readonly MATERIAL_WireFrameFillMode: number;
  864. /**
  865. * Returns the point fill mode
  866. */
  867. static readonly MATERIAL_PointFillMode: number;
  868. /**
  869. * Returns the point list draw mode
  870. */
  871. static readonly MATERIAL_PointListDrawMode: number;
  872. /**
  873. * Returns the line list draw mode
  874. */
  875. static readonly MATERIAL_LineListDrawMode: number;
  876. /**
  877. * Returns the line loop draw mode
  878. */
  879. static readonly MATERIAL_LineLoopDrawMode: number;
  880. /**
  881. * Returns the line strip draw mode
  882. */
  883. static readonly MATERIAL_LineStripDrawMode: number;
  884. /**
  885. * Returns the triangle strip draw mode
  886. */
  887. static readonly MATERIAL_TriangleStripDrawMode: number;
  888. /**
  889. * Returns the triangle fan draw mode
  890. */
  891. static readonly MATERIAL_TriangleFanDrawMode: number;
  892. /**
  893. * Stores the clock-wise side orientation
  894. */
  895. static readonly MATERIAL_ClockWiseSideOrientation: number;
  896. /**
  897. * Stores the counter clock-wise side orientation
  898. */
  899. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  900. /**
  901. * Nothing
  902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  903. */
  904. static readonly ACTION_NothingTrigger: number;
  905. /**
  906. * On pick
  907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  908. */
  909. static readonly ACTION_OnPickTrigger: number;
  910. /**
  911. * On left pick
  912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  913. */
  914. static readonly ACTION_OnLeftPickTrigger: number;
  915. /**
  916. * On right pick
  917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  918. */
  919. static readonly ACTION_OnRightPickTrigger: number;
  920. /**
  921. * On center pick
  922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  923. */
  924. static readonly ACTION_OnCenterPickTrigger: number;
  925. /**
  926. * On pick down
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnPickDownTrigger: number;
  930. /**
  931. * On double pick
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnDoublePickTrigger: number;
  935. /**
  936. * On pick up
  937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  938. */
  939. static readonly ACTION_OnPickUpTrigger: number;
  940. /**
  941. * On pick out.
  942. * This trigger will only be raised if you also declared a OnPickDown
  943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  944. */
  945. static readonly ACTION_OnPickOutTrigger: number;
  946. /**
  947. * On long press
  948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  949. */
  950. static readonly ACTION_OnLongPressTrigger: number;
  951. /**
  952. * On pointer over
  953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  954. */
  955. static readonly ACTION_OnPointerOverTrigger: number;
  956. /**
  957. * On pointer out
  958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  959. */
  960. static readonly ACTION_OnPointerOutTrigger: number;
  961. /**
  962. * On every frame
  963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  964. */
  965. static readonly ACTION_OnEveryFrameTrigger: number;
  966. /**
  967. * On intersection enter
  968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  969. */
  970. static readonly ACTION_OnIntersectionEnterTrigger: number;
  971. /**
  972. * On intersection exit
  973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  974. */
  975. static readonly ACTION_OnIntersectionExitTrigger: number;
  976. /**
  977. * On key down
  978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  979. */
  980. static readonly ACTION_OnKeyDownTrigger: number;
  981. /**
  982. * On key up
  983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  984. */
  985. static readonly ACTION_OnKeyUpTrigger: number;
  986. /**
  987. * Billboard mode will only apply to Y axis
  988. */
  989. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  990. /**
  991. * Billboard mode will apply to all axes
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  994. /**
  995. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  998. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  999. * Test order :
  1000. * Is the bounding sphere outside the frustum ?
  1001. * If not, are the bounding box vertices outside the frustum ?
  1002. * It not, then the cullable object is in the frustum.
  1003. */
  1004. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1005. /** Culling strategy : Bounding Sphere Only.
  1006. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1007. * It's also less accurate than the standard because some not visible objects can still be selected.
  1008. * Test : is the bounding sphere outside the frustum ?
  1009. * If not, then the cullable object is in the frustum.
  1010. */
  1011. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1012. /** Culling strategy : Optimistic Inclusion.
  1013. * This in an inclusion test first, then the standard exclusion test.
  1014. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1015. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1016. * Anyway, it's as accurate as the standard strategy.
  1017. * Test :
  1018. * Is the cullable object bounding sphere center in the frustum ?
  1019. * If not, apply the default culling strategy.
  1020. */
  1021. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1022. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1023. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1024. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1025. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1026. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1027. * Test :
  1028. * Is the cullable object bounding sphere center in the frustum ?
  1029. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1030. */
  1031. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1032. /**
  1033. * No logging while loading
  1034. */
  1035. static readonly SCENELOADER_NO_LOGGING: number;
  1036. /**
  1037. * Minimal logging while loading
  1038. */
  1039. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1040. /**
  1041. * Summary logging while loading
  1042. */
  1043. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1044. /**
  1045. * Detailled logging while loading
  1046. */
  1047. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1048. }
  1049. }
  1050. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1051. import { Nullable } from "babylonjs/types";
  1052. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1053. /**
  1054. * This represents the required contract to create a new type of texture loader.
  1055. */
  1056. export interface IInternalTextureLoader {
  1057. /**
  1058. * Defines wether the loader supports cascade loading the different faces.
  1059. */
  1060. supportCascades: boolean;
  1061. /**
  1062. * This returns if the loader support the current file information.
  1063. * @param extension defines the file extension of the file being loaded
  1064. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1065. * @param fallback defines the fallback internal texture if any
  1066. * @param isBase64 defines whether the texture is encoded as a base64
  1067. * @param isBuffer defines whether the texture data are stored as a buffer
  1068. * @returns true if the loader can load the specified file
  1069. */
  1070. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1071. /**
  1072. * Transform the url before loading if required.
  1073. * @param rootUrl the url of the texture
  1074. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1075. * @returns the transformed texture
  1076. */
  1077. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1078. /**
  1079. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1080. * @param rootUrl the url of the texture
  1081. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1082. * @returns the fallback texture
  1083. */
  1084. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1085. /**
  1086. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1087. * @param data contains the texture data
  1088. * @param texture defines the BabylonJS internal texture
  1089. * @param createPolynomials will be true if polynomials have been requested
  1090. * @param onLoad defines the callback to trigger once the texture is ready
  1091. * @param onError defines the callback to trigger in case of error
  1092. */
  1093. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1094. /**
  1095. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1096. * @param data contains the texture data
  1097. * @param texture defines the BabylonJS internal texture
  1098. * @param callback defines the method to call once ready to upload
  1099. */
  1100. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1101. }
  1102. }
  1103. declare module "babylonjs/Engines/IPipelineContext" {
  1104. /**
  1105. * Class used to store and describe the pipeline context associated with an effect
  1106. */
  1107. export interface IPipelineContext {
  1108. /**
  1109. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1110. */
  1111. isAsync: boolean;
  1112. /**
  1113. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1114. */
  1115. isReady: boolean;
  1116. /** @hidden */
  1117. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1118. }
  1119. }
  1120. declare module "babylonjs/Meshes/dataBuffer" {
  1121. /**
  1122. * Class used to store gfx data (like WebGLBuffer)
  1123. */
  1124. export class DataBuffer {
  1125. /**
  1126. * Gets or sets the number of objects referencing this buffer
  1127. */
  1128. references: number;
  1129. /** Gets or sets the size of the underlying buffer */
  1130. capacity: number;
  1131. /**
  1132. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1133. */
  1134. is32Bits: boolean;
  1135. /**
  1136. * Gets the underlying buffer
  1137. */
  1138. get underlyingResource(): any;
  1139. }
  1140. }
  1141. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1142. /** @hidden */
  1143. export interface IShaderProcessor {
  1144. attributeProcessor?: (attribute: string) => string;
  1145. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1146. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1147. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1148. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1149. lineProcessor?: (line: string, isFragment: boolean) => string;
  1150. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1151. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1152. }
  1153. }
  1154. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1155. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1156. /** @hidden */
  1157. export interface ProcessingOptions {
  1158. defines: string[];
  1159. indexParameters: any;
  1160. isFragment: boolean;
  1161. shouldUseHighPrecisionShader: boolean;
  1162. supportsUniformBuffers: boolean;
  1163. shadersRepository: string;
  1164. includesShadersStore: {
  1165. [key: string]: string;
  1166. };
  1167. processor?: IShaderProcessor;
  1168. version: string;
  1169. platformName: string;
  1170. lookForClosingBracketForUniformBuffer?: boolean;
  1171. }
  1172. }
  1173. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1174. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1175. /** @hidden */
  1176. export class ShaderCodeNode {
  1177. line: string;
  1178. children: ShaderCodeNode[];
  1179. additionalDefineKey?: string;
  1180. additionalDefineValue?: string;
  1181. isValid(preprocessors: {
  1182. [key: string]: string;
  1183. }): boolean;
  1184. process(preprocessors: {
  1185. [key: string]: string;
  1186. }, options: ProcessingOptions): string;
  1187. }
  1188. }
  1189. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1190. /** @hidden */
  1191. export class ShaderCodeCursor {
  1192. private _lines;
  1193. lineIndex: number;
  1194. get currentLine(): string;
  1195. get canRead(): boolean;
  1196. set lines(value: string[]);
  1197. }
  1198. }
  1199. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1200. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1201. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1202. /** @hidden */
  1203. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1204. process(preprocessors: {
  1205. [key: string]: string;
  1206. }, options: ProcessingOptions): string;
  1207. }
  1208. }
  1209. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1210. /** @hidden */
  1211. export class ShaderDefineExpression {
  1212. isTrue(preprocessors: {
  1213. [key: string]: string;
  1214. }): boolean;
  1215. }
  1216. }
  1217. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1218. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1219. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1220. /** @hidden */
  1221. export class ShaderCodeTestNode extends ShaderCodeNode {
  1222. testExpression: ShaderDefineExpression;
  1223. isValid(preprocessors: {
  1224. [key: string]: string;
  1225. }): boolean;
  1226. }
  1227. }
  1228. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1229. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1230. /** @hidden */
  1231. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1232. define: string;
  1233. not: boolean;
  1234. constructor(define: string, not?: boolean);
  1235. isTrue(preprocessors: {
  1236. [key: string]: string;
  1237. }): boolean;
  1238. }
  1239. }
  1240. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1241. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1242. /** @hidden */
  1243. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1244. leftOperand: ShaderDefineExpression;
  1245. rightOperand: ShaderDefineExpression;
  1246. isTrue(preprocessors: {
  1247. [key: string]: string;
  1248. }): boolean;
  1249. }
  1250. }
  1251. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1252. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1253. /** @hidden */
  1254. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1255. leftOperand: ShaderDefineExpression;
  1256. rightOperand: ShaderDefineExpression;
  1257. isTrue(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1263. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1264. /** @hidden */
  1265. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1266. define: string;
  1267. operand: string;
  1268. testValue: string;
  1269. constructor(define: string, operand: string, testValue: string);
  1270. isTrue(preprocessors: {
  1271. [key: string]: string;
  1272. }): boolean;
  1273. }
  1274. }
  1275. declare module "babylonjs/Offline/IOfflineProvider" {
  1276. /**
  1277. * Class used to enable access to offline support
  1278. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1279. */
  1280. export interface IOfflineProvider {
  1281. /**
  1282. * Gets a boolean indicating if scene must be saved in the database
  1283. */
  1284. enableSceneOffline: boolean;
  1285. /**
  1286. * Gets a boolean indicating if textures must be saved in the database
  1287. */
  1288. enableTexturesOffline: boolean;
  1289. /**
  1290. * Open the offline support and make it available
  1291. * @param successCallback defines the callback to call on success
  1292. * @param errorCallback defines the callback to call on error
  1293. */
  1294. open(successCallback: () => void, errorCallback: () => void): void;
  1295. /**
  1296. * Loads an image from the offline support
  1297. * @param url defines the url to load from
  1298. * @param image defines the target DOM image
  1299. */
  1300. loadImage(url: string, image: HTMLImageElement): void;
  1301. /**
  1302. * Loads a file from offline support
  1303. * @param url defines the URL to load from
  1304. * @param sceneLoaded defines a callback to call on success
  1305. * @param progressCallBack defines a callback to call when progress changed
  1306. * @param errorCallback defines a callback to call on error
  1307. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1308. */
  1309. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1310. }
  1311. }
  1312. declare module "babylonjs/Misc/filesInputStore" {
  1313. /**
  1314. * Class used to help managing file picking and drag'n'drop
  1315. * File Storage
  1316. */
  1317. export class FilesInputStore {
  1318. /**
  1319. * List of files ready to be loaded
  1320. */
  1321. static FilesToLoad: {
  1322. [key: string]: File;
  1323. };
  1324. }
  1325. }
  1326. declare module "babylonjs/Misc/retryStrategy" {
  1327. import { WebRequest } from "babylonjs/Misc/webRequest";
  1328. /**
  1329. * Class used to define a retry strategy when error happens while loading assets
  1330. */
  1331. export class RetryStrategy {
  1332. /**
  1333. * Function used to defines an exponential back off strategy
  1334. * @param maxRetries defines the maximum number of retries (3 by default)
  1335. * @param baseInterval defines the interval between retries
  1336. * @returns the strategy function to use
  1337. */
  1338. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1339. }
  1340. }
  1341. declare module "babylonjs/Misc/baseError" {
  1342. /**
  1343. * @ignore
  1344. * Application error to support additional information when loading a file
  1345. */
  1346. export abstract class BaseError extends Error {
  1347. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1348. }
  1349. }
  1350. declare module "babylonjs/Misc/fileTools" {
  1351. import { WebRequest } from "babylonjs/Misc/webRequest";
  1352. import { Nullable } from "babylonjs/types";
  1353. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1354. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1355. import { BaseError } from "babylonjs/Misc/baseError";
  1356. /** @ignore */
  1357. export class LoadFileError extends BaseError {
  1358. request?: WebRequest;
  1359. file?: File;
  1360. /**
  1361. * Creates a new LoadFileError
  1362. * @param message defines the message of the error
  1363. * @param request defines the optional web request
  1364. * @param file defines the optional file
  1365. */
  1366. constructor(message: string, object?: WebRequest | File);
  1367. }
  1368. /** @ignore */
  1369. export class RequestFileError extends BaseError {
  1370. request: WebRequest;
  1371. /**
  1372. * Creates a new LoadFileError
  1373. * @param message defines the message of the error
  1374. * @param request defines the optional web request
  1375. */
  1376. constructor(message: string, request: WebRequest);
  1377. }
  1378. /** @ignore */
  1379. export class ReadFileError extends BaseError {
  1380. file: File;
  1381. /**
  1382. * Creates a new ReadFileError
  1383. * @param message defines the message of the error
  1384. * @param file defines the optional file
  1385. */
  1386. constructor(message: string, file: File);
  1387. }
  1388. /**
  1389. * @hidden
  1390. */
  1391. export class FileTools {
  1392. /**
  1393. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1394. */
  1395. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1396. /**
  1397. * Gets or sets the base URL to use to load assets
  1398. */
  1399. static BaseUrl: string;
  1400. /**
  1401. * Default behaviour for cors in the application.
  1402. * It can be a string if the expected behavior is identical in the entire app.
  1403. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1404. */
  1405. static CorsBehavior: string | ((url: string | string[]) => string);
  1406. /**
  1407. * Gets or sets a function used to pre-process url before using them to load assets
  1408. */
  1409. static PreprocessUrl: (url: string) => string;
  1410. /**
  1411. * Removes unwanted characters from an url
  1412. * @param url defines the url to clean
  1413. * @returns the cleaned url
  1414. */
  1415. private static _CleanUrl;
  1416. /**
  1417. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1418. * @param url define the url we are trying
  1419. * @param element define the dom element where to configure the cors policy
  1420. */
  1421. static SetCorsBehavior(url: string | string[], element: {
  1422. crossOrigin: string | null;
  1423. }): void;
  1424. /**
  1425. * Loads an image as an HTMLImageElement.
  1426. * @param input url string, ArrayBuffer, or Blob to load
  1427. * @param onLoad callback called when the image successfully loads
  1428. * @param onError callback called when the image fails to load
  1429. * @param offlineProvider offline provider for caching
  1430. * @param mimeType optional mime type
  1431. * @returns the HTMLImageElement of the loaded image
  1432. */
  1433. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1434. /**
  1435. * Reads a file from a File object
  1436. * @param file defines the file to load
  1437. * @param onSuccess defines the callback to call when data is loaded
  1438. * @param onProgress defines the callback to call during loading process
  1439. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1440. * @param onError defines the callback to call when an error occurs
  1441. * @returns a file request object
  1442. */
  1443. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1444. /**
  1445. * Loads a file from a url
  1446. * @param url url to load
  1447. * @param onSuccess callback called when the file successfully loads
  1448. * @param onProgress callback called while file is loading (if the server supports this mode)
  1449. * @param offlineProvider defines the offline provider for caching
  1450. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1451. * @param onError callback called when the file fails to load
  1452. * @returns a file request object
  1453. */
  1454. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1455. /**
  1456. * Loads a file
  1457. * @param url url to load
  1458. * @param onSuccess callback called when the file successfully loads
  1459. * @param onProgress callback called while file is loading (if the server supports this mode)
  1460. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1461. * @param onError callback called when the file fails to load
  1462. * @param onOpened callback called when the web request is opened
  1463. * @returns a file request object
  1464. */
  1465. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1466. /**
  1467. * Checks if the loaded document was accessed via `file:`-Protocol.
  1468. * @returns boolean
  1469. */
  1470. static IsFileURL(): boolean;
  1471. }
  1472. }
  1473. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1474. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1475. import { WebRequest } from "babylonjs/Misc/webRequest";
  1476. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1477. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1478. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1479. /** @hidden */
  1480. export class ShaderProcessor {
  1481. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1482. private static _ProcessPrecision;
  1483. private static _ExtractOperation;
  1484. private static _BuildSubExpression;
  1485. private static _BuildExpression;
  1486. private static _MoveCursorWithinIf;
  1487. private static _MoveCursor;
  1488. private static _EvaluatePreProcessors;
  1489. private static _PreparePreProcessors;
  1490. private static _ProcessShaderConversion;
  1491. private static _ProcessIncludes;
  1492. /**
  1493. * Loads a file from a url
  1494. * @param url url to load
  1495. * @param onSuccess callback called when the file successfully loads
  1496. * @param onProgress callback called while file is loading (if the server supports this mode)
  1497. * @param offlineProvider defines the offline provider for caching
  1498. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1499. * @param onError callback called when the file fails to load
  1500. * @returns a file request object
  1501. * @hidden
  1502. */
  1503. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1504. }
  1505. }
  1506. declare module "babylonjs/Maths/math.like" {
  1507. import { float, int, DeepImmutable } from "babylonjs/types";
  1508. /**
  1509. * @hidden
  1510. */
  1511. export interface IColor4Like {
  1512. r: float;
  1513. g: float;
  1514. b: float;
  1515. a: float;
  1516. }
  1517. /**
  1518. * @hidden
  1519. */
  1520. export interface IColor3Like {
  1521. r: float;
  1522. g: float;
  1523. b: float;
  1524. }
  1525. /**
  1526. * @hidden
  1527. */
  1528. export interface IVector4Like {
  1529. x: float;
  1530. y: float;
  1531. z: float;
  1532. w: float;
  1533. }
  1534. /**
  1535. * @hidden
  1536. */
  1537. export interface IVector3Like {
  1538. x: float;
  1539. y: float;
  1540. z: float;
  1541. }
  1542. /**
  1543. * @hidden
  1544. */
  1545. export interface IVector2Like {
  1546. x: float;
  1547. y: float;
  1548. }
  1549. /**
  1550. * @hidden
  1551. */
  1552. export interface IMatrixLike {
  1553. toArray(): DeepImmutable<Float32Array>;
  1554. updateFlag: int;
  1555. }
  1556. /**
  1557. * @hidden
  1558. */
  1559. export interface IViewportLike {
  1560. x: float;
  1561. y: float;
  1562. width: float;
  1563. height: float;
  1564. }
  1565. /**
  1566. * @hidden
  1567. */
  1568. export interface IPlaneLike {
  1569. normal: IVector3Like;
  1570. d: float;
  1571. normalize(): void;
  1572. }
  1573. }
  1574. declare module "babylonjs/Materials/iEffectFallbacks" {
  1575. import { Effect } from "babylonjs/Materials/effect";
  1576. /**
  1577. * Interface used to define common properties for effect fallbacks
  1578. */
  1579. export interface IEffectFallbacks {
  1580. /**
  1581. * Removes the defines that should be removed when falling back.
  1582. * @param currentDefines defines the current define statements for the shader.
  1583. * @param effect defines the current effect we try to compile
  1584. * @returns The resulting defines with defines of the current rank removed.
  1585. */
  1586. reduce(currentDefines: string, effect: Effect): string;
  1587. /**
  1588. * Removes the fallback from the bound mesh.
  1589. */
  1590. unBindMesh(): void;
  1591. /**
  1592. * Checks to see if more fallbacks are still availible.
  1593. */
  1594. hasMoreFallbacks: boolean;
  1595. }
  1596. }
  1597. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1598. /**
  1599. * Class used to evalaute queries containing `and` and `or` operators
  1600. */
  1601. export class AndOrNotEvaluator {
  1602. /**
  1603. * Evaluate a query
  1604. * @param query defines the query to evaluate
  1605. * @param evaluateCallback defines the callback used to filter result
  1606. * @returns true if the query matches
  1607. */
  1608. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1609. private static _HandleParenthesisContent;
  1610. private static _SimplifyNegation;
  1611. }
  1612. }
  1613. declare module "babylonjs/Misc/tags" {
  1614. /**
  1615. * Class used to store custom tags
  1616. */
  1617. export class Tags {
  1618. /**
  1619. * Adds support for tags on the given object
  1620. * @param obj defines the object to use
  1621. */
  1622. static EnableFor(obj: any): void;
  1623. /**
  1624. * Removes tags support
  1625. * @param obj defines the object to use
  1626. */
  1627. static DisableFor(obj: any): void;
  1628. /**
  1629. * Gets a boolean indicating if the given object has tags
  1630. * @param obj defines the object to use
  1631. * @returns a boolean
  1632. */
  1633. static HasTags(obj: any): boolean;
  1634. /**
  1635. * Gets the tags available on a given object
  1636. * @param obj defines the object to use
  1637. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1638. * @returns the tags
  1639. */
  1640. static GetTags(obj: any, asString?: boolean): any;
  1641. /**
  1642. * Adds tags to an object
  1643. * @param obj defines the object to use
  1644. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1645. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1646. */
  1647. static AddTagsTo(obj: any, tagsString: string): void;
  1648. /**
  1649. * @hidden
  1650. */
  1651. static _AddTagTo(obj: any, tag: string): void;
  1652. /**
  1653. * Removes specific tags from a specific object
  1654. * @param obj defines the object to use
  1655. * @param tagsString defines the tags to remove
  1656. */
  1657. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1658. /**
  1659. * @hidden
  1660. */
  1661. static _RemoveTagFrom(obj: any, tag: string): void;
  1662. /**
  1663. * Defines if tags hosted on an object match a given query
  1664. * @param obj defines the object to use
  1665. * @param tagsQuery defines the tag query
  1666. * @returns a boolean
  1667. */
  1668. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1669. }
  1670. }
  1671. declare module "babylonjs/Maths/math.scalar" {
  1672. /**
  1673. * Scalar computation library
  1674. */
  1675. export class Scalar {
  1676. /**
  1677. * Two pi constants convenient for computation.
  1678. */
  1679. static TwoPi: number;
  1680. /**
  1681. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1682. * @param a number
  1683. * @param b number
  1684. * @param epsilon (default = 1.401298E-45)
  1685. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1686. */
  1687. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1688. /**
  1689. * Returns a string : the upper case translation of the number i to hexadecimal.
  1690. * @param i number
  1691. * @returns the upper case translation of the number i to hexadecimal.
  1692. */
  1693. static ToHex(i: number): string;
  1694. /**
  1695. * Returns -1 if value is negative and +1 is value is positive.
  1696. * @param value the value
  1697. * @returns the value itself if it's equal to zero.
  1698. */
  1699. static Sign(value: number): number;
  1700. /**
  1701. * Returns the value itself if it's between min and max.
  1702. * Returns min if the value is lower than min.
  1703. * Returns max if the value is greater than max.
  1704. * @param value the value to clmap
  1705. * @param min the min value to clamp to (default: 0)
  1706. * @param max the max value to clamp to (default: 1)
  1707. * @returns the clamped value
  1708. */
  1709. static Clamp(value: number, min?: number, max?: number): number;
  1710. /**
  1711. * the log2 of value.
  1712. * @param value the value to compute log2 of
  1713. * @returns the log2 of value.
  1714. */
  1715. static Log2(value: number): number;
  1716. /**
  1717. * Loops the value, so that it is never larger than length and never smaller than 0.
  1718. *
  1719. * This is similar to the modulo operator but it works with floating point numbers.
  1720. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1721. * With t = 5 and length = 2.5, the result would be 0.0.
  1722. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1723. * @param value the value
  1724. * @param length the length
  1725. * @returns the looped value
  1726. */
  1727. static Repeat(value: number, length: number): number;
  1728. /**
  1729. * Normalize the value between 0.0 and 1.0 using min and max values
  1730. * @param value value to normalize
  1731. * @param min max to normalize between
  1732. * @param max min to normalize between
  1733. * @returns the normalized value
  1734. */
  1735. static Normalize(value: number, min: number, max: number): number;
  1736. /**
  1737. * Denormalize the value from 0.0 and 1.0 using min and max values
  1738. * @param normalized value to denormalize
  1739. * @param min max to denormalize between
  1740. * @param max min to denormalize between
  1741. * @returns the denormalized value
  1742. */
  1743. static Denormalize(normalized: number, min: number, max: number): number;
  1744. /**
  1745. * Calculates the shortest difference between two given angles given in degrees.
  1746. * @param current current angle in degrees
  1747. * @param target target angle in degrees
  1748. * @returns the delta
  1749. */
  1750. static DeltaAngle(current: number, target: number): number;
  1751. /**
  1752. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1753. * @param tx value
  1754. * @param length length
  1755. * @returns The returned value will move back and forth between 0 and length
  1756. */
  1757. static PingPong(tx: number, length: number): number;
  1758. /**
  1759. * Interpolates between min and max with smoothing at the limits.
  1760. *
  1761. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1762. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1763. * @param from from
  1764. * @param to to
  1765. * @param tx value
  1766. * @returns the smooth stepped value
  1767. */
  1768. static SmoothStep(from: number, to: number, tx: number): number;
  1769. /**
  1770. * Moves a value current towards target.
  1771. *
  1772. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1773. * Negative values of maxDelta pushes the value away from target.
  1774. * @param current current value
  1775. * @param target target value
  1776. * @param maxDelta max distance to move
  1777. * @returns resulting value
  1778. */
  1779. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1780. /**
  1781. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1782. *
  1783. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1784. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1785. * @param current current value
  1786. * @param target target value
  1787. * @param maxDelta max distance to move
  1788. * @returns resulting angle
  1789. */
  1790. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1791. /**
  1792. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1793. * @param start start value
  1794. * @param end target value
  1795. * @param amount amount to lerp between
  1796. * @returns the lerped value
  1797. */
  1798. static Lerp(start: number, end: number, amount: number): number;
  1799. /**
  1800. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1801. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1802. * @param start start value
  1803. * @param end target value
  1804. * @param amount amount to lerp between
  1805. * @returns the lerped value
  1806. */
  1807. static LerpAngle(start: number, end: number, amount: number): number;
  1808. /**
  1809. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1810. * @param a start value
  1811. * @param b target value
  1812. * @param value value between a and b
  1813. * @returns the inverseLerp value
  1814. */
  1815. static InverseLerp(a: number, b: number, value: number): number;
  1816. /**
  1817. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1818. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1819. * @param value1 spline value
  1820. * @param tangent1 spline value
  1821. * @param value2 spline value
  1822. * @param tangent2 spline value
  1823. * @param amount input value
  1824. * @returns hermite result
  1825. */
  1826. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1827. /**
  1828. * Returns a random float number between and min and max values
  1829. * @param min min value of random
  1830. * @param max max value of random
  1831. * @returns random value
  1832. */
  1833. static RandomRange(min: number, max: number): number;
  1834. /**
  1835. * This function returns percentage of a number in a given range.
  1836. *
  1837. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1838. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1839. * @param number to convert to percentage
  1840. * @param min min range
  1841. * @param max max range
  1842. * @returns the percentage
  1843. */
  1844. static RangeToPercent(number: number, min: number, max: number): number;
  1845. /**
  1846. * This function returns number that corresponds to the percentage in a given range.
  1847. *
  1848. * PercentToRange(0.34,0,100) will return 34.
  1849. * @param percent to convert to number
  1850. * @param min min range
  1851. * @param max max range
  1852. * @returns the number
  1853. */
  1854. static PercentToRange(percent: number, min: number, max: number): number;
  1855. /**
  1856. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1857. * @param angle The angle to normalize in radian.
  1858. * @return The converted angle.
  1859. */
  1860. static NormalizeRadians(angle: number): number;
  1861. }
  1862. }
  1863. declare module "babylonjs/Maths/math.constants" {
  1864. /**
  1865. * Constant used to convert a value to gamma space
  1866. * @ignorenaming
  1867. */
  1868. export const ToGammaSpace: number;
  1869. /**
  1870. * Constant used to convert a value to linear space
  1871. * @ignorenaming
  1872. */
  1873. export const ToLinearSpace = 2.2;
  1874. /**
  1875. * Constant used to define the minimal number value in Babylon.js
  1876. * @ignorenaming
  1877. */
  1878. let Epsilon: number;
  1879. export { Epsilon };
  1880. }
  1881. declare module "babylonjs/Maths/math.viewport" {
  1882. /**
  1883. * Class used to represent a viewport on screen
  1884. */
  1885. export class Viewport {
  1886. /** viewport left coordinate */
  1887. x: number;
  1888. /** viewport top coordinate */
  1889. y: number;
  1890. /**viewport width */
  1891. width: number;
  1892. /** viewport height */
  1893. height: number;
  1894. /**
  1895. * Creates a Viewport object located at (x, y) and sized (width, height)
  1896. * @param x defines viewport left coordinate
  1897. * @param y defines viewport top coordinate
  1898. * @param width defines the viewport width
  1899. * @param height defines the viewport height
  1900. */
  1901. constructor(
  1902. /** viewport left coordinate */
  1903. x: number,
  1904. /** viewport top coordinate */
  1905. y: number,
  1906. /**viewport width */
  1907. width: number,
  1908. /** viewport height */
  1909. height: number);
  1910. /**
  1911. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1912. * @param renderWidth defines the rendering width
  1913. * @param renderHeight defines the rendering height
  1914. * @returns a new Viewport
  1915. */
  1916. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1917. /**
  1918. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1919. * @param renderWidth defines the rendering width
  1920. * @param renderHeight defines the rendering height
  1921. * @param ref defines the target viewport
  1922. * @returns the current viewport
  1923. */
  1924. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1925. /**
  1926. * Returns a new Viewport copied from the current one
  1927. * @returns a new Viewport
  1928. */
  1929. clone(): Viewport;
  1930. }
  1931. }
  1932. declare module "babylonjs/Misc/arrayTools" {
  1933. /**
  1934. * Class containing a set of static utilities functions for arrays.
  1935. */
  1936. export class ArrayTools {
  1937. /**
  1938. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1939. * @param size the number of element to construct and put in the array
  1940. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1941. * @returns a new array filled with new objects
  1942. */
  1943. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1944. }
  1945. }
  1946. declare module "babylonjs/Maths/math.vector" {
  1947. import { Viewport } from "babylonjs/Maths/math.viewport";
  1948. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1949. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1950. /**
  1951. * Class representing a vector containing 2 coordinates
  1952. */
  1953. export class Vector2 {
  1954. /** defines the first coordinate */
  1955. x: number;
  1956. /** defines the second coordinate */
  1957. y: number;
  1958. /**
  1959. * Creates a new Vector2 from the given x and y coordinates
  1960. * @param x defines the first coordinate
  1961. * @param y defines the second coordinate
  1962. */
  1963. constructor(
  1964. /** defines the first coordinate */
  1965. x?: number,
  1966. /** defines the second coordinate */
  1967. y?: number);
  1968. /**
  1969. * Gets a string with the Vector2 coordinates
  1970. * @returns a string with the Vector2 coordinates
  1971. */
  1972. toString(): string;
  1973. /**
  1974. * Gets class name
  1975. * @returns the string "Vector2"
  1976. */
  1977. getClassName(): string;
  1978. /**
  1979. * Gets current vector hash code
  1980. * @returns the Vector2 hash code as a number
  1981. */
  1982. getHashCode(): number;
  1983. /**
  1984. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1985. * @param array defines the source array
  1986. * @param index defines the offset in source array
  1987. * @returns the current Vector2
  1988. */
  1989. toArray(array: FloatArray, index?: number): Vector2;
  1990. /**
  1991. * Copy the current vector to an array
  1992. * @returns a new array with 2 elements: the Vector2 coordinates.
  1993. */
  1994. asArray(): number[];
  1995. /**
  1996. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1997. * @param source defines the source Vector2
  1998. * @returns the current updated Vector2
  1999. */
  2000. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2001. /**
  2002. * Sets the Vector2 coordinates with the given floats
  2003. * @param x defines the first coordinate
  2004. * @param y defines the second coordinate
  2005. * @returns the current updated Vector2
  2006. */
  2007. copyFromFloats(x: number, y: number): Vector2;
  2008. /**
  2009. * Sets the Vector2 coordinates with the given floats
  2010. * @param x defines the first coordinate
  2011. * @param y defines the second coordinate
  2012. * @returns the current updated Vector2
  2013. */
  2014. set(x: number, y: number): Vector2;
  2015. /**
  2016. * Add another vector with the current one
  2017. * @param otherVector defines the other vector
  2018. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2019. */
  2020. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2021. /**
  2022. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2023. * @param otherVector defines the other vector
  2024. * @param result defines the target vector
  2025. * @returns the unmodified current Vector2
  2026. */
  2027. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2028. /**
  2029. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2030. * @param otherVector defines the other vector
  2031. * @returns the current updated Vector2
  2032. */
  2033. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2034. /**
  2035. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2036. * @param otherVector defines the other vector
  2037. * @returns a new Vector2
  2038. */
  2039. addVector3(otherVector: Vector3): Vector2;
  2040. /**
  2041. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2042. * @param otherVector defines the other vector
  2043. * @returns a new Vector2
  2044. */
  2045. subtract(otherVector: Vector2): Vector2;
  2046. /**
  2047. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2048. * @param otherVector defines the other vector
  2049. * @param result defines the target vector
  2050. * @returns the unmodified current Vector2
  2051. */
  2052. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2053. /**
  2054. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2055. * @param otherVector defines the other vector
  2056. * @returns the current updated Vector2
  2057. */
  2058. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2059. /**
  2060. * Multiplies in place the current Vector2 coordinates by the given ones
  2061. * @param otherVector defines the other vector
  2062. * @returns the current updated Vector2
  2063. */
  2064. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2065. /**
  2066. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2067. * @param otherVector defines the other vector
  2068. * @returns a new Vector2
  2069. */
  2070. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2071. /**
  2072. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2073. * @param otherVector defines the other vector
  2074. * @param result defines the target vector
  2075. * @returns the unmodified current Vector2
  2076. */
  2077. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2078. /**
  2079. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2080. * @param x defines the first coordinate
  2081. * @param y defines the second coordinate
  2082. * @returns a new Vector2
  2083. */
  2084. multiplyByFloats(x: number, y: number): Vector2;
  2085. /**
  2086. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2087. * @param otherVector defines the other vector
  2088. * @returns a new Vector2
  2089. */
  2090. divide(otherVector: Vector2): Vector2;
  2091. /**
  2092. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2093. * @param otherVector defines the other vector
  2094. * @param result defines the target vector
  2095. * @returns the unmodified current Vector2
  2096. */
  2097. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2098. /**
  2099. * Divides the current Vector2 coordinates by the given ones
  2100. * @param otherVector defines the other vector
  2101. * @returns the current updated Vector2
  2102. */
  2103. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2104. /**
  2105. * Gets a new Vector2 with current Vector2 negated coordinates
  2106. * @returns a new Vector2
  2107. */
  2108. negate(): Vector2;
  2109. /**
  2110. * Negate this vector in place
  2111. * @returns this
  2112. */
  2113. negateInPlace(): Vector2;
  2114. /**
  2115. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2116. * @param result defines the Vector3 object where to store the result
  2117. * @returns the current Vector2
  2118. */
  2119. negateToRef(result: Vector2): Vector2;
  2120. /**
  2121. * Multiply the Vector2 coordinates by scale
  2122. * @param scale defines the scaling factor
  2123. * @returns the current updated Vector2
  2124. */
  2125. scaleInPlace(scale: number): Vector2;
  2126. /**
  2127. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2128. * @param scale defines the scaling factor
  2129. * @returns a new Vector2
  2130. */
  2131. scale(scale: number): Vector2;
  2132. /**
  2133. * Scale the current Vector2 values by a factor to a given Vector2
  2134. * @param scale defines the scale factor
  2135. * @param result defines the Vector2 object where to store the result
  2136. * @returns the unmodified current Vector2
  2137. */
  2138. scaleToRef(scale: number, result: Vector2): Vector2;
  2139. /**
  2140. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2141. * @param scale defines the scale factor
  2142. * @param result defines the Vector2 object where to store the result
  2143. * @returns the unmodified current Vector2
  2144. */
  2145. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2146. /**
  2147. * Gets a boolean if two vectors are equals
  2148. * @param otherVector defines the other vector
  2149. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2150. */
  2151. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2152. /**
  2153. * Gets a boolean if two vectors are equals (using an epsilon value)
  2154. * @param otherVector defines the other vector
  2155. * @param epsilon defines the minimal distance to consider equality
  2156. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2157. */
  2158. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2159. /**
  2160. * Gets a new Vector2 from current Vector2 floored values
  2161. * @returns a new Vector2
  2162. */
  2163. floor(): Vector2;
  2164. /**
  2165. * Gets a new Vector2 from current Vector2 floored values
  2166. * @returns a new Vector2
  2167. */
  2168. fract(): Vector2;
  2169. /**
  2170. * Gets the length of the vector
  2171. * @returns the vector length (float)
  2172. */
  2173. length(): number;
  2174. /**
  2175. * Gets the vector squared length
  2176. * @returns the vector squared length (float)
  2177. */
  2178. lengthSquared(): number;
  2179. /**
  2180. * Normalize the vector
  2181. * @returns the current updated Vector2
  2182. */
  2183. normalize(): Vector2;
  2184. /**
  2185. * Gets a new Vector2 copied from the Vector2
  2186. * @returns a new Vector2
  2187. */
  2188. clone(): Vector2;
  2189. /**
  2190. * Gets a new Vector2(0, 0)
  2191. * @returns a new Vector2
  2192. */
  2193. static Zero(): Vector2;
  2194. /**
  2195. * Gets a new Vector2(1, 1)
  2196. * @returns a new Vector2
  2197. */
  2198. static One(): Vector2;
  2199. /**
  2200. * Gets a new Vector2 set from the given index element of the given array
  2201. * @param array defines the data source
  2202. * @param offset defines the offset in the data source
  2203. * @returns a new Vector2
  2204. */
  2205. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2206. /**
  2207. * Sets "result" from the given index element of the given array
  2208. * @param array defines the data source
  2209. * @param offset defines the offset in the data source
  2210. * @param result defines the target vector
  2211. */
  2212. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2213. /**
  2214. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2215. * @param value1 defines 1st point of control
  2216. * @param value2 defines 2nd point of control
  2217. * @param value3 defines 3rd point of control
  2218. * @param value4 defines 4th point of control
  2219. * @param amount defines the interpolation factor
  2220. * @returns a new Vector2
  2221. */
  2222. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2223. /**
  2224. * 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".
  2225. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2226. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2227. * @param value defines the value to clamp
  2228. * @param min defines the lower limit
  2229. * @param max defines the upper limit
  2230. * @returns a new Vector2
  2231. */
  2232. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2233. /**
  2234. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2235. * @param value1 defines the 1st control point
  2236. * @param tangent1 defines the outgoing tangent
  2237. * @param value2 defines the 2nd control point
  2238. * @param tangent2 defines the incoming tangent
  2239. * @param amount defines the interpolation factor
  2240. * @returns a new Vector2
  2241. */
  2242. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2243. /**
  2244. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2245. * @param start defines the start vector
  2246. * @param end defines the end vector
  2247. * @param amount defines the interpolation factor
  2248. * @returns a new Vector2
  2249. */
  2250. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2251. /**
  2252. * Gets the dot product of the vector "left" and the vector "right"
  2253. * @param left defines first vector
  2254. * @param right defines second vector
  2255. * @returns the dot product (float)
  2256. */
  2257. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2258. /**
  2259. * Returns a new Vector2 equal to the normalized given vector
  2260. * @param vector defines the vector to normalize
  2261. * @returns a new Vector2
  2262. */
  2263. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2264. /**
  2265. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2266. * @param left defines 1st vector
  2267. * @param right defines 2nd vector
  2268. * @returns a new Vector2
  2269. */
  2270. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2271. /**
  2272. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2273. * @param left defines 1st vector
  2274. * @param right defines 2nd vector
  2275. * @returns a new Vector2
  2276. */
  2277. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2278. /**
  2279. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2280. * @param vector defines the vector to transform
  2281. * @param transformation defines the matrix to apply
  2282. * @returns a new Vector2
  2283. */
  2284. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2285. /**
  2286. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2287. * @param vector defines the vector to transform
  2288. * @param transformation defines the matrix to apply
  2289. * @param result defines the target vector
  2290. */
  2291. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2292. /**
  2293. * Determines if a given vector is included in a triangle
  2294. * @param p defines the vector to test
  2295. * @param p0 defines 1st triangle point
  2296. * @param p1 defines 2nd triangle point
  2297. * @param p2 defines 3rd triangle point
  2298. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2299. */
  2300. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2301. /**
  2302. * Gets the distance between the vectors "value1" and "value2"
  2303. * @param value1 defines first vector
  2304. * @param value2 defines second vector
  2305. * @returns the distance between vectors
  2306. */
  2307. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2308. /**
  2309. * Returns the squared distance between the vectors "value1" and "value2"
  2310. * @param value1 defines first vector
  2311. * @param value2 defines second vector
  2312. * @returns the squared distance between vectors
  2313. */
  2314. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2315. /**
  2316. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2317. * @param value1 defines first vector
  2318. * @param value2 defines second vector
  2319. * @returns a new Vector2
  2320. */
  2321. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2322. /**
  2323. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2324. * @param p defines the middle point
  2325. * @param segA defines one point of the segment
  2326. * @param segB defines the other point of the segment
  2327. * @returns the shortest distance
  2328. */
  2329. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2330. }
  2331. /**
  2332. * Class used to store (x,y,z) vector representation
  2333. * A Vector3 is the main object used in 3D geometry
  2334. * It can represent etiher the coordinates of a point the space, either a direction
  2335. * Reminder: js uses a left handed forward facing system
  2336. */
  2337. export class Vector3 {
  2338. /**
  2339. * Defines the first coordinates (on X axis)
  2340. */
  2341. x: number;
  2342. /**
  2343. * Defines the second coordinates (on Y axis)
  2344. */
  2345. y: number;
  2346. /**
  2347. * Defines the third coordinates (on Z axis)
  2348. */
  2349. z: number;
  2350. private static _UpReadOnly;
  2351. private static _ZeroReadOnly;
  2352. /**
  2353. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2354. * @param x defines the first coordinates (on X axis)
  2355. * @param y defines the second coordinates (on Y axis)
  2356. * @param z defines the third coordinates (on Z axis)
  2357. */
  2358. constructor(
  2359. /**
  2360. * Defines the first coordinates (on X axis)
  2361. */
  2362. x?: number,
  2363. /**
  2364. * Defines the second coordinates (on Y axis)
  2365. */
  2366. y?: number,
  2367. /**
  2368. * Defines the third coordinates (on Z axis)
  2369. */
  2370. z?: number);
  2371. /**
  2372. * Creates a string representation of the Vector3
  2373. * @returns a string with the Vector3 coordinates.
  2374. */
  2375. toString(): string;
  2376. /**
  2377. * Gets the class name
  2378. * @returns the string "Vector3"
  2379. */
  2380. getClassName(): string;
  2381. /**
  2382. * Creates the Vector3 hash code
  2383. * @returns a number which tends to be unique between Vector3 instances
  2384. */
  2385. getHashCode(): number;
  2386. /**
  2387. * Creates an array containing three elements : the coordinates of the Vector3
  2388. * @returns a new array of numbers
  2389. */
  2390. asArray(): number[];
  2391. /**
  2392. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2393. * @param array defines the destination array
  2394. * @param index defines the offset in the destination array
  2395. * @returns the current Vector3
  2396. */
  2397. toArray(array: FloatArray, index?: number): Vector3;
  2398. /**
  2399. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2400. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2401. */
  2402. toQuaternion(): Quaternion;
  2403. /**
  2404. * Adds the given vector to the current Vector3
  2405. * @param otherVector defines the second operand
  2406. * @returns the current updated Vector3
  2407. */
  2408. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2409. /**
  2410. * Adds the given coordinates to the current Vector3
  2411. * @param x defines the x coordinate of the operand
  2412. * @param y defines the y coordinate of the operand
  2413. * @param z defines the z coordinate of the operand
  2414. * @returns the current updated Vector3
  2415. */
  2416. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2417. /**
  2418. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2419. * @param otherVector defines the second operand
  2420. * @returns the resulting Vector3
  2421. */
  2422. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2423. /**
  2424. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2425. * @param otherVector defines the second operand
  2426. * @param result defines the Vector3 object where to store the result
  2427. * @returns the current Vector3
  2428. */
  2429. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2430. /**
  2431. * Subtract the given vector from the current Vector3
  2432. * @param otherVector defines the second operand
  2433. * @returns the current updated Vector3
  2434. */
  2435. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2436. /**
  2437. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2438. * @param otherVector defines the second operand
  2439. * @returns the resulting Vector3
  2440. */
  2441. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2442. /**
  2443. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2444. * @param otherVector defines the second operand
  2445. * @param result defines the Vector3 object where to store the result
  2446. * @returns the current Vector3
  2447. */
  2448. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2449. /**
  2450. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2451. * @param x defines the x coordinate of the operand
  2452. * @param y defines the y coordinate of the operand
  2453. * @param z defines the z coordinate of the operand
  2454. * @returns the resulting Vector3
  2455. */
  2456. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2457. /**
  2458. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2459. * @param x defines the x coordinate of the operand
  2460. * @param y defines the y coordinate of the operand
  2461. * @param z defines the z coordinate of the operand
  2462. * @param result defines the Vector3 object where to store the result
  2463. * @returns the current Vector3
  2464. */
  2465. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2466. /**
  2467. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2468. * @returns a new Vector3
  2469. */
  2470. negate(): Vector3;
  2471. /**
  2472. * Negate this vector in place
  2473. * @returns this
  2474. */
  2475. negateInPlace(): Vector3;
  2476. /**
  2477. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2478. * @param result defines the Vector3 object where to store the result
  2479. * @returns the current Vector3
  2480. */
  2481. negateToRef(result: Vector3): Vector3;
  2482. /**
  2483. * Multiplies the Vector3 coordinates by the float "scale"
  2484. * @param scale defines the multiplier factor
  2485. * @returns the current updated Vector3
  2486. */
  2487. scaleInPlace(scale: number): Vector3;
  2488. /**
  2489. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2490. * @param scale defines the multiplier factor
  2491. * @returns a new Vector3
  2492. */
  2493. scale(scale: number): Vector3;
  2494. /**
  2495. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2496. * @param scale defines the multiplier factor
  2497. * @param result defines the Vector3 object where to store the result
  2498. * @returns the current Vector3
  2499. */
  2500. scaleToRef(scale: number, result: Vector3): Vector3;
  2501. /**
  2502. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2503. * @param scale defines the scale factor
  2504. * @param result defines the Vector3 object where to store the result
  2505. * @returns the unmodified current Vector3
  2506. */
  2507. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2508. /**
  2509. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2510. * @param otherVector defines the second operand
  2511. * @returns true if both vectors are equals
  2512. */
  2513. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2514. /**
  2515. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2516. * @param otherVector defines the second operand
  2517. * @param epsilon defines the minimal distance to define values as equals
  2518. * @returns true if both vectors are distant less than epsilon
  2519. */
  2520. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2521. /**
  2522. * Returns true if the current Vector3 coordinates equals the given floats
  2523. * @param x defines the x coordinate of the operand
  2524. * @param y defines the y coordinate of the operand
  2525. * @param z defines the z coordinate of the operand
  2526. * @returns true if both vectors are equals
  2527. */
  2528. equalsToFloats(x: number, y: number, z: number): boolean;
  2529. /**
  2530. * Multiplies the current Vector3 coordinates by the given ones
  2531. * @param otherVector defines the second operand
  2532. * @returns the current updated Vector3
  2533. */
  2534. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2535. /**
  2536. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2537. * @param otherVector defines the second operand
  2538. * @returns the new Vector3
  2539. */
  2540. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2541. /**
  2542. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2543. * @param otherVector defines the second operand
  2544. * @param result defines the Vector3 object where to store the result
  2545. * @returns the current Vector3
  2546. */
  2547. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2548. /**
  2549. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2550. * @param x defines the x coordinate of the operand
  2551. * @param y defines the y coordinate of the operand
  2552. * @param z defines the z coordinate of the operand
  2553. * @returns the new Vector3
  2554. */
  2555. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2556. /**
  2557. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2558. * @param otherVector defines the second operand
  2559. * @returns the new Vector3
  2560. */
  2561. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2562. /**
  2563. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2564. * @param otherVector defines the second operand
  2565. * @param result defines the Vector3 object where to store the result
  2566. * @returns the current Vector3
  2567. */
  2568. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2569. /**
  2570. * Divides the current Vector3 coordinates by the given ones.
  2571. * @param otherVector defines the second operand
  2572. * @returns the current updated Vector3
  2573. */
  2574. divideInPlace(otherVector: Vector3): Vector3;
  2575. /**
  2576. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2577. * @param other defines the second operand
  2578. * @returns the current updated Vector3
  2579. */
  2580. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2581. /**
  2582. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2583. * @param other defines the second operand
  2584. * @returns the current updated Vector3
  2585. */
  2586. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2587. /**
  2588. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2589. * @param x defines the x coordinate of the operand
  2590. * @param y defines the y coordinate of the operand
  2591. * @param z defines the z coordinate of the operand
  2592. * @returns the current updated Vector3
  2593. */
  2594. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2595. /**
  2596. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2597. * @param x defines the x coordinate of the operand
  2598. * @param y defines the y coordinate of the operand
  2599. * @param z defines the z coordinate of the operand
  2600. * @returns the current updated Vector3
  2601. */
  2602. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2603. /**
  2604. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2605. * Check if is non uniform within a certain amount of decimal places to account for this
  2606. * @param epsilon the amount the values can differ
  2607. * @returns if the the vector is non uniform to a certain number of decimal places
  2608. */
  2609. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2610. /**
  2611. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2612. */
  2613. get isNonUniform(): boolean;
  2614. /**
  2615. * Gets a new Vector3 from current Vector3 floored values
  2616. * @returns a new Vector3
  2617. */
  2618. floor(): Vector3;
  2619. /**
  2620. * Gets a new Vector3 from current Vector3 floored values
  2621. * @returns a new Vector3
  2622. */
  2623. fract(): Vector3;
  2624. /**
  2625. * Gets the length of the Vector3
  2626. * @returns the length of the Vector3
  2627. */
  2628. length(): number;
  2629. /**
  2630. * Gets the squared length of the Vector3
  2631. * @returns squared length of the Vector3
  2632. */
  2633. lengthSquared(): number;
  2634. /**
  2635. * Normalize the current Vector3.
  2636. * Please note that this is an in place operation.
  2637. * @returns the current updated Vector3
  2638. */
  2639. normalize(): Vector3;
  2640. /**
  2641. * Reorders the x y z properties of the vector in place
  2642. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2643. * @returns the current updated vector
  2644. */
  2645. reorderInPlace(order: string): this;
  2646. /**
  2647. * Rotates the vector around 0,0,0 by a quaternion
  2648. * @param quaternion the rotation quaternion
  2649. * @param result vector to store the result
  2650. * @returns the resulting vector
  2651. */
  2652. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2653. /**
  2654. * Rotates a vector around a given point
  2655. * @param quaternion the rotation quaternion
  2656. * @param point the point to rotate around
  2657. * @param result vector to store the result
  2658. * @returns the resulting vector
  2659. */
  2660. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2661. /**
  2662. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2663. * The cross product is then orthogonal to both current and "other"
  2664. * @param other defines the right operand
  2665. * @returns the cross product
  2666. */
  2667. cross(other: Vector3): Vector3;
  2668. /**
  2669. * Normalize the current Vector3 with the given input length.
  2670. * Please note that this is an in place operation.
  2671. * @param len the length of the vector
  2672. * @returns the current updated Vector3
  2673. */
  2674. normalizeFromLength(len: number): Vector3;
  2675. /**
  2676. * Normalize the current Vector3 to a new vector
  2677. * @returns the new Vector3
  2678. */
  2679. normalizeToNew(): Vector3;
  2680. /**
  2681. * Normalize the current Vector3 to the reference
  2682. * @param reference define the Vector3 to update
  2683. * @returns the updated Vector3
  2684. */
  2685. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2686. /**
  2687. * Creates a new Vector3 copied from the current Vector3
  2688. * @returns the new Vector3
  2689. */
  2690. clone(): Vector3;
  2691. /**
  2692. * Copies the given vector coordinates to the current Vector3 ones
  2693. * @param source defines the source Vector3
  2694. * @returns the current updated Vector3
  2695. */
  2696. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2697. /**
  2698. * Copies the given floats to the current Vector3 coordinates
  2699. * @param x defines the x coordinate of the operand
  2700. * @param y defines the y coordinate of the operand
  2701. * @param z defines the z coordinate of the operand
  2702. * @returns the current updated Vector3
  2703. */
  2704. copyFromFloats(x: number, y: number, z: number): Vector3;
  2705. /**
  2706. * Copies the given floats to the current Vector3 coordinates
  2707. * @param x defines the x coordinate of the operand
  2708. * @param y defines the y coordinate of the operand
  2709. * @param z defines the z coordinate of the operand
  2710. * @returns the current updated Vector3
  2711. */
  2712. set(x: number, y: number, z: number): Vector3;
  2713. /**
  2714. * Copies the given float to the current Vector3 coordinates
  2715. * @param v defines the x, y and z coordinates of the operand
  2716. * @returns the current updated Vector3
  2717. */
  2718. setAll(v: number): Vector3;
  2719. /**
  2720. * Get the clip factor between two vectors
  2721. * @param vector0 defines the first operand
  2722. * @param vector1 defines the second operand
  2723. * @param axis defines the axis to use
  2724. * @param size defines the size along the axis
  2725. * @returns the clip factor
  2726. */
  2727. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2728. /**
  2729. * Get angle between two vectors
  2730. * @param vector0 angle between vector0 and vector1
  2731. * @param vector1 angle between vector0 and vector1
  2732. * @param normal direction of the normal
  2733. * @return the angle between vector0 and vector1
  2734. */
  2735. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2736. /**
  2737. * Returns a new Vector3 set from the index "offset" of the given array
  2738. * @param array defines the source array
  2739. * @param offset defines the offset in the source array
  2740. * @returns the new Vector3
  2741. */
  2742. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2743. /**
  2744. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2745. * @param array defines the source array
  2746. * @param offset defines the offset in the source array
  2747. * @returns the new Vector3
  2748. * @deprecated Please use FromArray instead.
  2749. */
  2750. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2751. /**
  2752. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2753. * @param array defines the source array
  2754. * @param offset defines the offset in the source array
  2755. * @param result defines the Vector3 where to store the result
  2756. */
  2757. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2758. /**
  2759. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2760. * @param array defines the source array
  2761. * @param offset defines the offset in the source array
  2762. * @param result defines the Vector3 where to store the result
  2763. * @deprecated Please use FromArrayToRef instead.
  2764. */
  2765. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2766. /**
  2767. * Sets the given vector "result" with the given floats.
  2768. * @param x defines the x coordinate of the source
  2769. * @param y defines the y coordinate of the source
  2770. * @param z defines the z coordinate of the source
  2771. * @param result defines the Vector3 where to store the result
  2772. */
  2773. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2774. /**
  2775. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2776. * @returns a new empty Vector3
  2777. */
  2778. static Zero(): Vector3;
  2779. /**
  2780. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2781. * @returns a new unit Vector3
  2782. */
  2783. static One(): Vector3;
  2784. /**
  2785. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2786. * @returns a new up Vector3
  2787. */
  2788. static Up(): Vector3;
  2789. /**
  2790. * Gets a up Vector3 that must not be updated
  2791. */
  2792. static get UpReadOnly(): DeepImmutable<Vector3>;
  2793. /**
  2794. * Gets a zero Vector3 that must not be updated
  2795. */
  2796. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2797. /**
  2798. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2799. * @returns a new down Vector3
  2800. */
  2801. static Down(): Vector3;
  2802. /**
  2803. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2804. * @returns a new forward Vector3
  2805. */
  2806. static Forward(): Vector3;
  2807. /**
  2808. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2809. * @returns a new forward Vector3
  2810. */
  2811. static Backward(): Vector3;
  2812. /**
  2813. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2814. * @returns a new right Vector3
  2815. */
  2816. static Right(): Vector3;
  2817. /**
  2818. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2819. * @returns a new left Vector3
  2820. */
  2821. static Left(): Vector3;
  2822. /**
  2823. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2824. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2825. * @param vector defines the Vector3 to transform
  2826. * @param transformation defines the transformation matrix
  2827. * @returns the transformed Vector3
  2828. */
  2829. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2830. /**
  2831. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2832. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2833. * @param vector defines the Vector3 to transform
  2834. * @param transformation defines the transformation matrix
  2835. * @param result defines the Vector3 where to store the result
  2836. */
  2837. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2838. /**
  2839. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2840. * This method computes tranformed coordinates only, not transformed direction vectors
  2841. * @param x define the x coordinate of the source vector
  2842. * @param y define the y coordinate of the source vector
  2843. * @param z define the z coordinate of the source vector
  2844. * @param transformation defines the transformation matrix
  2845. * @param result defines the Vector3 where to store the result
  2846. */
  2847. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2848. /**
  2849. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2850. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2851. * @param vector defines the Vector3 to transform
  2852. * @param transformation defines the transformation matrix
  2853. * @returns the new Vector3
  2854. */
  2855. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2856. /**
  2857. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2858. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2859. * @param vector defines the Vector3 to transform
  2860. * @param transformation defines the transformation matrix
  2861. * @param result defines the Vector3 where to store the result
  2862. */
  2863. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2864. /**
  2865. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2866. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2867. * @param x define the x coordinate of the source vector
  2868. * @param y define the y coordinate of the source vector
  2869. * @param z define the z coordinate of the source vector
  2870. * @param transformation defines the transformation matrix
  2871. * @param result defines the Vector3 where to store the result
  2872. */
  2873. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2874. /**
  2875. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2876. * @param value1 defines the first control point
  2877. * @param value2 defines the second control point
  2878. * @param value3 defines the third control point
  2879. * @param value4 defines the fourth control point
  2880. * @param amount defines the amount on the spline to use
  2881. * @returns the new Vector3
  2882. */
  2883. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2884. /**
  2885. * 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"
  2886. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2887. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2888. * @param value defines the current value
  2889. * @param min defines the lower range value
  2890. * @param max defines the upper range value
  2891. * @returns the new Vector3
  2892. */
  2893. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2894. /**
  2895. * 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"
  2896. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2897. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2898. * @param value defines the current value
  2899. * @param min defines the lower range value
  2900. * @param max defines the upper range value
  2901. * @param result defines the Vector3 where to store the result
  2902. */
  2903. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2904. /**
  2905. * Checks if a given vector is inside a specific range
  2906. * @param v defines the vector to test
  2907. * @param min defines the minimum range
  2908. * @param max defines the maximum range
  2909. */
  2910. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2911. /**
  2912. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2913. * @param value1 defines the first control point
  2914. * @param tangent1 defines the first tangent vector
  2915. * @param value2 defines the second control point
  2916. * @param tangent2 defines the second tangent vector
  2917. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2918. * @returns the new Vector3
  2919. */
  2920. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2921. /**
  2922. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2923. * @param start defines the start value
  2924. * @param end defines the end value
  2925. * @param amount max defines amount between both (between 0 and 1)
  2926. * @returns the new Vector3
  2927. */
  2928. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2929. /**
  2930. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2931. * @param start defines the start value
  2932. * @param end defines the end value
  2933. * @param amount max defines amount between both (between 0 and 1)
  2934. * @param result defines the Vector3 where to store the result
  2935. */
  2936. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2937. /**
  2938. * Returns the dot product (float) between the vectors "left" and "right"
  2939. * @param left defines the left operand
  2940. * @param right defines the right operand
  2941. * @returns the dot product
  2942. */
  2943. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2944. /**
  2945. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2946. * The cross product is then orthogonal to both "left" and "right"
  2947. * @param left defines the left operand
  2948. * @param right defines the right operand
  2949. * @returns the cross product
  2950. */
  2951. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2952. /**
  2953. * Sets the given vector "result" with the cross product of "left" and "right"
  2954. * The cross product is then orthogonal to both "left" and "right"
  2955. * @param left defines the left operand
  2956. * @param right defines the right operand
  2957. * @param result defines the Vector3 where to store the result
  2958. */
  2959. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2960. /**
  2961. * Returns a new Vector3 as the normalization of the given vector
  2962. * @param vector defines the Vector3 to normalize
  2963. * @returns the new Vector3
  2964. */
  2965. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2966. /**
  2967. * Sets the given vector "result" with the normalization of the given first vector
  2968. * @param vector defines the Vector3 to normalize
  2969. * @param result defines the Vector3 where to store the result
  2970. */
  2971. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2972. /**
  2973. * Project a Vector3 onto screen space
  2974. * @param vector defines the Vector3 to project
  2975. * @param world defines the world matrix to use
  2976. * @param transform defines the transform (view x projection) matrix to use
  2977. * @param viewport defines the screen viewport to use
  2978. * @returns the new Vector3
  2979. */
  2980. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2981. /** @hidden */
  2982. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2983. /**
  2984. * Unproject from screen space to object space
  2985. * @param source defines the screen space Vector3 to use
  2986. * @param viewportWidth defines the current width of the viewport
  2987. * @param viewportHeight defines the current height of the viewport
  2988. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2989. * @param transform defines the transform (view x projection) matrix to use
  2990. * @returns the new Vector3
  2991. */
  2992. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2993. /**
  2994. * Unproject from screen space to object space
  2995. * @param source defines the screen space Vector3 to use
  2996. * @param viewportWidth defines the current width of the viewport
  2997. * @param viewportHeight defines the current height of the viewport
  2998. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2999. * @param view defines the view matrix to use
  3000. * @param projection defines the projection matrix to use
  3001. * @returns the new Vector3
  3002. */
  3003. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3004. /**
  3005. * Unproject from screen space to object space
  3006. * @param source defines the screen space Vector3 to use
  3007. * @param viewportWidth defines the current width of the viewport
  3008. * @param viewportHeight defines the current height of the viewport
  3009. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3010. * @param view defines the view matrix to use
  3011. * @param projection defines the projection matrix to use
  3012. * @param result defines the Vector3 where to store the result
  3013. */
  3014. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3015. /**
  3016. * Unproject from screen space to object space
  3017. * @param sourceX defines the screen space x coordinate to use
  3018. * @param sourceY defines the screen space y coordinate to use
  3019. * @param sourceZ defines the screen space z coordinate to use
  3020. * @param viewportWidth defines the current width of the viewport
  3021. * @param viewportHeight defines the current height of the viewport
  3022. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3023. * @param view defines the view matrix to use
  3024. * @param projection defines the projection matrix to use
  3025. * @param result defines the Vector3 where to store the result
  3026. */
  3027. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3028. /**
  3029. * Gets the minimal coordinate values between two Vector3
  3030. * @param left defines the first operand
  3031. * @param right defines the second operand
  3032. * @returns the new Vector3
  3033. */
  3034. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3035. /**
  3036. * Gets the maximal coordinate values between two Vector3
  3037. * @param left defines the first operand
  3038. * @param right defines the second operand
  3039. * @returns the new Vector3
  3040. */
  3041. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3042. /**
  3043. * Returns the distance between the vectors "value1" and "value2"
  3044. * @param value1 defines the first operand
  3045. * @param value2 defines the second operand
  3046. * @returns the distance
  3047. */
  3048. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3049. /**
  3050. * Returns the squared distance between the vectors "value1" and "value2"
  3051. * @param value1 defines the first operand
  3052. * @param value2 defines the second operand
  3053. * @returns the squared distance
  3054. */
  3055. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3056. /**
  3057. * Returns a new Vector3 located at the center between "value1" and "value2"
  3058. * @param value1 defines the first operand
  3059. * @param value2 defines the second operand
  3060. * @returns the new Vector3
  3061. */
  3062. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3063. /**
  3064. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3065. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3066. * to something in order to rotate it from its local system to the given target system
  3067. * Note: axis1, axis2 and axis3 are normalized during this operation
  3068. * @param axis1 defines the first axis
  3069. * @param axis2 defines the second axis
  3070. * @param axis3 defines the third axis
  3071. * @returns a new Vector3
  3072. */
  3073. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3074. /**
  3075. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3076. * @param axis1 defines the first axis
  3077. * @param axis2 defines the second axis
  3078. * @param axis3 defines the third axis
  3079. * @param ref defines the Vector3 where to store the result
  3080. */
  3081. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3082. }
  3083. /**
  3084. * Vector4 class created for EulerAngle class conversion to Quaternion
  3085. */
  3086. export class Vector4 {
  3087. /** x value of the vector */
  3088. x: number;
  3089. /** y value of the vector */
  3090. y: number;
  3091. /** z value of the vector */
  3092. z: number;
  3093. /** w value of the vector */
  3094. w: number;
  3095. /**
  3096. * Creates a Vector4 object from the given floats.
  3097. * @param x x value of the vector
  3098. * @param y y value of the vector
  3099. * @param z z value of the vector
  3100. * @param w w value of the vector
  3101. */
  3102. constructor(
  3103. /** x value of the vector */
  3104. x: number,
  3105. /** y value of the vector */
  3106. y: number,
  3107. /** z value of the vector */
  3108. z: number,
  3109. /** w value of the vector */
  3110. w: number);
  3111. /**
  3112. * Returns the string with the Vector4 coordinates.
  3113. * @returns a string containing all the vector values
  3114. */
  3115. toString(): string;
  3116. /**
  3117. * Returns the string "Vector4".
  3118. * @returns "Vector4"
  3119. */
  3120. getClassName(): string;
  3121. /**
  3122. * Returns the Vector4 hash code.
  3123. * @returns a unique hash code
  3124. */
  3125. getHashCode(): number;
  3126. /**
  3127. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3128. * @returns the resulting array
  3129. */
  3130. asArray(): number[];
  3131. /**
  3132. * Populates the given array from the given index with the Vector4 coordinates.
  3133. * @param array array to populate
  3134. * @param index index of the array to start at (default: 0)
  3135. * @returns the Vector4.
  3136. */
  3137. toArray(array: FloatArray, index?: number): Vector4;
  3138. /**
  3139. * Adds the given vector to the current Vector4.
  3140. * @param otherVector the vector to add
  3141. * @returns the updated Vector4.
  3142. */
  3143. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3144. /**
  3145. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3146. * @param otherVector the vector to add
  3147. * @returns the resulting vector
  3148. */
  3149. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3150. /**
  3151. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3152. * @param otherVector the vector to add
  3153. * @param result the vector to store the result
  3154. * @returns the current Vector4.
  3155. */
  3156. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3157. /**
  3158. * Subtract in place the given vector from the current Vector4.
  3159. * @param otherVector the vector to subtract
  3160. * @returns the updated Vector4.
  3161. */
  3162. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3163. /**
  3164. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3165. * @param otherVector the vector to add
  3166. * @returns the new vector with the result
  3167. */
  3168. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3169. /**
  3170. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3171. * @param otherVector the vector to subtract
  3172. * @param result the vector to store the result
  3173. * @returns the current Vector4.
  3174. */
  3175. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3176. /**
  3177. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3178. */
  3179. /**
  3180. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3181. * @param x value to subtract
  3182. * @param y value to subtract
  3183. * @param z value to subtract
  3184. * @param w value to subtract
  3185. * @returns new vector containing the result
  3186. */
  3187. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3188. /**
  3189. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3190. * @param x value to subtract
  3191. * @param y value to subtract
  3192. * @param z value to subtract
  3193. * @param w value to subtract
  3194. * @param result the vector to store the result in
  3195. * @returns the current Vector4.
  3196. */
  3197. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3198. /**
  3199. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3200. * @returns a new vector with the negated values
  3201. */
  3202. negate(): Vector4;
  3203. /**
  3204. * Negate this vector in place
  3205. * @returns this
  3206. */
  3207. negateInPlace(): Vector4;
  3208. /**
  3209. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3210. * @param result defines the Vector3 object where to store the result
  3211. * @returns the current Vector4
  3212. */
  3213. negateToRef(result: Vector4): Vector4;
  3214. /**
  3215. * Multiplies the current Vector4 coordinates by scale (float).
  3216. * @param scale the number to scale with
  3217. * @returns the updated Vector4.
  3218. */
  3219. scaleInPlace(scale: number): Vector4;
  3220. /**
  3221. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3222. * @param scale the number to scale with
  3223. * @returns a new vector with the result
  3224. */
  3225. scale(scale: number): Vector4;
  3226. /**
  3227. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3228. * @param scale the number to scale with
  3229. * @param result a vector to store the result in
  3230. * @returns the current Vector4.
  3231. */
  3232. scaleToRef(scale: number, result: Vector4): Vector4;
  3233. /**
  3234. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3235. * @param scale defines the scale factor
  3236. * @param result defines the Vector4 object where to store the result
  3237. * @returns the unmodified current Vector4
  3238. */
  3239. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3240. /**
  3241. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3242. * @param otherVector the vector to compare against
  3243. * @returns true if they are equal
  3244. */
  3245. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3246. /**
  3247. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3248. * @param otherVector vector to compare against
  3249. * @param epsilon (Default: very small number)
  3250. * @returns true if they are equal
  3251. */
  3252. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3253. /**
  3254. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3255. * @param x x value to compare against
  3256. * @param y y value to compare against
  3257. * @param z z value to compare against
  3258. * @param w w value to compare against
  3259. * @returns true if equal
  3260. */
  3261. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3262. /**
  3263. * Multiplies in place the current Vector4 by the given one.
  3264. * @param otherVector vector to multiple with
  3265. * @returns the updated Vector4.
  3266. */
  3267. multiplyInPlace(otherVector: Vector4): Vector4;
  3268. /**
  3269. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3270. * @param otherVector vector to multiple with
  3271. * @returns resulting new vector
  3272. */
  3273. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3274. /**
  3275. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3276. * @param otherVector vector to multiple with
  3277. * @param result vector to store the result
  3278. * @returns the current Vector4.
  3279. */
  3280. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3281. /**
  3282. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3283. * @param x x value multiply with
  3284. * @param y y value multiply with
  3285. * @param z z value multiply with
  3286. * @param w w value multiply with
  3287. * @returns resulting new vector
  3288. */
  3289. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3290. /**
  3291. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3292. * @param otherVector vector to devide with
  3293. * @returns resulting new vector
  3294. */
  3295. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3296. /**
  3297. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3298. * @param otherVector vector to devide with
  3299. * @param result vector to store the result
  3300. * @returns the current Vector4.
  3301. */
  3302. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3303. /**
  3304. * Divides the current Vector3 coordinates by the given ones.
  3305. * @param otherVector vector to devide with
  3306. * @returns the updated Vector3.
  3307. */
  3308. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3309. /**
  3310. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3311. * @param other defines the second operand
  3312. * @returns the current updated Vector4
  3313. */
  3314. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3315. /**
  3316. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3317. * @param other defines the second operand
  3318. * @returns the current updated Vector4
  3319. */
  3320. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3321. /**
  3322. * Gets a new Vector4 from current Vector4 floored values
  3323. * @returns a new Vector4
  3324. */
  3325. floor(): Vector4;
  3326. /**
  3327. * Gets a new Vector4 from current Vector3 floored values
  3328. * @returns a new Vector4
  3329. */
  3330. fract(): Vector4;
  3331. /**
  3332. * Returns the Vector4 length (float).
  3333. * @returns the length
  3334. */
  3335. length(): number;
  3336. /**
  3337. * Returns the Vector4 squared length (float).
  3338. * @returns the length squared
  3339. */
  3340. lengthSquared(): number;
  3341. /**
  3342. * Normalizes in place the Vector4.
  3343. * @returns the updated Vector4.
  3344. */
  3345. normalize(): Vector4;
  3346. /**
  3347. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3348. * @returns this converted to a new vector3
  3349. */
  3350. toVector3(): Vector3;
  3351. /**
  3352. * Returns a new Vector4 copied from the current one.
  3353. * @returns the new cloned vector
  3354. */
  3355. clone(): Vector4;
  3356. /**
  3357. * Updates the current Vector4 with the given one coordinates.
  3358. * @param source the source vector to copy from
  3359. * @returns the updated Vector4.
  3360. */
  3361. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3362. /**
  3363. * Updates the current Vector4 coordinates with the given floats.
  3364. * @param x float to copy from
  3365. * @param y float to copy from
  3366. * @param z float to copy from
  3367. * @param w float to copy from
  3368. * @returns the updated Vector4.
  3369. */
  3370. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3371. /**
  3372. * Updates the current Vector4 coordinates with the given floats.
  3373. * @param x float to set from
  3374. * @param y float to set from
  3375. * @param z float to set from
  3376. * @param w float to set from
  3377. * @returns the updated Vector4.
  3378. */
  3379. set(x: number, y: number, z: number, w: number): Vector4;
  3380. /**
  3381. * Copies the given float to the current Vector3 coordinates
  3382. * @param v defines the x, y, z and w coordinates of the operand
  3383. * @returns the current updated Vector3
  3384. */
  3385. setAll(v: number): Vector4;
  3386. /**
  3387. * Returns a new Vector4 set from the starting index of the given array.
  3388. * @param array the array to pull values from
  3389. * @param offset the offset into the array to start at
  3390. * @returns the new vector
  3391. */
  3392. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3393. /**
  3394. * Updates the given vector "result" from the starting index of the given array.
  3395. * @param array the array to pull values from
  3396. * @param offset the offset into the array to start at
  3397. * @param result the vector to store the result in
  3398. */
  3399. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3400. /**
  3401. * Updates the given vector "result" from the starting index of the given Float32Array.
  3402. * @param array the array to pull values from
  3403. * @param offset the offset into the array to start at
  3404. * @param result the vector to store the result in
  3405. */
  3406. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3407. /**
  3408. * Updates the given vector "result" coordinates from the given floats.
  3409. * @param x float to set from
  3410. * @param y float to set from
  3411. * @param z float to set from
  3412. * @param w float to set from
  3413. * @param result the vector to the floats in
  3414. */
  3415. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3416. /**
  3417. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3418. * @returns the new vector
  3419. */
  3420. static Zero(): Vector4;
  3421. /**
  3422. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3423. * @returns the new vector
  3424. */
  3425. static One(): Vector4;
  3426. /**
  3427. * Returns a new normalized Vector4 from the given one.
  3428. * @param vector the vector to normalize
  3429. * @returns the vector
  3430. */
  3431. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3432. /**
  3433. * Updates the given vector "result" from the normalization of the given one.
  3434. * @param vector the vector to normalize
  3435. * @param result the vector to store the result in
  3436. */
  3437. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3438. /**
  3439. * Returns a vector with the minimum values from the left and right vectors
  3440. * @param left left vector to minimize
  3441. * @param right right vector to minimize
  3442. * @returns a new vector with the minimum of the left and right vector values
  3443. */
  3444. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3445. /**
  3446. * Returns a vector with the maximum values from the left and right vectors
  3447. * @param left left vector to maximize
  3448. * @param right right vector to maximize
  3449. * @returns a new vector with the maximum of the left and right vector values
  3450. */
  3451. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3452. /**
  3453. * Returns the distance (float) between the vectors "value1" and "value2".
  3454. * @param value1 value to calulate the distance between
  3455. * @param value2 value to calulate the distance between
  3456. * @return the distance between the two vectors
  3457. */
  3458. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3459. /**
  3460. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3461. * @param value1 value to calulate the distance between
  3462. * @param value2 value to calulate the distance between
  3463. * @return the distance between the two vectors squared
  3464. */
  3465. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3466. /**
  3467. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3468. * @param value1 value to calulate the center between
  3469. * @param value2 value to calulate the center between
  3470. * @return the center between the two vectors
  3471. */
  3472. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3473. /**
  3474. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3475. * This methods computes transformed normalized direction vectors only.
  3476. * @param vector the vector to transform
  3477. * @param transformation the transformation matrix to apply
  3478. * @returns the new vector
  3479. */
  3480. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3481. /**
  3482. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3483. * This methods computes transformed normalized direction vectors only.
  3484. * @param vector the vector to transform
  3485. * @param transformation the transformation matrix to apply
  3486. * @param result the vector to store the result in
  3487. */
  3488. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3489. /**
  3490. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3491. * This methods computes transformed normalized direction vectors only.
  3492. * @param x value to transform
  3493. * @param y value to transform
  3494. * @param z value to transform
  3495. * @param w value to transform
  3496. * @param transformation the transformation matrix to apply
  3497. * @param result the vector to store the results in
  3498. */
  3499. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3500. /**
  3501. * Creates a new Vector4 from a Vector3
  3502. * @param source defines the source data
  3503. * @param w defines the 4th component (default is 0)
  3504. * @returns a new Vector4
  3505. */
  3506. static FromVector3(source: Vector3, w?: number): Vector4;
  3507. }
  3508. /**
  3509. * Class used to store quaternion data
  3510. * @see https://en.wikipedia.org/wiki/Quaternion
  3511. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3512. */
  3513. export class Quaternion {
  3514. /** defines the first component (0 by default) */
  3515. x: number;
  3516. /** defines the second component (0 by default) */
  3517. y: number;
  3518. /** defines the third component (0 by default) */
  3519. z: number;
  3520. /** defines the fourth component (1.0 by default) */
  3521. w: number;
  3522. /**
  3523. * Creates a new Quaternion from the given floats
  3524. * @param x defines the first component (0 by default)
  3525. * @param y defines the second component (0 by default)
  3526. * @param z defines the third component (0 by default)
  3527. * @param w defines the fourth component (1.0 by default)
  3528. */
  3529. constructor(
  3530. /** defines the first component (0 by default) */
  3531. x?: number,
  3532. /** defines the second component (0 by default) */
  3533. y?: number,
  3534. /** defines the third component (0 by default) */
  3535. z?: number,
  3536. /** defines the fourth component (1.0 by default) */
  3537. w?: number);
  3538. /**
  3539. * Gets a string representation for the current quaternion
  3540. * @returns a string with the Quaternion coordinates
  3541. */
  3542. toString(): string;
  3543. /**
  3544. * Gets the class name of the quaternion
  3545. * @returns the string "Quaternion"
  3546. */
  3547. getClassName(): string;
  3548. /**
  3549. * Gets a hash code for this quaternion
  3550. * @returns the quaternion hash code
  3551. */
  3552. getHashCode(): number;
  3553. /**
  3554. * Copy the quaternion to an array
  3555. * @returns a new array populated with 4 elements from the quaternion coordinates
  3556. */
  3557. asArray(): number[];
  3558. /**
  3559. * Check if two quaternions are equals
  3560. * @param otherQuaternion defines the second operand
  3561. * @return true if the current quaternion and the given one coordinates are strictly equals
  3562. */
  3563. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3564. /**
  3565. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3566. * @param otherQuaternion defines the other quaternion
  3567. * @param epsilon defines the minimal distance to consider equality
  3568. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3569. */
  3570. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3571. /**
  3572. * Clone the current quaternion
  3573. * @returns a new quaternion copied from the current one
  3574. */
  3575. clone(): Quaternion;
  3576. /**
  3577. * Copy a quaternion to the current one
  3578. * @param other defines the other quaternion
  3579. * @returns the updated current quaternion
  3580. */
  3581. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3582. /**
  3583. * Updates the current quaternion with the given float coordinates
  3584. * @param x defines the x coordinate
  3585. * @param y defines the y coordinate
  3586. * @param z defines the z coordinate
  3587. * @param w defines the w coordinate
  3588. * @returns the updated current quaternion
  3589. */
  3590. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3591. /**
  3592. * Updates the current quaternion from the given float coordinates
  3593. * @param x defines the x coordinate
  3594. * @param y defines the y coordinate
  3595. * @param z defines the z coordinate
  3596. * @param w defines the w coordinate
  3597. * @returns the updated current quaternion
  3598. */
  3599. set(x: number, y: number, z: number, w: number): Quaternion;
  3600. /**
  3601. * Adds two quaternions
  3602. * @param other defines the second operand
  3603. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3604. */
  3605. add(other: DeepImmutable<Quaternion>): Quaternion;
  3606. /**
  3607. * Add a quaternion to the current one
  3608. * @param other defines the quaternion to add
  3609. * @returns the current quaternion
  3610. */
  3611. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3612. /**
  3613. * Subtract two quaternions
  3614. * @param other defines the second operand
  3615. * @returns a new quaternion as the subtraction result of the given one from the current one
  3616. */
  3617. subtract(other: Quaternion): Quaternion;
  3618. /**
  3619. * Multiplies the current quaternion by a scale factor
  3620. * @param value defines the scale factor
  3621. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3622. */
  3623. scale(value: number): Quaternion;
  3624. /**
  3625. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3626. * @param scale defines the scale factor
  3627. * @param result defines the Quaternion object where to store the result
  3628. * @returns the unmodified current quaternion
  3629. */
  3630. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3631. /**
  3632. * Multiplies in place the current quaternion by a scale factor
  3633. * @param value defines the scale factor
  3634. * @returns the current modified quaternion
  3635. */
  3636. scaleInPlace(value: number): Quaternion;
  3637. /**
  3638. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3639. * @param scale defines the scale factor
  3640. * @param result defines the Quaternion object where to store the result
  3641. * @returns the unmodified current quaternion
  3642. */
  3643. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3644. /**
  3645. * Multiplies two quaternions
  3646. * @param q1 defines the second operand
  3647. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3648. */
  3649. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3650. /**
  3651. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3652. * @param q1 defines the second operand
  3653. * @param result defines the target quaternion
  3654. * @returns the current quaternion
  3655. */
  3656. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3657. /**
  3658. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3659. * @param q1 defines the second operand
  3660. * @returns the currentupdated quaternion
  3661. */
  3662. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3663. /**
  3664. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3665. * @param ref defines the target quaternion
  3666. * @returns the current quaternion
  3667. */
  3668. conjugateToRef(ref: Quaternion): Quaternion;
  3669. /**
  3670. * Conjugates in place (1-q) the current quaternion
  3671. * @returns the current updated quaternion
  3672. */
  3673. conjugateInPlace(): Quaternion;
  3674. /**
  3675. * Conjugates in place (1-q) the current quaternion
  3676. * @returns a new quaternion
  3677. */
  3678. conjugate(): Quaternion;
  3679. /**
  3680. * Gets length of current quaternion
  3681. * @returns the quaternion length (float)
  3682. */
  3683. length(): number;
  3684. /**
  3685. * Normalize in place the current quaternion
  3686. * @returns the current updated quaternion
  3687. */
  3688. normalize(): Quaternion;
  3689. /**
  3690. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3691. * @param order is a reserved parameter and is ignore for now
  3692. * @returns a new Vector3 containing the Euler angles
  3693. */
  3694. toEulerAngles(order?: string): Vector3;
  3695. /**
  3696. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3697. * @param result defines the vector which will be filled with the Euler angles
  3698. * @param order is a reserved parameter and is ignore for now
  3699. * @returns the current unchanged quaternion
  3700. */
  3701. toEulerAnglesToRef(result: Vector3): Quaternion;
  3702. /**
  3703. * Updates the given rotation matrix with the current quaternion values
  3704. * @param result defines the target matrix
  3705. * @returns the current unchanged quaternion
  3706. */
  3707. toRotationMatrix(result: Matrix): Quaternion;
  3708. /**
  3709. * Updates the current quaternion from the given rotation matrix values
  3710. * @param matrix defines the source matrix
  3711. * @returns the current updated quaternion
  3712. */
  3713. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3714. /**
  3715. * Creates a new quaternion from a rotation matrix
  3716. * @param matrix defines the source matrix
  3717. * @returns a new quaternion created from the given rotation matrix values
  3718. */
  3719. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3720. /**
  3721. * Updates the given quaternion with the given rotation matrix values
  3722. * @param matrix defines the source matrix
  3723. * @param result defines the target quaternion
  3724. */
  3725. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3726. /**
  3727. * Returns the dot product (float) between the quaternions "left" and "right"
  3728. * @param left defines the left operand
  3729. * @param right defines the right operand
  3730. * @returns the dot product
  3731. */
  3732. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3733. /**
  3734. * Checks if the two quaternions are close to each other
  3735. * @param quat0 defines the first quaternion to check
  3736. * @param quat1 defines the second quaternion to check
  3737. * @returns true if the two quaternions are close to each other
  3738. */
  3739. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3740. /**
  3741. * Creates an empty quaternion
  3742. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3743. */
  3744. static Zero(): Quaternion;
  3745. /**
  3746. * Inverse a given quaternion
  3747. * @param q defines the source quaternion
  3748. * @returns a new quaternion as the inverted current quaternion
  3749. */
  3750. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3751. /**
  3752. * Inverse a given quaternion
  3753. * @param q defines the source quaternion
  3754. * @param result the quaternion the result will be stored in
  3755. * @returns the result quaternion
  3756. */
  3757. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3758. /**
  3759. * Creates an identity quaternion
  3760. * @returns the identity quaternion
  3761. */
  3762. static Identity(): Quaternion;
  3763. /**
  3764. * Gets a boolean indicating if the given quaternion is identity
  3765. * @param quaternion defines the quaternion to check
  3766. * @returns true if the quaternion is identity
  3767. */
  3768. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3769. /**
  3770. * Creates a quaternion from a rotation around an axis
  3771. * @param axis defines the axis to use
  3772. * @param angle defines the angle to use
  3773. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3774. */
  3775. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3776. /**
  3777. * Creates a rotation around an axis and stores it into the given quaternion
  3778. * @param axis defines the axis to use
  3779. * @param angle defines the angle to use
  3780. * @param result defines the target quaternion
  3781. * @returns the target quaternion
  3782. */
  3783. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3784. /**
  3785. * Creates a new quaternion from data stored into an array
  3786. * @param array defines the data source
  3787. * @param offset defines the offset in the source array where the data starts
  3788. * @returns a new quaternion
  3789. */
  3790. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3791. /**
  3792. * Create a quaternion from Euler rotation angles
  3793. * @param x Pitch
  3794. * @param y Yaw
  3795. * @param z Roll
  3796. * @returns the new Quaternion
  3797. */
  3798. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3799. /**
  3800. * Updates a quaternion from Euler rotation angles
  3801. * @param x Pitch
  3802. * @param y Yaw
  3803. * @param z Roll
  3804. * @param result the quaternion to store the result
  3805. * @returns the updated quaternion
  3806. */
  3807. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3808. /**
  3809. * Create a quaternion from Euler rotation vector
  3810. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3811. * @returns the new Quaternion
  3812. */
  3813. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3814. /**
  3815. * Updates a quaternion from Euler rotation vector
  3816. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3817. * @param result the quaternion to store the result
  3818. * @returns the updated quaternion
  3819. */
  3820. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3821. /**
  3822. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3823. * @param yaw defines the rotation around Y axis
  3824. * @param pitch defines the rotation around X axis
  3825. * @param roll defines the rotation around Z axis
  3826. * @returns the new quaternion
  3827. */
  3828. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3829. /**
  3830. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3831. * @param yaw defines the rotation around Y axis
  3832. * @param pitch defines the rotation around X axis
  3833. * @param roll defines the rotation around Z axis
  3834. * @param result defines the target quaternion
  3835. */
  3836. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3837. /**
  3838. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3839. * @param alpha defines the rotation around first axis
  3840. * @param beta defines the rotation around second axis
  3841. * @param gamma defines the rotation around third axis
  3842. * @returns the new quaternion
  3843. */
  3844. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3845. /**
  3846. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3847. * @param alpha defines the rotation around first axis
  3848. * @param beta defines the rotation around second axis
  3849. * @param gamma defines the rotation around third axis
  3850. * @param result defines the target quaternion
  3851. */
  3852. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3853. /**
  3854. * 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)
  3855. * @param axis1 defines the first axis
  3856. * @param axis2 defines the second axis
  3857. * @param axis3 defines the third axis
  3858. * @returns the new quaternion
  3859. */
  3860. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3861. /**
  3862. * 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
  3863. * @param axis1 defines the first axis
  3864. * @param axis2 defines the second axis
  3865. * @param axis3 defines the third axis
  3866. * @param ref defines the target quaternion
  3867. */
  3868. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3869. /**
  3870. * Interpolates between two quaternions
  3871. * @param left defines first quaternion
  3872. * @param right defines second quaternion
  3873. * @param amount defines the gradient to use
  3874. * @returns the new interpolated quaternion
  3875. */
  3876. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3877. /**
  3878. * Interpolates between two quaternions and stores it into a target quaternion
  3879. * @param left defines first quaternion
  3880. * @param right defines second quaternion
  3881. * @param amount defines the gradient to use
  3882. * @param result defines the target quaternion
  3883. */
  3884. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3885. /**
  3886. * Interpolate between two quaternions using Hermite interpolation
  3887. * @param value1 defines first quaternion
  3888. * @param tangent1 defines the incoming tangent
  3889. * @param value2 defines second quaternion
  3890. * @param tangent2 defines the outgoing tangent
  3891. * @param amount defines the target quaternion
  3892. * @returns the new interpolated quaternion
  3893. */
  3894. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3895. }
  3896. /**
  3897. * Class used to store matrix data (4x4)
  3898. */
  3899. export class Matrix {
  3900. private static _updateFlagSeed;
  3901. private static _identityReadOnly;
  3902. private _isIdentity;
  3903. private _isIdentityDirty;
  3904. private _isIdentity3x2;
  3905. private _isIdentity3x2Dirty;
  3906. /**
  3907. * Gets the update flag of the matrix which is an unique number for the matrix.
  3908. * It will be incremented every time the matrix data change.
  3909. * You can use it to speed the comparison between two versions of the same matrix.
  3910. */
  3911. updateFlag: number;
  3912. private readonly _m;
  3913. /**
  3914. * Gets the internal data of the matrix
  3915. */
  3916. get m(): DeepImmutable<Float32Array>;
  3917. /** @hidden */
  3918. _markAsUpdated(): void;
  3919. /** @hidden */
  3920. private _updateIdentityStatus;
  3921. /**
  3922. * Creates an empty matrix (filled with zeros)
  3923. */
  3924. constructor();
  3925. /**
  3926. * Check if the current matrix is identity
  3927. * @returns true is the matrix is the identity matrix
  3928. */
  3929. isIdentity(): boolean;
  3930. /**
  3931. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3932. * @returns true is the matrix is the identity matrix
  3933. */
  3934. isIdentityAs3x2(): boolean;
  3935. /**
  3936. * Gets the determinant of the matrix
  3937. * @returns the matrix determinant
  3938. */
  3939. determinant(): number;
  3940. /**
  3941. * Returns the matrix as a Float32Array
  3942. * @returns the matrix underlying array
  3943. */
  3944. toArray(): DeepImmutable<Float32Array>;
  3945. /**
  3946. * Returns the matrix as a Float32Array
  3947. * @returns the matrix underlying array.
  3948. */
  3949. asArray(): DeepImmutable<Float32Array>;
  3950. /**
  3951. * Inverts the current matrix in place
  3952. * @returns the current inverted matrix
  3953. */
  3954. invert(): Matrix;
  3955. /**
  3956. * Sets all the matrix elements to zero
  3957. * @returns the current matrix
  3958. */
  3959. reset(): Matrix;
  3960. /**
  3961. * Adds the current matrix with a second one
  3962. * @param other defines the matrix to add
  3963. * @returns a new matrix as the addition of the current matrix and the given one
  3964. */
  3965. add(other: DeepImmutable<Matrix>): Matrix;
  3966. /**
  3967. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3968. * @param other defines the matrix to add
  3969. * @param result defines the target matrix
  3970. * @returns the current matrix
  3971. */
  3972. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3973. /**
  3974. * Adds in place the given matrix to the current matrix
  3975. * @param other defines the second operand
  3976. * @returns the current updated matrix
  3977. */
  3978. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3979. /**
  3980. * Sets the given matrix to the current inverted Matrix
  3981. * @param other defines the target matrix
  3982. * @returns the unmodified current matrix
  3983. */
  3984. invertToRef(other: Matrix): Matrix;
  3985. /**
  3986. * add a value at the specified position in the current Matrix
  3987. * @param index the index of the value within the matrix. between 0 and 15.
  3988. * @param value the value to be added
  3989. * @returns the current updated matrix
  3990. */
  3991. addAtIndex(index: number, value: number): Matrix;
  3992. /**
  3993. * mutiply the specified position in the current Matrix by a value
  3994. * @param index the index of the value within the matrix. between 0 and 15.
  3995. * @param value the value to be added
  3996. * @returns the current updated matrix
  3997. */
  3998. multiplyAtIndex(index: number, value: number): Matrix;
  3999. /**
  4000. * Inserts the translation vector (using 3 floats) in the current matrix
  4001. * @param x defines the 1st component of the translation
  4002. * @param y defines the 2nd component of the translation
  4003. * @param z defines the 3rd component of the translation
  4004. * @returns the current updated matrix
  4005. */
  4006. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4007. /**
  4008. * Adds the translation vector (using 3 floats) in the current matrix
  4009. * @param x defines the 1st component of the translation
  4010. * @param y defines the 2nd component of the translation
  4011. * @param z defines the 3rd component of the translation
  4012. * @returns the current updated matrix
  4013. */
  4014. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4015. /**
  4016. * Inserts the translation vector in the current matrix
  4017. * @param vector3 defines the translation to insert
  4018. * @returns the current updated matrix
  4019. */
  4020. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4021. /**
  4022. * Gets the translation value of the current matrix
  4023. * @returns a new Vector3 as the extracted translation from the matrix
  4024. */
  4025. getTranslation(): Vector3;
  4026. /**
  4027. * Fill a Vector3 with the extracted translation from the matrix
  4028. * @param result defines the Vector3 where to store the translation
  4029. * @returns the current matrix
  4030. */
  4031. getTranslationToRef(result: Vector3): Matrix;
  4032. /**
  4033. * Remove rotation and scaling part from the matrix
  4034. * @returns the updated matrix
  4035. */
  4036. removeRotationAndScaling(): Matrix;
  4037. /**
  4038. * Multiply two matrices
  4039. * @param other defines the second operand
  4040. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4041. */
  4042. multiply(other: DeepImmutable<Matrix>): Matrix;
  4043. /**
  4044. * Copy the current matrix from the given one
  4045. * @param other defines the source matrix
  4046. * @returns the current updated matrix
  4047. */
  4048. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4049. /**
  4050. * Populates the given array from the starting index with the current matrix values
  4051. * @param array defines the target array
  4052. * @param offset defines the offset in the target array where to start storing values
  4053. * @returns the current matrix
  4054. */
  4055. copyToArray(array: Float32Array, offset?: number): Matrix;
  4056. /**
  4057. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4058. * @param other defines the second operand
  4059. * @param result defines the matrix where to store the multiplication
  4060. * @returns the current matrix
  4061. */
  4062. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4063. /**
  4064. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4065. * @param other defines the second operand
  4066. * @param result defines the array where to store the multiplication
  4067. * @param offset defines the offset in the target array where to start storing values
  4068. * @returns the current matrix
  4069. */
  4070. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4071. /**
  4072. * Check equality between this matrix and a second one
  4073. * @param value defines the second matrix to compare
  4074. * @returns true is the current matrix and the given one values are strictly equal
  4075. */
  4076. equals(value: DeepImmutable<Matrix>): boolean;
  4077. /**
  4078. * Clone the current matrix
  4079. * @returns a new matrix from the current matrix
  4080. */
  4081. clone(): Matrix;
  4082. /**
  4083. * Returns the name of the current matrix class
  4084. * @returns the string "Matrix"
  4085. */
  4086. getClassName(): string;
  4087. /**
  4088. * Gets the hash code of the current matrix
  4089. * @returns the hash code
  4090. */
  4091. getHashCode(): number;
  4092. /**
  4093. * Decomposes the current Matrix into a translation, rotation and scaling components
  4094. * @param scale defines the scale vector3 given as a reference to update
  4095. * @param rotation defines the rotation quaternion given as a reference to update
  4096. * @param translation defines the translation vector3 given as a reference to update
  4097. * @returns true if operation was successful
  4098. */
  4099. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4100. /**
  4101. * Gets specific row of the matrix
  4102. * @param index defines the number of the row to get
  4103. * @returns the index-th row of the current matrix as a new Vector4
  4104. */
  4105. getRow(index: number): Nullable<Vector4>;
  4106. /**
  4107. * Sets the index-th row of the current matrix to the vector4 values
  4108. * @param index defines the number of the row to set
  4109. * @param row defines the target vector4
  4110. * @returns the updated current matrix
  4111. */
  4112. setRow(index: number, row: Vector4): Matrix;
  4113. /**
  4114. * Compute the transpose of the matrix
  4115. * @returns the new transposed matrix
  4116. */
  4117. transpose(): Matrix;
  4118. /**
  4119. * Compute the transpose of the matrix and store it in a given matrix
  4120. * @param result defines the target matrix
  4121. * @returns the current matrix
  4122. */
  4123. transposeToRef(result: Matrix): Matrix;
  4124. /**
  4125. * Sets the index-th row of the current matrix with the given 4 x float values
  4126. * @param index defines the row index
  4127. * @param x defines the x component to set
  4128. * @param y defines the y component to set
  4129. * @param z defines the z component to set
  4130. * @param w defines the w component to set
  4131. * @returns the updated current matrix
  4132. */
  4133. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4134. /**
  4135. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4136. * @param scale defines the scale factor
  4137. * @returns a new matrix
  4138. */
  4139. scale(scale: number): Matrix;
  4140. /**
  4141. * Scale the current matrix values by a factor to a given result matrix
  4142. * @param scale defines the scale factor
  4143. * @param result defines the matrix to store the result
  4144. * @returns the current matrix
  4145. */
  4146. scaleToRef(scale: number, result: Matrix): Matrix;
  4147. /**
  4148. * Scale the current matrix values by a factor and add the result to a given matrix
  4149. * @param scale defines the scale factor
  4150. * @param result defines the Matrix to store the result
  4151. * @returns the current matrix
  4152. */
  4153. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4154. /**
  4155. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4156. * @param ref matrix to store the result
  4157. */
  4158. toNormalMatrix(ref: Matrix): void;
  4159. /**
  4160. * Gets only rotation part of the current matrix
  4161. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4162. */
  4163. getRotationMatrix(): Matrix;
  4164. /**
  4165. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4166. * @param result defines the target matrix to store data to
  4167. * @returns the current matrix
  4168. */
  4169. getRotationMatrixToRef(result: Matrix): Matrix;
  4170. /**
  4171. * Toggles model matrix from being right handed to left handed in place and vice versa
  4172. */
  4173. toggleModelMatrixHandInPlace(): void;
  4174. /**
  4175. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4176. */
  4177. toggleProjectionMatrixHandInPlace(): void;
  4178. /**
  4179. * Creates a matrix from an array
  4180. * @param array defines the source array
  4181. * @param offset defines an offset in the source array
  4182. * @returns a new Matrix set from the starting index of the given array
  4183. */
  4184. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4185. /**
  4186. * Copy the content of an array into a given matrix
  4187. * @param array defines the source array
  4188. * @param offset defines an offset in the source array
  4189. * @param result defines the target matrix
  4190. */
  4191. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4192. /**
  4193. * Stores an array into a matrix after having multiplied each component by a given factor
  4194. * @param array defines the source array
  4195. * @param offset defines the offset in the source array
  4196. * @param scale defines the scaling factor
  4197. * @param result defines the target matrix
  4198. */
  4199. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4200. /**
  4201. * Gets an identity matrix that must not be updated
  4202. */
  4203. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4204. /**
  4205. * Stores a list of values (16) inside a given matrix
  4206. * @param initialM11 defines 1st value of 1st row
  4207. * @param initialM12 defines 2nd value of 1st row
  4208. * @param initialM13 defines 3rd value of 1st row
  4209. * @param initialM14 defines 4th value of 1st row
  4210. * @param initialM21 defines 1st value of 2nd row
  4211. * @param initialM22 defines 2nd value of 2nd row
  4212. * @param initialM23 defines 3rd value of 2nd row
  4213. * @param initialM24 defines 4th value of 2nd row
  4214. * @param initialM31 defines 1st value of 3rd row
  4215. * @param initialM32 defines 2nd value of 3rd row
  4216. * @param initialM33 defines 3rd value of 3rd row
  4217. * @param initialM34 defines 4th value of 3rd row
  4218. * @param initialM41 defines 1st value of 4th row
  4219. * @param initialM42 defines 2nd value of 4th row
  4220. * @param initialM43 defines 3rd value of 4th row
  4221. * @param initialM44 defines 4th value of 4th row
  4222. * @param result defines the target matrix
  4223. */
  4224. 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;
  4225. /**
  4226. * Creates new matrix from a list of values (16)
  4227. * @param initialM11 defines 1st value of 1st row
  4228. * @param initialM12 defines 2nd value of 1st row
  4229. * @param initialM13 defines 3rd value of 1st row
  4230. * @param initialM14 defines 4th value of 1st row
  4231. * @param initialM21 defines 1st value of 2nd row
  4232. * @param initialM22 defines 2nd value of 2nd row
  4233. * @param initialM23 defines 3rd value of 2nd row
  4234. * @param initialM24 defines 4th value of 2nd row
  4235. * @param initialM31 defines 1st value of 3rd row
  4236. * @param initialM32 defines 2nd value of 3rd row
  4237. * @param initialM33 defines 3rd value of 3rd row
  4238. * @param initialM34 defines 4th value of 3rd row
  4239. * @param initialM41 defines 1st value of 4th row
  4240. * @param initialM42 defines 2nd value of 4th row
  4241. * @param initialM43 defines 3rd value of 4th row
  4242. * @param initialM44 defines 4th value of 4th row
  4243. * @returns the new matrix
  4244. */
  4245. 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;
  4246. /**
  4247. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4248. * @param scale defines the scale vector3
  4249. * @param rotation defines the rotation quaternion
  4250. * @param translation defines the translation vector3
  4251. * @returns a new matrix
  4252. */
  4253. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4254. /**
  4255. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4256. * @param scale defines the scale vector3
  4257. * @param rotation defines the rotation quaternion
  4258. * @param translation defines the translation vector3
  4259. * @param result defines the target matrix
  4260. */
  4261. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4262. /**
  4263. * Creates a new identity matrix
  4264. * @returns a new identity matrix
  4265. */
  4266. static Identity(): Matrix;
  4267. /**
  4268. * Creates a new identity matrix and stores the result in a given matrix
  4269. * @param result defines the target matrix
  4270. */
  4271. static IdentityToRef(result: Matrix): void;
  4272. /**
  4273. * Creates a new zero matrix
  4274. * @returns a new zero matrix
  4275. */
  4276. static Zero(): Matrix;
  4277. /**
  4278. * Creates a new rotation matrix for "angle" radians around the X axis
  4279. * @param angle defines the angle (in radians) to use
  4280. * @return the new matrix
  4281. */
  4282. static RotationX(angle: number): Matrix;
  4283. /**
  4284. * Creates a new matrix as the invert of a given matrix
  4285. * @param source defines the source matrix
  4286. * @returns the new matrix
  4287. */
  4288. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4289. /**
  4290. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4291. * @param angle defines the angle (in radians) to use
  4292. * @param result defines the target matrix
  4293. */
  4294. static RotationXToRef(angle: number, result: Matrix): void;
  4295. /**
  4296. * Creates a new rotation matrix for "angle" radians around the Y axis
  4297. * @param angle defines the angle (in radians) to use
  4298. * @return the new matrix
  4299. */
  4300. static RotationY(angle: number): Matrix;
  4301. /**
  4302. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4303. * @param angle defines the angle (in radians) to use
  4304. * @param result defines the target matrix
  4305. */
  4306. static RotationYToRef(angle: number, result: Matrix): void;
  4307. /**
  4308. * Creates a new rotation matrix for "angle" radians around the Z axis
  4309. * @param angle defines the angle (in radians) to use
  4310. * @return the new matrix
  4311. */
  4312. static RotationZ(angle: number): Matrix;
  4313. /**
  4314. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4315. * @param angle defines the angle (in radians) to use
  4316. * @param result defines the target matrix
  4317. */
  4318. static RotationZToRef(angle: number, result: Matrix): void;
  4319. /**
  4320. * Creates a new rotation matrix for "angle" radians around the given axis
  4321. * @param axis defines the axis to use
  4322. * @param angle defines the angle (in radians) to use
  4323. * @return the new matrix
  4324. */
  4325. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4326. /**
  4327. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4328. * @param axis defines the axis to use
  4329. * @param angle defines the angle (in radians) to use
  4330. * @param result defines the target matrix
  4331. */
  4332. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4333. /**
  4334. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4335. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4336. * @param from defines the vector to align
  4337. * @param to defines the vector to align to
  4338. * @param result defines the target matrix
  4339. */
  4340. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4341. /**
  4342. * Creates a rotation matrix
  4343. * @param yaw defines the yaw angle in radians (Y axis)
  4344. * @param pitch defines the pitch angle in radians (X axis)
  4345. * @param roll defines the roll angle in radians (X axis)
  4346. * @returns the new rotation matrix
  4347. */
  4348. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4349. /**
  4350. * Creates a rotation matrix and stores it in a given matrix
  4351. * @param yaw defines the yaw angle in radians (Y axis)
  4352. * @param pitch defines the pitch angle in radians (X axis)
  4353. * @param roll defines the roll angle in radians (X axis)
  4354. * @param result defines the target matrix
  4355. */
  4356. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4357. /**
  4358. * Creates a scaling matrix
  4359. * @param x defines the scale factor on X axis
  4360. * @param y defines the scale factor on Y axis
  4361. * @param z defines the scale factor on Z axis
  4362. * @returns the new matrix
  4363. */
  4364. static Scaling(x: number, y: number, z: number): Matrix;
  4365. /**
  4366. * Creates a scaling matrix and stores it in a given matrix
  4367. * @param x defines the scale factor on X axis
  4368. * @param y defines the scale factor on Y axis
  4369. * @param z defines the scale factor on Z axis
  4370. * @param result defines the target matrix
  4371. */
  4372. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4373. /**
  4374. * Creates a translation matrix
  4375. * @param x defines the translation on X axis
  4376. * @param y defines the translation on Y axis
  4377. * @param z defines the translationon Z axis
  4378. * @returns the new matrix
  4379. */
  4380. static Translation(x: number, y: number, z: number): Matrix;
  4381. /**
  4382. * Creates a translation matrix and stores it in a given matrix
  4383. * @param x defines the translation on X axis
  4384. * @param y defines the translation on Y axis
  4385. * @param z defines the translationon Z axis
  4386. * @param result defines the target matrix
  4387. */
  4388. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4389. /**
  4390. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4391. * @param startValue defines the start value
  4392. * @param endValue defines the end value
  4393. * @param gradient defines the gradient factor
  4394. * @returns the new matrix
  4395. */
  4396. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4397. /**
  4398. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4399. * @param startValue defines the start value
  4400. * @param endValue defines the end value
  4401. * @param gradient defines the gradient factor
  4402. * @param result defines the Matrix object where to store data
  4403. */
  4404. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4405. /**
  4406. * Builds a new matrix whose values are computed by:
  4407. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4408. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4409. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4410. * @param startValue defines the first matrix
  4411. * @param endValue defines the second matrix
  4412. * @param gradient defines the gradient between the two matrices
  4413. * @returns the new matrix
  4414. */
  4415. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4416. /**
  4417. * Update a matrix to values which are computed by:
  4418. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4419. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4420. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4421. * @param startValue defines the first matrix
  4422. * @param endValue defines the second matrix
  4423. * @param gradient defines the gradient between the two matrices
  4424. * @param result defines the target matrix
  4425. */
  4426. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4427. /**
  4428. * 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"
  4429. * This function works in left handed mode
  4430. * @param eye defines the final position of the entity
  4431. * @param target defines where the entity should look at
  4432. * @param up defines the up vector for the entity
  4433. * @returns the new matrix
  4434. */
  4435. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4436. /**
  4437. * 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".
  4438. * This function works in left handed mode
  4439. * @param eye defines the final position of the entity
  4440. * @param target defines where the entity should look at
  4441. * @param up defines the up vector for the entity
  4442. * @param result defines the target matrix
  4443. */
  4444. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4445. /**
  4446. * 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"
  4447. * This function works in right handed mode
  4448. * @param eye defines the final position of the entity
  4449. * @param target defines where the entity should look at
  4450. * @param up defines the up vector for the entity
  4451. * @returns the new matrix
  4452. */
  4453. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4454. /**
  4455. * 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".
  4456. * This function works in right handed mode
  4457. * @param eye defines the final position of the entity
  4458. * @param target defines where the entity should look at
  4459. * @param up defines the up vector for the entity
  4460. * @param result defines the target matrix
  4461. */
  4462. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4463. /**
  4464. * Create a left-handed orthographic projection matrix
  4465. * @param width defines the viewport width
  4466. * @param height defines the viewport height
  4467. * @param znear defines the near clip plane
  4468. * @param zfar defines the far clip plane
  4469. * @returns a new matrix as a left-handed orthographic projection matrix
  4470. */
  4471. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4472. /**
  4473. * Store a left-handed orthographic projection to a given matrix
  4474. * @param width defines the viewport width
  4475. * @param height defines the viewport height
  4476. * @param znear defines the near clip plane
  4477. * @param zfar defines the far clip plane
  4478. * @param result defines the target matrix
  4479. */
  4480. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4481. /**
  4482. * Create a left-handed orthographic projection matrix
  4483. * @param left defines the viewport left coordinate
  4484. * @param right defines the viewport right coordinate
  4485. * @param bottom defines the viewport bottom coordinate
  4486. * @param top defines the viewport top coordinate
  4487. * @param znear defines the near clip plane
  4488. * @param zfar defines the far clip plane
  4489. * @returns a new matrix as a left-handed orthographic projection matrix
  4490. */
  4491. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4492. /**
  4493. * Stores a left-handed orthographic projection into a given matrix
  4494. * @param left defines the viewport left coordinate
  4495. * @param right defines the viewport right coordinate
  4496. * @param bottom defines the viewport bottom coordinate
  4497. * @param top defines the viewport top coordinate
  4498. * @param znear defines the near clip plane
  4499. * @param zfar defines the far clip plane
  4500. * @param result defines the target matrix
  4501. */
  4502. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4503. /**
  4504. * Creates a right-handed orthographic projection matrix
  4505. * @param left defines the viewport left coordinate
  4506. * @param right defines the viewport right coordinate
  4507. * @param bottom defines the viewport bottom coordinate
  4508. * @param top defines the viewport top coordinate
  4509. * @param znear defines the near clip plane
  4510. * @param zfar defines the far clip plane
  4511. * @returns a new matrix as a right-handed orthographic projection matrix
  4512. */
  4513. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4514. /**
  4515. * Stores a right-handed orthographic projection into a given matrix
  4516. * @param left defines the viewport left coordinate
  4517. * @param right defines the viewport right coordinate
  4518. * @param bottom defines the viewport bottom coordinate
  4519. * @param top defines the viewport top coordinate
  4520. * @param znear defines the near clip plane
  4521. * @param zfar defines the far clip plane
  4522. * @param result defines the target matrix
  4523. */
  4524. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4525. /**
  4526. * Creates a left-handed perspective projection matrix
  4527. * @param width defines the viewport width
  4528. * @param height defines the viewport height
  4529. * @param znear defines the near clip plane
  4530. * @param zfar defines the far clip plane
  4531. * @returns a new matrix as a left-handed perspective projection matrix
  4532. */
  4533. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4534. /**
  4535. * Creates a left-handed perspective projection matrix
  4536. * @param fov defines the horizontal field of view
  4537. * @param aspect defines the aspect ratio
  4538. * @param znear defines the near clip plane
  4539. * @param zfar defines the far clip plane
  4540. * @returns a new matrix as a left-handed perspective projection matrix
  4541. */
  4542. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4543. /**
  4544. * Stores a left-handed perspective projection into a given matrix
  4545. * @param fov defines the horizontal field of view
  4546. * @param aspect defines the aspect ratio
  4547. * @param znear defines the near clip plane
  4548. * @param zfar defines the far clip plane
  4549. * @param result defines the target matrix
  4550. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4551. */
  4552. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4553. /**
  4554. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4555. * @param fov defines the horizontal field of view
  4556. * @param aspect defines the aspect ratio
  4557. * @param znear defines the near clip plane
  4558. * @param zfar not used as infinity is used as far clip
  4559. * @param result defines the target matrix
  4560. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4561. */
  4562. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4563. /**
  4564. * Creates a right-handed perspective projection matrix
  4565. * @param fov defines the horizontal field of view
  4566. * @param aspect defines the aspect ratio
  4567. * @param znear defines the near clip plane
  4568. * @param zfar defines the far clip plane
  4569. * @returns a new matrix as a right-handed perspective projection matrix
  4570. */
  4571. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4572. /**
  4573. * Stores a right-handed perspective projection into a given matrix
  4574. * @param fov defines the horizontal field of view
  4575. * @param aspect defines the aspect ratio
  4576. * @param znear defines the near clip plane
  4577. * @param zfar defines the far clip plane
  4578. * @param result defines the target matrix
  4579. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4580. */
  4581. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4582. /**
  4583. * Stores a right-handed perspective projection into a given matrix
  4584. * @param fov defines the horizontal field of view
  4585. * @param aspect defines the aspect ratio
  4586. * @param znear defines the near clip plane
  4587. * @param zfar not used as infinity is used as far clip
  4588. * @param result defines the target matrix
  4589. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4590. */
  4591. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4592. /**
  4593. * Stores a perspective projection for WebVR info a given matrix
  4594. * @param fov defines the field of view
  4595. * @param znear defines the near clip plane
  4596. * @param zfar defines the far clip plane
  4597. * @param result defines the target matrix
  4598. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4599. */
  4600. static PerspectiveFovWebVRToRef(fov: {
  4601. upDegrees: number;
  4602. downDegrees: number;
  4603. leftDegrees: number;
  4604. rightDegrees: number;
  4605. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4606. /**
  4607. * Computes a complete transformation matrix
  4608. * @param viewport defines the viewport to use
  4609. * @param world defines the world matrix
  4610. * @param view defines the view matrix
  4611. * @param projection defines the projection matrix
  4612. * @param zmin defines the near clip plane
  4613. * @param zmax defines the far clip plane
  4614. * @returns the transformation matrix
  4615. */
  4616. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4617. /**
  4618. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4619. * @param matrix defines the matrix to use
  4620. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4621. */
  4622. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4623. /**
  4624. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4625. * @param matrix defines the matrix to use
  4626. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4627. */
  4628. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4629. /**
  4630. * Compute the transpose of a given matrix
  4631. * @param matrix defines the matrix to transpose
  4632. * @returns the new matrix
  4633. */
  4634. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4635. /**
  4636. * Compute the transpose of a matrix and store it in a target matrix
  4637. * @param matrix defines the matrix to transpose
  4638. * @param result defines the target matrix
  4639. */
  4640. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4641. /**
  4642. * Computes a reflection matrix from a plane
  4643. * @param plane defines the reflection plane
  4644. * @returns a new matrix
  4645. */
  4646. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4647. /**
  4648. * Computes a reflection matrix from a plane
  4649. * @param plane defines the reflection plane
  4650. * @param result defines the target matrix
  4651. */
  4652. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4653. /**
  4654. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4655. * @param xaxis defines the value of the 1st axis
  4656. * @param yaxis defines the value of the 2nd axis
  4657. * @param zaxis defines the value of the 3rd axis
  4658. * @param result defines the target matrix
  4659. */
  4660. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4661. /**
  4662. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4663. * @param quat defines the quaternion to use
  4664. * @param result defines the target matrix
  4665. */
  4666. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4667. }
  4668. /**
  4669. * @hidden
  4670. */
  4671. export class TmpVectors {
  4672. static Vector2: Vector2[];
  4673. static Vector3: Vector3[];
  4674. static Vector4: Vector4[];
  4675. static Quaternion: Quaternion[];
  4676. static Matrix: Matrix[];
  4677. }
  4678. }
  4679. declare module "babylonjs/Maths/math.path" {
  4680. import { DeepImmutable, Nullable } from "babylonjs/types";
  4681. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4682. /**
  4683. * Defines potential orientation for back face culling
  4684. */
  4685. export enum Orientation {
  4686. /**
  4687. * Clockwise
  4688. */
  4689. CW = 0,
  4690. /** Counter clockwise */
  4691. CCW = 1
  4692. }
  4693. /** Class used to represent a Bezier curve */
  4694. export class BezierCurve {
  4695. /**
  4696. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4697. * @param t defines the time
  4698. * @param x1 defines the left coordinate on X axis
  4699. * @param y1 defines the left coordinate on Y axis
  4700. * @param x2 defines the right coordinate on X axis
  4701. * @param y2 defines the right coordinate on Y axis
  4702. * @returns the interpolated value
  4703. */
  4704. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4705. }
  4706. /**
  4707. * Defines angle representation
  4708. */
  4709. export class Angle {
  4710. private _radians;
  4711. /**
  4712. * Creates an Angle object of "radians" radians (float).
  4713. * @param radians the angle in radians
  4714. */
  4715. constructor(radians: number);
  4716. /**
  4717. * Get value in degrees
  4718. * @returns the Angle value in degrees (float)
  4719. */
  4720. degrees(): number;
  4721. /**
  4722. * Get value in radians
  4723. * @returns the Angle value in radians (float)
  4724. */
  4725. radians(): number;
  4726. /**
  4727. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4728. * @param a defines first vector
  4729. * @param b defines second vector
  4730. * @returns a new Angle
  4731. */
  4732. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4733. /**
  4734. * Gets a new Angle object from the given float in radians
  4735. * @param radians defines the angle value in radians
  4736. * @returns a new Angle
  4737. */
  4738. static FromRadians(radians: number): Angle;
  4739. /**
  4740. * Gets a new Angle object from the given float in degrees
  4741. * @param degrees defines the angle value in degrees
  4742. * @returns a new Angle
  4743. */
  4744. static FromDegrees(degrees: number): Angle;
  4745. }
  4746. /**
  4747. * This represents an arc in a 2d space.
  4748. */
  4749. export class Arc2 {
  4750. /** Defines the start point of the arc */
  4751. startPoint: Vector2;
  4752. /** Defines the mid point of the arc */
  4753. midPoint: Vector2;
  4754. /** Defines the end point of the arc */
  4755. endPoint: Vector2;
  4756. /**
  4757. * Defines the center point of the arc.
  4758. */
  4759. centerPoint: Vector2;
  4760. /**
  4761. * Defines the radius of the arc.
  4762. */
  4763. radius: number;
  4764. /**
  4765. * Defines the angle of the arc (from mid point to end point).
  4766. */
  4767. angle: Angle;
  4768. /**
  4769. * Defines the start angle of the arc (from start point to middle point).
  4770. */
  4771. startAngle: Angle;
  4772. /**
  4773. * Defines the orientation of the arc (clock wise/counter clock wise).
  4774. */
  4775. orientation: Orientation;
  4776. /**
  4777. * Creates an Arc object from the three given points : start, middle and end.
  4778. * @param startPoint Defines the start point of the arc
  4779. * @param midPoint Defines the midlle point of the arc
  4780. * @param endPoint Defines the end point of the arc
  4781. */
  4782. constructor(
  4783. /** Defines the start point of the arc */
  4784. startPoint: Vector2,
  4785. /** Defines the mid point of the arc */
  4786. midPoint: Vector2,
  4787. /** Defines the end point of the arc */
  4788. endPoint: Vector2);
  4789. }
  4790. /**
  4791. * Represents a 2D path made up of multiple 2D points
  4792. */
  4793. export class Path2 {
  4794. private _points;
  4795. private _length;
  4796. /**
  4797. * If the path start and end point are the same
  4798. */
  4799. closed: boolean;
  4800. /**
  4801. * Creates a Path2 object from the starting 2D coordinates x and y.
  4802. * @param x the starting points x value
  4803. * @param y the starting points y value
  4804. */
  4805. constructor(x: number, y: number);
  4806. /**
  4807. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4808. * @param x the added points x value
  4809. * @param y the added points y value
  4810. * @returns the updated Path2.
  4811. */
  4812. addLineTo(x: number, y: number): Path2;
  4813. /**
  4814. * 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.
  4815. * @param midX middle point x value
  4816. * @param midY middle point y value
  4817. * @param endX end point x value
  4818. * @param endY end point y value
  4819. * @param numberOfSegments (default: 36)
  4820. * @returns the updated Path2.
  4821. */
  4822. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4823. /**
  4824. * Closes the Path2.
  4825. * @returns the Path2.
  4826. */
  4827. close(): Path2;
  4828. /**
  4829. * Gets the sum of the distance between each sequential point in the path
  4830. * @returns the Path2 total length (float).
  4831. */
  4832. length(): number;
  4833. /**
  4834. * Gets the points which construct the path
  4835. * @returns the Path2 internal array of points.
  4836. */
  4837. getPoints(): Vector2[];
  4838. /**
  4839. * Retreives the point at the distance aways from the starting point
  4840. * @param normalizedLengthPosition the length along the path to retreive the point from
  4841. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4842. */
  4843. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4844. /**
  4845. * Creates a new path starting from an x and y position
  4846. * @param x starting x value
  4847. * @param y starting y value
  4848. * @returns a new Path2 starting at the coordinates (x, y).
  4849. */
  4850. static StartingAt(x: number, y: number): Path2;
  4851. }
  4852. /**
  4853. * Represents a 3D path made up of multiple 3D points
  4854. */
  4855. export class Path3D {
  4856. /**
  4857. * an array of Vector3, the curve axis of the Path3D
  4858. */
  4859. path: Vector3[];
  4860. private _curve;
  4861. private _distances;
  4862. private _tangents;
  4863. private _normals;
  4864. private _binormals;
  4865. private _raw;
  4866. private _alignTangentsWithPath;
  4867. private readonly _pointAtData;
  4868. /**
  4869. * new Path3D(path, normal, raw)
  4870. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4871. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4872. * @param path an array of Vector3, the curve axis of the Path3D
  4873. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4874. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4875. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4876. */
  4877. constructor(
  4878. /**
  4879. * an array of Vector3, the curve axis of the Path3D
  4880. */
  4881. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4882. /**
  4883. * Returns the Path3D array of successive Vector3 designing its curve.
  4884. * @returns the Path3D array of successive Vector3 designing its curve.
  4885. */
  4886. getCurve(): Vector3[];
  4887. /**
  4888. * Returns the Path3D array of successive Vector3 designing its curve.
  4889. * @returns the Path3D array of successive Vector3 designing its curve.
  4890. */
  4891. getPoints(): Vector3[];
  4892. /**
  4893. * @returns the computed length (float) of the path.
  4894. */
  4895. length(): number;
  4896. /**
  4897. * Returns an array populated with tangent vectors on each Path3D curve point.
  4898. * @returns an array populated with tangent vectors on each Path3D curve point.
  4899. */
  4900. getTangents(): Vector3[];
  4901. /**
  4902. * Returns an array populated with normal vectors on each Path3D curve point.
  4903. * @returns an array populated with normal vectors on each Path3D curve point.
  4904. */
  4905. getNormals(): Vector3[];
  4906. /**
  4907. * Returns an array populated with binormal vectors on each Path3D curve point.
  4908. * @returns an array populated with binormal vectors on each Path3D curve point.
  4909. */
  4910. getBinormals(): Vector3[];
  4911. /**
  4912. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4913. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4914. */
  4915. getDistances(): number[];
  4916. /**
  4917. * Returns an interpolated point along this path
  4918. * @param position the position of the point along this path, from 0.0 to 1.0
  4919. * @returns a new Vector3 as the point
  4920. */
  4921. getPointAt(position: number): Vector3;
  4922. /**
  4923. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4924. * @param position the position of the point along this path, from 0.0 to 1.0
  4925. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4926. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4927. */
  4928. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4929. /**
  4930. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4931. * @param position the position of the point along this path, from 0.0 to 1.0
  4932. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4933. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4934. */
  4935. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4936. /**
  4937. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4938. * @param position the position of the point along this path, from 0.0 to 1.0
  4939. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4940. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4941. */
  4942. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4943. /**
  4944. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4945. * @param position the position of the point along this path, from 0.0 to 1.0
  4946. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4947. */
  4948. getDistanceAt(position: number): number;
  4949. /**
  4950. * Returns the array index of the previous point of an interpolated point along this path
  4951. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4952. * @returns the array index
  4953. */
  4954. getPreviousPointIndexAt(position: number): number;
  4955. /**
  4956. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4957. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4958. * @returns the sub position
  4959. */
  4960. getSubPositionAt(position: number): number;
  4961. /**
  4962. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4963. * @param target the vector of which to get the closest position to
  4964. * @returns the position of the closest virtual point on this path to the target vector
  4965. */
  4966. getClosestPositionTo(target: Vector3): number;
  4967. /**
  4968. * Returns a sub path (slice) of this path
  4969. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4970. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4971. * @returns a sub path (slice) of this path
  4972. */
  4973. slice(start?: number, end?: number): Path3D;
  4974. /**
  4975. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4976. * @param path path which all values are copied into the curves points
  4977. * @param firstNormal which should be projected onto the curve
  4978. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4979. * @returns the same object updated.
  4980. */
  4981. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4982. private _compute;
  4983. private _getFirstNonNullVector;
  4984. private _getLastNonNullVector;
  4985. private _normalVector;
  4986. /**
  4987. * Updates the point at data for an interpolated point along this curve
  4988. * @param position the position of the point along this curve, from 0.0 to 1.0
  4989. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4990. * @returns the (updated) point at data
  4991. */
  4992. private _updatePointAtData;
  4993. /**
  4994. * Updates the point at data from the specified parameters
  4995. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4996. * @param point the interpolated point
  4997. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4998. */
  4999. private _setPointAtData;
  5000. /**
  5001. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5002. */
  5003. private _updateInterpolationMatrix;
  5004. }
  5005. /**
  5006. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5007. * A Curve3 is designed from a series of successive Vector3.
  5008. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5009. */
  5010. export class Curve3 {
  5011. private _points;
  5012. private _length;
  5013. /**
  5014. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5015. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5016. * @param v1 (Vector3) the control point
  5017. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5018. * @param nbPoints (integer) the wanted number of points in the curve
  5019. * @returns the created Curve3
  5020. */
  5021. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5022. /**
  5023. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5024. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5025. * @param v1 (Vector3) the first control point
  5026. * @param v2 (Vector3) the second control point
  5027. * @param v3 (Vector3) the end point of the Cubic Bezier
  5028. * @param nbPoints (integer) the wanted number of points in the curve
  5029. * @returns the created Curve3
  5030. */
  5031. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5032. /**
  5033. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5034. * @param p1 (Vector3) the origin point of the Hermite Spline
  5035. * @param t1 (Vector3) the tangent vector at the origin point
  5036. * @param p2 (Vector3) the end point of the Hermite Spline
  5037. * @param t2 (Vector3) the tangent vector at the end point
  5038. * @param nbPoints (integer) the wanted number of points in the curve
  5039. * @returns the created Curve3
  5040. */
  5041. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5042. /**
  5043. * Returns a Curve3 object along a CatmullRom Spline curve :
  5044. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5045. * @param nbPoints (integer) the wanted number of points between each curve control points
  5046. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5047. * @returns the created Curve3
  5048. */
  5049. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5050. /**
  5051. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5052. * A Curve3 is designed from a series of successive Vector3.
  5053. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5054. * @param points points which make up the curve
  5055. */
  5056. constructor(points: Vector3[]);
  5057. /**
  5058. * @returns the Curve3 stored array of successive Vector3
  5059. */
  5060. getPoints(): Vector3[];
  5061. /**
  5062. * @returns the computed length (float) of the curve.
  5063. */
  5064. length(): number;
  5065. /**
  5066. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5067. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5068. * curveA and curveB keep unchanged.
  5069. * @param curve the curve to continue from this curve
  5070. * @returns the newly constructed curve
  5071. */
  5072. continue(curve: DeepImmutable<Curve3>): Curve3;
  5073. private _computeLength;
  5074. }
  5075. }
  5076. declare module "babylonjs/Animations/easing" {
  5077. /**
  5078. * This represents the main contract an easing function should follow.
  5079. * Easing functions are used throughout the animation system.
  5080. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5081. */
  5082. export interface IEasingFunction {
  5083. /**
  5084. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5085. * of the easing function.
  5086. * The link below provides some of the most common examples of easing functions.
  5087. * @see https://easings.net/
  5088. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5089. * @returns the corresponding value on the curve defined by the easing function
  5090. */
  5091. ease(gradient: number): number;
  5092. }
  5093. /**
  5094. * Base class used for every default easing function.
  5095. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5096. */
  5097. export class EasingFunction implements IEasingFunction {
  5098. /**
  5099. * Interpolation follows the mathematical formula associated with the easing function.
  5100. */
  5101. static readonly EASINGMODE_EASEIN: number;
  5102. /**
  5103. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5104. */
  5105. static readonly EASINGMODE_EASEOUT: number;
  5106. /**
  5107. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5108. */
  5109. static readonly EASINGMODE_EASEINOUT: number;
  5110. private _easingMode;
  5111. /**
  5112. * Sets the easing mode of the current function.
  5113. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5114. */
  5115. setEasingMode(easingMode: number): void;
  5116. /**
  5117. * Gets the current easing mode.
  5118. * @returns the easing mode
  5119. */
  5120. getEasingMode(): number;
  5121. /**
  5122. * @hidden
  5123. */
  5124. easeInCore(gradient: number): number;
  5125. /**
  5126. * Given an input gradient between 0 and 1, this returns the corresponding value
  5127. * of the easing function.
  5128. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5129. * @returns the corresponding value on the curve defined by the easing function
  5130. */
  5131. ease(gradient: number): number;
  5132. }
  5133. /**
  5134. * Easing function with a circle shape (see link below).
  5135. * @see https://easings.net/#easeInCirc
  5136. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5137. */
  5138. export class CircleEase extends EasingFunction implements IEasingFunction {
  5139. /** @hidden */
  5140. easeInCore(gradient: number): number;
  5141. }
  5142. /**
  5143. * Easing function with a ease back shape (see link below).
  5144. * @see https://easings.net/#easeInBack
  5145. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5146. */
  5147. export class BackEase extends EasingFunction implements IEasingFunction {
  5148. /** Defines the amplitude of the function */
  5149. amplitude: number;
  5150. /**
  5151. * Instantiates a back ease easing
  5152. * @see https://easings.net/#easeInBack
  5153. * @param amplitude Defines the amplitude of the function
  5154. */
  5155. constructor(
  5156. /** Defines the amplitude of the function */
  5157. amplitude?: number);
  5158. /** @hidden */
  5159. easeInCore(gradient: number): number;
  5160. }
  5161. /**
  5162. * Easing function with a bouncing shape (see link below).
  5163. * @see https://easings.net/#easeInBounce
  5164. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5165. */
  5166. export class BounceEase extends EasingFunction implements IEasingFunction {
  5167. /** Defines the number of bounces */
  5168. bounces: number;
  5169. /** Defines the amplitude of the bounce */
  5170. bounciness: number;
  5171. /**
  5172. * Instantiates a bounce easing
  5173. * @see https://easings.net/#easeInBounce
  5174. * @param bounces Defines the number of bounces
  5175. * @param bounciness Defines the amplitude of the bounce
  5176. */
  5177. constructor(
  5178. /** Defines the number of bounces */
  5179. bounces?: number,
  5180. /** Defines the amplitude of the bounce */
  5181. bounciness?: number);
  5182. /** @hidden */
  5183. easeInCore(gradient: number): number;
  5184. }
  5185. /**
  5186. * Easing function with a power of 3 shape (see link below).
  5187. * @see https://easings.net/#easeInCubic
  5188. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5189. */
  5190. export class CubicEase extends EasingFunction implements IEasingFunction {
  5191. /** @hidden */
  5192. easeInCore(gradient: number): number;
  5193. }
  5194. /**
  5195. * Easing function with an elastic shape (see link below).
  5196. * @see https://easings.net/#easeInElastic
  5197. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5198. */
  5199. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5200. /** Defines the number of oscillations*/
  5201. oscillations: number;
  5202. /** Defines the amplitude of the oscillations*/
  5203. springiness: number;
  5204. /**
  5205. * Instantiates an elastic easing function
  5206. * @see https://easings.net/#easeInElastic
  5207. * @param oscillations Defines the number of oscillations
  5208. * @param springiness Defines the amplitude of the oscillations
  5209. */
  5210. constructor(
  5211. /** Defines the number of oscillations*/
  5212. oscillations?: number,
  5213. /** Defines the amplitude of the oscillations*/
  5214. springiness?: number);
  5215. /** @hidden */
  5216. easeInCore(gradient: number): number;
  5217. }
  5218. /**
  5219. * Easing function with an exponential shape (see link below).
  5220. * @see https://easings.net/#easeInExpo
  5221. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5222. */
  5223. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5224. /** Defines the exponent of the function */
  5225. exponent: number;
  5226. /**
  5227. * Instantiates an exponential easing function
  5228. * @see https://easings.net/#easeInExpo
  5229. * @param exponent Defines the exponent of the function
  5230. */
  5231. constructor(
  5232. /** Defines the exponent of the function */
  5233. exponent?: number);
  5234. /** @hidden */
  5235. easeInCore(gradient: number): number;
  5236. }
  5237. /**
  5238. * Easing function with a power shape (see link below).
  5239. * @see https://easings.net/#easeInQuad
  5240. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5241. */
  5242. export class PowerEase extends EasingFunction implements IEasingFunction {
  5243. /** Defines the power of the function */
  5244. power: number;
  5245. /**
  5246. * Instantiates an power base easing function
  5247. * @see https://easings.net/#easeInQuad
  5248. * @param power Defines the power of the function
  5249. */
  5250. constructor(
  5251. /** Defines the power of the function */
  5252. power?: number);
  5253. /** @hidden */
  5254. easeInCore(gradient: number): number;
  5255. }
  5256. /**
  5257. * Easing function with a power of 2 shape (see link below).
  5258. * @see https://easings.net/#easeInQuad
  5259. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5260. */
  5261. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5262. /** @hidden */
  5263. easeInCore(gradient: number): number;
  5264. }
  5265. /**
  5266. * Easing function with a power of 4 shape (see link below).
  5267. * @see https://easings.net/#easeInQuart
  5268. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5269. */
  5270. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5271. /** @hidden */
  5272. easeInCore(gradient: number): number;
  5273. }
  5274. /**
  5275. * Easing function with a power of 5 shape (see link below).
  5276. * @see https://easings.net/#easeInQuint
  5277. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5278. */
  5279. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5280. /** @hidden */
  5281. easeInCore(gradient: number): number;
  5282. }
  5283. /**
  5284. * Easing function with a sin shape (see link below).
  5285. * @see https://easings.net/#easeInSine
  5286. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5287. */
  5288. export class SineEase extends EasingFunction implements IEasingFunction {
  5289. /** @hidden */
  5290. easeInCore(gradient: number): number;
  5291. }
  5292. /**
  5293. * Easing function with a bezier shape (see link below).
  5294. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5295. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5296. */
  5297. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5298. /** Defines the x component of the start tangent in the bezier curve */
  5299. x1: number;
  5300. /** Defines the y component of the start tangent in the bezier curve */
  5301. y1: number;
  5302. /** Defines the x component of the end tangent in the bezier curve */
  5303. x2: number;
  5304. /** Defines the y component of the end tangent in the bezier curve */
  5305. y2: number;
  5306. /**
  5307. * Instantiates a bezier function
  5308. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5309. * @param x1 Defines the x component of the start tangent in the bezier curve
  5310. * @param y1 Defines the y component of the start tangent in the bezier curve
  5311. * @param x2 Defines the x component of the end tangent in the bezier curve
  5312. * @param y2 Defines the y component of the end tangent in the bezier curve
  5313. */
  5314. constructor(
  5315. /** Defines the x component of the start tangent in the bezier curve */
  5316. x1?: number,
  5317. /** Defines the y component of the start tangent in the bezier curve */
  5318. y1?: number,
  5319. /** Defines the x component of the end tangent in the bezier curve */
  5320. x2?: number,
  5321. /** Defines the y component of the end tangent in the bezier curve */
  5322. y2?: number);
  5323. /** @hidden */
  5324. easeInCore(gradient: number): number;
  5325. }
  5326. }
  5327. declare module "babylonjs/Maths/math.color" {
  5328. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5329. /**
  5330. * Class used to hold a RBG color
  5331. */
  5332. export class Color3 {
  5333. /**
  5334. * Defines the red component (between 0 and 1, default is 0)
  5335. */
  5336. r: number;
  5337. /**
  5338. * Defines the green component (between 0 and 1, default is 0)
  5339. */
  5340. g: number;
  5341. /**
  5342. * Defines the blue component (between 0 and 1, default is 0)
  5343. */
  5344. b: number;
  5345. /**
  5346. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5347. * @param r defines the red component (between 0 and 1, default is 0)
  5348. * @param g defines the green component (between 0 and 1, default is 0)
  5349. * @param b defines the blue component (between 0 and 1, default is 0)
  5350. */
  5351. constructor(
  5352. /**
  5353. * Defines the red component (between 0 and 1, default is 0)
  5354. */
  5355. r?: number,
  5356. /**
  5357. * Defines the green component (between 0 and 1, default is 0)
  5358. */
  5359. g?: number,
  5360. /**
  5361. * Defines the blue component (between 0 and 1, default is 0)
  5362. */
  5363. b?: number);
  5364. /**
  5365. * Creates a string with the Color3 current values
  5366. * @returns the string representation of the Color3 object
  5367. */
  5368. toString(): string;
  5369. /**
  5370. * Returns the string "Color3"
  5371. * @returns "Color3"
  5372. */
  5373. getClassName(): string;
  5374. /**
  5375. * Compute the Color3 hash code
  5376. * @returns an unique number that can be used to hash Color3 objects
  5377. */
  5378. getHashCode(): number;
  5379. /**
  5380. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5381. * @param array defines the array where to store the r,g,b components
  5382. * @param index defines an optional index in the target array to define where to start storing values
  5383. * @returns the current Color3 object
  5384. */
  5385. toArray(array: FloatArray, index?: number): Color3;
  5386. /**
  5387. * Returns a new Color4 object from the current Color3 and the given alpha
  5388. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5389. * @returns a new Color4 object
  5390. */
  5391. toColor4(alpha?: number): Color4;
  5392. /**
  5393. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5394. * @returns the new array
  5395. */
  5396. asArray(): number[];
  5397. /**
  5398. * Returns the luminance value
  5399. * @returns a float value
  5400. */
  5401. toLuminance(): number;
  5402. /**
  5403. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5404. * @param otherColor defines the second operand
  5405. * @returns the new Color3 object
  5406. */
  5407. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5408. /**
  5409. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5410. * @param otherColor defines the second operand
  5411. * @param result defines the Color3 object where to store the result
  5412. * @returns the current Color3
  5413. */
  5414. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5415. /**
  5416. * Determines equality between Color3 objects
  5417. * @param otherColor defines the second operand
  5418. * @returns true if the rgb values are equal to the given ones
  5419. */
  5420. equals(otherColor: DeepImmutable<Color3>): boolean;
  5421. /**
  5422. * Determines equality between the current Color3 object and a set of r,b,g values
  5423. * @param r defines the red component to check
  5424. * @param g defines the green component to check
  5425. * @param b defines the blue component to check
  5426. * @returns true if the rgb values are equal to the given ones
  5427. */
  5428. equalsFloats(r: number, g: number, b: number): boolean;
  5429. /**
  5430. * Multiplies in place each rgb value by scale
  5431. * @param scale defines the scaling factor
  5432. * @returns the updated Color3
  5433. */
  5434. scale(scale: number): Color3;
  5435. /**
  5436. * Multiplies the rgb values by scale and stores the result into "result"
  5437. * @param scale defines the scaling factor
  5438. * @param result defines the Color3 object where to store the result
  5439. * @returns the unmodified current Color3
  5440. */
  5441. scaleToRef(scale: number, result: Color3): Color3;
  5442. /**
  5443. * Scale the current Color3 values by a factor and add the result to a given Color3
  5444. * @param scale defines the scale factor
  5445. * @param result defines color to store the result into
  5446. * @returns the unmodified current Color3
  5447. */
  5448. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5449. /**
  5450. * Clamps the rgb values by the min and max values and stores the result into "result"
  5451. * @param min defines minimum clamping value (default is 0)
  5452. * @param max defines maximum clamping value (default is 1)
  5453. * @param result defines color to store the result into
  5454. * @returns the original Color3
  5455. */
  5456. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5457. /**
  5458. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5459. * @param otherColor defines the second operand
  5460. * @returns the new Color3
  5461. */
  5462. add(otherColor: DeepImmutable<Color3>): Color3;
  5463. /**
  5464. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5465. * @param otherColor defines the second operand
  5466. * @param result defines Color3 object to store the result into
  5467. * @returns the unmodified current Color3
  5468. */
  5469. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5470. /**
  5471. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5472. * @param otherColor defines the second operand
  5473. * @returns the new Color3
  5474. */
  5475. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5476. /**
  5477. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5478. * @param otherColor defines the second operand
  5479. * @param result defines Color3 object to store the result into
  5480. * @returns the unmodified current Color3
  5481. */
  5482. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5483. /**
  5484. * Copy the current object
  5485. * @returns a new Color3 copied the current one
  5486. */
  5487. clone(): Color3;
  5488. /**
  5489. * Copies the rgb values from the source in the current Color3
  5490. * @param source defines the source Color3 object
  5491. * @returns the updated Color3 object
  5492. */
  5493. copyFrom(source: DeepImmutable<Color3>): Color3;
  5494. /**
  5495. * Updates the Color3 rgb values from the given floats
  5496. * @param r defines the red component to read from
  5497. * @param g defines the green component to read from
  5498. * @param b defines the blue component to read from
  5499. * @returns the current Color3 object
  5500. */
  5501. copyFromFloats(r: number, g: number, b: number): Color3;
  5502. /**
  5503. * Updates the Color3 rgb values from the given floats
  5504. * @param r defines the red component to read from
  5505. * @param g defines the green component to read from
  5506. * @param b defines the blue component to read from
  5507. * @returns the current Color3 object
  5508. */
  5509. set(r: number, g: number, b: number): Color3;
  5510. /**
  5511. * Compute the Color3 hexadecimal code as a string
  5512. * @returns a string containing the hexadecimal representation of the Color3 object
  5513. */
  5514. toHexString(): string;
  5515. /**
  5516. * Computes a new Color3 converted from the current one to linear space
  5517. * @returns a new Color3 object
  5518. */
  5519. toLinearSpace(): Color3;
  5520. /**
  5521. * Converts current color in rgb space to HSV values
  5522. * @returns a new color3 representing the HSV values
  5523. */
  5524. toHSV(): Color3;
  5525. /**
  5526. * Converts current color in rgb space to HSV values
  5527. * @param result defines the Color3 where to store the HSV values
  5528. */
  5529. toHSVToRef(result: Color3): void;
  5530. /**
  5531. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5532. * @param convertedColor defines the Color3 object where to store the linear space version
  5533. * @returns the unmodified Color3
  5534. */
  5535. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5536. /**
  5537. * Computes a new Color3 converted from the current one to gamma space
  5538. * @returns a new Color3 object
  5539. */
  5540. toGammaSpace(): Color3;
  5541. /**
  5542. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5543. * @param convertedColor defines the Color3 object where to store the gamma space version
  5544. * @returns the unmodified Color3
  5545. */
  5546. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5547. private static _BlackReadOnly;
  5548. /**
  5549. * Convert Hue, saturation and value to a Color3 (RGB)
  5550. * @param hue defines the hue
  5551. * @param saturation defines the saturation
  5552. * @param value defines the value
  5553. * @param result defines the Color3 where to store the RGB values
  5554. */
  5555. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5556. /**
  5557. * Creates a new Color3 from the string containing valid hexadecimal values
  5558. * @param hex defines a string containing valid hexadecimal values
  5559. * @returns a new Color3 object
  5560. */
  5561. static FromHexString(hex: string): Color3;
  5562. /**
  5563. * Creates a new Color3 from the starting index of the given array
  5564. * @param array defines the source array
  5565. * @param offset defines an offset in the source array
  5566. * @returns a new Color3 object
  5567. */
  5568. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5569. /**
  5570. * Creates a new Color3 from integer values (< 256)
  5571. * @param r defines the red component to read from (value between 0 and 255)
  5572. * @param g defines the green component to read from (value between 0 and 255)
  5573. * @param b defines the blue component to read from (value between 0 and 255)
  5574. * @returns a new Color3 object
  5575. */
  5576. static FromInts(r: number, g: number, b: number): Color3;
  5577. /**
  5578. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5579. * @param start defines the start Color3 value
  5580. * @param end defines the end Color3 value
  5581. * @param amount defines the gradient value between start and end
  5582. * @returns a new Color3 object
  5583. */
  5584. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5585. /**
  5586. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5587. * @param left defines the start value
  5588. * @param right defines the end value
  5589. * @param amount defines the gradient factor
  5590. * @param result defines the Color3 object where to store the result
  5591. */
  5592. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5593. /**
  5594. * Returns a Color3 value containing a red color
  5595. * @returns a new Color3 object
  5596. */
  5597. static Red(): Color3;
  5598. /**
  5599. * Returns a Color3 value containing a green color
  5600. * @returns a new Color3 object
  5601. */
  5602. static Green(): Color3;
  5603. /**
  5604. * Returns a Color3 value containing a blue color
  5605. * @returns a new Color3 object
  5606. */
  5607. static Blue(): Color3;
  5608. /**
  5609. * Returns a Color3 value containing a black color
  5610. * @returns a new Color3 object
  5611. */
  5612. static Black(): Color3;
  5613. /**
  5614. * Gets a Color3 value containing a black color that must not be updated
  5615. */
  5616. static get BlackReadOnly(): DeepImmutable<Color3>;
  5617. /**
  5618. * Returns a Color3 value containing a white color
  5619. * @returns a new Color3 object
  5620. */
  5621. static White(): Color3;
  5622. /**
  5623. * Returns a Color3 value containing a purple color
  5624. * @returns a new Color3 object
  5625. */
  5626. static Purple(): Color3;
  5627. /**
  5628. * Returns a Color3 value containing a magenta color
  5629. * @returns a new Color3 object
  5630. */
  5631. static Magenta(): Color3;
  5632. /**
  5633. * Returns a Color3 value containing a yellow color
  5634. * @returns a new Color3 object
  5635. */
  5636. static Yellow(): Color3;
  5637. /**
  5638. * Returns a Color3 value containing a gray color
  5639. * @returns a new Color3 object
  5640. */
  5641. static Gray(): Color3;
  5642. /**
  5643. * Returns a Color3 value containing a teal color
  5644. * @returns a new Color3 object
  5645. */
  5646. static Teal(): Color3;
  5647. /**
  5648. * Returns a Color3 value containing a random color
  5649. * @returns a new Color3 object
  5650. */
  5651. static Random(): Color3;
  5652. }
  5653. /**
  5654. * Class used to hold a RBGA color
  5655. */
  5656. export class Color4 {
  5657. /**
  5658. * Defines the red component (between 0 and 1, default is 0)
  5659. */
  5660. r: number;
  5661. /**
  5662. * Defines the green component (between 0 and 1, default is 0)
  5663. */
  5664. g: number;
  5665. /**
  5666. * Defines the blue component (between 0 and 1, default is 0)
  5667. */
  5668. b: number;
  5669. /**
  5670. * Defines the alpha component (between 0 and 1, default is 1)
  5671. */
  5672. a: number;
  5673. /**
  5674. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5675. * @param r defines the red component (between 0 and 1, default is 0)
  5676. * @param g defines the green component (between 0 and 1, default is 0)
  5677. * @param b defines the blue component (between 0 and 1, default is 0)
  5678. * @param a defines the alpha component (between 0 and 1, default is 1)
  5679. */
  5680. constructor(
  5681. /**
  5682. * Defines the red component (between 0 and 1, default is 0)
  5683. */
  5684. r?: number,
  5685. /**
  5686. * Defines the green component (between 0 and 1, default is 0)
  5687. */
  5688. g?: number,
  5689. /**
  5690. * Defines the blue component (between 0 and 1, default is 0)
  5691. */
  5692. b?: number,
  5693. /**
  5694. * Defines the alpha component (between 0 and 1, default is 1)
  5695. */
  5696. a?: number);
  5697. /**
  5698. * Adds in place the given Color4 values to the current Color4 object
  5699. * @param right defines the second operand
  5700. * @returns the current updated Color4 object
  5701. */
  5702. addInPlace(right: DeepImmutable<Color4>): Color4;
  5703. /**
  5704. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5705. * @returns the new array
  5706. */
  5707. asArray(): number[];
  5708. /**
  5709. * Stores from the starting index in the given array the Color4 successive values
  5710. * @param array defines the array where to store the r,g,b components
  5711. * @param index defines an optional index in the target array to define where to start storing values
  5712. * @returns the current Color4 object
  5713. */
  5714. toArray(array: number[], index?: number): Color4;
  5715. /**
  5716. * Determines equality between Color4 objects
  5717. * @param otherColor defines the second operand
  5718. * @returns true if the rgba values are equal to the given ones
  5719. */
  5720. equals(otherColor: DeepImmutable<Color4>): boolean;
  5721. /**
  5722. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5723. * @param right defines the second operand
  5724. * @returns a new Color4 object
  5725. */
  5726. add(right: DeepImmutable<Color4>): Color4;
  5727. /**
  5728. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5729. * @param right defines the second operand
  5730. * @returns a new Color4 object
  5731. */
  5732. subtract(right: DeepImmutable<Color4>): Color4;
  5733. /**
  5734. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5735. * @param right defines the second operand
  5736. * @param result defines the Color4 object where to store the result
  5737. * @returns the current Color4 object
  5738. */
  5739. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5740. /**
  5741. * Creates a new Color4 with the current Color4 values multiplied by scale
  5742. * @param scale defines the scaling factor to apply
  5743. * @returns a new Color4 object
  5744. */
  5745. scale(scale: number): Color4;
  5746. /**
  5747. * Multiplies the current Color4 values by scale and stores the result in "result"
  5748. * @param scale defines the scaling factor to apply
  5749. * @param result defines the Color4 object where to store the result
  5750. * @returns the current unmodified Color4
  5751. */
  5752. scaleToRef(scale: number, result: Color4): Color4;
  5753. /**
  5754. * Scale the current Color4 values by a factor and add the result to a given Color4
  5755. * @param scale defines the scale factor
  5756. * @param result defines the Color4 object where to store the result
  5757. * @returns the unmodified current Color4
  5758. */
  5759. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5760. /**
  5761. * Clamps the rgb values by the min and max values and stores the result into "result"
  5762. * @param min defines minimum clamping value (default is 0)
  5763. * @param max defines maximum clamping value (default is 1)
  5764. * @param result defines color to store the result into.
  5765. * @returns the cuurent Color4
  5766. */
  5767. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5768. /**
  5769. * Multipy an Color4 value by another and return a new Color4 object
  5770. * @param color defines the Color4 value to multiply by
  5771. * @returns a new Color4 object
  5772. */
  5773. multiply(color: Color4): Color4;
  5774. /**
  5775. * Multipy a Color4 value by another and push the result in a reference value
  5776. * @param color defines the Color4 value to multiply by
  5777. * @param result defines the Color4 to fill the result in
  5778. * @returns the result Color4
  5779. */
  5780. multiplyToRef(color: Color4, result: Color4): Color4;
  5781. /**
  5782. * Creates a string with the Color4 current values
  5783. * @returns the string representation of the Color4 object
  5784. */
  5785. toString(): string;
  5786. /**
  5787. * Returns the string "Color4"
  5788. * @returns "Color4"
  5789. */
  5790. getClassName(): string;
  5791. /**
  5792. * Compute the Color4 hash code
  5793. * @returns an unique number that can be used to hash Color4 objects
  5794. */
  5795. getHashCode(): number;
  5796. /**
  5797. * Creates a new Color4 copied from the current one
  5798. * @returns a new Color4 object
  5799. */
  5800. clone(): Color4;
  5801. /**
  5802. * Copies the given Color4 values into the current one
  5803. * @param source defines the source Color4 object
  5804. * @returns the current updated Color4 object
  5805. */
  5806. copyFrom(source: Color4): Color4;
  5807. /**
  5808. * Copies the given float values into the current one
  5809. * @param r defines the red component to read from
  5810. * @param g defines the green component to read from
  5811. * @param b defines the blue component to read from
  5812. * @param a defines the alpha component to read from
  5813. * @returns the current updated Color4 object
  5814. */
  5815. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5816. /**
  5817. * Copies the given float values into the current one
  5818. * @param r defines the red component to read from
  5819. * @param g defines the green component to read from
  5820. * @param b defines the blue component to read from
  5821. * @param a defines the alpha component to read from
  5822. * @returns the current updated Color4 object
  5823. */
  5824. set(r: number, g: number, b: number, a: number): Color4;
  5825. /**
  5826. * Compute the Color4 hexadecimal code as a string
  5827. * @returns a string containing the hexadecimal representation of the Color4 object
  5828. */
  5829. toHexString(): string;
  5830. /**
  5831. * Computes a new Color4 converted from the current one to linear space
  5832. * @returns a new Color4 object
  5833. */
  5834. toLinearSpace(): Color4;
  5835. /**
  5836. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5837. * @param convertedColor defines the Color4 object where to store the linear space version
  5838. * @returns the unmodified Color4
  5839. */
  5840. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5841. /**
  5842. * Computes a new Color4 converted from the current one to gamma space
  5843. * @returns a new Color4 object
  5844. */
  5845. toGammaSpace(): Color4;
  5846. /**
  5847. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5848. * @param convertedColor defines the Color4 object where to store the gamma space version
  5849. * @returns the unmodified Color4
  5850. */
  5851. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5852. /**
  5853. * Creates a new Color4 from the string containing valid hexadecimal values
  5854. * @param hex defines a string containing valid hexadecimal values
  5855. * @returns a new Color4 object
  5856. */
  5857. static FromHexString(hex: string): Color4;
  5858. /**
  5859. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5860. * @param left defines the start value
  5861. * @param right defines the end value
  5862. * @param amount defines the gradient factor
  5863. * @returns a new Color4 object
  5864. */
  5865. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5866. /**
  5867. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5868. * @param left defines the start value
  5869. * @param right defines the end value
  5870. * @param amount defines the gradient factor
  5871. * @param result defines the Color4 object where to store data
  5872. */
  5873. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5874. /**
  5875. * Creates a new Color4 from a Color3 and an alpha value
  5876. * @param color3 defines the source Color3 to read from
  5877. * @param alpha defines the alpha component (1.0 by default)
  5878. * @returns a new Color4 object
  5879. */
  5880. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5881. /**
  5882. * Creates a new Color4 from the starting index element of the given array
  5883. * @param array defines the source array to read from
  5884. * @param offset defines the offset in the source array
  5885. * @returns a new Color4 object
  5886. */
  5887. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5888. /**
  5889. * Creates a new Color3 from integer values (< 256)
  5890. * @param r defines the red component to read from (value between 0 and 255)
  5891. * @param g defines the green component to read from (value between 0 and 255)
  5892. * @param b defines the blue component to read from (value between 0 and 255)
  5893. * @param a defines the alpha component to read from (value between 0 and 255)
  5894. * @returns a new Color3 object
  5895. */
  5896. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5897. /**
  5898. * Check the content of a given array and convert it to an array containing RGBA data
  5899. * If the original array was already containing count * 4 values then it is returned directly
  5900. * @param colors defines the array to check
  5901. * @param count defines the number of RGBA data to expect
  5902. * @returns an array containing count * 4 values (RGBA)
  5903. */
  5904. static CheckColors4(colors: number[], count: number): number[];
  5905. }
  5906. /**
  5907. * @hidden
  5908. */
  5909. export class TmpColors {
  5910. static Color3: Color3[];
  5911. static Color4: Color4[];
  5912. }
  5913. }
  5914. declare module "babylonjs/Animations/animationKey" {
  5915. /**
  5916. * Defines an interface which represents an animation key frame
  5917. */
  5918. export interface IAnimationKey {
  5919. /**
  5920. * Frame of the key frame
  5921. */
  5922. frame: number;
  5923. /**
  5924. * Value at the specifies key frame
  5925. */
  5926. value: any;
  5927. /**
  5928. * The input tangent for the cubic hermite spline
  5929. */
  5930. inTangent?: any;
  5931. /**
  5932. * The output tangent for the cubic hermite spline
  5933. */
  5934. outTangent?: any;
  5935. /**
  5936. * The animation interpolation type
  5937. */
  5938. interpolation?: AnimationKeyInterpolation;
  5939. }
  5940. /**
  5941. * Enum for the animation key frame interpolation type
  5942. */
  5943. export enum AnimationKeyInterpolation {
  5944. /**
  5945. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5946. */
  5947. STEP = 1
  5948. }
  5949. }
  5950. declare module "babylonjs/Animations/animationRange" {
  5951. /**
  5952. * Represents the range of an animation
  5953. */
  5954. export class AnimationRange {
  5955. /**The name of the animation range**/
  5956. name: string;
  5957. /**The starting frame of the animation */
  5958. from: number;
  5959. /**The ending frame of the animation*/
  5960. to: number;
  5961. /**
  5962. * Initializes the range of an animation
  5963. * @param name The name of the animation range
  5964. * @param from The starting frame of the animation
  5965. * @param to The ending frame of the animation
  5966. */
  5967. constructor(
  5968. /**The name of the animation range**/
  5969. name: string,
  5970. /**The starting frame of the animation */
  5971. from: number,
  5972. /**The ending frame of the animation*/
  5973. to: number);
  5974. /**
  5975. * Makes a copy of the animation range
  5976. * @returns A copy of the animation range
  5977. */
  5978. clone(): AnimationRange;
  5979. }
  5980. }
  5981. declare module "babylonjs/Animations/animationEvent" {
  5982. /**
  5983. * Composed of a frame, and an action function
  5984. */
  5985. export class AnimationEvent {
  5986. /** The frame for which the event is triggered **/
  5987. frame: number;
  5988. /** The event to perform when triggered **/
  5989. action: (currentFrame: number) => void;
  5990. /** Specifies if the event should be triggered only once**/
  5991. onlyOnce?: boolean | undefined;
  5992. /**
  5993. * Specifies if the animation event is done
  5994. */
  5995. isDone: boolean;
  5996. /**
  5997. * Initializes the animation event
  5998. * @param frame The frame for which the event is triggered
  5999. * @param action The event to perform when triggered
  6000. * @param onlyOnce Specifies if the event should be triggered only once
  6001. */
  6002. constructor(
  6003. /** The frame for which the event is triggered **/
  6004. frame: number,
  6005. /** The event to perform when triggered **/
  6006. action: (currentFrame: number) => void,
  6007. /** Specifies if the event should be triggered only once**/
  6008. onlyOnce?: boolean | undefined);
  6009. /** @hidden */
  6010. _clone(): AnimationEvent;
  6011. }
  6012. }
  6013. declare module "babylonjs/Behaviors/behavior" {
  6014. import { Nullable } from "babylonjs/types";
  6015. /**
  6016. * Interface used to define a behavior
  6017. */
  6018. export interface Behavior<T> {
  6019. /** gets or sets behavior's name */
  6020. name: string;
  6021. /**
  6022. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6023. */
  6024. init(): void;
  6025. /**
  6026. * Called when the behavior is attached to a target
  6027. * @param target defines the target where the behavior is attached to
  6028. */
  6029. attach(target: T): void;
  6030. /**
  6031. * Called when the behavior is detached from its target
  6032. */
  6033. detach(): void;
  6034. }
  6035. /**
  6036. * Interface implemented by classes supporting behaviors
  6037. */
  6038. export interface IBehaviorAware<T> {
  6039. /**
  6040. * Attach a behavior
  6041. * @param behavior defines the behavior to attach
  6042. * @returns the current host
  6043. */
  6044. addBehavior(behavior: Behavior<T>): T;
  6045. /**
  6046. * Remove a behavior from the current object
  6047. * @param behavior defines the behavior to detach
  6048. * @returns the current host
  6049. */
  6050. removeBehavior(behavior: Behavior<T>): T;
  6051. /**
  6052. * Gets a behavior using its name to search
  6053. * @param name defines the name to search
  6054. * @returns the behavior or null if not found
  6055. */
  6056. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6057. }
  6058. }
  6059. declare module "babylonjs/Misc/smartArray" {
  6060. /**
  6061. * Defines an array and its length.
  6062. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6063. */
  6064. export interface ISmartArrayLike<T> {
  6065. /**
  6066. * The data of the array.
  6067. */
  6068. data: Array<T>;
  6069. /**
  6070. * The active length of the array.
  6071. */
  6072. length: number;
  6073. }
  6074. /**
  6075. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6076. */
  6077. export class SmartArray<T> implements ISmartArrayLike<T> {
  6078. /**
  6079. * The full set of data from the array.
  6080. */
  6081. data: Array<T>;
  6082. /**
  6083. * The active length of the array.
  6084. */
  6085. length: number;
  6086. protected _id: number;
  6087. /**
  6088. * Instantiates a Smart Array.
  6089. * @param capacity defines the default capacity of the array.
  6090. */
  6091. constructor(capacity: number);
  6092. /**
  6093. * Pushes a value at the end of the active data.
  6094. * @param value defines the object to push in the array.
  6095. */
  6096. push(value: T): void;
  6097. /**
  6098. * Iterates over the active data and apply the lambda to them.
  6099. * @param func defines the action to apply on each value.
  6100. */
  6101. forEach(func: (content: T) => void): void;
  6102. /**
  6103. * Sorts the full sets of data.
  6104. * @param compareFn defines the comparison function to apply.
  6105. */
  6106. sort(compareFn: (a: T, b: T) => number): void;
  6107. /**
  6108. * Resets the active data to an empty array.
  6109. */
  6110. reset(): void;
  6111. /**
  6112. * Releases all the data from the array as well as the array.
  6113. */
  6114. dispose(): void;
  6115. /**
  6116. * Concats the active data with a given array.
  6117. * @param array defines the data to concatenate with.
  6118. */
  6119. concat(array: any): void;
  6120. /**
  6121. * Returns the position of a value in the active data.
  6122. * @param value defines the value to find the index for
  6123. * @returns the index if found in the active data otherwise -1
  6124. */
  6125. indexOf(value: T): number;
  6126. /**
  6127. * Returns whether an element is part of the active data.
  6128. * @param value defines the value to look for
  6129. * @returns true if found in the active data otherwise false
  6130. */
  6131. contains(value: T): boolean;
  6132. private static _GlobalId;
  6133. }
  6134. /**
  6135. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6136. * The data in this array can only be present once
  6137. */
  6138. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6139. private _duplicateId;
  6140. /**
  6141. * Pushes a value at the end of the active data.
  6142. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6143. * @param value defines the object to push in the array.
  6144. */
  6145. push(value: T): void;
  6146. /**
  6147. * Pushes a value at the end of the active data.
  6148. * If the data is already present, it won t be added again
  6149. * @param value defines the object to push in the array.
  6150. * @returns true if added false if it was already present
  6151. */
  6152. pushNoDuplicate(value: T): boolean;
  6153. /**
  6154. * Resets the active data to an empty array.
  6155. */
  6156. reset(): void;
  6157. /**
  6158. * Concats the active data with a given array.
  6159. * This ensures no dupplicate will be present in the result.
  6160. * @param array defines the data to concatenate with.
  6161. */
  6162. concatWithNoDuplicate(array: any): void;
  6163. }
  6164. }
  6165. declare module "babylonjs/Cameras/cameraInputsManager" {
  6166. import { Nullable } from "babylonjs/types";
  6167. import { Camera } from "babylonjs/Cameras/camera";
  6168. /**
  6169. * @ignore
  6170. * This is a list of all the different input types that are available in the application.
  6171. * Fo instance: ArcRotateCameraGamepadInput...
  6172. */
  6173. export var CameraInputTypes: {};
  6174. /**
  6175. * This is the contract to implement in order to create a new input class.
  6176. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6177. */
  6178. export interface ICameraInput<TCamera extends Camera> {
  6179. /**
  6180. * Defines the camera the input is attached to.
  6181. */
  6182. camera: Nullable<TCamera>;
  6183. /**
  6184. * Gets the class name of the current intput.
  6185. * @returns the class name
  6186. */
  6187. getClassName(): string;
  6188. /**
  6189. * Get the friendly name associated with the input class.
  6190. * @returns the input friendly name
  6191. */
  6192. getSimpleName(): string;
  6193. /**
  6194. * Attach the input controls to a specific dom element to get the input from.
  6195. * @param element Defines the element the controls should be listened from
  6196. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6197. */
  6198. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6199. /**
  6200. * Detach the current controls from the specified dom element.
  6201. * @param element Defines the element to stop listening the inputs from
  6202. */
  6203. detachControl(element: Nullable<HTMLElement>): void;
  6204. /**
  6205. * Update the current camera state depending on the inputs that have been used this frame.
  6206. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6207. */
  6208. checkInputs?: () => void;
  6209. }
  6210. /**
  6211. * Represents a map of input types to input instance or input index to input instance.
  6212. */
  6213. export interface CameraInputsMap<TCamera extends Camera> {
  6214. /**
  6215. * Accessor to the input by input type.
  6216. */
  6217. [name: string]: ICameraInput<TCamera>;
  6218. /**
  6219. * Accessor to the input by input index.
  6220. */
  6221. [idx: number]: ICameraInput<TCamera>;
  6222. }
  6223. /**
  6224. * This represents the input manager used within a camera.
  6225. * It helps dealing with all the different kind of input attached to a camera.
  6226. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6227. */
  6228. export class CameraInputsManager<TCamera extends Camera> {
  6229. /**
  6230. * Defines the list of inputs attahed to the camera.
  6231. */
  6232. attached: CameraInputsMap<TCamera>;
  6233. /**
  6234. * Defines the dom element the camera is collecting inputs from.
  6235. * This is null if the controls have not been attached.
  6236. */
  6237. attachedElement: Nullable<HTMLElement>;
  6238. /**
  6239. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6240. */
  6241. noPreventDefault: boolean;
  6242. /**
  6243. * Defined the camera the input manager belongs to.
  6244. */
  6245. camera: TCamera;
  6246. /**
  6247. * Update the current camera state depending on the inputs that have been used this frame.
  6248. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6249. */
  6250. checkInputs: () => void;
  6251. /**
  6252. * Instantiate a new Camera Input Manager.
  6253. * @param camera Defines the camera the input manager blongs to
  6254. */
  6255. constructor(camera: TCamera);
  6256. /**
  6257. * Add an input method to a camera
  6258. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6259. * @param input camera input method
  6260. */
  6261. add(input: ICameraInput<TCamera>): void;
  6262. /**
  6263. * Remove a specific input method from a camera
  6264. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6265. * @param inputToRemove camera input method
  6266. */
  6267. remove(inputToRemove: ICameraInput<TCamera>): void;
  6268. /**
  6269. * Remove a specific input type from a camera
  6270. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6271. * @param inputType the type of the input to remove
  6272. */
  6273. removeByType(inputType: string): void;
  6274. private _addCheckInputs;
  6275. /**
  6276. * Attach the input controls to the currently attached dom element to listen the events from.
  6277. * @param input Defines the input to attach
  6278. */
  6279. attachInput(input: ICameraInput<TCamera>): void;
  6280. /**
  6281. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6282. * @param element Defines the dom element to collect the events from
  6283. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6284. */
  6285. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6286. /**
  6287. * Detach the current manager inputs controls from a specific dom element.
  6288. * @param element Defines the dom element to collect the events from
  6289. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6290. */
  6291. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6292. /**
  6293. * Rebuild the dynamic inputCheck function from the current list of
  6294. * defined inputs in the manager.
  6295. */
  6296. rebuildInputCheck(): void;
  6297. /**
  6298. * Remove all attached input methods from a camera
  6299. */
  6300. clear(): void;
  6301. /**
  6302. * Serialize the current input manager attached to a camera.
  6303. * This ensures than once parsed,
  6304. * the input associated to the camera will be identical to the current ones
  6305. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6306. */
  6307. serialize(serializedCamera: any): void;
  6308. /**
  6309. * Parses an input manager serialized JSON to restore the previous list of inputs
  6310. * and states associated to a camera.
  6311. * @param parsedCamera Defines the JSON to parse
  6312. */
  6313. parse(parsedCamera: any): void;
  6314. }
  6315. }
  6316. declare module "babylonjs/Meshes/buffer" {
  6317. import { Nullable, DataArray } from "babylonjs/types";
  6318. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6319. /**
  6320. * Class used to store data that will be store in GPU memory
  6321. */
  6322. export class Buffer {
  6323. private _engine;
  6324. private _buffer;
  6325. /** @hidden */
  6326. _data: Nullable<DataArray>;
  6327. private _updatable;
  6328. private _instanced;
  6329. private _divisor;
  6330. /**
  6331. * Gets the byte stride.
  6332. */
  6333. readonly byteStride: number;
  6334. /**
  6335. * Constructor
  6336. * @param engine the engine
  6337. * @param data the data to use for this buffer
  6338. * @param updatable whether the data is updatable
  6339. * @param stride the stride (optional)
  6340. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6341. * @param instanced whether the buffer is instanced (optional)
  6342. * @param useBytes set to true if the stride in in bytes (optional)
  6343. * @param divisor sets an optional divisor for instances (1 by default)
  6344. */
  6345. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6346. /**
  6347. * Create a new VertexBuffer based on the current buffer
  6348. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6349. * @param offset defines offset in the buffer (0 by default)
  6350. * @param size defines the size in floats of attributes (position is 3 for instance)
  6351. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6352. * @param instanced defines if the vertex buffer contains indexed data
  6353. * @param useBytes defines if the offset and stride are in bytes *
  6354. * @param divisor sets an optional divisor for instances (1 by default)
  6355. * @returns the new vertex buffer
  6356. */
  6357. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6358. /**
  6359. * Gets a boolean indicating if the Buffer is updatable?
  6360. * @returns true if the buffer is updatable
  6361. */
  6362. isUpdatable(): boolean;
  6363. /**
  6364. * Gets current buffer's data
  6365. * @returns a DataArray or null
  6366. */
  6367. getData(): Nullable<DataArray>;
  6368. /**
  6369. * Gets underlying native buffer
  6370. * @returns underlying native buffer
  6371. */
  6372. getBuffer(): Nullable<DataBuffer>;
  6373. /**
  6374. * Gets the stride in float32 units (i.e. byte stride / 4).
  6375. * May not be an integer if the byte stride is not divisible by 4.
  6376. * @returns the stride in float32 units
  6377. * @deprecated Please use byteStride instead.
  6378. */
  6379. getStrideSize(): number;
  6380. /**
  6381. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6382. * @param data defines the data to store
  6383. */
  6384. create(data?: Nullable<DataArray>): void;
  6385. /** @hidden */
  6386. _rebuild(): void;
  6387. /**
  6388. * Update current buffer data
  6389. * @param data defines the data to store
  6390. */
  6391. update(data: DataArray): void;
  6392. /**
  6393. * Updates the data directly.
  6394. * @param data the new data
  6395. * @param offset the new offset
  6396. * @param vertexCount the vertex count (optional)
  6397. * @param useBytes set to true if the offset is in bytes
  6398. */
  6399. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6400. /**
  6401. * Release all resources
  6402. */
  6403. dispose(): void;
  6404. }
  6405. /**
  6406. * Specialized buffer used to store vertex data
  6407. */
  6408. export class VertexBuffer {
  6409. /** @hidden */
  6410. _buffer: Buffer;
  6411. private _kind;
  6412. private _size;
  6413. private _ownsBuffer;
  6414. private _instanced;
  6415. private _instanceDivisor;
  6416. /**
  6417. * The byte type.
  6418. */
  6419. static readonly BYTE: number;
  6420. /**
  6421. * The unsigned byte type.
  6422. */
  6423. static readonly UNSIGNED_BYTE: number;
  6424. /**
  6425. * The short type.
  6426. */
  6427. static readonly SHORT: number;
  6428. /**
  6429. * The unsigned short type.
  6430. */
  6431. static readonly UNSIGNED_SHORT: number;
  6432. /**
  6433. * The integer type.
  6434. */
  6435. static readonly INT: number;
  6436. /**
  6437. * The unsigned integer type.
  6438. */
  6439. static readonly UNSIGNED_INT: number;
  6440. /**
  6441. * The float type.
  6442. */
  6443. static readonly FLOAT: number;
  6444. /**
  6445. * Gets or sets the instance divisor when in instanced mode
  6446. */
  6447. get instanceDivisor(): number;
  6448. set instanceDivisor(value: number);
  6449. /**
  6450. * Gets the byte stride.
  6451. */
  6452. readonly byteStride: number;
  6453. /**
  6454. * Gets the byte offset.
  6455. */
  6456. readonly byteOffset: number;
  6457. /**
  6458. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6459. */
  6460. readonly normalized: boolean;
  6461. /**
  6462. * Gets the data type of each component in the array.
  6463. */
  6464. readonly type: number;
  6465. /**
  6466. * Constructor
  6467. * @param engine the engine
  6468. * @param data the data to use for this vertex buffer
  6469. * @param kind the vertex buffer kind
  6470. * @param updatable whether the data is updatable
  6471. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6472. * @param stride the stride (optional)
  6473. * @param instanced whether the buffer is instanced (optional)
  6474. * @param offset the offset of the data (optional)
  6475. * @param size the number of components (optional)
  6476. * @param type the type of the component (optional)
  6477. * @param normalized whether the data contains normalized data (optional)
  6478. * @param useBytes set to true if stride and offset are in bytes (optional)
  6479. * @param divisor defines the instance divisor to use (1 by default)
  6480. */
  6481. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6482. /** @hidden */
  6483. _rebuild(): void;
  6484. /**
  6485. * Returns the kind of the VertexBuffer (string)
  6486. * @returns a string
  6487. */
  6488. getKind(): string;
  6489. /**
  6490. * Gets a boolean indicating if the VertexBuffer is updatable?
  6491. * @returns true if the buffer is updatable
  6492. */
  6493. isUpdatable(): boolean;
  6494. /**
  6495. * Gets current buffer's data
  6496. * @returns a DataArray or null
  6497. */
  6498. getData(): Nullable<DataArray>;
  6499. /**
  6500. * Gets underlying native buffer
  6501. * @returns underlying native buffer
  6502. */
  6503. getBuffer(): Nullable<DataBuffer>;
  6504. /**
  6505. * Gets the stride in float32 units (i.e. byte stride / 4).
  6506. * May not be an integer if the byte stride is not divisible by 4.
  6507. * @returns the stride in float32 units
  6508. * @deprecated Please use byteStride instead.
  6509. */
  6510. getStrideSize(): number;
  6511. /**
  6512. * Returns the offset as a multiple of the type byte length.
  6513. * @returns the offset in bytes
  6514. * @deprecated Please use byteOffset instead.
  6515. */
  6516. getOffset(): number;
  6517. /**
  6518. * Returns the number of components per vertex attribute (integer)
  6519. * @returns the size in float
  6520. */
  6521. getSize(): number;
  6522. /**
  6523. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6524. * @returns true if this buffer is instanced
  6525. */
  6526. getIsInstanced(): boolean;
  6527. /**
  6528. * Returns the instancing divisor, zero for non-instanced (integer).
  6529. * @returns a number
  6530. */
  6531. getInstanceDivisor(): number;
  6532. /**
  6533. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6534. * @param data defines the data to store
  6535. */
  6536. create(data?: DataArray): void;
  6537. /**
  6538. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6539. * This function will create a new buffer if the current one is not updatable
  6540. * @param data defines the data to store
  6541. */
  6542. update(data: DataArray): void;
  6543. /**
  6544. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6545. * Returns the directly updated WebGLBuffer.
  6546. * @param data the new data
  6547. * @param offset the new offset
  6548. * @param useBytes set to true if the offset is in bytes
  6549. */
  6550. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6551. /**
  6552. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6553. */
  6554. dispose(): void;
  6555. /**
  6556. * Enumerates each value of this vertex buffer as numbers.
  6557. * @param count the number of values to enumerate
  6558. * @param callback the callback function called for each value
  6559. */
  6560. forEach(count: number, callback: (value: number, index: number) => void): void;
  6561. /**
  6562. * Positions
  6563. */
  6564. static readonly PositionKind: string;
  6565. /**
  6566. * Normals
  6567. */
  6568. static readonly NormalKind: string;
  6569. /**
  6570. * Tangents
  6571. */
  6572. static readonly TangentKind: string;
  6573. /**
  6574. * Texture coordinates
  6575. */
  6576. static readonly UVKind: string;
  6577. /**
  6578. * Texture coordinates 2
  6579. */
  6580. static readonly UV2Kind: string;
  6581. /**
  6582. * Texture coordinates 3
  6583. */
  6584. static readonly UV3Kind: string;
  6585. /**
  6586. * Texture coordinates 4
  6587. */
  6588. static readonly UV4Kind: string;
  6589. /**
  6590. * Texture coordinates 5
  6591. */
  6592. static readonly UV5Kind: string;
  6593. /**
  6594. * Texture coordinates 6
  6595. */
  6596. static readonly UV6Kind: string;
  6597. /**
  6598. * Colors
  6599. */
  6600. static readonly ColorKind: string;
  6601. /**
  6602. * Matrix indices (for bones)
  6603. */
  6604. static readonly MatricesIndicesKind: string;
  6605. /**
  6606. * Matrix weights (for bones)
  6607. */
  6608. static readonly MatricesWeightsKind: string;
  6609. /**
  6610. * Additional matrix indices (for bones)
  6611. */
  6612. static readonly MatricesIndicesExtraKind: string;
  6613. /**
  6614. * Additional matrix weights (for bones)
  6615. */
  6616. static readonly MatricesWeightsExtraKind: string;
  6617. /**
  6618. * Deduces the stride given a kind.
  6619. * @param kind The kind string to deduce
  6620. * @returns The deduced stride
  6621. */
  6622. static DeduceStride(kind: string): number;
  6623. /**
  6624. * Gets the byte length of the given type.
  6625. * @param type the type
  6626. * @returns the number of bytes
  6627. */
  6628. static GetTypeByteLength(type: number): number;
  6629. /**
  6630. * Enumerates each value of the given parameters as numbers.
  6631. * @param data the data to enumerate
  6632. * @param byteOffset the byte offset of the data
  6633. * @param byteStride the byte stride of the data
  6634. * @param componentCount the number of components per element
  6635. * @param componentType the type of the component
  6636. * @param count the number of values to enumerate
  6637. * @param normalized whether the data is normalized
  6638. * @param callback the callback function called for each value
  6639. */
  6640. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6641. private static _GetFloatValue;
  6642. }
  6643. }
  6644. declare module "babylonjs/Collisions/intersectionInfo" {
  6645. import { Nullable } from "babylonjs/types";
  6646. /**
  6647. * @hidden
  6648. */
  6649. export class IntersectionInfo {
  6650. bu: Nullable<number>;
  6651. bv: Nullable<number>;
  6652. distance: number;
  6653. faceId: number;
  6654. subMeshId: number;
  6655. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6656. }
  6657. }
  6658. declare module "babylonjs/Maths/math.plane" {
  6659. import { DeepImmutable } from "babylonjs/types";
  6660. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6661. /**
  6662. * Represens a plane by the equation ax + by + cz + d = 0
  6663. */
  6664. export class Plane {
  6665. private static _TmpMatrix;
  6666. /**
  6667. * Normal of the plane (a,b,c)
  6668. */
  6669. normal: Vector3;
  6670. /**
  6671. * d component of the plane
  6672. */
  6673. d: number;
  6674. /**
  6675. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6676. * @param a a component of the plane
  6677. * @param b b component of the plane
  6678. * @param c c component of the plane
  6679. * @param d d component of the plane
  6680. */
  6681. constructor(a: number, b: number, c: number, d: number);
  6682. /**
  6683. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6684. */
  6685. asArray(): number[];
  6686. /**
  6687. * @returns a new plane copied from the current Plane.
  6688. */
  6689. clone(): Plane;
  6690. /**
  6691. * @returns the string "Plane".
  6692. */
  6693. getClassName(): string;
  6694. /**
  6695. * @returns the Plane hash code.
  6696. */
  6697. getHashCode(): number;
  6698. /**
  6699. * Normalize the current Plane in place.
  6700. * @returns the updated Plane.
  6701. */
  6702. normalize(): Plane;
  6703. /**
  6704. * Applies a transformation the plane and returns the result
  6705. * @param transformation the transformation matrix to be applied to the plane
  6706. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6707. */
  6708. transform(transformation: DeepImmutable<Matrix>): Plane;
  6709. /**
  6710. * Calcualtte the dot product between the point and the plane normal
  6711. * @param point point to calculate the dot product with
  6712. * @returns the dot product (float) of the point coordinates and the plane normal.
  6713. */
  6714. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6715. /**
  6716. * Updates the current Plane from the plane defined by the three given points.
  6717. * @param point1 one of the points used to contruct the plane
  6718. * @param point2 one of the points used to contruct the plane
  6719. * @param point3 one of the points used to contruct the plane
  6720. * @returns the updated Plane.
  6721. */
  6722. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6723. /**
  6724. * Checks if the plane is facing a given direction
  6725. * @param direction the direction to check if the plane is facing
  6726. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6727. * @returns True is the vector "direction" is the same side than the plane normal.
  6728. */
  6729. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6730. /**
  6731. * Calculates the distance to a point
  6732. * @param point point to calculate distance to
  6733. * @returns the signed distance (float) from the given point to the Plane.
  6734. */
  6735. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6736. /**
  6737. * Creates a plane from an array
  6738. * @param array the array to create a plane from
  6739. * @returns a new Plane from the given array.
  6740. */
  6741. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6742. /**
  6743. * Creates a plane from three points
  6744. * @param point1 point used to create the plane
  6745. * @param point2 point used to create the plane
  6746. * @param point3 point used to create the plane
  6747. * @returns a new Plane defined by the three given points.
  6748. */
  6749. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6750. /**
  6751. * Creates a plane from an origin point and a normal
  6752. * @param origin origin of the plane to be constructed
  6753. * @param normal normal of the plane to be constructed
  6754. * @returns a new Plane the normal vector to this plane at the given origin point.
  6755. * Note : the vector "normal" is updated because normalized.
  6756. */
  6757. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6758. /**
  6759. * Calculates the distance from a plane and a point
  6760. * @param origin origin of the plane to be constructed
  6761. * @param normal normal of the plane to be constructed
  6762. * @param point point to calculate distance to
  6763. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6764. */
  6765. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6766. }
  6767. }
  6768. declare module "babylonjs/Culling/boundingSphere" {
  6769. import { DeepImmutable } from "babylonjs/types";
  6770. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6771. import { Plane } from "babylonjs/Maths/math.plane";
  6772. /**
  6773. * Class used to store bounding sphere information
  6774. */
  6775. export class BoundingSphere {
  6776. /**
  6777. * Gets the center of the bounding sphere in local space
  6778. */
  6779. readonly center: Vector3;
  6780. /**
  6781. * Radius of the bounding sphere in local space
  6782. */
  6783. radius: number;
  6784. /**
  6785. * Gets the center of the bounding sphere in world space
  6786. */
  6787. readonly centerWorld: Vector3;
  6788. /**
  6789. * Radius of the bounding sphere in world space
  6790. */
  6791. radiusWorld: number;
  6792. /**
  6793. * Gets the minimum vector in local space
  6794. */
  6795. readonly minimum: Vector3;
  6796. /**
  6797. * Gets the maximum vector in local space
  6798. */
  6799. readonly maximum: Vector3;
  6800. private _worldMatrix;
  6801. private static readonly TmpVector3;
  6802. /**
  6803. * Creates a new bounding sphere
  6804. * @param min defines the minimum vector (in local space)
  6805. * @param max defines the maximum vector (in local space)
  6806. * @param worldMatrix defines the new world matrix
  6807. */
  6808. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6809. /**
  6810. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6811. * @param min defines the new minimum vector (in local space)
  6812. * @param max defines the new maximum vector (in local space)
  6813. * @param worldMatrix defines the new world matrix
  6814. */
  6815. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6816. /**
  6817. * Scale the current bounding sphere by applying a scale factor
  6818. * @param factor defines the scale factor to apply
  6819. * @returns the current bounding box
  6820. */
  6821. scale(factor: number): BoundingSphere;
  6822. /**
  6823. * Gets the world matrix of the bounding box
  6824. * @returns a matrix
  6825. */
  6826. getWorldMatrix(): DeepImmutable<Matrix>;
  6827. /** @hidden */
  6828. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6829. /**
  6830. * Tests if the bounding sphere is intersecting the frustum planes
  6831. * @param frustumPlanes defines the frustum planes to test
  6832. * @returns true if there is an intersection
  6833. */
  6834. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6835. /**
  6836. * Tests if the bounding sphere center is in between the frustum planes.
  6837. * Used for optimistic fast inclusion.
  6838. * @param frustumPlanes defines the frustum planes to test
  6839. * @returns true if the sphere center is in between the frustum planes
  6840. */
  6841. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6842. /**
  6843. * Tests if a point is inside the bounding sphere
  6844. * @param point defines the point to test
  6845. * @returns true if the point is inside the bounding sphere
  6846. */
  6847. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6848. /**
  6849. * Checks if two sphere intersct
  6850. * @param sphere0 sphere 0
  6851. * @param sphere1 sphere 1
  6852. * @returns true if the speres intersect
  6853. */
  6854. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6855. }
  6856. }
  6857. declare module "babylonjs/Culling/boundingBox" {
  6858. import { DeepImmutable } from "babylonjs/types";
  6859. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6860. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6861. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6862. import { Plane } from "babylonjs/Maths/math.plane";
  6863. /**
  6864. * Class used to store bounding box information
  6865. */
  6866. export class BoundingBox implements ICullable {
  6867. /**
  6868. * Gets the 8 vectors representing the bounding box in local space
  6869. */
  6870. readonly vectors: Vector3[];
  6871. /**
  6872. * Gets the center of the bounding box in local space
  6873. */
  6874. readonly center: Vector3;
  6875. /**
  6876. * Gets the center of the bounding box in world space
  6877. */
  6878. readonly centerWorld: Vector3;
  6879. /**
  6880. * Gets the extend size in local space
  6881. */
  6882. readonly extendSize: Vector3;
  6883. /**
  6884. * Gets the extend size in world space
  6885. */
  6886. readonly extendSizeWorld: Vector3;
  6887. /**
  6888. * Gets the OBB (object bounding box) directions
  6889. */
  6890. readonly directions: Vector3[];
  6891. /**
  6892. * Gets the 8 vectors representing the bounding box in world space
  6893. */
  6894. readonly vectorsWorld: Vector3[];
  6895. /**
  6896. * Gets the minimum vector in world space
  6897. */
  6898. readonly minimumWorld: Vector3;
  6899. /**
  6900. * Gets the maximum vector in world space
  6901. */
  6902. readonly maximumWorld: Vector3;
  6903. /**
  6904. * Gets the minimum vector in local space
  6905. */
  6906. readonly minimum: Vector3;
  6907. /**
  6908. * Gets the maximum vector in local space
  6909. */
  6910. readonly maximum: Vector3;
  6911. private _worldMatrix;
  6912. private static readonly TmpVector3;
  6913. /**
  6914. * @hidden
  6915. */
  6916. _tag: number;
  6917. /**
  6918. * Creates a new bounding box
  6919. * @param min defines the minimum vector (in local space)
  6920. * @param max defines the maximum vector (in local space)
  6921. * @param worldMatrix defines the new world matrix
  6922. */
  6923. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6924. /**
  6925. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6926. * @param min defines the new minimum vector (in local space)
  6927. * @param max defines the new maximum vector (in local space)
  6928. * @param worldMatrix defines the new world matrix
  6929. */
  6930. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6931. /**
  6932. * Scale the current bounding box by applying a scale factor
  6933. * @param factor defines the scale factor to apply
  6934. * @returns the current bounding box
  6935. */
  6936. scale(factor: number): BoundingBox;
  6937. /**
  6938. * Gets the world matrix of the bounding box
  6939. * @returns a matrix
  6940. */
  6941. getWorldMatrix(): DeepImmutable<Matrix>;
  6942. /** @hidden */
  6943. _update(world: DeepImmutable<Matrix>): void;
  6944. /**
  6945. * Tests if the bounding box is intersecting the frustum planes
  6946. * @param frustumPlanes defines the frustum planes to test
  6947. * @returns true if there is an intersection
  6948. */
  6949. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6950. /**
  6951. * Tests if the bounding box is entirely inside the frustum planes
  6952. * @param frustumPlanes defines the frustum planes to test
  6953. * @returns true if there is an inclusion
  6954. */
  6955. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6956. /**
  6957. * Tests if a point is inside the bounding box
  6958. * @param point defines the point to test
  6959. * @returns true if the point is inside the bounding box
  6960. */
  6961. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6962. /**
  6963. * Tests if the bounding box intersects with a bounding sphere
  6964. * @param sphere defines the sphere to test
  6965. * @returns true if there is an intersection
  6966. */
  6967. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6968. /**
  6969. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6970. * @param min defines the min vector to use
  6971. * @param max defines the max vector to use
  6972. * @returns true if there is an intersection
  6973. */
  6974. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6975. /**
  6976. * Tests if two bounding boxes are intersections
  6977. * @param box0 defines the first box to test
  6978. * @param box1 defines the second box to test
  6979. * @returns true if there is an intersection
  6980. */
  6981. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6982. /**
  6983. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6984. * @param minPoint defines the minimum vector of the bounding box
  6985. * @param maxPoint defines the maximum vector of the bounding box
  6986. * @param sphereCenter defines the sphere center
  6987. * @param sphereRadius defines the sphere radius
  6988. * @returns true if there is an intersection
  6989. */
  6990. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6991. /**
  6992. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6993. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6994. * @param frustumPlanes defines the frustum planes to test
  6995. * @return true if there is an inclusion
  6996. */
  6997. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6998. /**
  6999. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7000. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7001. * @param frustumPlanes defines the frustum planes to test
  7002. * @return true if there is an intersection
  7003. */
  7004. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7005. }
  7006. }
  7007. declare module "babylonjs/Collisions/collider" {
  7008. import { Nullable, IndicesArray } from "babylonjs/types";
  7009. import { Vector3 } from "babylonjs/Maths/math.vector";
  7010. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7011. import { Plane } from "babylonjs/Maths/math.plane";
  7012. /** @hidden */
  7013. export class Collider {
  7014. /** Define if a collision was found */
  7015. collisionFound: boolean;
  7016. /**
  7017. * Define last intersection point in local space
  7018. */
  7019. intersectionPoint: Vector3;
  7020. /**
  7021. * Define last collided mesh
  7022. */
  7023. collidedMesh: Nullable<AbstractMesh>;
  7024. private _collisionPoint;
  7025. private _planeIntersectionPoint;
  7026. private _tempVector;
  7027. private _tempVector2;
  7028. private _tempVector3;
  7029. private _tempVector4;
  7030. private _edge;
  7031. private _baseToVertex;
  7032. private _destinationPoint;
  7033. private _slidePlaneNormal;
  7034. private _displacementVector;
  7035. /** @hidden */
  7036. _radius: Vector3;
  7037. /** @hidden */
  7038. _retry: number;
  7039. private _velocity;
  7040. private _basePoint;
  7041. private _epsilon;
  7042. /** @hidden */
  7043. _velocityWorldLength: number;
  7044. /** @hidden */
  7045. _basePointWorld: Vector3;
  7046. private _velocityWorld;
  7047. private _normalizedVelocity;
  7048. /** @hidden */
  7049. _initialVelocity: Vector3;
  7050. /** @hidden */
  7051. _initialPosition: Vector3;
  7052. private _nearestDistance;
  7053. private _collisionMask;
  7054. get collisionMask(): number;
  7055. set collisionMask(mask: number);
  7056. /**
  7057. * Gets the plane normal used to compute the sliding response (in local space)
  7058. */
  7059. get slidePlaneNormal(): Vector3;
  7060. /** @hidden */
  7061. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7062. /** @hidden */
  7063. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7064. /** @hidden */
  7065. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7066. /** @hidden */
  7067. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7068. /** @hidden */
  7069. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7070. /** @hidden */
  7071. _getResponse(pos: Vector3, vel: Vector3): void;
  7072. }
  7073. }
  7074. declare module "babylonjs/Culling/boundingInfo" {
  7075. import { DeepImmutable } from "babylonjs/types";
  7076. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7077. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7078. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7079. import { Plane } from "babylonjs/Maths/math.plane";
  7080. import { Collider } from "babylonjs/Collisions/collider";
  7081. /**
  7082. * Interface for cullable objects
  7083. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7084. */
  7085. export interface ICullable {
  7086. /**
  7087. * Checks if the object or part of the object is in the frustum
  7088. * @param frustumPlanes Camera near/planes
  7089. * @returns true if the object is in frustum otherwise false
  7090. */
  7091. isInFrustum(frustumPlanes: Plane[]): boolean;
  7092. /**
  7093. * Checks if a cullable object (mesh...) is in the camera frustum
  7094. * Unlike isInFrustum this cheks the full bounding box
  7095. * @param frustumPlanes Camera near/planes
  7096. * @returns true if the object is in frustum otherwise false
  7097. */
  7098. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7099. }
  7100. /**
  7101. * Info for a bounding data of a mesh
  7102. */
  7103. export class BoundingInfo implements ICullable {
  7104. /**
  7105. * Bounding box for the mesh
  7106. */
  7107. readonly boundingBox: BoundingBox;
  7108. /**
  7109. * Bounding sphere for the mesh
  7110. */
  7111. readonly boundingSphere: BoundingSphere;
  7112. private _isLocked;
  7113. private static readonly TmpVector3;
  7114. /**
  7115. * Constructs bounding info
  7116. * @param minimum min vector of the bounding box/sphere
  7117. * @param maximum max vector of the bounding box/sphere
  7118. * @param worldMatrix defines the new world matrix
  7119. */
  7120. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7121. /**
  7122. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7123. * @param min defines the new minimum vector (in local space)
  7124. * @param max defines the new maximum vector (in local space)
  7125. * @param worldMatrix defines the new world matrix
  7126. */
  7127. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7128. /**
  7129. * min vector of the bounding box/sphere
  7130. */
  7131. get minimum(): Vector3;
  7132. /**
  7133. * max vector of the bounding box/sphere
  7134. */
  7135. get maximum(): Vector3;
  7136. /**
  7137. * If the info is locked and won't be updated to avoid perf overhead
  7138. */
  7139. get isLocked(): boolean;
  7140. set isLocked(value: boolean);
  7141. /**
  7142. * Updates the bounding sphere and box
  7143. * @param world world matrix to be used to update
  7144. */
  7145. update(world: DeepImmutable<Matrix>): void;
  7146. /**
  7147. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7148. * @param center New center of the bounding info
  7149. * @param extend New extend of the bounding info
  7150. * @returns the current bounding info
  7151. */
  7152. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7153. /**
  7154. * Scale the current bounding info by applying a scale factor
  7155. * @param factor defines the scale factor to apply
  7156. * @returns the current bounding info
  7157. */
  7158. scale(factor: number): BoundingInfo;
  7159. /**
  7160. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7161. * @param frustumPlanes defines the frustum to test
  7162. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7163. * @returns true if the bounding info is in the frustum planes
  7164. */
  7165. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7166. /**
  7167. * Gets the world distance between the min and max points of the bounding box
  7168. */
  7169. get diagonalLength(): number;
  7170. /**
  7171. * Checks if a cullable object (mesh...) is in the camera frustum
  7172. * Unlike isInFrustum this cheks the full bounding box
  7173. * @param frustumPlanes Camera near/planes
  7174. * @returns true if the object is in frustum otherwise false
  7175. */
  7176. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7177. /** @hidden */
  7178. _checkCollision(collider: Collider): boolean;
  7179. /**
  7180. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7181. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7182. * @param point the point to check intersection with
  7183. * @returns if the point intersects
  7184. */
  7185. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7186. /**
  7187. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7188. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7189. * @param boundingInfo the bounding info to check intersection with
  7190. * @param precise if the intersection should be done using OBB
  7191. * @returns if the bounding info intersects
  7192. */
  7193. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7194. }
  7195. }
  7196. declare module "babylonjs/Maths/math.functions" {
  7197. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7198. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7199. /**
  7200. * Extracts minimum and maximum values from a list of indexed positions
  7201. * @param positions defines the positions to use
  7202. * @param indices defines the indices to the positions
  7203. * @param indexStart defines the start index
  7204. * @param indexCount defines the end index
  7205. * @param bias defines bias value to add to the result
  7206. * @return minimum and maximum values
  7207. */
  7208. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7209. minimum: Vector3;
  7210. maximum: Vector3;
  7211. };
  7212. /**
  7213. * Extracts minimum and maximum values from a list of positions
  7214. * @param positions defines the positions to use
  7215. * @param start defines the start index in the positions array
  7216. * @param count defines the number of positions to handle
  7217. * @param bias defines bias value to add to the result
  7218. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7219. * @return minimum and maximum values
  7220. */
  7221. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7222. minimum: Vector3;
  7223. maximum: Vector3;
  7224. };
  7225. }
  7226. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7227. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7228. /** @hidden */
  7229. export class WebGLDataBuffer extends DataBuffer {
  7230. private _buffer;
  7231. constructor(resource: WebGLBuffer);
  7232. get underlyingResource(): any;
  7233. }
  7234. }
  7235. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7236. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7237. import { Nullable } from "babylonjs/types";
  7238. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7239. /** @hidden */
  7240. export class WebGLPipelineContext implements IPipelineContext {
  7241. engine: ThinEngine;
  7242. program: Nullable<WebGLProgram>;
  7243. context?: WebGLRenderingContext;
  7244. vertexShader?: WebGLShader;
  7245. fragmentShader?: WebGLShader;
  7246. isParallelCompiled: boolean;
  7247. onCompiled?: () => void;
  7248. transformFeedback?: WebGLTransformFeedback | null;
  7249. vertexCompilationError: Nullable<string>;
  7250. fragmentCompilationError: Nullable<string>;
  7251. programLinkError: Nullable<string>;
  7252. programValidationError: Nullable<string>;
  7253. get isAsync(): boolean;
  7254. get isReady(): boolean;
  7255. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7256. }
  7257. }
  7258. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7259. import { FloatArray, Nullable } from "babylonjs/types";
  7260. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7261. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7262. module "babylonjs/Engines/thinEngine" {
  7263. interface ThinEngine {
  7264. /**
  7265. * Create an uniform buffer
  7266. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7267. * @param elements defines the content of the uniform buffer
  7268. * @returns the webGL uniform buffer
  7269. */
  7270. createUniformBuffer(elements: FloatArray): DataBuffer;
  7271. /**
  7272. * Create a dynamic uniform buffer
  7273. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7274. * @param elements defines the content of the uniform buffer
  7275. * @returns the webGL uniform buffer
  7276. */
  7277. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7278. /**
  7279. * Update an existing uniform buffer
  7280. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7281. * @param uniformBuffer defines the target uniform buffer
  7282. * @param elements defines the content to update
  7283. * @param offset defines the offset in the uniform buffer where update should start
  7284. * @param count defines the size of the data to update
  7285. */
  7286. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7287. /**
  7288. * Bind an uniform buffer to the current webGL context
  7289. * @param buffer defines the buffer to bind
  7290. */
  7291. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7292. /**
  7293. * Bind a buffer to the current webGL context at a given location
  7294. * @param buffer defines the buffer to bind
  7295. * @param location defines the index where to bind the buffer
  7296. */
  7297. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7298. /**
  7299. * Bind a specific block at a given index in a specific shader program
  7300. * @param pipelineContext defines the pipeline context to use
  7301. * @param blockName defines the block name
  7302. * @param index defines the index where to bind the block
  7303. */
  7304. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7305. }
  7306. }
  7307. }
  7308. declare module "babylonjs/Materials/uniformBuffer" {
  7309. import { Nullable, FloatArray } from "babylonjs/types";
  7310. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7311. import { Engine } from "babylonjs/Engines/engine";
  7312. import { Effect } from "babylonjs/Materials/effect";
  7313. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7314. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7315. import { Color3 } from "babylonjs/Maths/math.color";
  7316. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7317. /**
  7318. * Uniform buffer objects.
  7319. *
  7320. * Handles blocks of uniform on the GPU.
  7321. *
  7322. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7323. *
  7324. * For more information, please refer to :
  7325. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7326. */
  7327. export class UniformBuffer {
  7328. private _engine;
  7329. private _buffer;
  7330. private _data;
  7331. private _bufferData;
  7332. private _dynamic?;
  7333. private _uniformLocations;
  7334. private _uniformSizes;
  7335. private _uniformLocationPointer;
  7336. private _needSync;
  7337. private _noUBO;
  7338. private _currentEffect;
  7339. /** @hidden */
  7340. _alreadyBound: boolean;
  7341. private static _MAX_UNIFORM_SIZE;
  7342. private static _tempBuffer;
  7343. /**
  7344. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7345. * This is dynamic to allow compat with webgl 1 and 2.
  7346. * You will need to pass the name of the uniform as well as the value.
  7347. */
  7348. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7349. /**
  7350. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7351. * This is dynamic to allow compat with webgl 1 and 2.
  7352. * You will need to pass the name of the uniform as well as the value.
  7353. */
  7354. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7355. /**
  7356. * Lambda to Update a single float in a uniform buffer.
  7357. * This is dynamic to allow compat with webgl 1 and 2.
  7358. * You will need to pass the name of the uniform as well as the value.
  7359. */
  7360. updateFloat: (name: string, x: number) => void;
  7361. /**
  7362. * Lambda to Update a vec2 of float in a uniform buffer.
  7363. * This is dynamic to allow compat with webgl 1 and 2.
  7364. * You will need to pass the name of the uniform as well as the value.
  7365. */
  7366. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7367. /**
  7368. * Lambda to Update a vec3 of float in a uniform buffer.
  7369. * This is dynamic to allow compat with webgl 1 and 2.
  7370. * You will need to pass the name of the uniform as well as the value.
  7371. */
  7372. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7373. /**
  7374. * Lambda to Update a vec4 of float in a uniform buffer.
  7375. * This is dynamic to allow compat with webgl 1 and 2.
  7376. * You will need to pass the name of the uniform as well as the value.
  7377. */
  7378. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7379. /**
  7380. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7381. * This is dynamic to allow compat with webgl 1 and 2.
  7382. * You will need to pass the name of the uniform as well as the value.
  7383. */
  7384. updateMatrix: (name: string, mat: Matrix) => void;
  7385. /**
  7386. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7387. * This is dynamic to allow compat with webgl 1 and 2.
  7388. * You will need to pass the name of the uniform as well as the value.
  7389. */
  7390. updateVector3: (name: string, vector: Vector3) => void;
  7391. /**
  7392. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7393. * This is dynamic to allow compat with webgl 1 and 2.
  7394. * You will need to pass the name of the uniform as well as the value.
  7395. */
  7396. updateVector4: (name: string, vector: Vector4) => void;
  7397. /**
  7398. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7399. * This is dynamic to allow compat with webgl 1 and 2.
  7400. * You will need to pass the name of the uniform as well as the value.
  7401. */
  7402. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7403. /**
  7404. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7405. * This is dynamic to allow compat with webgl 1 and 2.
  7406. * You will need to pass the name of the uniform as well as the value.
  7407. */
  7408. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7409. /**
  7410. * Instantiates a new Uniform buffer objects.
  7411. *
  7412. * Handles blocks of uniform on the GPU.
  7413. *
  7414. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7415. *
  7416. * For more information, please refer to :
  7417. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7418. * @param engine Define the engine the buffer is associated with
  7419. * @param data Define the data contained in the buffer
  7420. * @param dynamic Define if the buffer is updatable
  7421. */
  7422. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7423. /**
  7424. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7425. * or just falling back on setUniformXXX calls.
  7426. */
  7427. get useUbo(): boolean;
  7428. /**
  7429. * Indicates if the WebGL underlying uniform buffer is in sync
  7430. * with the javascript cache data.
  7431. */
  7432. get isSync(): boolean;
  7433. /**
  7434. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7435. * Also, a dynamic UniformBuffer will disable cache verification and always
  7436. * update the underlying WebGL uniform buffer to the GPU.
  7437. * @returns if Dynamic, otherwise false
  7438. */
  7439. isDynamic(): boolean;
  7440. /**
  7441. * The data cache on JS side.
  7442. * @returns the underlying data as a float array
  7443. */
  7444. getData(): Float32Array;
  7445. /**
  7446. * The underlying WebGL Uniform buffer.
  7447. * @returns the webgl buffer
  7448. */
  7449. getBuffer(): Nullable<DataBuffer>;
  7450. /**
  7451. * std140 layout specifies how to align data within an UBO structure.
  7452. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7453. * for specs.
  7454. */
  7455. private _fillAlignment;
  7456. /**
  7457. * Adds an uniform in the buffer.
  7458. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7459. * for the layout to be correct !
  7460. * @param name Name of the uniform, as used in the uniform block in the shader.
  7461. * @param size Data size, or data directly.
  7462. */
  7463. addUniform(name: string, size: number | number[]): void;
  7464. /**
  7465. * Adds a Matrix 4x4 to the uniform buffer.
  7466. * @param name Name of the uniform, as used in the uniform block in the shader.
  7467. * @param mat A 4x4 matrix.
  7468. */
  7469. addMatrix(name: string, mat: Matrix): void;
  7470. /**
  7471. * Adds a vec2 to the uniform buffer.
  7472. * @param name Name of the uniform, as used in the uniform block in the shader.
  7473. * @param x Define the x component value of the vec2
  7474. * @param y Define the y component value of the vec2
  7475. */
  7476. addFloat2(name: string, x: number, y: number): void;
  7477. /**
  7478. * Adds a vec3 to the uniform buffer.
  7479. * @param name Name of the uniform, as used in the uniform block in the shader.
  7480. * @param x Define the x component value of the vec3
  7481. * @param y Define the y component value of the vec3
  7482. * @param z Define the z component value of the vec3
  7483. */
  7484. addFloat3(name: string, x: number, y: number, z: number): void;
  7485. /**
  7486. * Adds a vec3 to the uniform buffer.
  7487. * @param name Name of the uniform, as used in the uniform block in the shader.
  7488. * @param color Define the vec3 from a Color
  7489. */
  7490. addColor3(name: string, color: Color3): void;
  7491. /**
  7492. * Adds a vec4 to the uniform buffer.
  7493. * @param name Name of the uniform, as used in the uniform block in the shader.
  7494. * @param color Define the rgb components from a Color
  7495. * @param alpha Define the a component of the vec4
  7496. */
  7497. addColor4(name: string, color: Color3, alpha: number): void;
  7498. /**
  7499. * Adds a vec3 to the uniform buffer.
  7500. * @param name Name of the uniform, as used in the uniform block in the shader.
  7501. * @param vector Define the vec3 components from a Vector
  7502. */
  7503. addVector3(name: string, vector: Vector3): void;
  7504. /**
  7505. * Adds a Matrix 3x3 to the uniform buffer.
  7506. * @param name Name of the uniform, as used in the uniform block in the shader.
  7507. */
  7508. addMatrix3x3(name: string): void;
  7509. /**
  7510. * Adds a Matrix 2x2 to the uniform buffer.
  7511. * @param name Name of the uniform, as used in the uniform block in the shader.
  7512. */
  7513. addMatrix2x2(name: string): void;
  7514. /**
  7515. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7516. */
  7517. create(): void;
  7518. /** @hidden */
  7519. _rebuild(): void;
  7520. /**
  7521. * Updates the WebGL Uniform Buffer on the GPU.
  7522. * If the `dynamic` flag is set to true, no cache comparison is done.
  7523. * Otherwise, the buffer will be updated only if the cache differs.
  7524. */
  7525. update(): void;
  7526. /**
  7527. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7528. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7529. * @param data Define the flattened data
  7530. * @param size Define the size of the data.
  7531. */
  7532. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7533. private _valueCache;
  7534. private _cacheMatrix;
  7535. private _updateMatrix3x3ForUniform;
  7536. private _updateMatrix3x3ForEffect;
  7537. private _updateMatrix2x2ForEffect;
  7538. private _updateMatrix2x2ForUniform;
  7539. private _updateFloatForEffect;
  7540. private _updateFloatForUniform;
  7541. private _updateFloat2ForEffect;
  7542. private _updateFloat2ForUniform;
  7543. private _updateFloat3ForEffect;
  7544. private _updateFloat3ForUniform;
  7545. private _updateFloat4ForEffect;
  7546. private _updateFloat4ForUniform;
  7547. private _updateMatrixForEffect;
  7548. private _updateMatrixForUniform;
  7549. private _updateVector3ForEffect;
  7550. private _updateVector3ForUniform;
  7551. private _updateVector4ForEffect;
  7552. private _updateVector4ForUniform;
  7553. private _updateColor3ForEffect;
  7554. private _updateColor3ForUniform;
  7555. private _updateColor4ForEffect;
  7556. private _updateColor4ForUniform;
  7557. /**
  7558. * Sets a sampler uniform on the effect.
  7559. * @param name Define the name of the sampler.
  7560. * @param texture Define the texture to set in the sampler
  7561. */
  7562. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7563. /**
  7564. * Directly updates the value of the uniform in the cache AND on the GPU.
  7565. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7566. * @param data Define the flattened data
  7567. */
  7568. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7569. /**
  7570. * Binds this uniform buffer to an effect.
  7571. * @param effect Define the effect to bind the buffer to
  7572. * @param name Name of the uniform block in the shader.
  7573. */
  7574. bindToEffect(effect: Effect, name: string): void;
  7575. /**
  7576. * Disposes the uniform buffer.
  7577. */
  7578. dispose(): void;
  7579. }
  7580. }
  7581. declare module "babylonjs/Misc/iInspectable" {
  7582. /**
  7583. * Enum that determines the text-wrapping mode to use.
  7584. */
  7585. export enum InspectableType {
  7586. /**
  7587. * Checkbox for booleans
  7588. */
  7589. Checkbox = 0,
  7590. /**
  7591. * Sliders for numbers
  7592. */
  7593. Slider = 1,
  7594. /**
  7595. * Vector3
  7596. */
  7597. Vector3 = 2,
  7598. /**
  7599. * Quaternions
  7600. */
  7601. Quaternion = 3,
  7602. /**
  7603. * Color3
  7604. */
  7605. Color3 = 4,
  7606. /**
  7607. * String
  7608. */
  7609. String = 5
  7610. }
  7611. /**
  7612. * Interface used to define custom inspectable properties.
  7613. * This interface is used by the inspector to display custom property grids
  7614. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7615. */
  7616. export interface IInspectable {
  7617. /**
  7618. * Gets the label to display
  7619. */
  7620. label: string;
  7621. /**
  7622. * Gets the name of the property to edit
  7623. */
  7624. propertyName: string;
  7625. /**
  7626. * Gets the type of the editor to use
  7627. */
  7628. type: InspectableType;
  7629. /**
  7630. * Gets the minimum value of the property when using in "slider" mode
  7631. */
  7632. min?: number;
  7633. /**
  7634. * Gets the maximum value of the property when using in "slider" mode
  7635. */
  7636. max?: number;
  7637. /**
  7638. * Gets the setp to use when using in "slider" mode
  7639. */
  7640. step?: number;
  7641. }
  7642. }
  7643. declare module "babylonjs/Misc/timingTools" {
  7644. /**
  7645. * Class used to provide helper for timing
  7646. */
  7647. export class TimingTools {
  7648. /**
  7649. * Polyfill for setImmediate
  7650. * @param action defines the action to execute after the current execution block
  7651. */
  7652. static SetImmediate(action: () => void): void;
  7653. }
  7654. }
  7655. declare module "babylonjs/Misc/instantiationTools" {
  7656. /**
  7657. * Class used to enable instatition of objects by class name
  7658. */
  7659. export class InstantiationTools {
  7660. /**
  7661. * Use this object to register external classes like custom textures or material
  7662. * to allow the laoders to instantiate them
  7663. */
  7664. static RegisteredExternalClasses: {
  7665. [key: string]: Object;
  7666. };
  7667. /**
  7668. * Tries to instantiate a new object from a given class name
  7669. * @param className defines the class name to instantiate
  7670. * @returns the new object or null if the system was not able to do the instantiation
  7671. */
  7672. static Instantiate(className: string): any;
  7673. }
  7674. }
  7675. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7676. /**
  7677. * Define options used to create a depth texture
  7678. */
  7679. export class DepthTextureCreationOptions {
  7680. /** Specifies whether or not a stencil should be allocated in the texture */
  7681. generateStencil?: boolean;
  7682. /** Specifies whether or not bilinear filtering is enable on the texture */
  7683. bilinearFiltering?: boolean;
  7684. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7685. comparisonFunction?: number;
  7686. /** Specifies if the created texture is a cube texture */
  7687. isCube?: boolean;
  7688. }
  7689. }
  7690. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7691. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7692. import { Nullable } from "babylonjs/types";
  7693. import { Scene } from "babylonjs/scene";
  7694. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7695. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7696. module "babylonjs/Engines/thinEngine" {
  7697. interface ThinEngine {
  7698. /**
  7699. * Creates a depth stencil cube texture.
  7700. * This is only available in WebGL 2.
  7701. * @param size The size of face edge in the cube texture.
  7702. * @param options The options defining the cube texture.
  7703. * @returns The cube texture
  7704. */
  7705. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7706. /**
  7707. * Creates a cube texture
  7708. * @param rootUrl defines the url where the files to load is located
  7709. * @param scene defines the current scene
  7710. * @param files defines the list of files to load (1 per face)
  7711. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7712. * @param onLoad defines an optional callback raised when the texture is loaded
  7713. * @param onError defines an optional callback raised if there is an issue to load the texture
  7714. * @param format defines the format of the data
  7715. * @param forcedExtension defines the extension to use to pick the right loader
  7716. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7717. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7718. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7719. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7720. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7721. * @returns the cube texture as an InternalTexture
  7722. */
  7723. 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;
  7724. /**
  7725. * Creates a cube texture
  7726. * @param rootUrl defines the url where the files to load is located
  7727. * @param scene defines the current scene
  7728. * @param files defines the list of files to load (1 per face)
  7729. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7730. * @param onLoad defines an optional callback raised when the texture is loaded
  7731. * @param onError defines an optional callback raised if there is an issue to load the texture
  7732. * @param format defines the format of the data
  7733. * @param forcedExtension defines the extension to use to pick the right loader
  7734. * @returns the cube texture as an InternalTexture
  7735. */
  7736. 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;
  7737. /**
  7738. * Creates a cube texture
  7739. * @param rootUrl defines the url where the files to load is located
  7740. * @param scene defines the current scene
  7741. * @param files defines the list of files to load (1 per face)
  7742. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7743. * @param onLoad defines an optional callback raised when the texture is loaded
  7744. * @param onError defines an optional callback raised if there is an issue to load the texture
  7745. * @param format defines the format of the data
  7746. * @param forcedExtension defines the extension to use to pick the right loader
  7747. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7748. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7749. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7750. * @returns the cube texture as an InternalTexture
  7751. */
  7752. 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;
  7753. /** @hidden */
  7754. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7755. /** @hidden */
  7756. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7757. /** @hidden */
  7758. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7759. /** @hidden */
  7760. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7761. /**
  7762. * @hidden
  7763. */
  7764. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7765. }
  7766. }
  7767. }
  7768. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7769. import { Nullable } from "babylonjs/types";
  7770. import { Scene } from "babylonjs/scene";
  7771. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7772. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7773. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7774. /**
  7775. * Class for creating a cube texture
  7776. */
  7777. export class CubeTexture extends BaseTexture {
  7778. private _delayedOnLoad;
  7779. /**
  7780. * The url of the texture
  7781. */
  7782. url: string;
  7783. /**
  7784. * Gets or sets the center of the bounding box associated with the cube texture.
  7785. * It must define where the camera used to render the texture was set
  7786. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7787. */
  7788. boundingBoxPosition: Vector3;
  7789. private _boundingBoxSize;
  7790. /**
  7791. * Gets or sets the size of the bounding box associated with the cube texture
  7792. * When defined, the cubemap will switch to local mode
  7793. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7794. * @example https://www.babylonjs-playground.com/#RNASML
  7795. */
  7796. set boundingBoxSize(value: Vector3);
  7797. /**
  7798. * Returns the bounding box size
  7799. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7800. */
  7801. get boundingBoxSize(): Vector3;
  7802. protected _rotationY: number;
  7803. /**
  7804. * Sets texture matrix rotation angle around Y axis in radians.
  7805. */
  7806. set rotationY(value: number);
  7807. /**
  7808. * Gets texture matrix rotation angle around Y axis radians.
  7809. */
  7810. get rotationY(): number;
  7811. /**
  7812. * Are mip maps generated for this texture or not.
  7813. */
  7814. get noMipmap(): boolean;
  7815. private _noMipmap;
  7816. private _files;
  7817. protected _forcedExtension: Nullable<string>;
  7818. private _extensions;
  7819. private _textureMatrix;
  7820. private _format;
  7821. private _createPolynomials;
  7822. /** @hidden */
  7823. _prefiltered: boolean;
  7824. /**
  7825. * Creates a cube texture from an array of image urls
  7826. * @param files defines an array of image urls
  7827. * @param scene defines the hosting scene
  7828. * @param noMipmap specifies if mip maps are not used
  7829. * @returns a cube texture
  7830. */
  7831. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7832. /**
  7833. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7834. * @param url defines the url of the prefiltered texture
  7835. * @param scene defines the scene the texture is attached to
  7836. * @param forcedExtension defines the extension of the file if different from the url
  7837. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7838. * @return the prefiltered texture
  7839. */
  7840. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7841. /**
  7842. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7843. * as prefiltered data.
  7844. * @param rootUrl defines the url of the texture or the root name of the six images
  7845. * @param scene defines the scene the texture is attached to
  7846. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7847. * @param noMipmap defines if mipmaps should be created or not
  7848. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7849. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7850. * @param onError defines a callback triggered in case of error during load
  7851. * @param format defines the internal format to use for the texture once loaded
  7852. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7853. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7854. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7855. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7856. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7857. * @return the cube texture
  7858. */
  7859. 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);
  7860. /**
  7861. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7862. */
  7863. get isPrefiltered(): boolean;
  7864. /**
  7865. * Get the current class name of the texture useful for serialization or dynamic coding.
  7866. * @returns "CubeTexture"
  7867. */
  7868. getClassName(): string;
  7869. /**
  7870. * Update the url (and optional buffer) of this texture if url was null during construction.
  7871. * @param url the url of the texture
  7872. * @param forcedExtension defines the extension to use
  7873. * @param onLoad callback called when the texture is loaded (defaults to null)
  7874. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7875. */
  7876. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7877. /**
  7878. * Delays loading of the cube texture
  7879. * @param forcedExtension defines the extension to use
  7880. */
  7881. delayLoad(forcedExtension?: string): void;
  7882. /**
  7883. * Returns the reflection texture matrix
  7884. * @returns the reflection texture matrix
  7885. */
  7886. getReflectionTextureMatrix(): Matrix;
  7887. /**
  7888. * Sets the reflection texture matrix
  7889. * @param value Reflection texture matrix
  7890. */
  7891. setReflectionTextureMatrix(value: Matrix): void;
  7892. /**
  7893. * Parses text to create a cube texture
  7894. * @param parsedTexture define the serialized text to read from
  7895. * @param scene defines the hosting scene
  7896. * @param rootUrl defines the root url of the cube texture
  7897. * @returns a cube texture
  7898. */
  7899. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7900. /**
  7901. * Makes a clone, or deep copy, of the cube texture
  7902. * @returns a new cube texture
  7903. */
  7904. clone(): CubeTexture;
  7905. }
  7906. }
  7907. declare module "babylonjs/Materials/materialDefines" {
  7908. /**
  7909. * Manages the defines for the Material
  7910. */
  7911. export class MaterialDefines {
  7912. /** @hidden */
  7913. protected _keys: string[];
  7914. private _isDirty;
  7915. /** @hidden */
  7916. _renderId: number;
  7917. /** @hidden */
  7918. _areLightsDirty: boolean;
  7919. /** @hidden */
  7920. _areLightsDisposed: boolean;
  7921. /** @hidden */
  7922. _areAttributesDirty: boolean;
  7923. /** @hidden */
  7924. _areTexturesDirty: boolean;
  7925. /** @hidden */
  7926. _areFresnelDirty: boolean;
  7927. /** @hidden */
  7928. _areMiscDirty: boolean;
  7929. /** @hidden */
  7930. _areImageProcessingDirty: boolean;
  7931. /** @hidden */
  7932. _normals: boolean;
  7933. /** @hidden */
  7934. _uvs: boolean;
  7935. /** @hidden */
  7936. _needNormals: boolean;
  7937. /** @hidden */
  7938. _needUVs: boolean;
  7939. [id: string]: any;
  7940. /**
  7941. * Specifies if the material needs to be re-calculated
  7942. */
  7943. get isDirty(): boolean;
  7944. /**
  7945. * Marks the material to indicate that it has been re-calculated
  7946. */
  7947. markAsProcessed(): void;
  7948. /**
  7949. * Marks the material to indicate that it needs to be re-calculated
  7950. */
  7951. markAsUnprocessed(): void;
  7952. /**
  7953. * Marks the material to indicate all of its defines need to be re-calculated
  7954. */
  7955. markAllAsDirty(): void;
  7956. /**
  7957. * Marks the material to indicate that image processing needs to be re-calculated
  7958. */
  7959. markAsImageProcessingDirty(): void;
  7960. /**
  7961. * Marks the material to indicate the lights need to be re-calculated
  7962. * @param disposed Defines whether the light is dirty due to dispose or not
  7963. */
  7964. markAsLightDirty(disposed?: boolean): void;
  7965. /**
  7966. * Marks the attribute state as changed
  7967. */
  7968. markAsAttributesDirty(): void;
  7969. /**
  7970. * Marks the texture state as changed
  7971. */
  7972. markAsTexturesDirty(): void;
  7973. /**
  7974. * Marks the fresnel state as changed
  7975. */
  7976. markAsFresnelDirty(): void;
  7977. /**
  7978. * Marks the misc state as changed
  7979. */
  7980. markAsMiscDirty(): void;
  7981. /**
  7982. * Rebuilds the material defines
  7983. */
  7984. rebuild(): void;
  7985. /**
  7986. * Specifies if two material defines are equal
  7987. * @param other - A material define instance to compare to
  7988. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7989. */
  7990. isEqual(other: MaterialDefines): boolean;
  7991. /**
  7992. * Clones this instance's defines to another instance
  7993. * @param other - material defines to clone values to
  7994. */
  7995. cloneTo(other: MaterialDefines): void;
  7996. /**
  7997. * Resets the material define values
  7998. */
  7999. reset(): void;
  8000. /**
  8001. * Converts the material define values to a string
  8002. * @returns - String of material define information
  8003. */
  8004. toString(): string;
  8005. }
  8006. }
  8007. declare module "babylonjs/Materials/colorCurves" {
  8008. import { Effect } from "babylonjs/Materials/effect";
  8009. /**
  8010. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8011. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8012. * 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;
  8013. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8014. */
  8015. export class ColorCurves {
  8016. private _dirty;
  8017. private _tempColor;
  8018. private _globalCurve;
  8019. private _highlightsCurve;
  8020. private _midtonesCurve;
  8021. private _shadowsCurve;
  8022. private _positiveCurve;
  8023. private _negativeCurve;
  8024. private _globalHue;
  8025. private _globalDensity;
  8026. private _globalSaturation;
  8027. private _globalExposure;
  8028. /**
  8029. * Gets the global Hue value.
  8030. * 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).
  8031. */
  8032. get globalHue(): number;
  8033. /**
  8034. * Sets the global Hue value.
  8035. * 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).
  8036. */
  8037. set globalHue(value: number);
  8038. /**
  8039. * Gets the global Density value.
  8040. * 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.
  8041. * Values less than zero provide a filter of opposite hue.
  8042. */
  8043. get globalDensity(): number;
  8044. /**
  8045. * Sets the global Density value.
  8046. * 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.
  8047. * Values less than zero provide a filter of opposite hue.
  8048. */
  8049. set globalDensity(value: number);
  8050. /**
  8051. * Gets the global Saturation value.
  8052. * 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.
  8053. */
  8054. get globalSaturation(): number;
  8055. /**
  8056. * Sets the global Saturation value.
  8057. * 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.
  8058. */
  8059. set globalSaturation(value: number);
  8060. /**
  8061. * Gets the global Exposure value.
  8062. * 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.
  8063. */
  8064. get globalExposure(): number;
  8065. /**
  8066. * Sets the global Exposure value.
  8067. * 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.
  8068. */
  8069. set globalExposure(value: number);
  8070. private _highlightsHue;
  8071. private _highlightsDensity;
  8072. private _highlightsSaturation;
  8073. private _highlightsExposure;
  8074. /**
  8075. * Gets the highlights Hue value.
  8076. * 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).
  8077. */
  8078. get highlightsHue(): number;
  8079. /**
  8080. * Sets the highlights Hue value.
  8081. * 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).
  8082. */
  8083. set highlightsHue(value: number);
  8084. /**
  8085. * Gets the highlights Density value.
  8086. * 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.
  8087. * Values less than zero provide a filter of opposite hue.
  8088. */
  8089. get highlightsDensity(): number;
  8090. /**
  8091. * Sets the highlights Density value.
  8092. * 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.
  8093. * Values less than zero provide a filter of opposite hue.
  8094. */
  8095. set highlightsDensity(value: number);
  8096. /**
  8097. * Gets the highlights Saturation value.
  8098. * 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.
  8099. */
  8100. get highlightsSaturation(): number;
  8101. /**
  8102. * Sets the highlights Saturation value.
  8103. * 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.
  8104. */
  8105. set highlightsSaturation(value: number);
  8106. /**
  8107. * Gets the highlights Exposure value.
  8108. * 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.
  8109. */
  8110. get highlightsExposure(): number;
  8111. /**
  8112. * Sets the highlights Exposure value.
  8113. * 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.
  8114. */
  8115. set highlightsExposure(value: number);
  8116. private _midtonesHue;
  8117. private _midtonesDensity;
  8118. private _midtonesSaturation;
  8119. private _midtonesExposure;
  8120. /**
  8121. * Gets the midtones Hue value.
  8122. * 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).
  8123. */
  8124. get midtonesHue(): number;
  8125. /**
  8126. * Sets the midtones Hue value.
  8127. * 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).
  8128. */
  8129. set midtonesHue(value: number);
  8130. /**
  8131. * Gets the midtones Density value.
  8132. * 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.
  8133. * Values less than zero provide a filter of opposite hue.
  8134. */
  8135. get midtonesDensity(): number;
  8136. /**
  8137. * Sets the midtones Density value.
  8138. * 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.
  8139. * Values less than zero provide a filter of opposite hue.
  8140. */
  8141. set midtonesDensity(value: number);
  8142. /**
  8143. * Gets the midtones Saturation value.
  8144. * 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.
  8145. */
  8146. get midtonesSaturation(): number;
  8147. /**
  8148. * Sets the midtones Saturation value.
  8149. * 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.
  8150. */
  8151. set midtonesSaturation(value: number);
  8152. /**
  8153. * Gets the midtones Exposure value.
  8154. * 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.
  8155. */
  8156. get midtonesExposure(): number;
  8157. /**
  8158. * Sets the midtones Exposure value.
  8159. * 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.
  8160. */
  8161. set midtonesExposure(value: number);
  8162. private _shadowsHue;
  8163. private _shadowsDensity;
  8164. private _shadowsSaturation;
  8165. private _shadowsExposure;
  8166. /**
  8167. * Gets the shadows Hue value.
  8168. * 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).
  8169. */
  8170. get shadowsHue(): number;
  8171. /**
  8172. * Sets the shadows Hue value.
  8173. * 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).
  8174. */
  8175. set shadowsHue(value: number);
  8176. /**
  8177. * Gets the shadows Density value.
  8178. * 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.
  8179. * Values less than zero provide a filter of opposite hue.
  8180. */
  8181. get shadowsDensity(): number;
  8182. /**
  8183. * Sets the shadows Density value.
  8184. * 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.
  8185. * Values less than zero provide a filter of opposite hue.
  8186. */
  8187. set shadowsDensity(value: number);
  8188. /**
  8189. * Gets the shadows Saturation value.
  8190. * 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.
  8191. */
  8192. get shadowsSaturation(): number;
  8193. /**
  8194. * Sets the shadows Saturation value.
  8195. * 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.
  8196. */
  8197. set shadowsSaturation(value: number);
  8198. /**
  8199. * Gets the shadows Exposure value.
  8200. * 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.
  8201. */
  8202. get shadowsExposure(): number;
  8203. /**
  8204. * Sets the shadows Exposure value.
  8205. * 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.
  8206. */
  8207. set shadowsExposure(value: number);
  8208. /**
  8209. * Returns the class name
  8210. * @returns The class name
  8211. */
  8212. getClassName(): string;
  8213. /**
  8214. * Binds the color curves to the shader.
  8215. * @param colorCurves The color curve to bind
  8216. * @param effect The effect to bind to
  8217. * @param positiveUniform The positive uniform shader parameter
  8218. * @param neutralUniform The neutral uniform shader parameter
  8219. * @param negativeUniform The negative uniform shader parameter
  8220. */
  8221. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8222. /**
  8223. * Prepare the list of uniforms associated with the ColorCurves effects.
  8224. * @param uniformsList The list of uniforms used in the effect
  8225. */
  8226. static PrepareUniforms(uniformsList: string[]): void;
  8227. /**
  8228. * Returns color grading data based on a hue, density, saturation and exposure value.
  8229. * @param filterHue The hue of the color filter.
  8230. * @param filterDensity The density of the color filter.
  8231. * @param saturation The saturation.
  8232. * @param exposure The exposure.
  8233. * @param result The result data container.
  8234. */
  8235. private getColorGradingDataToRef;
  8236. /**
  8237. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8238. * @param value The input slider value in range [-100,100].
  8239. * @returns Adjusted value.
  8240. */
  8241. private static applyColorGradingSliderNonlinear;
  8242. /**
  8243. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8244. * @param hue The hue (H) input.
  8245. * @param saturation The saturation (S) input.
  8246. * @param brightness The brightness (B) input.
  8247. * @result An RGBA color represented as Vector4.
  8248. */
  8249. private static fromHSBToRef;
  8250. /**
  8251. * Returns a value clamped between min and max
  8252. * @param value The value to clamp
  8253. * @param min The minimum of value
  8254. * @param max The maximum of value
  8255. * @returns The clamped value.
  8256. */
  8257. private static clamp;
  8258. /**
  8259. * Clones the current color curve instance.
  8260. * @return The cloned curves
  8261. */
  8262. clone(): ColorCurves;
  8263. /**
  8264. * Serializes the current color curve instance to a json representation.
  8265. * @return a JSON representation
  8266. */
  8267. serialize(): any;
  8268. /**
  8269. * Parses the color curve from a json representation.
  8270. * @param source the JSON source to parse
  8271. * @return The parsed curves
  8272. */
  8273. static Parse(source: any): ColorCurves;
  8274. }
  8275. }
  8276. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8277. import { Observable } from "babylonjs/Misc/observable";
  8278. import { Nullable } from "babylonjs/types";
  8279. import { Color4 } from "babylonjs/Maths/math.color";
  8280. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8281. import { Effect } from "babylonjs/Materials/effect";
  8282. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8283. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8284. /**
  8285. * Interface to follow in your material defines to integrate easily the
  8286. * Image proccessing functions.
  8287. * @hidden
  8288. */
  8289. export interface IImageProcessingConfigurationDefines {
  8290. IMAGEPROCESSING: boolean;
  8291. VIGNETTE: boolean;
  8292. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8293. VIGNETTEBLENDMODEOPAQUE: boolean;
  8294. TONEMAPPING: boolean;
  8295. TONEMAPPING_ACES: boolean;
  8296. CONTRAST: boolean;
  8297. EXPOSURE: boolean;
  8298. COLORCURVES: boolean;
  8299. COLORGRADING: boolean;
  8300. COLORGRADING3D: boolean;
  8301. SAMPLER3DGREENDEPTH: boolean;
  8302. SAMPLER3DBGRMAP: boolean;
  8303. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8304. }
  8305. /**
  8306. * @hidden
  8307. */
  8308. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8309. IMAGEPROCESSING: boolean;
  8310. VIGNETTE: boolean;
  8311. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8312. VIGNETTEBLENDMODEOPAQUE: boolean;
  8313. TONEMAPPING: boolean;
  8314. TONEMAPPING_ACES: boolean;
  8315. CONTRAST: boolean;
  8316. COLORCURVES: boolean;
  8317. COLORGRADING: boolean;
  8318. COLORGRADING3D: boolean;
  8319. SAMPLER3DGREENDEPTH: boolean;
  8320. SAMPLER3DBGRMAP: boolean;
  8321. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8322. EXPOSURE: boolean;
  8323. constructor();
  8324. }
  8325. /**
  8326. * This groups together the common properties used for image processing either in direct forward pass
  8327. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8328. * or not.
  8329. */
  8330. export class ImageProcessingConfiguration {
  8331. /**
  8332. * Default tone mapping applied in BabylonJS.
  8333. */
  8334. static readonly TONEMAPPING_STANDARD: number;
  8335. /**
  8336. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8337. * to other engines rendering to increase portability.
  8338. */
  8339. static readonly TONEMAPPING_ACES: number;
  8340. /**
  8341. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8342. */
  8343. colorCurves: Nullable<ColorCurves>;
  8344. private _colorCurvesEnabled;
  8345. /**
  8346. * Gets wether the color curves effect is enabled.
  8347. */
  8348. get colorCurvesEnabled(): boolean;
  8349. /**
  8350. * Sets wether the color curves effect is enabled.
  8351. */
  8352. set colorCurvesEnabled(value: boolean);
  8353. private _colorGradingTexture;
  8354. /**
  8355. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8356. */
  8357. get colorGradingTexture(): Nullable<BaseTexture>;
  8358. /**
  8359. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8360. */
  8361. set colorGradingTexture(value: Nullable<BaseTexture>);
  8362. private _colorGradingEnabled;
  8363. /**
  8364. * Gets wether the color grading effect is enabled.
  8365. */
  8366. get colorGradingEnabled(): boolean;
  8367. /**
  8368. * Sets wether the color grading effect is enabled.
  8369. */
  8370. set colorGradingEnabled(value: boolean);
  8371. private _colorGradingWithGreenDepth;
  8372. /**
  8373. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8374. */
  8375. get colorGradingWithGreenDepth(): boolean;
  8376. /**
  8377. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8378. */
  8379. set colorGradingWithGreenDepth(value: boolean);
  8380. private _colorGradingBGR;
  8381. /**
  8382. * Gets wether the color grading texture contains BGR values.
  8383. */
  8384. get colorGradingBGR(): boolean;
  8385. /**
  8386. * Sets wether the color grading texture contains BGR values.
  8387. */
  8388. set colorGradingBGR(value: boolean);
  8389. /** @hidden */
  8390. _exposure: number;
  8391. /**
  8392. * Gets the Exposure used in the effect.
  8393. */
  8394. get exposure(): number;
  8395. /**
  8396. * Sets the Exposure used in the effect.
  8397. */
  8398. set exposure(value: number);
  8399. private _toneMappingEnabled;
  8400. /**
  8401. * Gets wether the tone mapping effect is enabled.
  8402. */
  8403. get toneMappingEnabled(): boolean;
  8404. /**
  8405. * Sets wether the tone mapping effect is enabled.
  8406. */
  8407. set toneMappingEnabled(value: boolean);
  8408. private _toneMappingType;
  8409. /**
  8410. * Gets the type of tone mapping effect.
  8411. */
  8412. get toneMappingType(): number;
  8413. /**
  8414. * Sets the type of tone mapping effect used in BabylonJS.
  8415. */
  8416. set toneMappingType(value: number);
  8417. protected _contrast: number;
  8418. /**
  8419. * Gets the contrast used in the effect.
  8420. */
  8421. get contrast(): number;
  8422. /**
  8423. * Sets the contrast used in the effect.
  8424. */
  8425. set contrast(value: number);
  8426. /**
  8427. * Vignette stretch size.
  8428. */
  8429. vignetteStretch: number;
  8430. /**
  8431. * Vignette centre X Offset.
  8432. */
  8433. vignetteCentreX: number;
  8434. /**
  8435. * Vignette centre Y Offset.
  8436. */
  8437. vignetteCentreY: number;
  8438. /**
  8439. * Vignette weight or intensity of the vignette effect.
  8440. */
  8441. vignetteWeight: number;
  8442. /**
  8443. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8444. * if vignetteEnabled is set to true.
  8445. */
  8446. vignetteColor: Color4;
  8447. /**
  8448. * Camera field of view used by the Vignette effect.
  8449. */
  8450. vignetteCameraFov: number;
  8451. private _vignetteBlendMode;
  8452. /**
  8453. * Gets the vignette blend mode allowing different kind of effect.
  8454. */
  8455. get vignetteBlendMode(): number;
  8456. /**
  8457. * Sets the vignette blend mode allowing different kind of effect.
  8458. */
  8459. set vignetteBlendMode(value: number);
  8460. private _vignetteEnabled;
  8461. /**
  8462. * Gets wether the vignette effect is enabled.
  8463. */
  8464. get vignetteEnabled(): boolean;
  8465. /**
  8466. * Sets wether the vignette effect is enabled.
  8467. */
  8468. set vignetteEnabled(value: boolean);
  8469. private _applyByPostProcess;
  8470. /**
  8471. * Gets wether the image processing is applied through a post process or not.
  8472. */
  8473. get applyByPostProcess(): boolean;
  8474. /**
  8475. * Sets wether the image processing is applied through a post process or not.
  8476. */
  8477. set applyByPostProcess(value: boolean);
  8478. private _isEnabled;
  8479. /**
  8480. * Gets wether the image processing is enabled or not.
  8481. */
  8482. get isEnabled(): boolean;
  8483. /**
  8484. * Sets wether the image processing is enabled or not.
  8485. */
  8486. set isEnabled(value: boolean);
  8487. /**
  8488. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8489. */
  8490. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8491. /**
  8492. * Method called each time the image processing information changes requires to recompile the effect.
  8493. */
  8494. protected _updateParameters(): void;
  8495. /**
  8496. * Gets the current class name.
  8497. * @return "ImageProcessingConfiguration"
  8498. */
  8499. getClassName(): string;
  8500. /**
  8501. * Prepare the list of uniforms associated with the Image Processing effects.
  8502. * @param uniforms The list of uniforms used in the effect
  8503. * @param defines the list of defines currently in use
  8504. */
  8505. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8506. /**
  8507. * Prepare the list of samplers associated with the Image Processing effects.
  8508. * @param samplersList The list of uniforms used in the effect
  8509. * @param defines the list of defines currently in use
  8510. */
  8511. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8512. /**
  8513. * Prepare the list of defines associated to the shader.
  8514. * @param defines the list of defines to complete
  8515. * @param forPostProcess Define if we are currently in post process mode or not
  8516. */
  8517. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8518. /**
  8519. * Returns true if all the image processing information are ready.
  8520. * @returns True if ready, otherwise, false
  8521. */
  8522. isReady(): boolean;
  8523. /**
  8524. * Binds the image processing to the shader.
  8525. * @param effect The effect to bind to
  8526. * @param overrideAspectRatio Override the aspect ratio of the effect
  8527. */
  8528. bind(effect: Effect, overrideAspectRatio?: number): void;
  8529. /**
  8530. * Clones the current image processing instance.
  8531. * @return The cloned image processing
  8532. */
  8533. clone(): ImageProcessingConfiguration;
  8534. /**
  8535. * Serializes the current image processing instance to a json representation.
  8536. * @return a JSON representation
  8537. */
  8538. serialize(): any;
  8539. /**
  8540. * Parses the image processing from a json representation.
  8541. * @param source the JSON source to parse
  8542. * @return The parsed image processing
  8543. */
  8544. static Parse(source: any): ImageProcessingConfiguration;
  8545. private static _VIGNETTEMODE_MULTIPLY;
  8546. private static _VIGNETTEMODE_OPAQUE;
  8547. /**
  8548. * Used to apply the vignette as a mix with the pixel color.
  8549. */
  8550. static get VIGNETTEMODE_MULTIPLY(): number;
  8551. /**
  8552. * Used to apply the vignette as a replacement of the pixel color.
  8553. */
  8554. static get VIGNETTEMODE_OPAQUE(): number;
  8555. }
  8556. }
  8557. declare module "babylonjs/Shaders/postprocess.vertex" {
  8558. /** @hidden */
  8559. export var postprocessVertexShader: {
  8560. name: string;
  8561. shader: string;
  8562. };
  8563. }
  8564. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8565. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8566. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8567. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8568. module "babylonjs/Engines/thinEngine" {
  8569. interface ThinEngine {
  8570. /**
  8571. * Creates a new render target texture
  8572. * @param size defines the size of the texture
  8573. * @param options defines the options used to create the texture
  8574. * @returns a new render target texture stored in an InternalTexture
  8575. */
  8576. createRenderTargetTexture(size: number | {
  8577. width: number;
  8578. height: number;
  8579. layers?: number;
  8580. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8581. /**
  8582. * Creates a depth stencil texture.
  8583. * This is only available in WebGL 2 or with the depth texture extension available.
  8584. * @param size The size of face edge in the texture.
  8585. * @param options The options defining the texture.
  8586. * @returns The texture
  8587. */
  8588. createDepthStencilTexture(size: number | {
  8589. width: number;
  8590. height: number;
  8591. layers?: number;
  8592. }, options: DepthTextureCreationOptions): InternalTexture;
  8593. /** @hidden */
  8594. _createDepthStencilTexture(size: number | {
  8595. width: number;
  8596. height: number;
  8597. layers?: number;
  8598. }, options: DepthTextureCreationOptions): InternalTexture;
  8599. }
  8600. }
  8601. }
  8602. declare module "babylonjs/Maths/math.axis" {
  8603. import { Vector3 } from "babylonjs/Maths/math.vector";
  8604. /** Defines supported spaces */
  8605. export enum Space {
  8606. /** Local (object) space */
  8607. LOCAL = 0,
  8608. /** World space */
  8609. WORLD = 1,
  8610. /** Bone space */
  8611. BONE = 2
  8612. }
  8613. /** Defines the 3 main axes */
  8614. export class Axis {
  8615. /** X axis */
  8616. static X: Vector3;
  8617. /** Y axis */
  8618. static Y: Vector3;
  8619. /** Z axis */
  8620. static Z: Vector3;
  8621. }
  8622. }
  8623. declare module "babylonjs/Cameras/targetCamera" {
  8624. import { Nullable } from "babylonjs/types";
  8625. import { Camera } from "babylonjs/Cameras/camera";
  8626. import { Scene } from "babylonjs/scene";
  8627. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8628. /**
  8629. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8630. * This is the base of the follow, arc rotate cameras and Free camera
  8631. * @see http://doc.babylonjs.com/features/cameras
  8632. */
  8633. export class TargetCamera extends Camera {
  8634. private static _RigCamTransformMatrix;
  8635. private static _TargetTransformMatrix;
  8636. private static _TargetFocalPoint;
  8637. /**
  8638. * Define the current direction the camera is moving to
  8639. */
  8640. cameraDirection: Vector3;
  8641. /**
  8642. * Define the current rotation the camera is rotating to
  8643. */
  8644. cameraRotation: Vector2;
  8645. /**
  8646. * When set, the up vector of the camera will be updated by the rotation of the camera
  8647. */
  8648. updateUpVectorFromRotation: boolean;
  8649. private _tmpQuaternion;
  8650. /**
  8651. * Define the current rotation of the camera
  8652. */
  8653. rotation: Vector3;
  8654. /**
  8655. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8656. */
  8657. rotationQuaternion: Quaternion;
  8658. /**
  8659. * Define the current speed of the camera
  8660. */
  8661. speed: number;
  8662. /**
  8663. * Add constraint to the camera to prevent it to move freely in all directions and
  8664. * around all axis.
  8665. */
  8666. noRotationConstraint: boolean;
  8667. /**
  8668. * Define the current target of the camera as an object or a position.
  8669. */
  8670. lockedTarget: any;
  8671. /** @hidden */
  8672. _currentTarget: Vector3;
  8673. /** @hidden */
  8674. _initialFocalDistance: number;
  8675. /** @hidden */
  8676. _viewMatrix: Matrix;
  8677. /** @hidden */
  8678. _camMatrix: Matrix;
  8679. /** @hidden */
  8680. _cameraTransformMatrix: Matrix;
  8681. /** @hidden */
  8682. _cameraRotationMatrix: Matrix;
  8683. /** @hidden */
  8684. _referencePoint: Vector3;
  8685. /** @hidden */
  8686. _transformedReferencePoint: Vector3;
  8687. protected _globalCurrentTarget: Vector3;
  8688. protected _globalCurrentUpVector: Vector3;
  8689. /** @hidden */
  8690. _reset: () => void;
  8691. private _defaultUp;
  8692. /**
  8693. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8694. * This is the base of the follow, arc rotate cameras and Free camera
  8695. * @see http://doc.babylonjs.com/features/cameras
  8696. * @param name Defines the name of the camera in the scene
  8697. * @param position Defines the start position of the camera in the scene
  8698. * @param scene Defines the scene the camera belongs to
  8699. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8700. */
  8701. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8702. /**
  8703. * Gets the position in front of the camera at a given distance.
  8704. * @param distance The distance from the camera we want the position to be
  8705. * @returns the position
  8706. */
  8707. getFrontPosition(distance: number): Vector3;
  8708. /** @hidden */
  8709. _getLockedTargetPosition(): Nullable<Vector3>;
  8710. private _storedPosition;
  8711. private _storedRotation;
  8712. private _storedRotationQuaternion;
  8713. /**
  8714. * Store current camera state of the camera (fov, position, rotation, etc..)
  8715. * @returns the camera
  8716. */
  8717. storeState(): Camera;
  8718. /**
  8719. * Restored camera state. You must call storeState() first
  8720. * @returns whether it was successful or not
  8721. * @hidden
  8722. */
  8723. _restoreStateValues(): boolean;
  8724. /** @hidden */
  8725. _initCache(): void;
  8726. /** @hidden */
  8727. _updateCache(ignoreParentClass?: boolean): void;
  8728. /** @hidden */
  8729. _isSynchronizedViewMatrix(): boolean;
  8730. /** @hidden */
  8731. _computeLocalCameraSpeed(): number;
  8732. /**
  8733. * Defines the target the camera should look at.
  8734. * @param target Defines the new target as a Vector or a mesh
  8735. */
  8736. setTarget(target: Vector3): void;
  8737. /**
  8738. * Return the current target position of the camera. This value is expressed in local space.
  8739. * @returns the target position
  8740. */
  8741. getTarget(): Vector3;
  8742. /** @hidden */
  8743. _decideIfNeedsToMove(): boolean;
  8744. /** @hidden */
  8745. _updatePosition(): void;
  8746. /** @hidden */
  8747. _checkInputs(): void;
  8748. protected _updateCameraRotationMatrix(): void;
  8749. /**
  8750. * 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)
  8751. * @returns the current camera
  8752. */
  8753. private _rotateUpVectorWithCameraRotationMatrix;
  8754. private _cachedRotationZ;
  8755. private _cachedQuaternionRotationZ;
  8756. /** @hidden */
  8757. _getViewMatrix(): Matrix;
  8758. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8759. /**
  8760. * @hidden
  8761. */
  8762. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8763. /**
  8764. * @hidden
  8765. */
  8766. _updateRigCameras(): void;
  8767. private _getRigCamPositionAndTarget;
  8768. /**
  8769. * Gets the current object class name.
  8770. * @return the class name
  8771. */
  8772. getClassName(): string;
  8773. }
  8774. }
  8775. declare module "babylonjs/Events/keyboardEvents" {
  8776. /**
  8777. * Gather the list of keyboard event types as constants.
  8778. */
  8779. export class KeyboardEventTypes {
  8780. /**
  8781. * The keydown event is fired when a key becomes active (pressed).
  8782. */
  8783. static readonly KEYDOWN: number;
  8784. /**
  8785. * The keyup event is fired when a key has been released.
  8786. */
  8787. static readonly KEYUP: number;
  8788. }
  8789. /**
  8790. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8791. */
  8792. export class KeyboardInfo {
  8793. /**
  8794. * Defines the type of event (KeyboardEventTypes)
  8795. */
  8796. type: number;
  8797. /**
  8798. * Defines the related dom event
  8799. */
  8800. event: KeyboardEvent;
  8801. /**
  8802. * Instantiates a new keyboard info.
  8803. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8804. * @param type Defines the type of event (KeyboardEventTypes)
  8805. * @param event Defines the related dom event
  8806. */
  8807. constructor(
  8808. /**
  8809. * Defines the type of event (KeyboardEventTypes)
  8810. */
  8811. type: number,
  8812. /**
  8813. * Defines the related dom event
  8814. */
  8815. event: KeyboardEvent);
  8816. }
  8817. /**
  8818. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8819. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8820. */
  8821. export class KeyboardInfoPre extends KeyboardInfo {
  8822. /**
  8823. * Defines the type of event (KeyboardEventTypes)
  8824. */
  8825. type: number;
  8826. /**
  8827. * Defines the related dom event
  8828. */
  8829. event: KeyboardEvent;
  8830. /**
  8831. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8832. */
  8833. skipOnPointerObservable: boolean;
  8834. /**
  8835. * Instantiates a new keyboard pre info.
  8836. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8837. * @param type Defines the type of event (KeyboardEventTypes)
  8838. * @param event Defines the related dom event
  8839. */
  8840. constructor(
  8841. /**
  8842. * Defines the type of event (KeyboardEventTypes)
  8843. */
  8844. type: number,
  8845. /**
  8846. * Defines the related dom event
  8847. */
  8848. event: KeyboardEvent);
  8849. }
  8850. }
  8851. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8852. import { Nullable } from "babylonjs/types";
  8853. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8854. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8855. /**
  8856. * Manage the keyboard inputs to control the movement of a free camera.
  8857. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8858. */
  8859. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8860. /**
  8861. * Defines the camera the input is attached to.
  8862. */
  8863. camera: FreeCamera;
  8864. /**
  8865. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8866. */
  8867. keysUp: number[];
  8868. /**
  8869. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8870. */
  8871. keysDown: number[];
  8872. /**
  8873. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8874. */
  8875. keysLeft: number[];
  8876. /**
  8877. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8878. */
  8879. keysRight: number[];
  8880. private _keys;
  8881. private _onCanvasBlurObserver;
  8882. private _onKeyboardObserver;
  8883. private _engine;
  8884. private _scene;
  8885. /**
  8886. * Attach the input controls to a specific dom element to get the input from.
  8887. * @param element Defines the element the controls should be listened from
  8888. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8889. */
  8890. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8891. /**
  8892. * Detach the current controls from the specified dom element.
  8893. * @param element Defines the element to stop listening the inputs from
  8894. */
  8895. detachControl(element: Nullable<HTMLElement>): void;
  8896. /**
  8897. * Update the current camera state depending on the inputs that have been used this frame.
  8898. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8899. */
  8900. checkInputs(): void;
  8901. /**
  8902. * Gets the class name of the current intput.
  8903. * @returns the class name
  8904. */
  8905. getClassName(): string;
  8906. /** @hidden */
  8907. _onLostFocus(): void;
  8908. /**
  8909. * Get the friendly name associated with the input class.
  8910. * @returns the input friendly name
  8911. */
  8912. getSimpleName(): string;
  8913. }
  8914. }
  8915. declare module "babylonjs/Lights/shadowLight" {
  8916. import { Camera } from "babylonjs/Cameras/camera";
  8917. import { Scene } from "babylonjs/scene";
  8918. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8919. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8920. import { Light } from "babylonjs/Lights/light";
  8921. /**
  8922. * Interface describing all the common properties and methods a shadow light needs to implement.
  8923. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8924. * as well as binding the different shadow properties to the effects.
  8925. */
  8926. export interface IShadowLight extends Light {
  8927. /**
  8928. * The light id in the scene (used in scene.findLighById for instance)
  8929. */
  8930. id: string;
  8931. /**
  8932. * The position the shdow will be casted from.
  8933. */
  8934. position: Vector3;
  8935. /**
  8936. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8937. */
  8938. direction: Vector3;
  8939. /**
  8940. * The transformed position. Position of the light in world space taking parenting in account.
  8941. */
  8942. transformedPosition: Vector3;
  8943. /**
  8944. * The transformed direction. Direction of the light in world space taking parenting in account.
  8945. */
  8946. transformedDirection: Vector3;
  8947. /**
  8948. * The friendly name of the light in the scene.
  8949. */
  8950. name: string;
  8951. /**
  8952. * Defines the shadow projection clipping minimum z value.
  8953. */
  8954. shadowMinZ: number;
  8955. /**
  8956. * Defines the shadow projection clipping maximum z value.
  8957. */
  8958. shadowMaxZ: number;
  8959. /**
  8960. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8961. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8962. */
  8963. computeTransformedInformation(): boolean;
  8964. /**
  8965. * Gets the scene the light belongs to.
  8966. * @returns The scene
  8967. */
  8968. getScene(): Scene;
  8969. /**
  8970. * Callback defining a custom Projection Matrix Builder.
  8971. * This can be used to override the default projection matrix computation.
  8972. */
  8973. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8974. /**
  8975. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8976. * @param matrix The materix to updated with the projection information
  8977. * @param viewMatrix The transform matrix of the light
  8978. * @param renderList The list of mesh to render in the map
  8979. * @returns The current light
  8980. */
  8981. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8982. /**
  8983. * Gets the current depth scale used in ESM.
  8984. * @returns The scale
  8985. */
  8986. getDepthScale(): number;
  8987. /**
  8988. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8989. * @returns true if a cube texture needs to be use
  8990. */
  8991. needCube(): boolean;
  8992. /**
  8993. * Detects if the projection matrix requires to be recomputed this frame.
  8994. * @returns true if it requires to be recomputed otherwise, false.
  8995. */
  8996. needProjectionMatrixCompute(): boolean;
  8997. /**
  8998. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8999. */
  9000. forceProjectionMatrixCompute(): void;
  9001. /**
  9002. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9003. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9004. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9005. */
  9006. getShadowDirection(faceIndex?: number): Vector3;
  9007. /**
  9008. * Gets the minZ used for shadow according to both the scene and the light.
  9009. * @param activeCamera The camera we are returning the min for
  9010. * @returns the depth min z
  9011. */
  9012. getDepthMinZ(activeCamera: Camera): number;
  9013. /**
  9014. * Gets the maxZ used for shadow according to both the scene and the light.
  9015. * @param activeCamera The camera we are returning the max for
  9016. * @returns the depth max z
  9017. */
  9018. getDepthMaxZ(activeCamera: Camera): number;
  9019. }
  9020. /**
  9021. * Base implementation IShadowLight
  9022. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9023. */
  9024. export abstract class ShadowLight extends Light implements IShadowLight {
  9025. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9026. protected _position: Vector3;
  9027. protected _setPosition(value: Vector3): void;
  9028. /**
  9029. * Sets the position the shadow will be casted from. Also use as the light position for both
  9030. * point and spot lights.
  9031. */
  9032. get position(): Vector3;
  9033. /**
  9034. * Sets the position the shadow will be casted from. Also use as the light position for both
  9035. * point and spot lights.
  9036. */
  9037. set position(value: Vector3);
  9038. protected _direction: Vector3;
  9039. protected _setDirection(value: Vector3): void;
  9040. /**
  9041. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9042. * Also use as the light direction on spot and directional lights.
  9043. */
  9044. get direction(): Vector3;
  9045. /**
  9046. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9047. * Also use as the light direction on spot and directional lights.
  9048. */
  9049. set direction(value: Vector3);
  9050. protected _shadowMinZ: number;
  9051. /**
  9052. * Gets the shadow projection clipping minimum z value.
  9053. */
  9054. get shadowMinZ(): number;
  9055. /**
  9056. * Sets the shadow projection clipping minimum z value.
  9057. */
  9058. set shadowMinZ(value: number);
  9059. protected _shadowMaxZ: number;
  9060. /**
  9061. * Sets the shadow projection clipping maximum z value.
  9062. */
  9063. get shadowMaxZ(): number;
  9064. /**
  9065. * Gets the shadow projection clipping maximum z value.
  9066. */
  9067. set shadowMaxZ(value: number);
  9068. /**
  9069. * Callback defining a custom Projection Matrix Builder.
  9070. * This can be used to override the default projection matrix computation.
  9071. */
  9072. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9073. /**
  9074. * The transformed position. Position of the light in world space taking parenting in account.
  9075. */
  9076. transformedPosition: Vector3;
  9077. /**
  9078. * The transformed direction. Direction of the light in world space taking parenting in account.
  9079. */
  9080. transformedDirection: Vector3;
  9081. private _needProjectionMatrixCompute;
  9082. /**
  9083. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9084. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9085. */
  9086. computeTransformedInformation(): boolean;
  9087. /**
  9088. * Return the depth scale used for the shadow map.
  9089. * @returns the depth scale.
  9090. */
  9091. getDepthScale(): number;
  9092. /**
  9093. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9094. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9095. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9096. */
  9097. getShadowDirection(faceIndex?: number): Vector3;
  9098. /**
  9099. * Returns the ShadowLight absolute position in the World.
  9100. * @returns the position vector in world space
  9101. */
  9102. getAbsolutePosition(): Vector3;
  9103. /**
  9104. * Sets the ShadowLight direction toward the passed target.
  9105. * @param target The point to target in local space
  9106. * @returns the updated ShadowLight direction
  9107. */
  9108. setDirectionToTarget(target: Vector3): Vector3;
  9109. /**
  9110. * Returns the light rotation in euler definition.
  9111. * @returns the x y z rotation in local space.
  9112. */
  9113. getRotation(): Vector3;
  9114. /**
  9115. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9116. * @returns true if a cube texture needs to be use
  9117. */
  9118. needCube(): boolean;
  9119. /**
  9120. * Detects if the projection matrix requires to be recomputed this frame.
  9121. * @returns true if it requires to be recomputed otherwise, false.
  9122. */
  9123. needProjectionMatrixCompute(): boolean;
  9124. /**
  9125. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9126. */
  9127. forceProjectionMatrixCompute(): void;
  9128. /** @hidden */
  9129. _initCache(): void;
  9130. /** @hidden */
  9131. _isSynchronized(): boolean;
  9132. /**
  9133. * Computes the world matrix of the node
  9134. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9135. * @returns the world matrix
  9136. */
  9137. computeWorldMatrix(force?: boolean): Matrix;
  9138. /**
  9139. * Gets the minZ used for shadow according to both the scene and the light.
  9140. * @param activeCamera The camera we are returning the min for
  9141. * @returns the depth min z
  9142. */
  9143. getDepthMinZ(activeCamera: Camera): number;
  9144. /**
  9145. * Gets the maxZ used for shadow according to both the scene and the light.
  9146. * @param activeCamera The camera we are returning the max for
  9147. * @returns the depth max z
  9148. */
  9149. getDepthMaxZ(activeCamera: Camera): number;
  9150. /**
  9151. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9152. * @param matrix The materix to updated with the projection information
  9153. * @param viewMatrix The transform matrix of the light
  9154. * @param renderList The list of mesh to render in the map
  9155. * @returns The current light
  9156. */
  9157. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9158. }
  9159. }
  9160. declare module "babylonjs/Materials/effectFallbacks" {
  9161. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9162. import { Effect } from "babylonjs/Materials/effect";
  9163. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9164. /**
  9165. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9166. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9167. */
  9168. export class EffectFallbacks implements IEffectFallbacks {
  9169. private _defines;
  9170. private _currentRank;
  9171. private _maxRank;
  9172. private _mesh;
  9173. /**
  9174. * Removes the fallback from the bound mesh.
  9175. */
  9176. unBindMesh(): void;
  9177. /**
  9178. * Adds a fallback on the specified property.
  9179. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9180. * @param define The name of the define in the shader
  9181. */
  9182. addFallback(rank: number, define: string): void;
  9183. /**
  9184. * Sets the mesh to use CPU skinning when needing to fallback.
  9185. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9186. * @param mesh The mesh to use the fallbacks.
  9187. */
  9188. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9189. /**
  9190. * Checks to see if more fallbacks are still availible.
  9191. */
  9192. get hasMoreFallbacks(): boolean;
  9193. /**
  9194. * Removes the defines that should be removed when falling back.
  9195. * @param currentDefines defines the current define statements for the shader.
  9196. * @param effect defines the current effect we try to compile
  9197. * @returns The resulting defines with defines of the current rank removed.
  9198. */
  9199. reduce(currentDefines: string, effect: Effect): string;
  9200. }
  9201. }
  9202. declare module "babylonjs/Materials/materialHelper" {
  9203. import { Nullable } from "babylonjs/types";
  9204. import { Scene } from "babylonjs/scene";
  9205. import { Engine } from "babylonjs/Engines/engine";
  9206. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9207. import { Light } from "babylonjs/Lights/light";
  9208. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9209. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9210. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9211. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9212. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9213. /**
  9214. * "Static Class" containing the most commonly used helper while dealing with material for
  9215. * rendering purpose.
  9216. *
  9217. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9218. *
  9219. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9220. */
  9221. export class MaterialHelper {
  9222. /**
  9223. * Bind the current view position to an effect.
  9224. * @param effect The effect to be bound
  9225. * @param scene The scene the eyes position is used from
  9226. */
  9227. static BindEyePosition(effect: Effect, scene: Scene): void;
  9228. /**
  9229. * Helps preparing the defines values about the UVs in used in the effect.
  9230. * UVs are shared as much as we can accross channels in the shaders.
  9231. * @param texture The texture we are preparing the UVs for
  9232. * @param defines The defines to update
  9233. * @param key The channel key "diffuse", "specular"... used in the shader
  9234. */
  9235. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9236. /**
  9237. * Binds a texture matrix value to its corrsponding uniform
  9238. * @param texture The texture to bind the matrix for
  9239. * @param uniformBuffer The uniform buffer receivin the data
  9240. * @param key The channel key "diffuse", "specular"... used in the shader
  9241. */
  9242. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9243. /**
  9244. * Gets the current status of the fog (should it be enabled?)
  9245. * @param mesh defines the mesh to evaluate for fog support
  9246. * @param scene defines the hosting scene
  9247. * @returns true if fog must be enabled
  9248. */
  9249. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9250. /**
  9251. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9252. * @param mesh defines the current mesh
  9253. * @param scene defines the current scene
  9254. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9255. * @param pointsCloud defines if point cloud rendering has to be turned on
  9256. * @param fogEnabled defines if fog has to be turned on
  9257. * @param alphaTest defines if alpha testing has to be turned on
  9258. * @param defines defines the current list of defines
  9259. */
  9260. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9261. /**
  9262. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9263. * @param scene defines the current scene
  9264. * @param engine defines the current engine
  9265. * @param defines specifies the list of active defines
  9266. * @param useInstances defines if instances have to be turned on
  9267. * @param useClipPlane defines if clip plane have to be turned on
  9268. */
  9269. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9270. /**
  9271. * Prepares the defines for bones
  9272. * @param mesh The mesh containing the geometry data we will draw
  9273. * @param defines The defines to update
  9274. */
  9275. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9276. /**
  9277. * Prepares the defines for morph targets
  9278. * @param mesh The mesh containing the geometry data we will draw
  9279. * @param defines The defines to update
  9280. */
  9281. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9282. /**
  9283. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9284. * @param mesh The mesh containing the geometry data we will draw
  9285. * @param defines The defines to update
  9286. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9287. * @param useBones Precise whether bones should be used or not (override mesh info)
  9288. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9289. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9290. * @returns false if defines are considered not dirty and have not been checked
  9291. */
  9292. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9293. /**
  9294. * Prepares the defines related to multiview
  9295. * @param scene The scene we are intending to draw
  9296. * @param defines The defines to update
  9297. */
  9298. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9299. /**
  9300. * Prepares the defines related to the light information passed in parameter
  9301. * @param scene The scene we are intending to draw
  9302. * @param mesh The mesh the effect is compiling for
  9303. * @param light The light the effect is compiling for
  9304. * @param lightIndex The index of the light
  9305. * @param defines The defines to update
  9306. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9307. * @param state Defines the current state regarding what is needed (normals, etc...)
  9308. */
  9309. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9310. needNormals: boolean;
  9311. needRebuild: boolean;
  9312. shadowEnabled: boolean;
  9313. specularEnabled: boolean;
  9314. lightmapMode: boolean;
  9315. }): void;
  9316. /**
  9317. * Prepares the defines related to the light information passed in parameter
  9318. * @param scene The scene we are intending to draw
  9319. * @param mesh The mesh the effect is compiling for
  9320. * @param defines The defines to update
  9321. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9322. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9323. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9324. * @returns true if normals will be required for the rest of the effect
  9325. */
  9326. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9327. /**
  9328. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9329. * @param lightIndex defines the light index
  9330. * @param uniformsList The uniform list
  9331. * @param samplersList The sampler list
  9332. * @param projectedLightTexture defines if projected texture must be used
  9333. * @param uniformBuffersList defines an optional list of uniform buffers
  9334. */
  9335. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9336. /**
  9337. * Prepares the uniforms and samplers list to be used in the effect
  9338. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9339. * @param samplersList The sampler list
  9340. * @param defines The defines helping in the list generation
  9341. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9342. */
  9343. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9344. /**
  9345. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9346. * @param defines The defines to update while falling back
  9347. * @param fallbacks The authorized effect fallbacks
  9348. * @param maxSimultaneousLights The maximum number of lights allowed
  9349. * @param rank the current rank of the Effect
  9350. * @returns The newly affected rank
  9351. */
  9352. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9353. private static _TmpMorphInfluencers;
  9354. /**
  9355. * Prepares the list of attributes required for morph targets according to the effect defines.
  9356. * @param attribs The current list of supported attribs
  9357. * @param mesh The mesh to prepare the morph targets attributes for
  9358. * @param influencers The number of influencers
  9359. */
  9360. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9361. /**
  9362. * Prepares the list of attributes required for morph targets according to the effect defines.
  9363. * @param attribs The current list of supported attribs
  9364. * @param mesh The mesh to prepare the morph targets attributes for
  9365. * @param defines The current Defines of the effect
  9366. */
  9367. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9368. /**
  9369. * Prepares the list of attributes required for bones according to the effect defines.
  9370. * @param attribs The current list of supported attribs
  9371. * @param mesh The mesh to prepare the bones attributes for
  9372. * @param defines The current Defines of the effect
  9373. * @param fallbacks The current efffect fallback strategy
  9374. */
  9375. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9376. /**
  9377. * Check and prepare the list of attributes required for instances according to the effect defines.
  9378. * @param attribs The current list of supported attribs
  9379. * @param defines The current MaterialDefines of the effect
  9380. */
  9381. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9382. /**
  9383. * Add the list of attributes required for instances to the attribs array.
  9384. * @param attribs The current list of supported attribs
  9385. */
  9386. static PushAttributesForInstances(attribs: string[]): void;
  9387. /**
  9388. * Binds the light information to the effect.
  9389. * @param light The light containing the generator
  9390. * @param effect The effect we are binding the data to
  9391. * @param lightIndex The light index in the effect used to render
  9392. */
  9393. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9394. /**
  9395. * Binds the lights information from the scene to the effect for the given mesh.
  9396. * @param light Light to bind
  9397. * @param lightIndex Light index
  9398. * @param scene The scene where the light belongs to
  9399. * @param effect The effect we are binding the data to
  9400. * @param useSpecular Defines if specular is supported
  9401. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9402. */
  9403. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9404. /**
  9405. * Binds the lights information from the scene to the effect for the given mesh.
  9406. * @param scene The scene the lights belongs to
  9407. * @param mesh The mesh we are binding the information to render
  9408. * @param effect The effect we are binding the data to
  9409. * @param defines The generated defines for the effect
  9410. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9411. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9412. */
  9413. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9414. private static _tempFogColor;
  9415. /**
  9416. * Binds the fog information from the scene to the effect for the given mesh.
  9417. * @param scene The scene the lights belongs to
  9418. * @param mesh The mesh we are binding the information to render
  9419. * @param effect The effect we are binding the data to
  9420. * @param linearSpace Defines if the fog effect is applied in linear space
  9421. */
  9422. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9423. /**
  9424. * Binds the bones information from the mesh to the effect.
  9425. * @param mesh The mesh we are binding the information to render
  9426. * @param effect The effect we are binding the data to
  9427. */
  9428. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9429. /**
  9430. * Binds the morph targets information from the mesh to the effect.
  9431. * @param abstractMesh The mesh we are binding the information to render
  9432. * @param effect The effect we are binding the data to
  9433. */
  9434. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9435. /**
  9436. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9437. * @param defines The generated defines used in the effect
  9438. * @param effect The effect we are binding the data to
  9439. * @param scene The scene we are willing to render with logarithmic scale for
  9440. */
  9441. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9442. /**
  9443. * Binds the clip plane information from the scene to the effect.
  9444. * @param scene The scene the clip plane information are extracted from
  9445. * @param effect The effect we are binding the data to
  9446. */
  9447. static BindClipPlane(effect: Effect, scene: Scene): void;
  9448. }
  9449. }
  9450. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9451. /** @hidden */
  9452. export var packingFunctions: {
  9453. name: string;
  9454. shader: string;
  9455. };
  9456. }
  9457. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9458. /** @hidden */
  9459. export var clipPlaneFragmentDeclaration: {
  9460. name: string;
  9461. shader: string;
  9462. };
  9463. }
  9464. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9465. /** @hidden */
  9466. export var clipPlaneFragment: {
  9467. name: string;
  9468. shader: string;
  9469. };
  9470. }
  9471. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9472. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9473. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9474. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9475. /** @hidden */
  9476. export var shadowMapPixelShader: {
  9477. name: string;
  9478. shader: string;
  9479. };
  9480. }
  9481. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9482. /** @hidden */
  9483. export var bonesDeclaration: {
  9484. name: string;
  9485. shader: string;
  9486. };
  9487. }
  9488. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9489. /** @hidden */
  9490. export var morphTargetsVertexGlobalDeclaration: {
  9491. name: string;
  9492. shader: string;
  9493. };
  9494. }
  9495. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9496. /** @hidden */
  9497. export var morphTargetsVertexDeclaration: {
  9498. name: string;
  9499. shader: string;
  9500. };
  9501. }
  9502. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9503. /** @hidden */
  9504. export var instancesDeclaration: {
  9505. name: string;
  9506. shader: string;
  9507. };
  9508. }
  9509. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9510. /** @hidden */
  9511. export var helperFunctions: {
  9512. name: string;
  9513. shader: string;
  9514. };
  9515. }
  9516. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9517. /** @hidden */
  9518. export var clipPlaneVertexDeclaration: {
  9519. name: string;
  9520. shader: string;
  9521. };
  9522. }
  9523. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9524. /** @hidden */
  9525. export var morphTargetsVertex: {
  9526. name: string;
  9527. shader: string;
  9528. };
  9529. }
  9530. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9531. /** @hidden */
  9532. export var instancesVertex: {
  9533. name: string;
  9534. shader: string;
  9535. };
  9536. }
  9537. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9538. /** @hidden */
  9539. export var bonesVertex: {
  9540. name: string;
  9541. shader: string;
  9542. };
  9543. }
  9544. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9545. /** @hidden */
  9546. export var clipPlaneVertex: {
  9547. name: string;
  9548. shader: string;
  9549. };
  9550. }
  9551. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9552. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9553. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9554. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9555. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9556. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9557. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9558. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9559. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9560. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9561. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9562. /** @hidden */
  9563. export var shadowMapVertexShader: {
  9564. name: string;
  9565. shader: string;
  9566. };
  9567. }
  9568. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9569. /** @hidden */
  9570. export var depthBoxBlurPixelShader: {
  9571. name: string;
  9572. shader: string;
  9573. };
  9574. }
  9575. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9576. import { SmartArray } from "babylonjs/Misc/smartArray";
  9577. import { Nullable } from "babylonjs/types";
  9578. import { Scene } from "babylonjs/scene";
  9579. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9580. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9581. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9582. import { Mesh } from "babylonjs/Meshes/mesh";
  9583. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9584. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9585. import { Effect } from "babylonjs/Materials/effect";
  9586. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9587. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  9588. import "babylonjs/Shaders/shadowMap.fragment";
  9589. import "babylonjs/Shaders/shadowMap.vertex";
  9590. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9591. import { Observable } from "babylonjs/Misc/observable";
  9592. /**
  9593. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9594. */
  9595. export interface ICustomShaderOptions {
  9596. /**
  9597. * Gets or sets the custom shader name to use
  9598. */
  9599. shaderName: string;
  9600. /**
  9601. * The list of attribute names used in the shader
  9602. */
  9603. attributes?: string[];
  9604. /**
  9605. * The list of unifrom names used in the shader
  9606. */
  9607. uniforms?: string[];
  9608. /**
  9609. * The list of sampler names used in the shader
  9610. */
  9611. samplers?: string[];
  9612. /**
  9613. * The list of defines used in the shader
  9614. */
  9615. defines?: string[];
  9616. }
  9617. /**
  9618. * Interface to implement to create a shadow generator compatible with BJS.
  9619. */
  9620. export interface IShadowGenerator {
  9621. /**
  9622. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9623. * @returns The render target texture if present otherwise, null
  9624. */
  9625. getShadowMap(): Nullable<RenderTargetTexture>;
  9626. /**
  9627. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9628. * @param subMesh The submesh we want to render in the shadow map
  9629. * @param useInstances Defines wether will draw in the map using instances
  9630. * @returns true if ready otherwise, false
  9631. */
  9632. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9633. /**
  9634. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9635. * @param defines Defines of the material we want to update
  9636. * @param lightIndex Index of the light in the enabled light list of the material
  9637. */
  9638. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9639. /**
  9640. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9641. * defined in the generator but impacting the effect).
  9642. * It implies the unifroms available on the materials are the standard BJS ones.
  9643. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9644. * @param effect The effect we are binfing the information for
  9645. */
  9646. bindShadowLight(lightIndex: string, effect: Effect): void;
  9647. /**
  9648. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9649. * (eq to shadow prjection matrix * light transform matrix)
  9650. * @returns The transform matrix used to create the shadow map
  9651. */
  9652. getTransformMatrix(): Matrix;
  9653. /**
  9654. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9655. * Cube and 2D textures for instance.
  9656. */
  9657. recreateShadowMap(): void;
  9658. /**
  9659. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9660. * @param onCompiled Callback triggered at the and of the effects compilation
  9661. * @param options Sets of optional options forcing the compilation with different modes
  9662. */
  9663. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  9664. useInstances: boolean;
  9665. }>): void;
  9666. /**
  9667. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9668. * @param options Sets of optional options forcing the compilation with different modes
  9669. * @returns A promise that resolves when the compilation completes
  9670. */
  9671. forceCompilationAsync(options?: Partial<{
  9672. useInstances: boolean;
  9673. }>): Promise<void>;
  9674. /**
  9675. * Serializes the shadow generator setup to a json object.
  9676. * @returns The serialized JSON object
  9677. */
  9678. serialize(): any;
  9679. /**
  9680. * Disposes the Shadow map and related Textures and effects.
  9681. */
  9682. dispose(): void;
  9683. }
  9684. /**
  9685. * Default implementation IShadowGenerator.
  9686. * This is the main object responsible of generating shadows in the framework.
  9687. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9688. */
  9689. export class ShadowGenerator implements IShadowGenerator {
  9690. /**
  9691. * Name of the shadow generator class
  9692. */
  9693. static CLASSNAME: string;
  9694. /**
  9695. * Shadow generator mode None: no filtering applied.
  9696. */
  9697. static readonly FILTER_NONE: number;
  9698. /**
  9699. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9700. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9701. */
  9702. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9703. /**
  9704. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9705. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9706. */
  9707. static readonly FILTER_POISSONSAMPLING: number;
  9708. /**
  9709. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9710. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9711. */
  9712. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9713. /**
  9714. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9715. * edge artifacts on steep falloff.
  9716. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9717. */
  9718. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9719. /**
  9720. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9721. * edge artifacts on steep falloff.
  9722. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9723. */
  9724. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9725. /**
  9726. * Shadow generator mode PCF: Percentage Closer Filtering
  9727. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9728. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9729. */
  9730. static readonly FILTER_PCF: number;
  9731. /**
  9732. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9733. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9734. * Contact Hardening
  9735. */
  9736. static readonly FILTER_PCSS: number;
  9737. /**
  9738. * Reserved for PCF and PCSS
  9739. * Highest Quality.
  9740. *
  9741. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9742. *
  9743. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9744. */
  9745. static readonly QUALITY_HIGH: number;
  9746. /**
  9747. * Reserved for PCF and PCSS
  9748. * Good tradeoff for quality/perf cross devices
  9749. *
  9750. * Execute PCF on a 3*3 kernel.
  9751. *
  9752. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9753. */
  9754. static readonly QUALITY_MEDIUM: number;
  9755. /**
  9756. * Reserved for PCF and PCSS
  9757. * The lowest quality but the fastest.
  9758. *
  9759. * Execute PCF on a 1*1 kernel.
  9760. *
  9761. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9762. */
  9763. static readonly QUALITY_LOW: number;
  9764. /** Gets or sets the custom shader name to use */
  9765. customShaderOptions: ICustomShaderOptions;
  9766. /**
  9767. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9768. */
  9769. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9770. /**
  9771. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9772. */
  9773. onAfterShadowMapRenderObservable: Observable<Effect>;
  9774. /**
  9775. * Observable triggered before a mesh is rendered in the shadow map.
  9776. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9777. */
  9778. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9779. /**
  9780. * Observable triggered after a mesh is rendered in the shadow map.
  9781. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9782. */
  9783. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9784. protected _bias: number;
  9785. /**
  9786. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9787. */
  9788. get bias(): number;
  9789. /**
  9790. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9791. */
  9792. set bias(bias: number);
  9793. protected _normalBias: number;
  9794. /**
  9795. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9796. */
  9797. get normalBias(): number;
  9798. /**
  9799. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9800. */
  9801. set normalBias(normalBias: number);
  9802. protected _blurBoxOffset: number;
  9803. /**
  9804. * Gets the blur box offset: offset applied during the blur pass.
  9805. * Only useful if useKernelBlur = false
  9806. */
  9807. get blurBoxOffset(): number;
  9808. /**
  9809. * Sets the blur box offset: offset applied during the blur pass.
  9810. * Only useful if useKernelBlur = false
  9811. */
  9812. set blurBoxOffset(value: number);
  9813. protected _blurScale: number;
  9814. /**
  9815. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9816. * 2 means half of the size.
  9817. */
  9818. get blurScale(): number;
  9819. /**
  9820. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9821. * 2 means half of the size.
  9822. */
  9823. set blurScale(value: number);
  9824. protected _blurKernel: number;
  9825. /**
  9826. * Gets the blur kernel: kernel size of the blur pass.
  9827. * Only useful if useKernelBlur = true
  9828. */
  9829. get blurKernel(): number;
  9830. /**
  9831. * Sets the blur kernel: kernel size of the blur pass.
  9832. * Only useful if useKernelBlur = true
  9833. */
  9834. set blurKernel(value: number);
  9835. protected _useKernelBlur: boolean;
  9836. /**
  9837. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9838. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9839. */
  9840. get useKernelBlur(): boolean;
  9841. /**
  9842. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9843. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9844. */
  9845. set useKernelBlur(value: boolean);
  9846. protected _depthScale: number;
  9847. /**
  9848. * Gets the depth scale used in ESM mode.
  9849. */
  9850. get depthScale(): number;
  9851. /**
  9852. * Sets the depth scale used in ESM mode.
  9853. * This can override the scale stored on the light.
  9854. */
  9855. set depthScale(value: number);
  9856. protected _validateFilter(filter: number): number;
  9857. protected _filter: number;
  9858. /**
  9859. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9860. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9861. */
  9862. get filter(): number;
  9863. /**
  9864. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9865. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9866. */
  9867. set filter(value: number);
  9868. /**
  9869. * Gets if the current filter is set to Poisson Sampling.
  9870. */
  9871. get usePoissonSampling(): boolean;
  9872. /**
  9873. * Sets the current filter to Poisson Sampling.
  9874. */
  9875. set usePoissonSampling(value: boolean);
  9876. /**
  9877. * Gets if the current filter is set to ESM.
  9878. */
  9879. get useExponentialShadowMap(): boolean;
  9880. /**
  9881. * Sets the current filter is to ESM.
  9882. */
  9883. set useExponentialShadowMap(value: boolean);
  9884. /**
  9885. * Gets if the current filter is set to filtered ESM.
  9886. */
  9887. get useBlurExponentialShadowMap(): boolean;
  9888. /**
  9889. * Gets if the current filter is set to filtered ESM.
  9890. */
  9891. set useBlurExponentialShadowMap(value: boolean);
  9892. /**
  9893. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9894. * exponential to prevent steep falloff artifacts).
  9895. */
  9896. get useCloseExponentialShadowMap(): boolean;
  9897. /**
  9898. * Sets the current filter to "close ESM" (using the inverse of the
  9899. * exponential to prevent steep falloff artifacts).
  9900. */
  9901. set useCloseExponentialShadowMap(value: boolean);
  9902. /**
  9903. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9904. * exponential to prevent steep falloff artifacts).
  9905. */
  9906. get useBlurCloseExponentialShadowMap(): boolean;
  9907. /**
  9908. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9909. * exponential to prevent steep falloff artifacts).
  9910. */
  9911. set useBlurCloseExponentialShadowMap(value: boolean);
  9912. /**
  9913. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9914. */
  9915. get usePercentageCloserFiltering(): boolean;
  9916. /**
  9917. * Sets the current filter to "PCF" (percentage closer filtering).
  9918. */
  9919. set usePercentageCloserFiltering(value: boolean);
  9920. protected _filteringQuality: number;
  9921. /**
  9922. * Gets the PCF or PCSS Quality.
  9923. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9924. */
  9925. get filteringQuality(): number;
  9926. /**
  9927. * Sets the PCF or PCSS Quality.
  9928. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9929. */
  9930. set filteringQuality(filteringQuality: number);
  9931. /**
  9932. * Gets if the current filter is set to "PCSS" (contact hardening).
  9933. */
  9934. get useContactHardeningShadow(): boolean;
  9935. /**
  9936. * Sets the current filter to "PCSS" (contact hardening).
  9937. */
  9938. set useContactHardeningShadow(value: boolean);
  9939. protected _contactHardeningLightSizeUVRatio: number;
  9940. /**
  9941. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9942. * Using a ratio helps keeping shape stability independently of the map size.
  9943. *
  9944. * It does not account for the light projection as it was having too much
  9945. * instability during the light setup or during light position changes.
  9946. *
  9947. * Only valid if useContactHardeningShadow is true.
  9948. */
  9949. get contactHardeningLightSizeUVRatio(): number;
  9950. /**
  9951. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9952. * Using a ratio helps keeping shape stability independently of the map size.
  9953. *
  9954. * It does not account for the light projection as it was having too much
  9955. * instability during the light setup or during light position changes.
  9956. *
  9957. * Only valid if useContactHardeningShadow is true.
  9958. */
  9959. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  9960. protected _darkness: number;
  9961. /** Gets or sets the actual darkness of a shadow */
  9962. get darkness(): number;
  9963. set darkness(value: number);
  9964. /**
  9965. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9966. * 0 means strongest and 1 would means no shadow.
  9967. * @returns the darkness.
  9968. */
  9969. getDarkness(): number;
  9970. /**
  9971. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9972. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9973. * @returns the shadow generator allowing fluent coding.
  9974. */
  9975. setDarkness(darkness: number): ShadowGenerator;
  9976. protected _transparencyShadow: boolean;
  9977. /** Gets or sets the ability to have transparent shadow */
  9978. get transparencyShadow(): boolean;
  9979. set transparencyShadow(value: boolean);
  9980. /**
  9981. * Sets the ability to have transparent shadow (boolean).
  9982. * @param transparent True if transparent else False
  9983. * @returns the shadow generator allowing fluent coding
  9984. */
  9985. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9986. protected _shadowMap: Nullable<RenderTargetTexture>;
  9987. protected _shadowMap2: Nullable<RenderTargetTexture>;
  9988. /**
  9989. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9990. * @returns The render target texture if present otherwise, null
  9991. */
  9992. getShadowMap(): Nullable<RenderTargetTexture>;
  9993. /**
  9994. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9995. * @returns The render target texture if the shadow map is present otherwise, null
  9996. */
  9997. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9998. /**
  9999. * Gets the class name of that object
  10000. * @returns "ShadowGenerator"
  10001. */
  10002. getClassName(): string;
  10003. /**
  10004. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10005. * @param mesh Mesh to add
  10006. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10007. * @returns the Shadow Generator itself
  10008. */
  10009. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10010. /**
  10011. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10012. * @param mesh Mesh to remove
  10013. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10014. * @returns the Shadow Generator itself
  10015. */
  10016. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10017. /**
  10018. * Controls the extent to which the shadows fade out at the edge of the frustum
  10019. */
  10020. frustumEdgeFalloff: number;
  10021. protected _light: IShadowLight;
  10022. /**
  10023. * Returns the associated light object.
  10024. * @returns the light generating the shadow
  10025. */
  10026. getLight(): IShadowLight;
  10027. /**
  10028. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10029. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10030. * It might on the other hand introduce peter panning.
  10031. */
  10032. forceBackFacesOnly: boolean;
  10033. protected _scene: Scene;
  10034. protected _lightDirection: Vector3;
  10035. protected _effect: Effect;
  10036. protected _viewMatrix: Matrix;
  10037. protected _projectionMatrix: Matrix;
  10038. protected _transformMatrix: Matrix;
  10039. protected _cachedPosition: Vector3;
  10040. protected _cachedDirection: Vector3;
  10041. protected _cachedDefines: string;
  10042. protected _currentRenderID: number;
  10043. protected _boxBlurPostprocess: Nullable<PostProcess>;
  10044. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  10045. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  10046. protected _blurPostProcesses: PostProcess[];
  10047. protected _mapSize: number;
  10048. protected _currentFaceIndex: number;
  10049. protected _currentFaceIndexCache: number;
  10050. protected _textureType: number;
  10051. protected _defaultTextureMatrix: Matrix;
  10052. protected _storedUniqueId: Nullable<number>;
  10053. /** @hidden */
  10054. static _SceneComponentInitialization: (scene: Scene) => void;
  10055. /**
  10056. * Creates a ShadowGenerator object.
  10057. * A ShadowGenerator is the required tool to use the shadows.
  10058. * Each light casting shadows needs to use its own ShadowGenerator.
  10059. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10060. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10061. * @param light The light object generating the shadows.
  10062. * @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.
  10063. */
  10064. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10065. protected _initializeGenerator(): void;
  10066. protected _createTargetRenderTexture(): void;
  10067. protected _initializeShadowMap(): void;
  10068. protected _initializeBlurRTTAndPostProcesses(): void;
  10069. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  10070. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  10071. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  10072. protected _applyFilterValues(): void;
  10073. /**
  10074. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10075. * @param onCompiled Callback triggered at the and of the effects compilation
  10076. * @param options Sets of optional options forcing the compilation with different modes
  10077. */
  10078. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  10079. useInstances: boolean;
  10080. }>): void;
  10081. /**
  10082. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10083. * @param options Sets of optional options forcing the compilation with different modes
  10084. * @returns A promise that resolves when the compilation completes
  10085. */
  10086. forceCompilationAsync(options?: Partial<{
  10087. useInstances: boolean;
  10088. }>): Promise<void>;
  10089. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  10090. /**
  10091. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10092. * @param subMesh The submesh we want to render in the shadow map
  10093. * @param useInstances Defines wether will draw in the map using instances
  10094. * @returns true if ready otherwise, false
  10095. */
  10096. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10097. /**
  10098. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10099. * @param defines Defines of the material we want to update
  10100. * @param lightIndex Index of the light in the enabled light list of the material
  10101. */
  10102. prepareDefines(defines: any, lightIndex: number): void;
  10103. /**
  10104. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10105. * defined in the generator but impacting the effect).
  10106. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10107. * @param effect The effect we are binfing the information for
  10108. */
  10109. bindShadowLight(lightIndex: string, effect: Effect): void;
  10110. /**
  10111. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10112. * (eq to shadow prjection matrix * light transform matrix)
  10113. * @returns The transform matrix used to create the shadow map
  10114. */
  10115. getTransformMatrix(): Matrix;
  10116. /**
  10117. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10118. * Cube and 2D textures for instance.
  10119. */
  10120. recreateShadowMap(): void;
  10121. protected _disposeBlurPostProcesses(): void;
  10122. protected _disposeRTTandPostProcesses(): void;
  10123. /**
  10124. * Disposes the ShadowGenerator.
  10125. * Returns nothing.
  10126. */
  10127. dispose(): void;
  10128. /**
  10129. * Serializes the shadow generator setup to a json object.
  10130. * @returns The serialized JSON object
  10131. */
  10132. serialize(): any;
  10133. /**
  10134. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10135. * @param parsedShadowGenerator The JSON object to parse
  10136. * @param scene The scene to create the shadow map for
  10137. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  10138. * @returns The parsed shadow generator
  10139. */
  10140. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  10141. }
  10142. }
  10143. declare module "babylonjs/Lights/light" {
  10144. import { Nullable } from "babylonjs/types";
  10145. import { Scene } from "babylonjs/scene";
  10146. import { Vector3 } from "babylonjs/Maths/math.vector";
  10147. import { Color3 } from "babylonjs/Maths/math.color";
  10148. import { Node } from "babylonjs/node";
  10149. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10150. import { Effect } from "babylonjs/Materials/effect";
  10151. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10152. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10153. /**
  10154. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10155. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10156. * 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.
  10157. */
  10158. export abstract class Light extends Node {
  10159. /**
  10160. * Falloff Default: light is falling off following the material specification:
  10161. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10162. */
  10163. static readonly FALLOFF_DEFAULT: number;
  10164. /**
  10165. * Falloff Physical: light is falling off following the inverse squared distance law.
  10166. */
  10167. static readonly FALLOFF_PHYSICAL: number;
  10168. /**
  10169. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10170. * to enhance interoperability with other engines.
  10171. */
  10172. static readonly FALLOFF_GLTF: number;
  10173. /**
  10174. * Falloff Standard: light is falling off like in the standard material
  10175. * to enhance interoperability with other materials.
  10176. */
  10177. static readonly FALLOFF_STANDARD: number;
  10178. /**
  10179. * If every light affecting the material is in this lightmapMode,
  10180. * material.lightmapTexture adds or multiplies
  10181. * (depends on material.useLightmapAsShadowmap)
  10182. * after every other light calculations.
  10183. */
  10184. static readonly LIGHTMAP_DEFAULT: number;
  10185. /**
  10186. * material.lightmapTexture as only diffuse lighting from this light
  10187. * adds only specular lighting from this light
  10188. * adds dynamic shadows
  10189. */
  10190. static readonly LIGHTMAP_SPECULAR: number;
  10191. /**
  10192. * material.lightmapTexture as only lighting
  10193. * no light calculation from this light
  10194. * only adds dynamic shadows from this light
  10195. */
  10196. static readonly LIGHTMAP_SHADOWSONLY: number;
  10197. /**
  10198. * Each light type uses the default quantity according to its type:
  10199. * point/spot lights use luminous intensity
  10200. * directional lights use illuminance
  10201. */
  10202. static readonly INTENSITYMODE_AUTOMATIC: number;
  10203. /**
  10204. * lumen (lm)
  10205. */
  10206. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10207. /**
  10208. * candela (lm/sr)
  10209. */
  10210. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10211. /**
  10212. * lux (lm/m^2)
  10213. */
  10214. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10215. /**
  10216. * nit (cd/m^2)
  10217. */
  10218. static readonly INTENSITYMODE_LUMINANCE: number;
  10219. /**
  10220. * Light type const id of the point light.
  10221. */
  10222. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10223. /**
  10224. * Light type const id of the directional light.
  10225. */
  10226. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10227. /**
  10228. * Light type const id of the spot light.
  10229. */
  10230. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10231. /**
  10232. * Light type const id of the hemispheric light.
  10233. */
  10234. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10235. /**
  10236. * Diffuse gives the basic color to an object.
  10237. */
  10238. diffuse: Color3;
  10239. /**
  10240. * Specular produces a highlight color on an object.
  10241. * Note: This is note affecting PBR materials.
  10242. */
  10243. specular: Color3;
  10244. /**
  10245. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10246. * falling off base on range or angle.
  10247. * This can be set to any values in Light.FALLOFF_x.
  10248. *
  10249. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10250. * other types of materials.
  10251. */
  10252. falloffType: number;
  10253. /**
  10254. * Strength of the light.
  10255. * Note: By default it is define in the framework own unit.
  10256. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10257. */
  10258. intensity: number;
  10259. private _range;
  10260. protected _inverseSquaredRange: number;
  10261. /**
  10262. * Defines how far from the source the light is impacting in scene units.
  10263. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10264. */
  10265. get range(): number;
  10266. /**
  10267. * Defines how far from the source the light is impacting in scene units.
  10268. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10269. */
  10270. set range(value: number);
  10271. /**
  10272. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10273. * of light.
  10274. */
  10275. private _photometricScale;
  10276. private _intensityMode;
  10277. /**
  10278. * Gets the photometric scale used to interpret the intensity.
  10279. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10280. */
  10281. get intensityMode(): number;
  10282. /**
  10283. * Sets the photometric scale used to interpret the intensity.
  10284. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10285. */
  10286. set intensityMode(value: number);
  10287. private _radius;
  10288. /**
  10289. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10290. */
  10291. get radius(): number;
  10292. /**
  10293. * sets the light radius used by PBR Materials to simulate soft area lights.
  10294. */
  10295. set radius(value: number);
  10296. private _renderPriority;
  10297. /**
  10298. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10299. * exceeding the number allowed of the materials.
  10300. */
  10301. renderPriority: number;
  10302. private _shadowEnabled;
  10303. /**
  10304. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10305. * the current shadow generator.
  10306. */
  10307. get shadowEnabled(): boolean;
  10308. /**
  10309. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10310. * the current shadow generator.
  10311. */
  10312. set shadowEnabled(value: boolean);
  10313. private _includedOnlyMeshes;
  10314. /**
  10315. * Gets the only meshes impacted by this light.
  10316. */
  10317. get includedOnlyMeshes(): AbstractMesh[];
  10318. /**
  10319. * Sets the only meshes impacted by this light.
  10320. */
  10321. set includedOnlyMeshes(value: AbstractMesh[]);
  10322. private _excludedMeshes;
  10323. /**
  10324. * Gets the meshes not impacted by this light.
  10325. */
  10326. get excludedMeshes(): AbstractMesh[];
  10327. /**
  10328. * Sets the meshes not impacted by this light.
  10329. */
  10330. set excludedMeshes(value: AbstractMesh[]);
  10331. private _excludeWithLayerMask;
  10332. /**
  10333. * Gets the layer id use to find what meshes are not impacted by the light.
  10334. * Inactive if 0
  10335. */
  10336. get excludeWithLayerMask(): number;
  10337. /**
  10338. * Sets the layer id use to find what meshes are not impacted by the light.
  10339. * Inactive if 0
  10340. */
  10341. set excludeWithLayerMask(value: number);
  10342. private _includeOnlyWithLayerMask;
  10343. /**
  10344. * Gets the layer id use to find what meshes are impacted by the light.
  10345. * Inactive if 0
  10346. */
  10347. get includeOnlyWithLayerMask(): number;
  10348. /**
  10349. * Sets the layer id use to find what meshes are impacted by the light.
  10350. * Inactive if 0
  10351. */
  10352. set includeOnlyWithLayerMask(value: number);
  10353. private _lightmapMode;
  10354. /**
  10355. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10356. */
  10357. get lightmapMode(): number;
  10358. /**
  10359. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10360. */
  10361. set lightmapMode(value: number);
  10362. /**
  10363. * Shadow generator associted to the light.
  10364. * @hidden Internal use only.
  10365. */
  10366. _shadowGenerator: Nullable<IShadowGenerator>;
  10367. /**
  10368. * @hidden Internal use only.
  10369. */
  10370. _excludedMeshesIds: string[];
  10371. /**
  10372. * @hidden Internal use only.
  10373. */
  10374. _includedOnlyMeshesIds: string[];
  10375. /**
  10376. * The current light unifom buffer.
  10377. * @hidden Internal use only.
  10378. */
  10379. _uniformBuffer: UniformBuffer;
  10380. /** @hidden */
  10381. _renderId: number;
  10382. /**
  10383. * Creates a Light object in the scene.
  10384. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10385. * @param name The firendly name of the light
  10386. * @param scene The scene the light belongs too
  10387. */
  10388. constructor(name: string, scene: Scene);
  10389. protected abstract _buildUniformLayout(): void;
  10390. /**
  10391. * Sets the passed Effect "effect" with the Light information.
  10392. * @param effect The effect to update
  10393. * @param lightIndex The index of the light in the effect to update
  10394. * @returns The light
  10395. */
  10396. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10397. /**
  10398. * Sets the passed Effect "effect" with the Light textures.
  10399. * @param effect The effect to update
  10400. * @param lightIndex The index of the light in the effect to update
  10401. * @returns The light
  10402. */
  10403. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10404. /**
  10405. * Binds the lights information from the scene to the effect for the given mesh.
  10406. * @param lightIndex Light index
  10407. * @param scene The scene where the light belongs to
  10408. * @param effect The effect we are binding the data to
  10409. * @param useSpecular Defines if specular is supported
  10410. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10411. */
  10412. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  10413. /**
  10414. * Sets the passed Effect "effect" with the Light information.
  10415. * @param effect The effect to update
  10416. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10417. * @returns The light
  10418. */
  10419. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10420. /**
  10421. * Returns the string "Light".
  10422. * @returns the class name
  10423. */
  10424. getClassName(): string;
  10425. /** @hidden */
  10426. readonly _isLight: boolean;
  10427. /**
  10428. * Converts the light information to a readable string for debug purpose.
  10429. * @param fullDetails Supports for multiple levels of logging within scene loading
  10430. * @returns the human readable light info
  10431. */
  10432. toString(fullDetails?: boolean): string;
  10433. /** @hidden */
  10434. protected _syncParentEnabledState(): void;
  10435. /**
  10436. * Set the enabled state of this node.
  10437. * @param value - the new enabled state
  10438. */
  10439. setEnabled(value: boolean): void;
  10440. /**
  10441. * Returns the Light associated shadow generator if any.
  10442. * @return the associated shadow generator.
  10443. */
  10444. getShadowGenerator(): Nullable<IShadowGenerator>;
  10445. /**
  10446. * Returns a Vector3, the absolute light position in the World.
  10447. * @returns the world space position of the light
  10448. */
  10449. getAbsolutePosition(): Vector3;
  10450. /**
  10451. * Specifies if the light will affect the passed mesh.
  10452. * @param mesh The mesh to test against the light
  10453. * @return true the mesh is affected otherwise, false.
  10454. */
  10455. canAffectMesh(mesh: AbstractMesh): boolean;
  10456. /**
  10457. * Sort function to order lights for rendering.
  10458. * @param a First Light object to compare to second.
  10459. * @param b Second Light object to compare first.
  10460. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10461. */
  10462. static CompareLightsPriority(a: Light, b: Light): number;
  10463. /**
  10464. * Releases resources associated with this node.
  10465. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10466. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10467. */
  10468. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10469. /**
  10470. * Returns the light type ID (integer).
  10471. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10472. */
  10473. getTypeID(): number;
  10474. /**
  10475. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10476. * @returns the scaled intensity in intensity mode unit
  10477. */
  10478. getScaledIntensity(): number;
  10479. /**
  10480. * Returns a new Light object, named "name", from the current one.
  10481. * @param name The name of the cloned light
  10482. * @returns the new created light
  10483. */
  10484. clone(name: string): Nullable<Light>;
  10485. /**
  10486. * Serializes the current light into a Serialization object.
  10487. * @returns the serialized object.
  10488. */
  10489. serialize(): any;
  10490. /**
  10491. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10492. * This new light is named "name" and added to the passed scene.
  10493. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10494. * @param name The friendly name of the light
  10495. * @param scene The scene the new light will belong to
  10496. * @returns the constructor function
  10497. */
  10498. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10499. /**
  10500. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10501. * @param parsedLight The JSON representation of the light
  10502. * @param scene The scene to create the parsed light in
  10503. * @returns the created light after parsing
  10504. */
  10505. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10506. private _hookArrayForExcluded;
  10507. private _hookArrayForIncludedOnly;
  10508. private _resyncMeshes;
  10509. /**
  10510. * Forces the meshes to update their light related information in their rendering used effects
  10511. * @hidden Internal Use Only
  10512. */
  10513. _markMeshesAsLightDirty(): void;
  10514. /**
  10515. * Recomputes the cached photometric scale if needed.
  10516. */
  10517. private _computePhotometricScale;
  10518. /**
  10519. * Returns the Photometric Scale according to the light type and intensity mode.
  10520. */
  10521. private _getPhotometricScale;
  10522. /**
  10523. * Reorder the light in the scene according to their defined priority.
  10524. * @hidden Internal Use Only
  10525. */
  10526. _reorderLightsInScene(): void;
  10527. /**
  10528. * Prepares the list of defines specific to the light type.
  10529. * @param defines the list of defines
  10530. * @param lightIndex defines the index of the light for the effect
  10531. */
  10532. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10533. }
  10534. }
  10535. declare module "babylonjs/Actions/action" {
  10536. import { Observable } from "babylonjs/Misc/observable";
  10537. import { Condition } from "babylonjs/Actions/condition";
  10538. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10539. import { ActionManager } from "babylonjs/Actions/actionManager";
  10540. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10541. /**
  10542. * Interface used to define Action
  10543. */
  10544. export interface IAction {
  10545. /**
  10546. * Trigger for the action
  10547. */
  10548. trigger: number;
  10549. /** Options of the trigger */
  10550. triggerOptions: any;
  10551. /**
  10552. * Gets the trigger parameters
  10553. * @returns the trigger parameters
  10554. */
  10555. getTriggerParameter(): any;
  10556. /**
  10557. * Internal only - executes current action event
  10558. * @hidden
  10559. */
  10560. _executeCurrent(evt?: ActionEvent): void;
  10561. /**
  10562. * Serialize placeholder for child classes
  10563. * @param parent of child
  10564. * @returns the serialized object
  10565. */
  10566. serialize(parent: any): any;
  10567. /**
  10568. * Internal only
  10569. * @hidden
  10570. */
  10571. _prepare(): void;
  10572. /**
  10573. * Internal only - manager for action
  10574. * @hidden
  10575. */
  10576. _actionManager: AbstractActionManager;
  10577. /**
  10578. * Adds action to chain of actions, may be a DoNothingAction
  10579. * @param action defines the next action to execute
  10580. * @returns The action passed in
  10581. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10582. */
  10583. then(action: IAction): IAction;
  10584. }
  10585. /**
  10586. * The action to be carried out following a trigger
  10587. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10588. */
  10589. export class Action implements IAction {
  10590. /** the trigger, with or without parameters, for the action */
  10591. triggerOptions: any;
  10592. /**
  10593. * Trigger for the action
  10594. */
  10595. trigger: number;
  10596. /**
  10597. * Internal only - manager for action
  10598. * @hidden
  10599. */
  10600. _actionManager: ActionManager;
  10601. private _nextActiveAction;
  10602. private _child;
  10603. private _condition?;
  10604. private _triggerParameter;
  10605. /**
  10606. * An event triggered prior to action being executed.
  10607. */
  10608. onBeforeExecuteObservable: Observable<Action>;
  10609. /**
  10610. * Creates a new Action
  10611. * @param triggerOptions the trigger, with or without parameters, for the action
  10612. * @param condition an optional determinant of action
  10613. */
  10614. constructor(
  10615. /** the trigger, with or without parameters, for the action */
  10616. triggerOptions: any, condition?: Condition);
  10617. /**
  10618. * Internal only
  10619. * @hidden
  10620. */
  10621. _prepare(): void;
  10622. /**
  10623. * Gets the trigger parameters
  10624. * @returns the trigger parameters
  10625. */
  10626. getTriggerParameter(): any;
  10627. /**
  10628. * Internal only - executes current action event
  10629. * @hidden
  10630. */
  10631. _executeCurrent(evt?: ActionEvent): void;
  10632. /**
  10633. * Execute placeholder for child classes
  10634. * @param evt optional action event
  10635. */
  10636. execute(evt?: ActionEvent): void;
  10637. /**
  10638. * Skips to next active action
  10639. */
  10640. skipToNextActiveAction(): void;
  10641. /**
  10642. * Adds action to chain of actions, may be a DoNothingAction
  10643. * @param action defines the next action to execute
  10644. * @returns The action passed in
  10645. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10646. */
  10647. then(action: Action): Action;
  10648. /**
  10649. * Internal only
  10650. * @hidden
  10651. */
  10652. _getProperty(propertyPath: string): string;
  10653. /**
  10654. * Internal only
  10655. * @hidden
  10656. */
  10657. _getEffectiveTarget(target: any, propertyPath: string): any;
  10658. /**
  10659. * Serialize placeholder for child classes
  10660. * @param parent of child
  10661. * @returns the serialized object
  10662. */
  10663. serialize(parent: any): any;
  10664. /**
  10665. * Internal only called by serialize
  10666. * @hidden
  10667. */
  10668. protected _serialize(serializedAction: any, parent?: any): any;
  10669. /**
  10670. * Internal only
  10671. * @hidden
  10672. */
  10673. static _SerializeValueAsString: (value: any) => string;
  10674. /**
  10675. * Internal only
  10676. * @hidden
  10677. */
  10678. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10679. name: string;
  10680. targetType: string;
  10681. value: string;
  10682. };
  10683. }
  10684. }
  10685. declare module "babylonjs/Actions/condition" {
  10686. import { ActionManager } from "babylonjs/Actions/actionManager";
  10687. /**
  10688. * A Condition applied to an Action
  10689. */
  10690. export class Condition {
  10691. /**
  10692. * Internal only - manager for action
  10693. * @hidden
  10694. */
  10695. _actionManager: ActionManager;
  10696. /**
  10697. * Internal only
  10698. * @hidden
  10699. */
  10700. _evaluationId: number;
  10701. /**
  10702. * Internal only
  10703. * @hidden
  10704. */
  10705. _currentResult: boolean;
  10706. /**
  10707. * Creates a new Condition
  10708. * @param actionManager the manager of the action the condition is applied to
  10709. */
  10710. constructor(actionManager: ActionManager);
  10711. /**
  10712. * Check if the current condition is valid
  10713. * @returns a boolean
  10714. */
  10715. isValid(): boolean;
  10716. /**
  10717. * Internal only
  10718. * @hidden
  10719. */
  10720. _getProperty(propertyPath: string): string;
  10721. /**
  10722. * Internal only
  10723. * @hidden
  10724. */
  10725. _getEffectiveTarget(target: any, propertyPath: string): any;
  10726. /**
  10727. * Serialize placeholder for child classes
  10728. * @returns the serialized object
  10729. */
  10730. serialize(): any;
  10731. /**
  10732. * Internal only
  10733. * @hidden
  10734. */
  10735. protected _serialize(serializedCondition: any): any;
  10736. }
  10737. /**
  10738. * Defines specific conditional operators as extensions of Condition
  10739. */
  10740. export class ValueCondition extends Condition {
  10741. /** path to specify the property of the target the conditional operator uses */
  10742. propertyPath: string;
  10743. /** the value compared by the conditional operator against the current value of the property */
  10744. value: any;
  10745. /** the conditional operator, default ValueCondition.IsEqual */
  10746. operator: number;
  10747. /**
  10748. * Internal only
  10749. * @hidden
  10750. */
  10751. private static _IsEqual;
  10752. /**
  10753. * Internal only
  10754. * @hidden
  10755. */
  10756. private static _IsDifferent;
  10757. /**
  10758. * Internal only
  10759. * @hidden
  10760. */
  10761. private static _IsGreater;
  10762. /**
  10763. * Internal only
  10764. * @hidden
  10765. */
  10766. private static _IsLesser;
  10767. /**
  10768. * returns the number for IsEqual
  10769. */
  10770. static get IsEqual(): number;
  10771. /**
  10772. * Returns the number for IsDifferent
  10773. */
  10774. static get IsDifferent(): number;
  10775. /**
  10776. * Returns the number for IsGreater
  10777. */
  10778. static get IsGreater(): number;
  10779. /**
  10780. * Returns the number for IsLesser
  10781. */
  10782. static get IsLesser(): number;
  10783. /**
  10784. * Internal only The action manager for the condition
  10785. * @hidden
  10786. */
  10787. _actionManager: ActionManager;
  10788. /**
  10789. * Internal only
  10790. * @hidden
  10791. */
  10792. private _target;
  10793. /**
  10794. * Internal only
  10795. * @hidden
  10796. */
  10797. private _effectiveTarget;
  10798. /**
  10799. * Internal only
  10800. * @hidden
  10801. */
  10802. private _property;
  10803. /**
  10804. * Creates a new ValueCondition
  10805. * @param actionManager manager for the action the condition applies to
  10806. * @param target for the action
  10807. * @param propertyPath path to specify the property of the target the conditional operator uses
  10808. * @param value the value compared by the conditional operator against the current value of the property
  10809. * @param operator the conditional operator, default ValueCondition.IsEqual
  10810. */
  10811. constructor(actionManager: ActionManager, target: any,
  10812. /** path to specify the property of the target the conditional operator uses */
  10813. propertyPath: string,
  10814. /** the value compared by the conditional operator against the current value of the property */
  10815. value: any,
  10816. /** the conditional operator, default ValueCondition.IsEqual */
  10817. operator?: number);
  10818. /**
  10819. * Compares the given value with the property value for the specified conditional operator
  10820. * @returns the result of the comparison
  10821. */
  10822. isValid(): boolean;
  10823. /**
  10824. * Serialize the ValueCondition into a JSON compatible object
  10825. * @returns serialization object
  10826. */
  10827. serialize(): any;
  10828. /**
  10829. * Gets the name of the conditional operator for the ValueCondition
  10830. * @param operator the conditional operator
  10831. * @returns the name
  10832. */
  10833. static GetOperatorName(operator: number): string;
  10834. }
  10835. /**
  10836. * Defines a predicate condition as an extension of Condition
  10837. */
  10838. export class PredicateCondition extends Condition {
  10839. /** defines the predicate function used to validate the condition */
  10840. predicate: () => boolean;
  10841. /**
  10842. * Internal only - manager for action
  10843. * @hidden
  10844. */
  10845. _actionManager: ActionManager;
  10846. /**
  10847. * Creates a new PredicateCondition
  10848. * @param actionManager manager for the action the condition applies to
  10849. * @param predicate defines the predicate function used to validate the condition
  10850. */
  10851. constructor(actionManager: ActionManager,
  10852. /** defines the predicate function used to validate the condition */
  10853. predicate: () => boolean);
  10854. /**
  10855. * @returns the validity of the predicate condition
  10856. */
  10857. isValid(): boolean;
  10858. }
  10859. /**
  10860. * Defines a state condition as an extension of Condition
  10861. */
  10862. export class StateCondition extends Condition {
  10863. /** Value to compare with target state */
  10864. value: string;
  10865. /**
  10866. * Internal only - manager for action
  10867. * @hidden
  10868. */
  10869. _actionManager: ActionManager;
  10870. /**
  10871. * Internal only
  10872. * @hidden
  10873. */
  10874. private _target;
  10875. /**
  10876. * Creates a new StateCondition
  10877. * @param actionManager manager for the action the condition applies to
  10878. * @param target of the condition
  10879. * @param value to compare with target state
  10880. */
  10881. constructor(actionManager: ActionManager, target: any,
  10882. /** Value to compare with target state */
  10883. value: string);
  10884. /**
  10885. * Gets a boolean indicating if the current condition is met
  10886. * @returns the validity of the state
  10887. */
  10888. isValid(): boolean;
  10889. /**
  10890. * Serialize the StateCondition into a JSON compatible object
  10891. * @returns serialization object
  10892. */
  10893. serialize(): any;
  10894. }
  10895. }
  10896. declare module "babylonjs/Actions/directActions" {
  10897. import { Action } from "babylonjs/Actions/action";
  10898. import { Condition } from "babylonjs/Actions/condition";
  10899. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10900. /**
  10901. * This defines an action responsible to toggle a boolean once triggered.
  10902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10903. */
  10904. export class SwitchBooleanAction extends Action {
  10905. /**
  10906. * The path to the boolean property in the target object
  10907. */
  10908. propertyPath: string;
  10909. private _target;
  10910. private _effectiveTarget;
  10911. private _property;
  10912. /**
  10913. * Instantiate the action
  10914. * @param triggerOptions defines the trigger options
  10915. * @param target defines the object containing the boolean
  10916. * @param propertyPath defines the path to the boolean property in the target object
  10917. * @param condition defines the trigger related conditions
  10918. */
  10919. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10920. /** @hidden */
  10921. _prepare(): void;
  10922. /**
  10923. * Execute the action toggle the boolean value.
  10924. */
  10925. execute(): void;
  10926. /**
  10927. * Serializes the actions and its related information.
  10928. * @param parent defines the object to serialize in
  10929. * @returns the serialized object
  10930. */
  10931. serialize(parent: any): any;
  10932. }
  10933. /**
  10934. * This defines an action responsible to set a the state field of the target
  10935. * to a desired value once triggered.
  10936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10937. */
  10938. export class SetStateAction extends Action {
  10939. /**
  10940. * The value to store in the state field.
  10941. */
  10942. value: string;
  10943. private _target;
  10944. /**
  10945. * Instantiate the action
  10946. * @param triggerOptions defines the trigger options
  10947. * @param target defines the object containing the state property
  10948. * @param value defines the value to store in the state field
  10949. * @param condition defines the trigger related conditions
  10950. */
  10951. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10952. /**
  10953. * Execute the action and store the value on the target state property.
  10954. */
  10955. execute(): void;
  10956. /**
  10957. * Serializes the actions and its related information.
  10958. * @param parent defines the object to serialize in
  10959. * @returns the serialized object
  10960. */
  10961. serialize(parent: any): any;
  10962. }
  10963. /**
  10964. * This defines an action responsible to set a property of the target
  10965. * to a desired value once triggered.
  10966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10967. */
  10968. export class SetValueAction extends Action {
  10969. /**
  10970. * The path of the property to set in the target.
  10971. */
  10972. propertyPath: string;
  10973. /**
  10974. * The value to set in the property
  10975. */
  10976. value: any;
  10977. private _target;
  10978. private _effectiveTarget;
  10979. private _property;
  10980. /**
  10981. * Instantiate the action
  10982. * @param triggerOptions defines the trigger options
  10983. * @param target defines the object containing the property
  10984. * @param propertyPath defines the path of the property to set in the target
  10985. * @param value defines the value to set in the property
  10986. * @param condition defines the trigger related conditions
  10987. */
  10988. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10989. /** @hidden */
  10990. _prepare(): void;
  10991. /**
  10992. * Execute the action and set the targetted property to the desired value.
  10993. */
  10994. execute(): void;
  10995. /**
  10996. * Serializes the actions and its related information.
  10997. * @param parent defines the object to serialize in
  10998. * @returns the serialized object
  10999. */
  11000. serialize(parent: any): any;
  11001. }
  11002. /**
  11003. * This defines an action responsible to increment the target value
  11004. * to a desired value once triggered.
  11005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11006. */
  11007. export class IncrementValueAction extends Action {
  11008. /**
  11009. * The path of the property to increment in the target.
  11010. */
  11011. propertyPath: string;
  11012. /**
  11013. * The value we should increment the property by.
  11014. */
  11015. value: any;
  11016. private _target;
  11017. private _effectiveTarget;
  11018. private _property;
  11019. /**
  11020. * Instantiate the action
  11021. * @param triggerOptions defines the trigger options
  11022. * @param target defines the object containing the property
  11023. * @param propertyPath defines the path of the property to increment in the target
  11024. * @param value defines the value value we should increment the property by
  11025. * @param condition defines the trigger related conditions
  11026. */
  11027. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11028. /** @hidden */
  11029. _prepare(): void;
  11030. /**
  11031. * Execute the action and increment the target of the value amount.
  11032. */
  11033. execute(): void;
  11034. /**
  11035. * Serializes the actions and its related information.
  11036. * @param parent defines the object to serialize in
  11037. * @returns the serialized object
  11038. */
  11039. serialize(parent: any): any;
  11040. }
  11041. /**
  11042. * This defines an action responsible to start an animation once triggered.
  11043. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11044. */
  11045. export class PlayAnimationAction extends Action {
  11046. /**
  11047. * Where the animation should start (animation frame)
  11048. */
  11049. from: number;
  11050. /**
  11051. * Where the animation should stop (animation frame)
  11052. */
  11053. to: number;
  11054. /**
  11055. * Define if the animation should loop or stop after the first play.
  11056. */
  11057. loop?: boolean;
  11058. private _target;
  11059. /**
  11060. * Instantiate the action
  11061. * @param triggerOptions defines the trigger options
  11062. * @param target defines the target animation or animation name
  11063. * @param from defines from where the animation should start (animation frame)
  11064. * @param end defines where the animation should stop (animation frame)
  11065. * @param loop defines if the animation should loop or stop after the first play
  11066. * @param condition defines the trigger related conditions
  11067. */
  11068. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11069. /** @hidden */
  11070. _prepare(): void;
  11071. /**
  11072. * Execute the action and play the animation.
  11073. */
  11074. execute(): void;
  11075. /**
  11076. * Serializes the actions and its related information.
  11077. * @param parent defines the object to serialize in
  11078. * @returns the serialized object
  11079. */
  11080. serialize(parent: any): any;
  11081. }
  11082. /**
  11083. * This defines an action responsible to stop an animation once triggered.
  11084. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11085. */
  11086. export class StopAnimationAction extends Action {
  11087. private _target;
  11088. /**
  11089. * Instantiate the action
  11090. * @param triggerOptions defines the trigger options
  11091. * @param target defines the target animation or animation name
  11092. * @param condition defines the trigger related conditions
  11093. */
  11094. constructor(triggerOptions: any, target: any, condition?: Condition);
  11095. /** @hidden */
  11096. _prepare(): void;
  11097. /**
  11098. * Execute the action and stop the animation.
  11099. */
  11100. execute(): void;
  11101. /**
  11102. * Serializes the actions and its related information.
  11103. * @param parent defines the object to serialize in
  11104. * @returns the serialized object
  11105. */
  11106. serialize(parent: any): any;
  11107. }
  11108. /**
  11109. * This defines an action responsible that does nothing once triggered.
  11110. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11111. */
  11112. export class DoNothingAction extends Action {
  11113. /**
  11114. * Instantiate the action
  11115. * @param triggerOptions defines the trigger options
  11116. * @param condition defines the trigger related conditions
  11117. */
  11118. constructor(triggerOptions?: any, condition?: Condition);
  11119. /**
  11120. * Execute the action and do nothing.
  11121. */
  11122. execute(): void;
  11123. /**
  11124. * Serializes the actions and its related information.
  11125. * @param parent defines the object to serialize in
  11126. * @returns the serialized object
  11127. */
  11128. serialize(parent: any): any;
  11129. }
  11130. /**
  11131. * This defines an action responsible to trigger several actions once triggered.
  11132. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11133. */
  11134. export class CombineAction extends Action {
  11135. /**
  11136. * The list of aggregated animations to run.
  11137. */
  11138. children: Action[];
  11139. /**
  11140. * Instantiate the action
  11141. * @param triggerOptions defines the trigger options
  11142. * @param children defines the list of aggregated animations to run
  11143. * @param condition defines the trigger related conditions
  11144. */
  11145. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11146. /** @hidden */
  11147. _prepare(): void;
  11148. /**
  11149. * Execute the action and executes all the aggregated actions.
  11150. */
  11151. execute(evt: ActionEvent): void;
  11152. /**
  11153. * Serializes the actions and its related information.
  11154. * @param parent defines the object to serialize in
  11155. * @returns the serialized object
  11156. */
  11157. serialize(parent: any): any;
  11158. }
  11159. /**
  11160. * This defines an action responsible to run code (external event) once triggered.
  11161. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11162. */
  11163. export class ExecuteCodeAction extends Action {
  11164. /**
  11165. * The callback function to run.
  11166. */
  11167. func: (evt: ActionEvent) => void;
  11168. /**
  11169. * Instantiate the action
  11170. * @param triggerOptions defines the trigger options
  11171. * @param func defines the callback function to run
  11172. * @param condition defines the trigger related conditions
  11173. */
  11174. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11175. /**
  11176. * Execute the action and run the attached code.
  11177. */
  11178. execute(evt: ActionEvent): void;
  11179. }
  11180. /**
  11181. * This defines an action responsible to set the parent property of the target once triggered.
  11182. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11183. */
  11184. export class SetParentAction extends Action {
  11185. private _parent;
  11186. private _target;
  11187. /**
  11188. * Instantiate the action
  11189. * @param triggerOptions defines the trigger options
  11190. * @param target defines the target containing the parent property
  11191. * @param parent defines from where the animation should start (animation frame)
  11192. * @param condition defines the trigger related conditions
  11193. */
  11194. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11195. /** @hidden */
  11196. _prepare(): void;
  11197. /**
  11198. * Execute the action and set the parent property.
  11199. */
  11200. execute(): void;
  11201. /**
  11202. * Serializes the actions and its related information.
  11203. * @param parent defines the object to serialize in
  11204. * @returns the serialized object
  11205. */
  11206. serialize(parent: any): any;
  11207. }
  11208. }
  11209. declare module "babylonjs/Actions/actionManager" {
  11210. import { Nullable } from "babylonjs/types";
  11211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11212. import { Scene } from "babylonjs/scene";
  11213. import { IAction } from "babylonjs/Actions/action";
  11214. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11215. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11216. /**
  11217. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11218. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11220. */
  11221. export class ActionManager extends AbstractActionManager {
  11222. /**
  11223. * Nothing
  11224. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11225. */
  11226. static readonly NothingTrigger: number;
  11227. /**
  11228. * On pick
  11229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11230. */
  11231. static readonly OnPickTrigger: number;
  11232. /**
  11233. * On left pick
  11234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11235. */
  11236. static readonly OnLeftPickTrigger: number;
  11237. /**
  11238. * On right pick
  11239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11240. */
  11241. static readonly OnRightPickTrigger: number;
  11242. /**
  11243. * On center pick
  11244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11245. */
  11246. static readonly OnCenterPickTrigger: number;
  11247. /**
  11248. * On pick down
  11249. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11250. */
  11251. static readonly OnPickDownTrigger: number;
  11252. /**
  11253. * On double pick
  11254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11255. */
  11256. static readonly OnDoublePickTrigger: number;
  11257. /**
  11258. * On pick up
  11259. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11260. */
  11261. static readonly OnPickUpTrigger: number;
  11262. /**
  11263. * On pick out.
  11264. * This trigger will only be raised if you also declared a OnPickDown
  11265. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11266. */
  11267. static readonly OnPickOutTrigger: number;
  11268. /**
  11269. * On long press
  11270. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11271. */
  11272. static readonly OnLongPressTrigger: number;
  11273. /**
  11274. * On pointer over
  11275. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11276. */
  11277. static readonly OnPointerOverTrigger: number;
  11278. /**
  11279. * On pointer out
  11280. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11281. */
  11282. static readonly OnPointerOutTrigger: number;
  11283. /**
  11284. * On every frame
  11285. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11286. */
  11287. static readonly OnEveryFrameTrigger: number;
  11288. /**
  11289. * On intersection enter
  11290. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11291. */
  11292. static readonly OnIntersectionEnterTrigger: number;
  11293. /**
  11294. * On intersection exit
  11295. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11296. */
  11297. static readonly OnIntersectionExitTrigger: number;
  11298. /**
  11299. * On key down
  11300. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11301. */
  11302. static readonly OnKeyDownTrigger: number;
  11303. /**
  11304. * On key up
  11305. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11306. */
  11307. static readonly OnKeyUpTrigger: number;
  11308. private _scene;
  11309. /**
  11310. * Creates a new action manager
  11311. * @param scene defines the hosting scene
  11312. */
  11313. constructor(scene: Scene);
  11314. /**
  11315. * Releases all associated resources
  11316. */
  11317. dispose(): void;
  11318. /**
  11319. * Gets hosting scene
  11320. * @returns the hosting scene
  11321. */
  11322. getScene(): Scene;
  11323. /**
  11324. * Does this action manager handles actions of any of the given triggers
  11325. * @param triggers defines the triggers to be tested
  11326. * @return a boolean indicating whether one (or more) of the triggers is handled
  11327. */
  11328. hasSpecificTriggers(triggers: number[]): boolean;
  11329. /**
  11330. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11331. * speed.
  11332. * @param triggerA defines the trigger to be tested
  11333. * @param triggerB defines the trigger to be tested
  11334. * @return a boolean indicating whether one (or more) of the triggers is handled
  11335. */
  11336. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11337. /**
  11338. * Does this action manager handles actions of a given trigger
  11339. * @param trigger defines the trigger to be tested
  11340. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11341. * @return whether the trigger is handled
  11342. */
  11343. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11344. /**
  11345. * Does this action manager has pointer triggers
  11346. */
  11347. get hasPointerTriggers(): boolean;
  11348. /**
  11349. * Does this action manager has pick triggers
  11350. */
  11351. get hasPickTriggers(): boolean;
  11352. /**
  11353. * Registers an action to this action manager
  11354. * @param action defines the action to be registered
  11355. * @return the action amended (prepared) after registration
  11356. */
  11357. registerAction(action: IAction): Nullable<IAction>;
  11358. /**
  11359. * Unregisters an action to this action manager
  11360. * @param action defines the action to be unregistered
  11361. * @return a boolean indicating whether the action has been unregistered
  11362. */
  11363. unregisterAction(action: IAction): Boolean;
  11364. /**
  11365. * Process a specific trigger
  11366. * @param trigger defines the trigger to process
  11367. * @param evt defines the event details to be processed
  11368. */
  11369. processTrigger(trigger: number, evt?: IActionEvent): void;
  11370. /** @hidden */
  11371. _getEffectiveTarget(target: any, propertyPath: string): any;
  11372. /** @hidden */
  11373. _getProperty(propertyPath: string): string;
  11374. /**
  11375. * Serialize this manager to a JSON object
  11376. * @param name defines the property name to store this manager
  11377. * @returns a JSON representation of this manager
  11378. */
  11379. serialize(name: string): any;
  11380. /**
  11381. * Creates a new ActionManager from a JSON data
  11382. * @param parsedActions defines the JSON data to read from
  11383. * @param object defines the hosting mesh
  11384. * @param scene defines the hosting scene
  11385. */
  11386. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11387. /**
  11388. * Get a trigger name by index
  11389. * @param trigger defines the trigger index
  11390. * @returns a trigger name
  11391. */
  11392. static GetTriggerName(trigger: number): string;
  11393. }
  11394. }
  11395. declare module "babylonjs/Culling/ray" {
  11396. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11397. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11398. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11399. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11400. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11401. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11402. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11403. import { Plane } from "babylonjs/Maths/math.plane";
  11404. /**
  11405. * Class representing a ray with position and direction
  11406. */
  11407. export class Ray {
  11408. /** origin point */
  11409. origin: Vector3;
  11410. /** direction */
  11411. direction: Vector3;
  11412. /** length of the ray */
  11413. length: number;
  11414. private static readonly TmpVector3;
  11415. private _tmpRay;
  11416. /**
  11417. * Creates a new ray
  11418. * @param origin origin point
  11419. * @param direction direction
  11420. * @param length length of the ray
  11421. */
  11422. constructor(
  11423. /** origin point */
  11424. origin: Vector3,
  11425. /** direction */
  11426. direction: Vector3,
  11427. /** length of the ray */
  11428. length?: number);
  11429. /**
  11430. * Checks if the ray intersects a box
  11431. * @param minimum bound of the box
  11432. * @param maximum bound of the box
  11433. * @param intersectionTreshold extra extend to be added to the box in all direction
  11434. * @returns if the box was hit
  11435. */
  11436. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11437. /**
  11438. * Checks if the ray intersects a box
  11439. * @param box the bounding box to check
  11440. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11441. * @returns if the box was hit
  11442. */
  11443. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11444. /**
  11445. * If the ray hits a sphere
  11446. * @param sphere the bounding sphere to check
  11447. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11448. * @returns true if it hits the sphere
  11449. */
  11450. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11451. /**
  11452. * If the ray hits a triange
  11453. * @param vertex0 triangle vertex
  11454. * @param vertex1 triangle vertex
  11455. * @param vertex2 triangle vertex
  11456. * @returns intersection information if hit
  11457. */
  11458. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11459. /**
  11460. * Checks if ray intersects a plane
  11461. * @param plane the plane to check
  11462. * @returns the distance away it was hit
  11463. */
  11464. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11465. /**
  11466. * Calculate the intercept of a ray on a given axis
  11467. * @param axis to check 'x' | 'y' | 'z'
  11468. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11469. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11470. */
  11471. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11472. /**
  11473. * Checks if ray intersects a mesh
  11474. * @param mesh the mesh to check
  11475. * @param fastCheck if only the bounding box should checked
  11476. * @returns picking info of the intersecton
  11477. */
  11478. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11479. /**
  11480. * Checks if ray intersects a mesh
  11481. * @param meshes the meshes to check
  11482. * @param fastCheck if only the bounding box should checked
  11483. * @param results array to store result in
  11484. * @returns Array of picking infos
  11485. */
  11486. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11487. private _comparePickingInfo;
  11488. private static smallnum;
  11489. private static rayl;
  11490. /**
  11491. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11492. * @param sega the first point of the segment to test the intersection against
  11493. * @param segb the second point of the segment to test the intersection against
  11494. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11495. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11496. */
  11497. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11498. /**
  11499. * Update the ray from viewport position
  11500. * @param x position
  11501. * @param y y position
  11502. * @param viewportWidth viewport width
  11503. * @param viewportHeight viewport height
  11504. * @param world world matrix
  11505. * @param view view matrix
  11506. * @param projection projection matrix
  11507. * @returns this ray updated
  11508. */
  11509. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11510. /**
  11511. * Creates a ray with origin and direction of 0,0,0
  11512. * @returns the new ray
  11513. */
  11514. static Zero(): Ray;
  11515. /**
  11516. * Creates a new ray from screen space and viewport
  11517. * @param x position
  11518. * @param y y position
  11519. * @param viewportWidth viewport width
  11520. * @param viewportHeight viewport height
  11521. * @param world world matrix
  11522. * @param view view matrix
  11523. * @param projection projection matrix
  11524. * @returns new ray
  11525. */
  11526. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11527. /**
  11528. * 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
  11529. * transformed to the given world matrix.
  11530. * @param origin The origin point
  11531. * @param end The end point
  11532. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11533. * @returns the new ray
  11534. */
  11535. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11536. /**
  11537. * Transforms a ray by a matrix
  11538. * @param ray ray to transform
  11539. * @param matrix matrix to apply
  11540. * @returns the resulting new ray
  11541. */
  11542. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11543. /**
  11544. * Transforms a ray by a matrix
  11545. * @param ray ray to transform
  11546. * @param matrix matrix to apply
  11547. * @param result ray to store result in
  11548. */
  11549. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11550. /**
  11551. * Unproject a ray from screen space to object space
  11552. * @param sourceX defines the screen space x coordinate to use
  11553. * @param sourceY defines the screen space y coordinate to use
  11554. * @param viewportWidth defines the current width of the viewport
  11555. * @param viewportHeight defines the current height of the viewport
  11556. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11557. * @param view defines the view matrix to use
  11558. * @param projection defines the projection matrix to use
  11559. */
  11560. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11561. }
  11562. /**
  11563. * Type used to define predicate used to select faces when a mesh intersection is detected
  11564. */
  11565. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11566. module "babylonjs/scene" {
  11567. interface Scene {
  11568. /** @hidden */
  11569. _tempPickingRay: Nullable<Ray>;
  11570. /** @hidden */
  11571. _cachedRayForTransform: Ray;
  11572. /** @hidden */
  11573. _pickWithRayInverseMatrix: Matrix;
  11574. /** @hidden */
  11575. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11576. /** @hidden */
  11577. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11578. }
  11579. }
  11580. }
  11581. declare module "babylonjs/sceneComponent" {
  11582. import { Scene } from "babylonjs/scene";
  11583. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11584. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11585. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11586. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11587. import { Nullable } from "babylonjs/types";
  11588. import { Camera } from "babylonjs/Cameras/camera";
  11589. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11590. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11591. import { AbstractScene } from "babylonjs/abstractScene";
  11592. import { Mesh } from "babylonjs/Meshes/mesh";
  11593. /**
  11594. * Groups all the scene component constants in one place to ease maintenance.
  11595. * @hidden
  11596. */
  11597. export class SceneComponentConstants {
  11598. static readonly NAME_EFFECTLAYER: string;
  11599. static readonly NAME_LAYER: string;
  11600. static readonly NAME_LENSFLARESYSTEM: string;
  11601. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11602. static readonly NAME_PARTICLESYSTEM: string;
  11603. static readonly NAME_GAMEPAD: string;
  11604. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11605. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11606. static readonly NAME_DEPTHRENDERER: string;
  11607. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11608. static readonly NAME_SPRITE: string;
  11609. static readonly NAME_OUTLINERENDERER: string;
  11610. static readonly NAME_PROCEDURALTEXTURE: string;
  11611. static readonly NAME_SHADOWGENERATOR: string;
  11612. static readonly NAME_OCTREE: string;
  11613. static readonly NAME_PHYSICSENGINE: string;
  11614. static readonly NAME_AUDIO: string;
  11615. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11616. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11617. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11618. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11619. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11620. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11621. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11622. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11623. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11624. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11625. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11626. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11627. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11628. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11629. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11630. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11631. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11632. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11633. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11634. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11635. static readonly STEP_AFTERRENDER_AUDIO: number;
  11636. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11637. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11638. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11639. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11640. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11641. static readonly STEP_POINTERMOVE_SPRITE: number;
  11642. static readonly STEP_POINTERDOWN_SPRITE: number;
  11643. static readonly STEP_POINTERUP_SPRITE: number;
  11644. }
  11645. /**
  11646. * This represents a scene component.
  11647. *
  11648. * This is used to decouple the dependency the scene is having on the different workloads like
  11649. * layers, post processes...
  11650. */
  11651. export interface ISceneComponent {
  11652. /**
  11653. * The name of the component. Each component must have a unique name.
  11654. */
  11655. name: string;
  11656. /**
  11657. * The scene the component belongs to.
  11658. */
  11659. scene: Scene;
  11660. /**
  11661. * Register the component to one instance of a scene.
  11662. */
  11663. register(): void;
  11664. /**
  11665. * Rebuilds the elements related to this component in case of
  11666. * context lost for instance.
  11667. */
  11668. rebuild(): void;
  11669. /**
  11670. * Disposes the component and the associated ressources.
  11671. */
  11672. dispose(): void;
  11673. }
  11674. /**
  11675. * This represents a SERIALIZABLE scene component.
  11676. *
  11677. * This extends Scene Component to add Serialization methods on top.
  11678. */
  11679. export interface ISceneSerializableComponent extends ISceneComponent {
  11680. /**
  11681. * Adds all the elements from the container to the scene
  11682. * @param container the container holding the elements
  11683. */
  11684. addFromContainer(container: AbstractScene): void;
  11685. /**
  11686. * Removes all the elements in the container from the scene
  11687. * @param container contains the elements to remove
  11688. * @param dispose if the removed element should be disposed (default: false)
  11689. */
  11690. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11691. /**
  11692. * Serializes the component data to the specified json object
  11693. * @param serializationObject The object to serialize to
  11694. */
  11695. serialize(serializationObject: any): void;
  11696. }
  11697. /**
  11698. * Strong typing of a Mesh related stage step action
  11699. */
  11700. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11701. /**
  11702. * Strong typing of a Evaluate Sub Mesh related stage step action
  11703. */
  11704. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11705. /**
  11706. * Strong typing of a Active Mesh related stage step action
  11707. */
  11708. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11709. /**
  11710. * Strong typing of a Camera related stage step action
  11711. */
  11712. export type CameraStageAction = (camera: Camera) => void;
  11713. /**
  11714. * Strong typing of a Camera Frame buffer related stage step action
  11715. */
  11716. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11717. /**
  11718. * Strong typing of a Render Target related stage step action
  11719. */
  11720. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11721. /**
  11722. * Strong typing of a RenderingGroup related stage step action
  11723. */
  11724. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11725. /**
  11726. * Strong typing of a Mesh Render related stage step action
  11727. */
  11728. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11729. /**
  11730. * Strong typing of a simple stage step action
  11731. */
  11732. export type SimpleStageAction = () => void;
  11733. /**
  11734. * Strong typing of a render target action.
  11735. */
  11736. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11737. /**
  11738. * Strong typing of a pointer move action.
  11739. */
  11740. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11741. /**
  11742. * Strong typing of a pointer up/down action.
  11743. */
  11744. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11745. /**
  11746. * Representation of a stage in the scene (Basically a list of ordered steps)
  11747. * @hidden
  11748. */
  11749. export class Stage<T extends Function> extends Array<{
  11750. index: number;
  11751. component: ISceneComponent;
  11752. action: T;
  11753. }> {
  11754. /**
  11755. * Hide ctor from the rest of the world.
  11756. * @param items The items to add.
  11757. */
  11758. private constructor();
  11759. /**
  11760. * Creates a new Stage.
  11761. * @returns A new instance of a Stage
  11762. */
  11763. static Create<T extends Function>(): Stage<T>;
  11764. /**
  11765. * Registers a step in an ordered way in the targeted stage.
  11766. * @param index Defines the position to register the step in
  11767. * @param component Defines the component attached to the step
  11768. * @param action Defines the action to launch during the step
  11769. */
  11770. registerStep(index: number, component: ISceneComponent, action: T): void;
  11771. /**
  11772. * Clears all the steps from the stage.
  11773. */
  11774. clear(): void;
  11775. }
  11776. }
  11777. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11778. import { Nullable } from "babylonjs/types";
  11779. import { Observable } from "babylonjs/Misc/observable";
  11780. import { Scene } from "babylonjs/scene";
  11781. import { Sprite } from "babylonjs/Sprites/sprite";
  11782. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11783. import { Ray } from "babylonjs/Culling/ray";
  11784. import { Camera } from "babylonjs/Cameras/camera";
  11785. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11786. import { ISceneComponent } from "babylonjs/sceneComponent";
  11787. module "babylonjs/scene" {
  11788. interface Scene {
  11789. /** @hidden */
  11790. _pointerOverSprite: Nullable<Sprite>;
  11791. /** @hidden */
  11792. _pickedDownSprite: Nullable<Sprite>;
  11793. /** @hidden */
  11794. _tempSpritePickingRay: Nullable<Ray>;
  11795. /**
  11796. * All of the sprite managers added to this scene
  11797. * @see http://doc.babylonjs.com/babylon101/sprites
  11798. */
  11799. spriteManagers: Array<ISpriteManager>;
  11800. /**
  11801. * An event triggered when sprites rendering is about to start
  11802. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11803. */
  11804. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11805. /**
  11806. * An event triggered when sprites rendering is done
  11807. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11808. */
  11809. onAfterSpritesRenderingObservable: Observable<Scene>;
  11810. /** @hidden */
  11811. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11812. /** Launch a ray to try to pick a sprite in the scene
  11813. * @param x position on screen
  11814. * @param y position on screen
  11815. * @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
  11816. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11817. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11818. * @returns a PickingInfo
  11819. */
  11820. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11821. /** Use the given ray to pick a sprite in the scene
  11822. * @param ray The ray (in world space) to use to pick meshes
  11823. * @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
  11824. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11825. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11826. * @returns a PickingInfo
  11827. */
  11828. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11829. /** @hidden */
  11830. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11831. /** Launch a ray to try to pick sprites in the scene
  11832. * @param x position on screen
  11833. * @param y position on screen
  11834. * @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
  11835. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11836. * @returns a PickingInfo array
  11837. */
  11838. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11839. /** Use the given ray to pick sprites in the scene
  11840. * @param ray The ray (in world space) to use to pick meshes
  11841. * @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
  11842. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11843. * @returns a PickingInfo array
  11844. */
  11845. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11846. /**
  11847. * Force the sprite under the pointer
  11848. * @param sprite defines the sprite to use
  11849. */
  11850. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11851. /**
  11852. * Gets the sprite under the pointer
  11853. * @returns a Sprite or null if no sprite is under the pointer
  11854. */
  11855. getPointerOverSprite(): Nullable<Sprite>;
  11856. }
  11857. }
  11858. /**
  11859. * Defines the sprite scene component responsible to manage sprites
  11860. * in a given scene.
  11861. */
  11862. export class SpriteSceneComponent implements ISceneComponent {
  11863. /**
  11864. * The component name helpfull to identify the component in the list of scene components.
  11865. */
  11866. readonly name: string;
  11867. /**
  11868. * The scene the component belongs to.
  11869. */
  11870. scene: Scene;
  11871. /** @hidden */
  11872. private _spritePredicate;
  11873. /**
  11874. * Creates a new instance of the component for the given scene
  11875. * @param scene Defines the scene to register the component in
  11876. */
  11877. constructor(scene: Scene);
  11878. /**
  11879. * Registers the component in a given scene
  11880. */
  11881. register(): void;
  11882. /**
  11883. * Rebuilds the elements related to this component in case of
  11884. * context lost for instance.
  11885. */
  11886. rebuild(): void;
  11887. /**
  11888. * Disposes the component and the associated ressources.
  11889. */
  11890. dispose(): void;
  11891. private _pickSpriteButKeepRay;
  11892. private _pointerMove;
  11893. private _pointerDown;
  11894. private _pointerUp;
  11895. }
  11896. }
  11897. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11898. /** @hidden */
  11899. export var fogFragmentDeclaration: {
  11900. name: string;
  11901. shader: string;
  11902. };
  11903. }
  11904. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11905. /** @hidden */
  11906. export var fogFragment: {
  11907. name: string;
  11908. shader: string;
  11909. };
  11910. }
  11911. declare module "babylonjs/Shaders/sprites.fragment" {
  11912. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11913. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11914. /** @hidden */
  11915. export var spritesPixelShader: {
  11916. name: string;
  11917. shader: string;
  11918. };
  11919. }
  11920. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11921. /** @hidden */
  11922. export var fogVertexDeclaration: {
  11923. name: string;
  11924. shader: string;
  11925. };
  11926. }
  11927. declare module "babylonjs/Shaders/sprites.vertex" {
  11928. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11929. /** @hidden */
  11930. export var spritesVertexShader: {
  11931. name: string;
  11932. shader: string;
  11933. };
  11934. }
  11935. declare module "babylonjs/Sprites/spriteManager" {
  11936. import { IDisposable, Scene } from "babylonjs/scene";
  11937. import { Nullable } from "babylonjs/types";
  11938. import { Observable } from "babylonjs/Misc/observable";
  11939. import { Sprite } from "babylonjs/Sprites/sprite";
  11940. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11941. import { Camera } from "babylonjs/Cameras/camera";
  11942. import { Texture } from "babylonjs/Materials/Textures/texture";
  11943. import "babylonjs/Shaders/sprites.fragment";
  11944. import "babylonjs/Shaders/sprites.vertex";
  11945. import { Ray } from "babylonjs/Culling/ray";
  11946. /**
  11947. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11948. */
  11949. export interface ISpriteManager extends IDisposable {
  11950. /**
  11951. * Restricts the camera to viewing objects with the same layerMask.
  11952. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11953. */
  11954. layerMask: number;
  11955. /**
  11956. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11957. */
  11958. isPickable: boolean;
  11959. /**
  11960. * Specifies the rendering group id for this mesh (0 by default)
  11961. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11962. */
  11963. renderingGroupId: number;
  11964. /**
  11965. * Defines the list of sprites managed by the manager.
  11966. */
  11967. sprites: Array<Sprite>;
  11968. /**
  11969. * Tests the intersection of a sprite with a specific ray.
  11970. * @param ray The ray we are sending to test the collision
  11971. * @param camera The camera space we are sending rays in
  11972. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11973. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11974. * @returns picking info or null.
  11975. */
  11976. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11977. /**
  11978. * Intersects the sprites with a ray
  11979. * @param ray defines the ray to intersect with
  11980. * @param camera defines the current active camera
  11981. * @param predicate defines a predicate used to select candidate sprites
  11982. * @returns null if no hit or a PickingInfo array
  11983. */
  11984. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11985. /**
  11986. * Renders the list of sprites on screen.
  11987. */
  11988. render(): void;
  11989. }
  11990. /**
  11991. * Class used to manage multiple sprites on the same spritesheet
  11992. * @see http://doc.babylonjs.com/babylon101/sprites
  11993. */
  11994. export class SpriteManager implements ISpriteManager {
  11995. /** defines the manager's name */
  11996. name: string;
  11997. /** Gets the list of sprites */
  11998. sprites: Sprite[];
  11999. /** Gets or sets the rendering group id (0 by default) */
  12000. renderingGroupId: number;
  12001. /** Gets or sets camera layer mask */
  12002. layerMask: number;
  12003. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  12004. fogEnabled: boolean;
  12005. /** Gets or sets a boolean indicating if the sprites are pickable */
  12006. isPickable: boolean;
  12007. /** Defines the default width of a cell in the spritesheet */
  12008. cellWidth: number;
  12009. /** Defines the default height of a cell in the spritesheet */
  12010. cellHeight: number;
  12011. /** Associative array from JSON sprite data file */
  12012. private _cellData;
  12013. /** Array of sprite names from JSON sprite data file */
  12014. private _spriteMap;
  12015. /** True when packed cell data from JSON file is ready*/
  12016. private _packedAndReady;
  12017. /**
  12018. * An event triggered when the manager is disposed.
  12019. */
  12020. onDisposeObservable: Observable<SpriteManager>;
  12021. private _onDisposeObserver;
  12022. /**
  12023. * Callback called when the manager is disposed
  12024. */
  12025. set onDispose(callback: () => void);
  12026. private _capacity;
  12027. private _fromPacked;
  12028. private _spriteTexture;
  12029. private _epsilon;
  12030. private _scene;
  12031. private _vertexData;
  12032. private _buffer;
  12033. private _vertexBuffers;
  12034. private _indexBuffer;
  12035. private _effectBase;
  12036. private _effectFog;
  12037. /**
  12038. * Gets or sets the spritesheet texture
  12039. */
  12040. get texture(): Texture;
  12041. set texture(value: Texture);
  12042. /**
  12043. * Creates a new sprite manager
  12044. * @param name defines the manager's name
  12045. * @param imgUrl defines the sprite sheet url
  12046. * @param capacity defines the maximum allowed number of sprites
  12047. * @param cellSize defines the size of a sprite cell
  12048. * @param scene defines the hosting scene
  12049. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  12050. * @param samplingMode defines the smapling mode to use with spritesheet
  12051. * @param fromPacked set to false; do not alter
  12052. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  12053. */
  12054. constructor(
  12055. /** defines the manager's name */
  12056. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  12057. private _makePacked;
  12058. private _appendSpriteVertex;
  12059. /**
  12060. * Intersects the sprites with a ray
  12061. * @param ray defines the ray to intersect with
  12062. * @param camera defines the current active camera
  12063. * @param predicate defines a predicate used to select candidate sprites
  12064. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  12065. * @returns null if no hit or a PickingInfo
  12066. */
  12067. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12068. /**
  12069. * Intersects the sprites with a ray
  12070. * @param ray defines the ray to intersect with
  12071. * @param camera defines the current active camera
  12072. * @param predicate defines a predicate used to select candidate sprites
  12073. * @returns null if no hit or a PickingInfo array
  12074. */
  12075. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  12076. /**
  12077. * Render all child sprites
  12078. */
  12079. render(): void;
  12080. /**
  12081. * Release associated resources
  12082. */
  12083. dispose(): void;
  12084. }
  12085. }
  12086. declare module "babylonjs/Sprites/sprite" {
  12087. import { Vector3 } from "babylonjs/Maths/math.vector";
  12088. import { Nullable } from "babylonjs/types";
  12089. import { ActionManager } from "babylonjs/Actions/actionManager";
  12090. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  12091. import { Color4 } from "babylonjs/Maths/math.color";
  12092. /**
  12093. * Class used to represent a sprite
  12094. * @see http://doc.babylonjs.com/babylon101/sprites
  12095. */
  12096. export class Sprite {
  12097. /** defines the name */
  12098. name: string;
  12099. /** Gets or sets the current world position */
  12100. position: Vector3;
  12101. /** Gets or sets the main color */
  12102. color: Color4;
  12103. /** Gets or sets the width */
  12104. width: number;
  12105. /** Gets or sets the height */
  12106. height: number;
  12107. /** Gets or sets rotation angle */
  12108. angle: number;
  12109. /** Gets or sets the cell index in the sprite sheet */
  12110. cellIndex: number;
  12111. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  12112. cellRef: string;
  12113. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12114. invertU: number;
  12115. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12116. invertV: number;
  12117. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12118. disposeWhenFinishedAnimating: boolean;
  12119. /** Gets the list of attached animations */
  12120. animations: Animation[];
  12121. /** Gets or sets a boolean indicating if the sprite can be picked */
  12122. isPickable: boolean;
  12123. /**
  12124. * Gets or sets the associated action manager
  12125. */
  12126. actionManager: Nullable<ActionManager>;
  12127. private _animationStarted;
  12128. private _loopAnimation;
  12129. private _fromIndex;
  12130. private _toIndex;
  12131. private _delay;
  12132. private _direction;
  12133. private _manager;
  12134. private _time;
  12135. private _onAnimationEnd;
  12136. /**
  12137. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12138. */
  12139. isVisible: boolean;
  12140. /**
  12141. * Gets or sets the sprite size
  12142. */
  12143. get size(): number;
  12144. set size(value: number);
  12145. /**
  12146. * Creates a new Sprite
  12147. * @param name defines the name
  12148. * @param manager defines the manager
  12149. */
  12150. constructor(
  12151. /** defines the name */
  12152. name: string, manager: ISpriteManager);
  12153. /**
  12154. * Starts an animation
  12155. * @param from defines the initial key
  12156. * @param to defines the end key
  12157. * @param loop defines if the animation must loop
  12158. * @param delay defines the start delay (in ms)
  12159. * @param onAnimationEnd defines a callback to call when animation ends
  12160. */
  12161. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12162. /** Stops current animation (if any) */
  12163. stopAnimation(): void;
  12164. /** @hidden */
  12165. _animate(deltaTime: number): void;
  12166. /** Release associated resources */
  12167. dispose(): void;
  12168. }
  12169. }
  12170. declare module "babylonjs/Collisions/pickingInfo" {
  12171. import { Nullable } from "babylonjs/types";
  12172. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  12173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12174. import { Sprite } from "babylonjs/Sprites/sprite";
  12175. import { Ray } from "babylonjs/Culling/ray";
  12176. /**
  12177. * Information about the result of picking within a scene
  12178. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12179. */
  12180. export class PickingInfo {
  12181. /** @hidden */
  12182. _pickingUnavailable: boolean;
  12183. /**
  12184. * If the pick collided with an object
  12185. */
  12186. hit: boolean;
  12187. /**
  12188. * Distance away where the pick collided
  12189. */
  12190. distance: number;
  12191. /**
  12192. * The location of pick collision
  12193. */
  12194. pickedPoint: Nullable<Vector3>;
  12195. /**
  12196. * The mesh corresponding the the pick collision
  12197. */
  12198. pickedMesh: Nullable<AbstractMesh>;
  12199. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  12200. bu: number;
  12201. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  12202. bv: number;
  12203. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12204. faceId: number;
  12205. /** Id of the the submesh that was picked */
  12206. subMeshId: number;
  12207. /** If a sprite was picked, this will be the sprite the pick collided with */
  12208. pickedSprite: Nullable<Sprite>;
  12209. /**
  12210. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12211. */
  12212. originMesh: Nullable<AbstractMesh>;
  12213. /**
  12214. * The ray that was used to perform the picking.
  12215. */
  12216. ray: Nullable<Ray>;
  12217. /**
  12218. * Gets the normal correspodning to the face the pick collided with
  12219. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12220. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12221. * @returns The normal correspodning to the face the pick collided with
  12222. */
  12223. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12224. /**
  12225. * Gets the texture coordinates of where the pick occured
  12226. * @returns the vector containing the coordnates of the texture
  12227. */
  12228. getTextureCoordinates(): Nullable<Vector2>;
  12229. }
  12230. }
  12231. declare module "babylonjs/Events/pointerEvents" {
  12232. import { Nullable } from "babylonjs/types";
  12233. import { Vector2 } from "babylonjs/Maths/math.vector";
  12234. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12235. import { Ray } from "babylonjs/Culling/ray";
  12236. /**
  12237. * Gather the list of pointer event types as constants.
  12238. */
  12239. export class PointerEventTypes {
  12240. /**
  12241. * 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.
  12242. */
  12243. static readonly POINTERDOWN: number;
  12244. /**
  12245. * The pointerup event is fired when a pointer is no longer active.
  12246. */
  12247. static readonly POINTERUP: number;
  12248. /**
  12249. * The pointermove event is fired when a pointer changes coordinates.
  12250. */
  12251. static readonly POINTERMOVE: number;
  12252. /**
  12253. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12254. */
  12255. static readonly POINTERWHEEL: number;
  12256. /**
  12257. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12258. */
  12259. static readonly POINTERPICK: number;
  12260. /**
  12261. * The pointertap event is fired when a the object has been touched and released without drag.
  12262. */
  12263. static readonly POINTERTAP: number;
  12264. /**
  12265. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12266. */
  12267. static readonly POINTERDOUBLETAP: number;
  12268. }
  12269. /**
  12270. * Base class of pointer info types.
  12271. */
  12272. export class PointerInfoBase {
  12273. /**
  12274. * Defines the type of event (PointerEventTypes)
  12275. */
  12276. type: number;
  12277. /**
  12278. * Defines the related dom event
  12279. */
  12280. event: PointerEvent | MouseWheelEvent;
  12281. /**
  12282. * Instantiates the base class of pointers info.
  12283. * @param type Defines the type of event (PointerEventTypes)
  12284. * @param event Defines the related dom event
  12285. */
  12286. constructor(
  12287. /**
  12288. * Defines the type of event (PointerEventTypes)
  12289. */
  12290. type: number,
  12291. /**
  12292. * Defines the related dom event
  12293. */
  12294. event: PointerEvent | MouseWheelEvent);
  12295. }
  12296. /**
  12297. * This class is used to store pointer related info for the onPrePointerObservable event.
  12298. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12299. */
  12300. export class PointerInfoPre extends PointerInfoBase {
  12301. /**
  12302. * Ray from a pointer if availible (eg. 6dof controller)
  12303. */
  12304. ray: Nullable<Ray>;
  12305. /**
  12306. * Defines the local position of the pointer on the canvas.
  12307. */
  12308. localPosition: Vector2;
  12309. /**
  12310. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12311. */
  12312. skipOnPointerObservable: boolean;
  12313. /**
  12314. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12315. * @param type Defines the type of event (PointerEventTypes)
  12316. * @param event Defines the related dom event
  12317. * @param localX Defines the local x coordinates of the pointer when the event occured
  12318. * @param localY Defines the local y coordinates of the pointer when the event occured
  12319. */
  12320. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12321. }
  12322. /**
  12323. * This type contains all the data related to a pointer event in Babylon.js.
  12324. * 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.
  12325. */
  12326. export class PointerInfo extends PointerInfoBase {
  12327. /**
  12328. * Defines the picking info associated to the info (if any)\
  12329. */
  12330. pickInfo: Nullable<PickingInfo>;
  12331. /**
  12332. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12333. * @param type Defines the type of event (PointerEventTypes)
  12334. * @param event Defines the related dom event
  12335. * @param pickInfo Defines the picking info associated to the info (if any)\
  12336. */
  12337. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12338. /**
  12339. * Defines the picking info associated to the info (if any)\
  12340. */
  12341. pickInfo: Nullable<PickingInfo>);
  12342. }
  12343. /**
  12344. * Data relating to a touch event on the screen.
  12345. */
  12346. export interface PointerTouch {
  12347. /**
  12348. * X coordinate of touch.
  12349. */
  12350. x: number;
  12351. /**
  12352. * Y coordinate of touch.
  12353. */
  12354. y: number;
  12355. /**
  12356. * Id of touch. Unique for each finger.
  12357. */
  12358. pointerId: number;
  12359. /**
  12360. * Event type passed from DOM.
  12361. */
  12362. type: any;
  12363. }
  12364. }
  12365. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12366. import { Observable } from "babylonjs/Misc/observable";
  12367. import { Nullable } from "babylonjs/types";
  12368. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12369. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12370. /**
  12371. * Manage the mouse inputs to control the movement of a free camera.
  12372. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12373. */
  12374. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12375. /**
  12376. * Define if touch is enabled in the mouse input
  12377. */
  12378. touchEnabled: boolean;
  12379. /**
  12380. * Defines the camera the input is attached to.
  12381. */
  12382. camera: FreeCamera;
  12383. /**
  12384. * Defines the buttons associated with the input to handle camera move.
  12385. */
  12386. buttons: number[];
  12387. /**
  12388. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12389. */
  12390. angularSensibility: number;
  12391. private _pointerInput;
  12392. private _onMouseMove;
  12393. private _observer;
  12394. private previousPosition;
  12395. /**
  12396. * Observable for when a pointer move event occurs containing the move offset
  12397. */
  12398. onPointerMovedObservable: Observable<{
  12399. offsetX: number;
  12400. offsetY: number;
  12401. }>;
  12402. /**
  12403. * @hidden
  12404. * If the camera should be rotated automatically based on pointer movement
  12405. */
  12406. _allowCameraRotation: boolean;
  12407. /**
  12408. * Manage the mouse inputs to control the movement of a free camera.
  12409. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12410. * @param touchEnabled Defines if touch is enabled or not
  12411. */
  12412. constructor(
  12413. /**
  12414. * Define if touch is enabled in the mouse input
  12415. */
  12416. touchEnabled?: boolean);
  12417. /**
  12418. * Attach the input controls to a specific dom element to get the input from.
  12419. * @param element Defines the element the controls should be listened from
  12420. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12421. */
  12422. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12423. /**
  12424. * Called on JS contextmenu event.
  12425. * Override this method to provide functionality.
  12426. */
  12427. protected onContextMenu(evt: PointerEvent): void;
  12428. /**
  12429. * Detach the current controls from the specified dom element.
  12430. * @param element Defines the element to stop listening the inputs from
  12431. */
  12432. detachControl(element: Nullable<HTMLElement>): void;
  12433. /**
  12434. * Gets the class name of the current intput.
  12435. * @returns the class name
  12436. */
  12437. getClassName(): string;
  12438. /**
  12439. * Get the friendly name associated with the input class.
  12440. * @returns the input friendly name
  12441. */
  12442. getSimpleName(): string;
  12443. }
  12444. }
  12445. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12446. import { Nullable } from "babylonjs/types";
  12447. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12448. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12449. /**
  12450. * Manage the touch inputs to control the movement of a free camera.
  12451. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12452. */
  12453. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12454. /**
  12455. * Defines the camera the input is attached to.
  12456. */
  12457. camera: FreeCamera;
  12458. /**
  12459. * Defines the touch sensibility for rotation.
  12460. * The higher the faster.
  12461. */
  12462. touchAngularSensibility: number;
  12463. /**
  12464. * Defines the touch sensibility for move.
  12465. * The higher the faster.
  12466. */
  12467. touchMoveSensibility: number;
  12468. private _offsetX;
  12469. private _offsetY;
  12470. private _pointerPressed;
  12471. private _pointerInput;
  12472. private _observer;
  12473. private _onLostFocus;
  12474. /**
  12475. * Attach the input controls to a specific dom element to get the input from.
  12476. * @param element Defines the element the controls should be listened from
  12477. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12478. */
  12479. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12480. /**
  12481. * Detach the current controls from the specified dom element.
  12482. * @param element Defines the element to stop listening the inputs from
  12483. */
  12484. detachControl(element: Nullable<HTMLElement>): void;
  12485. /**
  12486. * Update the current camera state depending on the inputs that have been used this frame.
  12487. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12488. */
  12489. checkInputs(): void;
  12490. /**
  12491. * Gets the class name of the current intput.
  12492. * @returns the class name
  12493. */
  12494. getClassName(): string;
  12495. /**
  12496. * Get the friendly name associated with the input class.
  12497. * @returns the input friendly name
  12498. */
  12499. getSimpleName(): string;
  12500. }
  12501. }
  12502. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12503. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12504. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12505. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12506. import { Nullable } from "babylonjs/types";
  12507. /**
  12508. * Default Inputs manager for the FreeCamera.
  12509. * It groups all the default supported inputs for ease of use.
  12510. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12511. */
  12512. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12513. /**
  12514. * @hidden
  12515. */
  12516. _mouseInput: Nullable<FreeCameraMouseInput>;
  12517. /**
  12518. * Instantiates a new FreeCameraInputsManager.
  12519. * @param camera Defines the camera the inputs belong to
  12520. */
  12521. constructor(camera: FreeCamera);
  12522. /**
  12523. * Add keyboard input support to the input manager.
  12524. * @returns the current input manager
  12525. */
  12526. addKeyboard(): FreeCameraInputsManager;
  12527. /**
  12528. * Add mouse input support to the input manager.
  12529. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12530. * @returns the current input manager
  12531. */
  12532. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12533. /**
  12534. * Removes the mouse input support from the manager
  12535. * @returns the current input manager
  12536. */
  12537. removeMouse(): FreeCameraInputsManager;
  12538. /**
  12539. * Add touch input support to the input manager.
  12540. * @returns the current input manager
  12541. */
  12542. addTouch(): FreeCameraInputsManager;
  12543. /**
  12544. * Remove all attached input methods from a camera
  12545. */
  12546. clear(): void;
  12547. }
  12548. }
  12549. declare module "babylonjs/Cameras/freeCamera" {
  12550. import { Vector3 } from "babylonjs/Maths/math.vector";
  12551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12552. import { Scene } from "babylonjs/scene";
  12553. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12554. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12555. /**
  12556. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12557. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12558. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12559. */
  12560. export class FreeCamera extends TargetCamera {
  12561. /**
  12562. * Define the collision ellipsoid of the camera.
  12563. * This is helpful to simulate a camera body like the player body around the camera
  12564. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12565. */
  12566. ellipsoid: Vector3;
  12567. /**
  12568. * Define an offset for the position of the ellipsoid around the camera.
  12569. * This can be helpful to determine the center of the body near the gravity center of the body
  12570. * instead of its head.
  12571. */
  12572. ellipsoidOffset: Vector3;
  12573. /**
  12574. * Enable or disable collisions of the camera with the rest of the scene objects.
  12575. */
  12576. checkCollisions: boolean;
  12577. /**
  12578. * Enable or disable gravity on the camera.
  12579. */
  12580. applyGravity: boolean;
  12581. /**
  12582. * Define the input manager associated to the camera.
  12583. */
  12584. inputs: FreeCameraInputsManager;
  12585. /**
  12586. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12587. * Higher values reduce sensitivity.
  12588. */
  12589. get angularSensibility(): number;
  12590. /**
  12591. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12592. * Higher values reduce sensitivity.
  12593. */
  12594. set angularSensibility(value: number);
  12595. /**
  12596. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12597. */
  12598. get keysUp(): number[];
  12599. set keysUp(value: number[]);
  12600. /**
  12601. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12602. */
  12603. get keysDown(): number[];
  12604. set keysDown(value: number[]);
  12605. /**
  12606. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12607. */
  12608. get keysLeft(): number[];
  12609. set keysLeft(value: number[]);
  12610. /**
  12611. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12612. */
  12613. get keysRight(): number[];
  12614. set keysRight(value: number[]);
  12615. /**
  12616. * Event raised when the camera collide with a mesh in the scene.
  12617. */
  12618. onCollide: (collidedMesh: AbstractMesh) => void;
  12619. private _collider;
  12620. private _needMoveForGravity;
  12621. private _oldPosition;
  12622. private _diffPosition;
  12623. private _newPosition;
  12624. /** @hidden */
  12625. _localDirection: Vector3;
  12626. /** @hidden */
  12627. _transformedDirection: Vector3;
  12628. /**
  12629. * Instantiates a Free Camera.
  12630. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12631. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12632. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12633. * @param name Define the name of the camera in the scene
  12634. * @param position Define the start position of the camera in the scene
  12635. * @param scene Define the scene the camera belongs to
  12636. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12637. */
  12638. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12639. /**
  12640. * Attached controls to the current camera.
  12641. * @param element Defines the element the controls should be listened from
  12642. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12643. */
  12644. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12645. /**
  12646. * Detach the current controls from the camera.
  12647. * The camera will stop reacting to inputs.
  12648. * @param element Defines the element to stop listening the inputs from
  12649. */
  12650. detachControl(element: HTMLElement): void;
  12651. private _collisionMask;
  12652. /**
  12653. * Define a collision mask to limit the list of object the camera can collide with
  12654. */
  12655. get collisionMask(): number;
  12656. set collisionMask(mask: number);
  12657. /** @hidden */
  12658. _collideWithWorld(displacement: Vector3): void;
  12659. private _onCollisionPositionChange;
  12660. /** @hidden */
  12661. _checkInputs(): void;
  12662. /** @hidden */
  12663. _decideIfNeedsToMove(): boolean;
  12664. /** @hidden */
  12665. _updatePosition(): void;
  12666. /**
  12667. * Destroy the camera and release the current resources hold by it.
  12668. */
  12669. dispose(): void;
  12670. /**
  12671. * Gets the current object class name.
  12672. * @return the class name
  12673. */
  12674. getClassName(): string;
  12675. }
  12676. }
  12677. declare module "babylonjs/Gamepads/gamepad" {
  12678. import { Observable } from "babylonjs/Misc/observable";
  12679. /**
  12680. * Represents a gamepad control stick position
  12681. */
  12682. export class StickValues {
  12683. /**
  12684. * The x component of the control stick
  12685. */
  12686. x: number;
  12687. /**
  12688. * The y component of the control stick
  12689. */
  12690. y: number;
  12691. /**
  12692. * Initializes the gamepad x and y control stick values
  12693. * @param x The x component of the gamepad control stick value
  12694. * @param y The y component of the gamepad control stick value
  12695. */
  12696. constructor(
  12697. /**
  12698. * The x component of the control stick
  12699. */
  12700. x: number,
  12701. /**
  12702. * The y component of the control stick
  12703. */
  12704. y: number);
  12705. }
  12706. /**
  12707. * An interface which manages callbacks for gamepad button changes
  12708. */
  12709. export interface GamepadButtonChanges {
  12710. /**
  12711. * Called when a gamepad has been changed
  12712. */
  12713. changed: boolean;
  12714. /**
  12715. * Called when a gamepad press event has been triggered
  12716. */
  12717. pressChanged: boolean;
  12718. /**
  12719. * Called when a touch event has been triggered
  12720. */
  12721. touchChanged: boolean;
  12722. /**
  12723. * Called when a value has changed
  12724. */
  12725. valueChanged: boolean;
  12726. }
  12727. /**
  12728. * Represents a gamepad
  12729. */
  12730. export class Gamepad {
  12731. /**
  12732. * The id of the gamepad
  12733. */
  12734. id: string;
  12735. /**
  12736. * The index of the gamepad
  12737. */
  12738. index: number;
  12739. /**
  12740. * The browser gamepad
  12741. */
  12742. browserGamepad: any;
  12743. /**
  12744. * Specifies what type of gamepad this represents
  12745. */
  12746. type: number;
  12747. private _leftStick;
  12748. private _rightStick;
  12749. /** @hidden */
  12750. _isConnected: boolean;
  12751. private _leftStickAxisX;
  12752. private _leftStickAxisY;
  12753. private _rightStickAxisX;
  12754. private _rightStickAxisY;
  12755. /**
  12756. * Triggered when the left control stick has been changed
  12757. */
  12758. private _onleftstickchanged;
  12759. /**
  12760. * Triggered when the right control stick has been changed
  12761. */
  12762. private _onrightstickchanged;
  12763. /**
  12764. * Represents a gamepad controller
  12765. */
  12766. static GAMEPAD: number;
  12767. /**
  12768. * Represents a generic controller
  12769. */
  12770. static GENERIC: number;
  12771. /**
  12772. * Represents an XBox controller
  12773. */
  12774. static XBOX: number;
  12775. /**
  12776. * Represents a pose-enabled controller
  12777. */
  12778. static POSE_ENABLED: number;
  12779. /**
  12780. * Represents an Dual Shock controller
  12781. */
  12782. static DUALSHOCK: number;
  12783. /**
  12784. * Specifies whether the left control stick should be Y-inverted
  12785. */
  12786. protected _invertLeftStickY: boolean;
  12787. /**
  12788. * Specifies if the gamepad has been connected
  12789. */
  12790. get isConnected(): boolean;
  12791. /**
  12792. * Initializes the gamepad
  12793. * @param id The id of the gamepad
  12794. * @param index The index of the gamepad
  12795. * @param browserGamepad The browser gamepad
  12796. * @param leftStickX The x component of the left joystick
  12797. * @param leftStickY The y component of the left joystick
  12798. * @param rightStickX The x component of the right joystick
  12799. * @param rightStickY The y component of the right joystick
  12800. */
  12801. constructor(
  12802. /**
  12803. * The id of the gamepad
  12804. */
  12805. id: string,
  12806. /**
  12807. * The index of the gamepad
  12808. */
  12809. index: number,
  12810. /**
  12811. * The browser gamepad
  12812. */
  12813. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12814. /**
  12815. * Callback triggered when the left joystick has changed
  12816. * @param callback
  12817. */
  12818. onleftstickchanged(callback: (values: StickValues) => void): void;
  12819. /**
  12820. * Callback triggered when the right joystick has changed
  12821. * @param callback
  12822. */
  12823. onrightstickchanged(callback: (values: StickValues) => void): void;
  12824. /**
  12825. * Gets the left joystick
  12826. */
  12827. get leftStick(): StickValues;
  12828. /**
  12829. * Sets the left joystick values
  12830. */
  12831. set leftStick(newValues: StickValues);
  12832. /**
  12833. * Gets the right joystick
  12834. */
  12835. get rightStick(): StickValues;
  12836. /**
  12837. * Sets the right joystick value
  12838. */
  12839. set rightStick(newValues: StickValues);
  12840. /**
  12841. * Updates the gamepad joystick positions
  12842. */
  12843. update(): void;
  12844. /**
  12845. * Disposes the gamepad
  12846. */
  12847. dispose(): void;
  12848. }
  12849. /**
  12850. * Represents a generic gamepad
  12851. */
  12852. export class GenericPad extends Gamepad {
  12853. private _buttons;
  12854. private _onbuttondown;
  12855. private _onbuttonup;
  12856. /**
  12857. * Observable triggered when a button has been pressed
  12858. */
  12859. onButtonDownObservable: Observable<number>;
  12860. /**
  12861. * Observable triggered when a button has been released
  12862. */
  12863. onButtonUpObservable: Observable<number>;
  12864. /**
  12865. * Callback triggered when a button has been pressed
  12866. * @param callback Called when a button has been pressed
  12867. */
  12868. onbuttondown(callback: (buttonPressed: number) => void): void;
  12869. /**
  12870. * Callback triggered when a button has been released
  12871. * @param callback Called when a button has been released
  12872. */
  12873. onbuttonup(callback: (buttonReleased: number) => void): void;
  12874. /**
  12875. * Initializes the generic gamepad
  12876. * @param id The id of the generic gamepad
  12877. * @param index The index of the generic gamepad
  12878. * @param browserGamepad The browser gamepad
  12879. */
  12880. constructor(id: string, index: number, browserGamepad: any);
  12881. private _setButtonValue;
  12882. /**
  12883. * Updates the generic gamepad
  12884. */
  12885. update(): void;
  12886. /**
  12887. * Disposes the generic gamepad
  12888. */
  12889. dispose(): void;
  12890. }
  12891. }
  12892. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12893. import { Nullable } from "babylonjs/types";
  12894. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12895. import { Scene } from "babylonjs/scene";
  12896. module "babylonjs/Engines/engine" {
  12897. interface Engine {
  12898. /**
  12899. * Creates a raw texture
  12900. * @param data defines the data to store in the texture
  12901. * @param width defines the width of the texture
  12902. * @param height defines the height of the texture
  12903. * @param format defines the format of the data
  12904. * @param generateMipMaps defines if the engine should generate the mip levels
  12905. * @param invertY defines if data must be stored with Y axis inverted
  12906. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12907. * @param compression defines the compression used (null by default)
  12908. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12909. * @returns the raw texture inside an InternalTexture
  12910. */
  12911. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12912. /**
  12913. * Update a raw texture
  12914. * @param texture defines the texture to update
  12915. * @param data defines the data to store in the texture
  12916. * @param format defines the format of the data
  12917. * @param invertY defines if data must be stored with Y axis inverted
  12918. */
  12919. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12920. /**
  12921. * Update a raw texture
  12922. * @param texture defines the texture to update
  12923. * @param data defines the data to store in the texture
  12924. * @param format defines the format of the data
  12925. * @param invertY defines if data must be stored with Y axis inverted
  12926. * @param compression defines the compression used (null by default)
  12927. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12928. */
  12929. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12930. /**
  12931. * Creates a new raw cube texture
  12932. * @param data defines the array of data to use to create each face
  12933. * @param size defines the size of the textures
  12934. * @param format defines the format of the data
  12935. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12936. * @param generateMipMaps defines if the engine should generate the mip levels
  12937. * @param invertY defines if data must be stored with Y axis inverted
  12938. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12939. * @param compression defines the compression used (null by default)
  12940. * @returns the cube texture as an InternalTexture
  12941. */
  12942. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12943. /**
  12944. * Update a raw cube texture
  12945. * @param texture defines the texture to udpdate
  12946. * @param data defines the data to store
  12947. * @param format defines the data format
  12948. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12949. * @param invertY defines if data must be stored with Y axis inverted
  12950. */
  12951. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12952. /**
  12953. * Update a raw cube texture
  12954. * @param texture defines the texture to udpdate
  12955. * @param data defines the data to store
  12956. * @param format defines the data format
  12957. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12958. * @param invertY defines if data must be stored with Y axis inverted
  12959. * @param compression defines the compression used (null by default)
  12960. */
  12961. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12962. /**
  12963. * Update a raw cube texture
  12964. * @param texture defines the texture to udpdate
  12965. * @param data defines the data to store
  12966. * @param format defines the data format
  12967. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12968. * @param invertY defines if data must be stored with Y axis inverted
  12969. * @param compression defines the compression used (null by default)
  12970. * @param level defines which level of the texture to update
  12971. */
  12972. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12973. /**
  12974. * Creates a new raw cube texture from a specified url
  12975. * @param url defines the url where the data is located
  12976. * @param scene defines the current scene
  12977. * @param size defines the size of the textures
  12978. * @param format defines the format of the data
  12979. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12980. * @param noMipmap defines if the engine should avoid generating the mip levels
  12981. * @param callback defines a callback used to extract texture data from loaded data
  12982. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12983. * @param onLoad defines a callback called when texture is loaded
  12984. * @param onError defines a callback called if there is an error
  12985. * @returns the cube texture as an InternalTexture
  12986. */
  12987. 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;
  12988. /**
  12989. * Creates a new raw cube texture from a specified url
  12990. * @param url defines the url where the data is located
  12991. * @param scene defines the current scene
  12992. * @param size defines the size of the textures
  12993. * @param format defines the format of the data
  12994. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12995. * @param noMipmap defines if the engine should avoid generating the mip levels
  12996. * @param callback defines a callback used to extract texture data from loaded data
  12997. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12998. * @param onLoad defines a callback called when texture is loaded
  12999. * @param onError defines a callback called if there is an error
  13000. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13001. * @param invertY defines if data must be stored with Y axis inverted
  13002. * @returns the cube texture as an InternalTexture
  13003. */
  13004. 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;
  13005. /**
  13006. * Creates a new raw 3D texture
  13007. * @param data defines the data used to create the texture
  13008. * @param width defines the width of the texture
  13009. * @param height defines the height of the texture
  13010. * @param depth defines the depth of the texture
  13011. * @param format defines the format of the texture
  13012. * @param generateMipMaps defines if the engine must generate mip levels
  13013. * @param invertY defines if data must be stored with Y axis inverted
  13014. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13015. * @param compression defines the compressed used (can be null)
  13016. * @param textureType defines the compressed used (can be null)
  13017. * @returns a new raw 3D texture (stored in an InternalTexture)
  13018. */
  13019. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  13020. /**
  13021. * Update a raw 3D texture
  13022. * @param texture defines the texture to update
  13023. * @param data defines the data to store
  13024. * @param format defines the data format
  13025. * @param invertY defines if data must be stored with Y axis inverted
  13026. */
  13027. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  13028. /**
  13029. * Update a raw 3D texture
  13030. * @param texture defines the texture to update
  13031. * @param data defines the data to store
  13032. * @param format defines the data format
  13033. * @param invertY defines if data must be stored with Y axis inverted
  13034. * @param compression defines the used compression (can be null)
  13035. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  13036. */
  13037. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  13038. /**
  13039. * Creates a new raw 2D array texture
  13040. * @param data defines the data used to create the texture
  13041. * @param width defines the width of the texture
  13042. * @param height defines the height of the texture
  13043. * @param depth defines the number of layers of the texture
  13044. * @param format defines the format of the texture
  13045. * @param generateMipMaps defines if the engine must generate mip levels
  13046. * @param invertY defines if data must be stored with Y axis inverted
  13047. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13048. * @param compression defines the compressed used (can be null)
  13049. * @param textureType defines the compressed used (can be null)
  13050. * @returns a new raw 2D array texture (stored in an InternalTexture)
  13051. */
  13052. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  13053. /**
  13054. * Update a raw 2D array texture
  13055. * @param texture defines the texture to update
  13056. * @param data defines the data to store
  13057. * @param format defines the data format
  13058. * @param invertY defines if data must be stored with Y axis inverted
  13059. */
  13060. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  13061. /**
  13062. * Update a raw 2D array texture
  13063. * @param texture defines the texture to update
  13064. * @param data defines the data to store
  13065. * @param format defines the data format
  13066. * @param invertY defines if data must be stored with Y axis inverted
  13067. * @param compression defines the used compression (can be null)
  13068. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  13069. */
  13070. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  13071. }
  13072. }
  13073. }
  13074. declare module "babylonjs/Materials/Textures/rawTexture" {
  13075. import { Scene } from "babylonjs/scene";
  13076. import { Texture } from "babylonjs/Materials/Textures/texture";
  13077. import "babylonjs/Engines/Extensions/engine.rawTexture";
  13078. /**
  13079. * Raw texture can help creating a texture directly from an array of data.
  13080. * This can be super useful if you either get the data from an uncompressed source or
  13081. * if you wish to create your texture pixel by pixel.
  13082. */
  13083. export class RawTexture extends Texture {
  13084. /**
  13085. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13086. */
  13087. format: number;
  13088. private _engine;
  13089. /**
  13090. * Instantiates a new RawTexture.
  13091. * Raw texture can help creating a texture directly from an array of data.
  13092. * This can be super useful if you either get the data from an uncompressed source or
  13093. * if you wish to create your texture pixel by pixel.
  13094. * @param data define the array of data to use to create the texture
  13095. * @param width define the width of the texture
  13096. * @param height define the height of the texture
  13097. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13098. * @param scene define the scene the texture belongs to
  13099. * @param generateMipMaps define whether mip maps should be generated or not
  13100. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13101. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13102. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13103. */
  13104. constructor(data: ArrayBufferView, width: number, height: number,
  13105. /**
  13106. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13107. */
  13108. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  13109. /**
  13110. * Updates the texture underlying data.
  13111. * @param data Define the new data of the texture
  13112. */
  13113. update(data: ArrayBufferView): void;
  13114. /**
  13115. * Creates a luminance texture from some data.
  13116. * @param data Define the texture data
  13117. * @param width Define the width of the texture
  13118. * @param height Define the height of the texture
  13119. * @param scene Define the scene the texture belongs to
  13120. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13121. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13122. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13123. * @returns the luminance texture
  13124. */
  13125. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13126. /**
  13127. * Creates a luminance alpha texture from some data.
  13128. * @param data Define the texture data
  13129. * @param width Define the width of the texture
  13130. * @param height Define the height of the texture
  13131. * @param scene Define the scene the texture belongs to
  13132. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13133. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13134. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13135. * @returns the luminance alpha texture
  13136. */
  13137. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13138. /**
  13139. * Creates an alpha texture from some data.
  13140. * @param data Define the texture data
  13141. * @param width Define the width of the texture
  13142. * @param height Define the height of the texture
  13143. * @param scene Define the scene the texture belongs to
  13144. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13145. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13146. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13147. * @returns the alpha texture
  13148. */
  13149. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13150. /**
  13151. * Creates a RGB texture from some data.
  13152. * @param data Define the texture data
  13153. * @param width Define the width of the texture
  13154. * @param height Define the height of the texture
  13155. * @param scene Define the scene the texture belongs to
  13156. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13157. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13158. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13159. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13160. * @returns the RGB alpha texture
  13161. */
  13162. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13163. /**
  13164. * Creates a RGBA texture from some data.
  13165. * @param data Define the texture data
  13166. * @param width Define the width of the texture
  13167. * @param height Define the height of the texture
  13168. * @param scene Define the scene the texture belongs to
  13169. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13170. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13171. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13172. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13173. * @returns the RGBA texture
  13174. */
  13175. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13176. /**
  13177. * Creates a R texture from some data.
  13178. * @param data Define the texture data
  13179. * @param width Define the width of the texture
  13180. * @param height Define the height of the texture
  13181. * @param scene Define the scene the texture belongs to
  13182. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13183. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13184. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13185. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13186. * @returns the R texture
  13187. */
  13188. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13189. }
  13190. }
  13191. declare module "babylonjs/Maths/math.size" {
  13192. /**
  13193. * Interface for the size containing width and height
  13194. */
  13195. export interface ISize {
  13196. /**
  13197. * Width
  13198. */
  13199. width: number;
  13200. /**
  13201. * Heighht
  13202. */
  13203. height: number;
  13204. }
  13205. /**
  13206. * Size containing widht and height
  13207. */
  13208. export class Size implements ISize {
  13209. /**
  13210. * Width
  13211. */
  13212. width: number;
  13213. /**
  13214. * Height
  13215. */
  13216. height: number;
  13217. /**
  13218. * Creates a Size object from the given width and height (floats).
  13219. * @param width width of the new size
  13220. * @param height height of the new size
  13221. */
  13222. constructor(width: number, height: number);
  13223. /**
  13224. * Returns a string with the Size width and height
  13225. * @returns a string with the Size width and height
  13226. */
  13227. toString(): string;
  13228. /**
  13229. * "Size"
  13230. * @returns the string "Size"
  13231. */
  13232. getClassName(): string;
  13233. /**
  13234. * Returns the Size hash code.
  13235. * @returns a hash code for a unique width and height
  13236. */
  13237. getHashCode(): number;
  13238. /**
  13239. * Updates the current size from the given one.
  13240. * @param src the given size
  13241. */
  13242. copyFrom(src: Size): void;
  13243. /**
  13244. * Updates in place the current Size from the given floats.
  13245. * @param width width of the new size
  13246. * @param height height of the new size
  13247. * @returns the updated Size.
  13248. */
  13249. copyFromFloats(width: number, height: number): Size;
  13250. /**
  13251. * Updates in place the current Size from the given floats.
  13252. * @param width width to set
  13253. * @param height height to set
  13254. * @returns the updated Size.
  13255. */
  13256. set(width: number, height: number): Size;
  13257. /**
  13258. * Multiplies the width and height by numbers
  13259. * @param w factor to multiple the width by
  13260. * @param h factor to multiple the height by
  13261. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  13262. */
  13263. multiplyByFloats(w: number, h: number): Size;
  13264. /**
  13265. * Clones the size
  13266. * @returns a new Size copied from the given one.
  13267. */
  13268. clone(): Size;
  13269. /**
  13270. * True if the current Size and the given one width and height are strictly equal.
  13271. * @param other the other size to compare against
  13272. * @returns True if the current Size and the given one width and height are strictly equal.
  13273. */
  13274. equals(other: Size): boolean;
  13275. /**
  13276. * The surface of the Size : width * height (float).
  13277. */
  13278. get surface(): number;
  13279. /**
  13280. * Create a new size of zero
  13281. * @returns a new Size set to (0.0, 0.0)
  13282. */
  13283. static Zero(): Size;
  13284. /**
  13285. * Sums the width and height of two sizes
  13286. * @param otherSize size to add to this size
  13287. * @returns a new Size set as the addition result of the current Size and the given one.
  13288. */
  13289. add(otherSize: Size): Size;
  13290. /**
  13291. * Subtracts the width and height of two
  13292. * @param otherSize size to subtract to this size
  13293. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13294. */
  13295. subtract(otherSize: Size): Size;
  13296. /**
  13297. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13298. * @param start starting size to lerp between
  13299. * @param end end size to lerp between
  13300. * @param amount amount to lerp between the start and end values
  13301. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13302. */
  13303. static Lerp(start: Size, end: Size, amount: number): Size;
  13304. }
  13305. }
  13306. declare module "babylonjs/Animations/runtimeAnimation" {
  13307. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13308. import { Animatable } from "babylonjs/Animations/animatable";
  13309. import { Scene } from "babylonjs/scene";
  13310. /**
  13311. * Defines a runtime animation
  13312. */
  13313. export class RuntimeAnimation {
  13314. private _events;
  13315. /**
  13316. * The current frame of the runtime animation
  13317. */
  13318. private _currentFrame;
  13319. /**
  13320. * The animation used by the runtime animation
  13321. */
  13322. private _animation;
  13323. /**
  13324. * The target of the runtime animation
  13325. */
  13326. private _target;
  13327. /**
  13328. * The initiating animatable
  13329. */
  13330. private _host;
  13331. /**
  13332. * The original value of the runtime animation
  13333. */
  13334. private _originalValue;
  13335. /**
  13336. * The original blend value of the runtime animation
  13337. */
  13338. private _originalBlendValue;
  13339. /**
  13340. * The offsets cache of the runtime animation
  13341. */
  13342. private _offsetsCache;
  13343. /**
  13344. * The high limits cache of the runtime animation
  13345. */
  13346. private _highLimitsCache;
  13347. /**
  13348. * Specifies if the runtime animation has been stopped
  13349. */
  13350. private _stopped;
  13351. /**
  13352. * The blending factor of the runtime animation
  13353. */
  13354. private _blendingFactor;
  13355. /**
  13356. * The BabylonJS scene
  13357. */
  13358. private _scene;
  13359. /**
  13360. * The current value of the runtime animation
  13361. */
  13362. private _currentValue;
  13363. /** @hidden */
  13364. _animationState: _IAnimationState;
  13365. /**
  13366. * The active target of the runtime animation
  13367. */
  13368. private _activeTargets;
  13369. private _currentActiveTarget;
  13370. private _directTarget;
  13371. /**
  13372. * The target path of the runtime animation
  13373. */
  13374. private _targetPath;
  13375. /**
  13376. * The weight of the runtime animation
  13377. */
  13378. private _weight;
  13379. /**
  13380. * The ratio offset of the runtime animation
  13381. */
  13382. private _ratioOffset;
  13383. /**
  13384. * The previous delay of the runtime animation
  13385. */
  13386. private _previousDelay;
  13387. /**
  13388. * The previous ratio of the runtime animation
  13389. */
  13390. private _previousRatio;
  13391. private _enableBlending;
  13392. private _keys;
  13393. private _minFrame;
  13394. private _maxFrame;
  13395. private _minValue;
  13396. private _maxValue;
  13397. private _targetIsArray;
  13398. /**
  13399. * Gets the current frame of the runtime animation
  13400. */
  13401. get currentFrame(): number;
  13402. /**
  13403. * Gets the weight of the runtime animation
  13404. */
  13405. get weight(): number;
  13406. /**
  13407. * Gets the current value of the runtime animation
  13408. */
  13409. get currentValue(): any;
  13410. /**
  13411. * Gets the target path of the runtime animation
  13412. */
  13413. get targetPath(): string;
  13414. /**
  13415. * Gets the actual target of the runtime animation
  13416. */
  13417. get target(): any;
  13418. /** @hidden */
  13419. _onLoop: () => void;
  13420. /**
  13421. * Create a new RuntimeAnimation object
  13422. * @param target defines the target of the animation
  13423. * @param animation defines the source animation object
  13424. * @param scene defines the hosting scene
  13425. * @param host defines the initiating Animatable
  13426. */
  13427. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13428. private _preparePath;
  13429. /**
  13430. * Gets the animation from the runtime animation
  13431. */
  13432. get animation(): Animation;
  13433. /**
  13434. * Resets the runtime animation to the beginning
  13435. * @param restoreOriginal defines whether to restore the target property to the original value
  13436. */
  13437. reset(restoreOriginal?: boolean): void;
  13438. /**
  13439. * Specifies if the runtime animation is stopped
  13440. * @returns Boolean specifying if the runtime animation is stopped
  13441. */
  13442. isStopped(): boolean;
  13443. /**
  13444. * Disposes of the runtime animation
  13445. */
  13446. dispose(): void;
  13447. /**
  13448. * Apply the interpolated value to the target
  13449. * @param currentValue defines the value computed by the animation
  13450. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13451. */
  13452. setValue(currentValue: any, weight: number): void;
  13453. private _getOriginalValues;
  13454. private _setValue;
  13455. /**
  13456. * Gets the loop pmode of the runtime animation
  13457. * @returns Loop Mode
  13458. */
  13459. private _getCorrectLoopMode;
  13460. /**
  13461. * Move the current animation to a given frame
  13462. * @param frame defines the frame to move to
  13463. */
  13464. goToFrame(frame: number): void;
  13465. /**
  13466. * @hidden Internal use only
  13467. */
  13468. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13469. /**
  13470. * Execute the current animation
  13471. * @param delay defines the delay to add to the current frame
  13472. * @param from defines the lower bound of the animation range
  13473. * @param to defines the upper bound of the animation range
  13474. * @param loop defines if the current animation must loop
  13475. * @param speedRatio defines the current speed ratio
  13476. * @param weight defines the weight of the animation (default is -1 so no weight)
  13477. * @param onLoop optional callback called when animation loops
  13478. * @returns a boolean indicating if the animation is running
  13479. */
  13480. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13481. }
  13482. }
  13483. declare module "babylonjs/Animations/animatable" {
  13484. import { Animation } from "babylonjs/Animations/animation";
  13485. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13486. import { Nullable } from "babylonjs/types";
  13487. import { Observable } from "babylonjs/Misc/observable";
  13488. import { Scene } from "babylonjs/scene";
  13489. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13490. import { Node } from "babylonjs/node";
  13491. /**
  13492. * Class used to store an actual running animation
  13493. */
  13494. export class Animatable {
  13495. /** defines the target object */
  13496. target: any;
  13497. /** defines the starting frame number (default is 0) */
  13498. fromFrame: number;
  13499. /** defines the ending frame number (default is 100) */
  13500. toFrame: number;
  13501. /** defines if the animation must loop (default is false) */
  13502. loopAnimation: boolean;
  13503. /** defines a callback to call when animation ends if it is not looping */
  13504. onAnimationEnd?: (() => void) | null | undefined;
  13505. /** defines a callback to call when animation loops */
  13506. onAnimationLoop?: (() => void) | null | undefined;
  13507. private _localDelayOffset;
  13508. private _pausedDelay;
  13509. private _runtimeAnimations;
  13510. private _paused;
  13511. private _scene;
  13512. private _speedRatio;
  13513. private _weight;
  13514. private _syncRoot;
  13515. /**
  13516. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13517. * This will only apply for non looping animation (default is true)
  13518. */
  13519. disposeOnEnd: boolean;
  13520. /**
  13521. * Gets a boolean indicating if the animation has started
  13522. */
  13523. animationStarted: boolean;
  13524. /**
  13525. * Observer raised when the animation ends
  13526. */
  13527. onAnimationEndObservable: Observable<Animatable>;
  13528. /**
  13529. * Observer raised when the animation loops
  13530. */
  13531. onAnimationLoopObservable: Observable<Animatable>;
  13532. /**
  13533. * Gets the root Animatable used to synchronize and normalize animations
  13534. */
  13535. get syncRoot(): Nullable<Animatable>;
  13536. /**
  13537. * Gets the current frame of the first RuntimeAnimation
  13538. * Used to synchronize Animatables
  13539. */
  13540. get masterFrame(): number;
  13541. /**
  13542. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13543. */
  13544. get weight(): number;
  13545. set weight(value: number);
  13546. /**
  13547. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13548. */
  13549. get speedRatio(): number;
  13550. set speedRatio(value: number);
  13551. /**
  13552. * Creates a new Animatable
  13553. * @param scene defines the hosting scene
  13554. * @param target defines the target object
  13555. * @param fromFrame defines the starting frame number (default is 0)
  13556. * @param toFrame defines the ending frame number (default is 100)
  13557. * @param loopAnimation defines if the animation must loop (default is false)
  13558. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13559. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13560. * @param animations defines a group of animation to add to the new Animatable
  13561. * @param onAnimationLoop defines a callback to call when animation loops
  13562. */
  13563. constructor(scene: Scene,
  13564. /** defines the target object */
  13565. target: any,
  13566. /** defines the starting frame number (default is 0) */
  13567. fromFrame?: number,
  13568. /** defines the ending frame number (default is 100) */
  13569. toFrame?: number,
  13570. /** defines if the animation must loop (default is false) */
  13571. loopAnimation?: boolean, speedRatio?: number,
  13572. /** defines a callback to call when animation ends if it is not looping */
  13573. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13574. /** defines a callback to call when animation loops */
  13575. onAnimationLoop?: (() => void) | null | undefined);
  13576. /**
  13577. * Synchronize and normalize current Animatable with a source Animatable
  13578. * This is useful when using animation weights and when animations are not of the same length
  13579. * @param root defines the root Animatable to synchronize with
  13580. * @returns the current Animatable
  13581. */
  13582. syncWith(root: Animatable): Animatable;
  13583. /**
  13584. * Gets the list of runtime animations
  13585. * @returns an array of RuntimeAnimation
  13586. */
  13587. getAnimations(): RuntimeAnimation[];
  13588. /**
  13589. * Adds more animations to the current animatable
  13590. * @param target defines the target of the animations
  13591. * @param animations defines the new animations to add
  13592. */
  13593. appendAnimations(target: any, animations: Animation[]): void;
  13594. /**
  13595. * Gets the source animation for a specific property
  13596. * @param property defines the propertyu to look for
  13597. * @returns null or the source animation for the given property
  13598. */
  13599. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13600. /**
  13601. * Gets the runtime animation for a specific property
  13602. * @param property defines the propertyu to look for
  13603. * @returns null or the runtime animation for the given property
  13604. */
  13605. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13606. /**
  13607. * Resets the animatable to its original state
  13608. */
  13609. reset(): void;
  13610. /**
  13611. * Allows the animatable to blend with current running animations
  13612. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13613. * @param blendingSpeed defines the blending speed to use
  13614. */
  13615. enableBlending(blendingSpeed: number): void;
  13616. /**
  13617. * Disable animation blending
  13618. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13619. */
  13620. disableBlending(): void;
  13621. /**
  13622. * Jump directly to a given frame
  13623. * @param frame defines the frame to jump to
  13624. */
  13625. goToFrame(frame: number): void;
  13626. /**
  13627. * Pause the animation
  13628. */
  13629. pause(): void;
  13630. /**
  13631. * Restart the animation
  13632. */
  13633. restart(): void;
  13634. private _raiseOnAnimationEnd;
  13635. /**
  13636. * Stop and delete the current animation
  13637. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13638. * @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)
  13639. */
  13640. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13641. /**
  13642. * Wait asynchronously for the animation to end
  13643. * @returns a promise which will be fullfilled when the animation ends
  13644. */
  13645. waitAsync(): Promise<Animatable>;
  13646. /** @hidden */
  13647. _animate(delay: number): boolean;
  13648. }
  13649. module "babylonjs/scene" {
  13650. interface Scene {
  13651. /** @hidden */
  13652. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13653. /** @hidden */
  13654. _processLateAnimationBindingsForMatrices(holder: {
  13655. totalWeight: number;
  13656. animations: RuntimeAnimation[];
  13657. originalValue: Matrix;
  13658. }): any;
  13659. /** @hidden */
  13660. _processLateAnimationBindingsForQuaternions(holder: {
  13661. totalWeight: number;
  13662. animations: RuntimeAnimation[];
  13663. originalValue: Quaternion;
  13664. }, refQuaternion: Quaternion): Quaternion;
  13665. /** @hidden */
  13666. _processLateAnimationBindings(): void;
  13667. /**
  13668. * Will start the animation sequence of a given target
  13669. * @param target defines the target
  13670. * @param from defines from which frame should animation start
  13671. * @param to defines until which frame should animation run.
  13672. * @param weight defines the weight to apply to the animation (1.0 by default)
  13673. * @param loop defines if the animation loops
  13674. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13675. * @param onAnimationEnd defines the function to be executed when the animation ends
  13676. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13677. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13678. * @param onAnimationLoop defines the callback to call when an animation loops
  13679. * @returns the animatable object created for this animation
  13680. */
  13681. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13682. /**
  13683. * Will start the animation sequence of a given target
  13684. * @param target defines the target
  13685. * @param from defines from which frame should animation start
  13686. * @param to defines until which frame should animation run.
  13687. * @param loop defines if the animation loops
  13688. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13689. * @param onAnimationEnd defines the function to be executed when the animation ends
  13690. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13691. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13692. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13693. * @param onAnimationLoop defines the callback to call when an animation loops
  13694. * @returns the animatable object created for this animation
  13695. */
  13696. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13697. /**
  13698. * Will start the animation sequence of a given target and its hierarchy
  13699. * @param target defines the target
  13700. * @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.
  13701. * @param from defines from which frame should animation start
  13702. * @param to defines until which frame should animation run.
  13703. * @param loop defines if the animation loops
  13704. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13705. * @param onAnimationEnd defines the function to be executed when the animation ends
  13706. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13707. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13708. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13709. * @param onAnimationLoop defines the callback to call when an animation loops
  13710. * @returns the list of created animatables
  13711. */
  13712. 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[];
  13713. /**
  13714. * Begin a new animation on a given node
  13715. * @param target defines the target where the animation will take place
  13716. * @param animations defines the list of animations to start
  13717. * @param from defines the initial value
  13718. * @param to defines the final value
  13719. * @param loop defines if you want animation to loop (off by default)
  13720. * @param speedRatio defines the speed ratio to apply to all animations
  13721. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13722. * @param onAnimationLoop defines the callback to call when an animation loops
  13723. * @returns the list of created animatables
  13724. */
  13725. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13726. /**
  13727. * Begin a new animation on a given node and its hierarchy
  13728. * @param target defines the root node where the animation will take place
  13729. * @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.
  13730. * @param animations defines the list of animations to start
  13731. * @param from defines the initial value
  13732. * @param to defines the final value
  13733. * @param loop defines if you want animation to loop (off by default)
  13734. * @param speedRatio defines the speed ratio to apply to all animations
  13735. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13736. * @param onAnimationLoop defines the callback to call when an animation loops
  13737. * @returns the list of animatables created for all nodes
  13738. */
  13739. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13740. /**
  13741. * Gets the animatable associated with a specific target
  13742. * @param target defines the target of the animatable
  13743. * @returns the required animatable if found
  13744. */
  13745. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13746. /**
  13747. * Gets all animatables associated with a given target
  13748. * @param target defines the target to look animatables for
  13749. * @returns an array of Animatables
  13750. */
  13751. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13752. /**
  13753. * Stops and removes all animations that have been applied to the scene
  13754. */
  13755. stopAllAnimations(): void;
  13756. /**
  13757. * Gets the current delta time used by animation engine
  13758. */
  13759. deltaTime: number;
  13760. }
  13761. }
  13762. module "babylonjs/Bones/bone" {
  13763. interface Bone {
  13764. /**
  13765. * Copy an animation range from another bone
  13766. * @param source defines the source bone
  13767. * @param rangeName defines the range name to copy
  13768. * @param frameOffset defines the frame offset
  13769. * @param rescaleAsRequired defines if rescaling must be applied if required
  13770. * @param skelDimensionsRatio defines the scaling ratio
  13771. * @returns true if operation was successful
  13772. */
  13773. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13774. }
  13775. }
  13776. }
  13777. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13778. /**
  13779. * Class used to override all child animations of a given target
  13780. */
  13781. export class AnimationPropertiesOverride {
  13782. /**
  13783. * Gets or sets a value indicating if animation blending must be used
  13784. */
  13785. enableBlending: boolean;
  13786. /**
  13787. * Gets or sets the blending speed to use when enableBlending is true
  13788. */
  13789. blendingSpeed: number;
  13790. /**
  13791. * Gets or sets the default loop mode to use
  13792. */
  13793. loopMode: number;
  13794. }
  13795. }
  13796. declare module "babylonjs/Bones/skeleton" {
  13797. import { Bone } from "babylonjs/Bones/bone";
  13798. import { Observable } from "babylonjs/Misc/observable";
  13799. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13800. import { Scene } from "babylonjs/scene";
  13801. import { Nullable } from "babylonjs/types";
  13802. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13803. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13804. import { Animatable } from "babylonjs/Animations/animatable";
  13805. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13806. import { Animation } from "babylonjs/Animations/animation";
  13807. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13808. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13809. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13810. /**
  13811. * Class used to handle skinning animations
  13812. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13813. */
  13814. export class Skeleton implements IAnimatable {
  13815. /** defines the skeleton name */
  13816. name: string;
  13817. /** defines the skeleton Id */
  13818. id: string;
  13819. /**
  13820. * Defines the list of child bones
  13821. */
  13822. bones: Bone[];
  13823. /**
  13824. * Defines an estimate of the dimension of the skeleton at rest
  13825. */
  13826. dimensionsAtRest: Vector3;
  13827. /**
  13828. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13829. */
  13830. needInitialSkinMatrix: boolean;
  13831. /**
  13832. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13833. */
  13834. overrideMesh: Nullable<AbstractMesh>;
  13835. /**
  13836. * Gets the list of animations attached to this skeleton
  13837. */
  13838. animations: Array<Animation>;
  13839. private _scene;
  13840. private _isDirty;
  13841. private _transformMatrices;
  13842. private _transformMatrixTexture;
  13843. private _meshesWithPoseMatrix;
  13844. private _animatables;
  13845. private _identity;
  13846. private _synchronizedWithMesh;
  13847. private _ranges;
  13848. private _lastAbsoluteTransformsUpdateId;
  13849. private _canUseTextureForBones;
  13850. private _uniqueId;
  13851. /** @hidden */
  13852. _numBonesWithLinkedTransformNode: number;
  13853. /** @hidden */
  13854. _hasWaitingData: Nullable<boolean>;
  13855. /**
  13856. * Specifies if the skeleton should be serialized
  13857. */
  13858. doNotSerialize: boolean;
  13859. private _useTextureToStoreBoneMatrices;
  13860. /**
  13861. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13862. * Please note that this option is not available if the hardware does not support it
  13863. */
  13864. get useTextureToStoreBoneMatrices(): boolean;
  13865. set useTextureToStoreBoneMatrices(value: boolean);
  13866. private _animationPropertiesOverride;
  13867. /**
  13868. * Gets or sets the animation properties override
  13869. */
  13870. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13871. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  13872. /**
  13873. * List of inspectable custom properties (used by the Inspector)
  13874. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13875. */
  13876. inspectableCustomProperties: IInspectable[];
  13877. /**
  13878. * An observable triggered before computing the skeleton's matrices
  13879. */
  13880. onBeforeComputeObservable: Observable<Skeleton>;
  13881. /**
  13882. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13883. */
  13884. get isUsingTextureForMatrices(): boolean;
  13885. /**
  13886. * Gets the unique ID of this skeleton
  13887. */
  13888. get uniqueId(): number;
  13889. /**
  13890. * Creates a new skeleton
  13891. * @param name defines the skeleton name
  13892. * @param id defines the skeleton Id
  13893. * @param scene defines the hosting scene
  13894. */
  13895. constructor(
  13896. /** defines the skeleton name */
  13897. name: string,
  13898. /** defines the skeleton Id */
  13899. id: string, scene: Scene);
  13900. /**
  13901. * Gets the current object class name.
  13902. * @return the class name
  13903. */
  13904. getClassName(): string;
  13905. /**
  13906. * Returns an array containing the root bones
  13907. * @returns an array containing the root bones
  13908. */
  13909. getChildren(): Array<Bone>;
  13910. /**
  13911. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13912. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13913. * @returns a Float32Array containing matrices data
  13914. */
  13915. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13916. /**
  13917. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13918. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13919. * @returns a raw texture containing the data
  13920. */
  13921. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13922. /**
  13923. * Gets the current hosting scene
  13924. * @returns a scene object
  13925. */
  13926. getScene(): Scene;
  13927. /**
  13928. * Gets a string representing the current skeleton data
  13929. * @param fullDetails defines a boolean indicating if we want a verbose version
  13930. * @returns a string representing the current skeleton data
  13931. */
  13932. toString(fullDetails?: boolean): string;
  13933. /**
  13934. * Get bone's index searching by name
  13935. * @param name defines bone's name to search for
  13936. * @return the indice of the bone. Returns -1 if not found
  13937. */
  13938. getBoneIndexByName(name: string): number;
  13939. /**
  13940. * Creater a new animation range
  13941. * @param name defines the name of the range
  13942. * @param from defines the start key
  13943. * @param to defines the end key
  13944. */
  13945. createAnimationRange(name: string, from: number, to: number): void;
  13946. /**
  13947. * Delete a specific animation range
  13948. * @param name defines the name of the range
  13949. * @param deleteFrames defines if frames must be removed as well
  13950. */
  13951. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13952. /**
  13953. * Gets a specific animation range
  13954. * @param name defines the name of the range to look for
  13955. * @returns the requested animation range or null if not found
  13956. */
  13957. getAnimationRange(name: string): Nullable<AnimationRange>;
  13958. /**
  13959. * Gets the list of all animation ranges defined on this skeleton
  13960. * @returns an array
  13961. */
  13962. getAnimationRanges(): Nullable<AnimationRange>[];
  13963. /**
  13964. * Copy animation range from a source skeleton.
  13965. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13966. * @param source defines the source skeleton
  13967. * @param name defines the name of the range to copy
  13968. * @param rescaleAsRequired defines if rescaling must be applied if required
  13969. * @returns true if operation was successful
  13970. */
  13971. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13972. /**
  13973. * Forces the skeleton to go to rest pose
  13974. */
  13975. returnToRest(): void;
  13976. private _getHighestAnimationFrame;
  13977. /**
  13978. * Begin a specific animation range
  13979. * @param name defines the name of the range to start
  13980. * @param loop defines if looping must be turned on (false by default)
  13981. * @param speedRatio defines the speed ratio to apply (1 by default)
  13982. * @param onAnimationEnd defines a callback which will be called when animation will end
  13983. * @returns a new animatable
  13984. */
  13985. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13986. /** @hidden */
  13987. _markAsDirty(): void;
  13988. /** @hidden */
  13989. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13990. /** @hidden */
  13991. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13992. private _computeTransformMatrices;
  13993. /**
  13994. * Build all resources required to render a skeleton
  13995. */
  13996. prepare(): void;
  13997. /**
  13998. * Gets the list of animatables currently running for this skeleton
  13999. * @returns an array of animatables
  14000. */
  14001. getAnimatables(): IAnimatable[];
  14002. /**
  14003. * Clone the current skeleton
  14004. * @param name defines the name of the new skeleton
  14005. * @param id defines the id of the new skeleton
  14006. * @returns the new skeleton
  14007. */
  14008. clone(name: string, id?: string): Skeleton;
  14009. /**
  14010. * Enable animation blending for this skeleton
  14011. * @param blendingSpeed defines the blending speed to apply
  14012. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14013. */
  14014. enableBlending(blendingSpeed?: number): void;
  14015. /**
  14016. * Releases all resources associated with the current skeleton
  14017. */
  14018. dispose(): void;
  14019. /**
  14020. * Serialize the skeleton in a JSON object
  14021. * @returns a JSON object
  14022. */
  14023. serialize(): any;
  14024. /**
  14025. * Creates a new skeleton from serialized data
  14026. * @param parsedSkeleton defines the serialized data
  14027. * @param scene defines the hosting scene
  14028. * @returns a new skeleton
  14029. */
  14030. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  14031. /**
  14032. * Compute all node absolute transforms
  14033. * @param forceUpdate defines if computation must be done even if cache is up to date
  14034. */
  14035. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  14036. /**
  14037. * Gets the root pose matrix
  14038. * @returns a matrix
  14039. */
  14040. getPoseMatrix(): Nullable<Matrix>;
  14041. /**
  14042. * Sorts bones per internal index
  14043. */
  14044. sortBones(): void;
  14045. private _sortBones;
  14046. }
  14047. }
  14048. declare module "babylonjs/Bones/bone" {
  14049. import { Skeleton } from "babylonjs/Bones/skeleton";
  14050. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  14051. import { Nullable } from "babylonjs/types";
  14052. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14053. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14054. import { Node } from "babylonjs/node";
  14055. import { Space } from "babylonjs/Maths/math.axis";
  14056. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  14057. /**
  14058. * Class used to store bone information
  14059. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14060. */
  14061. export class Bone extends Node {
  14062. /**
  14063. * defines the bone name
  14064. */
  14065. name: string;
  14066. private static _tmpVecs;
  14067. private static _tmpQuat;
  14068. private static _tmpMats;
  14069. /**
  14070. * Gets the list of child bones
  14071. */
  14072. children: Bone[];
  14073. /** Gets the animations associated with this bone */
  14074. animations: import("babylonjs/Animations/animation").Animation[];
  14075. /**
  14076. * Gets or sets bone length
  14077. */
  14078. length: number;
  14079. /**
  14080. * @hidden Internal only
  14081. * Set this value to map this bone to a different index in the transform matrices
  14082. * Set this value to -1 to exclude the bone from the transform matrices
  14083. */
  14084. _index: Nullable<number>;
  14085. private _skeleton;
  14086. private _localMatrix;
  14087. private _restPose;
  14088. private _baseMatrix;
  14089. private _absoluteTransform;
  14090. private _invertedAbsoluteTransform;
  14091. private _parent;
  14092. private _scalingDeterminant;
  14093. private _worldTransform;
  14094. private _localScaling;
  14095. private _localRotation;
  14096. private _localPosition;
  14097. private _needToDecompose;
  14098. private _needToCompose;
  14099. /** @hidden */
  14100. _linkedTransformNode: Nullable<TransformNode>;
  14101. /** @hidden */
  14102. _waitingTransformNodeId: Nullable<string>;
  14103. /** @hidden */
  14104. get _matrix(): Matrix;
  14105. /** @hidden */
  14106. set _matrix(value: Matrix);
  14107. /**
  14108. * Create a new bone
  14109. * @param name defines the bone name
  14110. * @param skeleton defines the parent skeleton
  14111. * @param parentBone defines the parent (can be null if the bone is the root)
  14112. * @param localMatrix defines the local matrix
  14113. * @param restPose defines the rest pose matrix
  14114. * @param baseMatrix defines the base matrix
  14115. * @param index defines index of the bone in the hiearchy
  14116. */
  14117. constructor(
  14118. /**
  14119. * defines the bone name
  14120. */
  14121. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14122. /**
  14123. * Gets the current object class name.
  14124. * @return the class name
  14125. */
  14126. getClassName(): string;
  14127. /**
  14128. * Gets the parent skeleton
  14129. * @returns a skeleton
  14130. */
  14131. getSkeleton(): Skeleton;
  14132. /**
  14133. * Gets parent bone
  14134. * @returns a bone or null if the bone is the root of the bone hierarchy
  14135. */
  14136. getParent(): Nullable<Bone>;
  14137. /**
  14138. * Returns an array containing the root bones
  14139. * @returns an array containing the root bones
  14140. */
  14141. getChildren(): Array<Bone>;
  14142. /**
  14143. * Gets the node index in matrix array generated for rendering
  14144. * @returns the node index
  14145. */
  14146. getIndex(): number;
  14147. /**
  14148. * Sets the parent bone
  14149. * @param parent defines the parent (can be null if the bone is the root)
  14150. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14151. */
  14152. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14153. /**
  14154. * Gets the local matrix
  14155. * @returns a matrix
  14156. */
  14157. getLocalMatrix(): Matrix;
  14158. /**
  14159. * Gets the base matrix (initial matrix which remains unchanged)
  14160. * @returns a matrix
  14161. */
  14162. getBaseMatrix(): Matrix;
  14163. /**
  14164. * Gets the rest pose matrix
  14165. * @returns a matrix
  14166. */
  14167. getRestPose(): Matrix;
  14168. /**
  14169. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14170. */
  14171. getWorldMatrix(): Matrix;
  14172. /**
  14173. * Sets the local matrix to rest pose matrix
  14174. */
  14175. returnToRest(): void;
  14176. /**
  14177. * Gets the inverse of the absolute transform matrix.
  14178. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14179. * @returns a matrix
  14180. */
  14181. getInvertedAbsoluteTransform(): Matrix;
  14182. /**
  14183. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14184. * @returns a matrix
  14185. */
  14186. getAbsoluteTransform(): Matrix;
  14187. /**
  14188. * Links with the given transform node.
  14189. * The local matrix of this bone is copied from the transform node every frame.
  14190. * @param transformNode defines the transform node to link to
  14191. */
  14192. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14193. /**
  14194. * Gets the node used to drive the bone's transformation
  14195. * @returns a transform node or null
  14196. */
  14197. getTransformNode(): Nullable<TransformNode>;
  14198. /** Gets or sets current position (in local space) */
  14199. get position(): Vector3;
  14200. set position(newPosition: Vector3);
  14201. /** Gets or sets current rotation (in local space) */
  14202. get rotation(): Vector3;
  14203. set rotation(newRotation: Vector3);
  14204. /** Gets or sets current rotation quaternion (in local space) */
  14205. get rotationQuaternion(): Quaternion;
  14206. set rotationQuaternion(newRotation: Quaternion);
  14207. /** Gets or sets current scaling (in local space) */
  14208. get scaling(): Vector3;
  14209. set scaling(newScaling: Vector3);
  14210. /**
  14211. * Gets the animation properties override
  14212. */
  14213. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14214. private _decompose;
  14215. private _compose;
  14216. /**
  14217. * Update the base and local matrices
  14218. * @param matrix defines the new base or local matrix
  14219. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14220. * @param updateLocalMatrix defines if the local matrix should be updated
  14221. */
  14222. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14223. /** @hidden */
  14224. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14225. /**
  14226. * Flag the bone as dirty (Forcing it to update everything)
  14227. */
  14228. markAsDirty(): void;
  14229. /** @hidden */
  14230. _markAsDirtyAndCompose(): void;
  14231. private _markAsDirtyAndDecompose;
  14232. /**
  14233. * Translate the bone in local or world space
  14234. * @param vec The amount to translate the bone
  14235. * @param space The space that the translation is in
  14236. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14237. */
  14238. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14239. /**
  14240. * Set the postion of the bone in local or world space
  14241. * @param position The position to set the bone
  14242. * @param space The space that the position is in
  14243. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14244. */
  14245. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14246. /**
  14247. * Set the absolute position of the bone (world space)
  14248. * @param position The position to set the bone
  14249. * @param mesh The mesh that this bone is attached to
  14250. */
  14251. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14252. /**
  14253. * Scale the bone on the x, y and z axes (in local space)
  14254. * @param x The amount to scale the bone on the x axis
  14255. * @param y The amount to scale the bone on the y axis
  14256. * @param z The amount to scale the bone on the z axis
  14257. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14258. */
  14259. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14260. /**
  14261. * Set the bone scaling in local space
  14262. * @param scale defines the scaling vector
  14263. */
  14264. setScale(scale: Vector3): void;
  14265. /**
  14266. * Gets the current scaling in local space
  14267. * @returns the current scaling vector
  14268. */
  14269. getScale(): Vector3;
  14270. /**
  14271. * Gets the current scaling in local space and stores it in a target vector
  14272. * @param result defines the target vector
  14273. */
  14274. getScaleToRef(result: Vector3): void;
  14275. /**
  14276. * Set the yaw, pitch, and roll of the bone in local or world space
  14277. * @param yaw The rotation of the bone on the y axis
  14278. * @param pitch The rotation of the bone on the x axis
  14279. * @param roll The rotation of the bone on the z axis
  14280. * @param space The space that the axes of rotation are in
  14281. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14282. */
  14283. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14284. /**
  14285. * Add a rotation to the bone on an axis in local or world space
  14286. * @param axis The axis to rotate the bone on
  14287. * @param amount The amount to rotate the bone
  14288. * @param space The space that the axis is in
  14289. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14290. */
  14291. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14292. /**
  14293. * Set the rotation of the bone to a particular axis angle in local or world space
  14294. * @param axis The axis to rotate the bone on
  14295. * @param angle The angle that the bone should be rotated to
  14296. * @param space The space that the axis is in
  14297. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14298. */
  14299. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14300. /**
  14301. * Set the euler rotation of the bone in local of world space
  14302. * @param rotation The euler rotation that the bone should be set to
  14303. * @param space The space that the rotation is in
  14304. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14305. */
  14306. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14307. /**
  14308. * Set the quaternion rotation of the bone in local of world space
  14309. * @param quat The quaternion rotation that the bone should be set to
  14310. * @param space The space that the rotation is in
  14311. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14312. */
  14313. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14314. /**
  14315. * Set the rotation matrix of the bone in local of world space
  14316. * @param rotMat The rotation matrix that the bone should be set to
  14317. * @param space The space that the rotation is in
  14318. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14319. */
  14320. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14321. private _rotateWithMatrix;
  14322. private _getNegativeRotationToRef;
  14323. /**
  14324. * Get the position of the bone in local or world space
  14325. * @param space The space that the returned position is in
  14326. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14327. * @returns The position of the bone
  14328. */
  14329. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14330. /**
  14331. * Copy the position of the bone to a vector3 in local or world space
  14332. * @param space The space that the returned position is in
  14333. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14334. * @param result The vector3 to copy the position to
  14335. */
  14336. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14337. /**
  14338. * Get the absolute position of the bone (world space)
  14339. * @param mesh The mesh that this bone is attached to
  14340. * @returns The absolute position of the bone
  14341. */
  14342. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14343. /**
  14344. * Copy the absolute position of the bone (world space) to the result param
  14345. * @param mesh The mesh that this bone is attached to
  14346. * @param result The vector3 to copy the absolute position to
  14347. */
  14348. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14349. /**
  14350. * Compute the absolute transforms of this bone and its children
  14351. */
  14352. computeAbsoluteTransforms(): void;
  14353. /**
  14354. * Get the world direction from an axis that is in the local space of the bone
  14355. * @param localAxis The local direction that is used to compute the world direction
  14356. * @param mesh The mesh that this bone is attached to
  14357. * @returns The world direction
  14358. */
  14359. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14360. /**
  14361. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14362. * @param localAxis The local direction that is used to compute the world direction
  14363. * @param mesh The mesh that this bone is attached to
  14364. * @param result The vector3 that the world direction will be copied to
  14365. */
  14366. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14367. /**
  14368. * Get the euler rotation of the bone in local or world space
  14369. * @param space The space that the rotation should be in
  14370. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14371. * @returns The euler rotation
  14372. */
  14373. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14374. /**
  14375. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14376. * @param space The space that the rotation should be in
  14377. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14378. * @param result The vector3 that the rotation should be copied to
  14379. */
  14380. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14381. /**
  14382. * Get the quaternion rotation of the bone in either local or world space
  14383. * @param space The space that the rotation should be in
  14384. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14385. * @returns The quaternion rotation
  14386. */
  14387. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14388. /**
  14389. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14390. * @param space The space that the rotation should be in
  14391. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14392. * @param result The quaternion that the rotation should be copied to
  14393. */
  14394. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14395. /**
  14396. * Get the rotation matrix of the bone in local or world space
  14397. * @param space The space that the rotation should be in
  14398. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14399. * @returns The rotation matrix
  14400. */
  14401. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14402. /**
  14403. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14404. * @param space The space that the rotation should be in
  14405. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14406. * @param result The quaternion that the rotation should be copied to
  14407. */
  14408. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14409. /**
  14410. * Get the world position of a point that is in the local space of the bone
  14411. * @param position The local position
  14412. * @param mesh The mesh that this bone is attached to
  14413. * @returns The world position
  14414. */
  14415. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14416. /**
  14417. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14418. * @param position The local position
  14419. * @param mesh The mesh that this bone is attached to
  14420. * @param result The vector3 that the world position should be copied to
  14421. */
  14422. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14423. /**
  14424. * Get the local position of a point that is in world space
  14425. * @param position The world position
  14426. * @param mesh The mesh that this bone is attached to
  14427. * @returns The local position
  14428. */
  14429. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14430. /**
  14431. * Get the local position of a point that is in world space and copy it to the result param
  14432. * @param position The world position
  14433. * @param mesh The mesh that this bone is attached to
  14434. * @param result The vector3 that the local position should be copied to
  14435. */
  14436. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14437. }
  14438. }
  14439. declare module "babylonjs/Meshes/transformNode" {
  14440. import { DeepImmutable } from "babylonjs/types";
  14441. import { Observable } from "babylonjs/Misc/observable";
  14442. import { Nullable } from "babylonjs/types";
  14443. import { Camera } from "babylonjs/Cameras/camera";
  14444. import { Scene } from "babylonjs/scene";
  14445. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14446. import { Node } from "babylonjs/node";
  14447. import { Bone } from "babylonjs/Bones/bone";
  14448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14449. import { Space } from "babylonjs/Maths/math.axis";
  14450. /**
  14451. * 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.
  14452. * @see https://doc.babylonjs.com/how_to/transformnode
  14453. */
  14454. export class TransformNode extends Node {
  14455. /**
  14456. * Object will not rotate to face the camera
  14457. */
  14458. static BILLBOARDMODE_NONE: number;
  14459. /**
  14460. * Object will rotate to face the camera but only on the x axis
  14461. */
  14462. static BILLBOARDMODE_X: number;
  14463. /**
  14464. * Object will rotate to face the camera but only on the y axis
  14465. */
  14466. static BILLBOARDMODE_Y: number;
  14467. /**
  14468. * Object will rotate to face the camera but only on the z axis
  14469. */
  14470. static BILLBOARDMODE_Z: number;
  14471. /**
  14472. * Object will rotate to face the camera
  14473. */
  14474. static BILLBOARDMODE_ALL: number;
  14475. /**
  14476. * Object will rotate to face the camera's position instead of orientation
  14477. */
  14478. static BILLBOARDMODE_USE_POSITION: number;
  14479. private _forward;
  14480. private _forwardInverted;
  14481. private _up;
  14482. private _right;
  14483. private _rightInverted;
  14484. private _position;
  14485. private _rotation;
  14486. private _rotationQuaternion;
  14487. protected _scaling: Vector3;
  14488. protected _isDirty: boolean;
  14489. private _transformToBoneReferal;
  14490. private _isAbsoluteSynced;
  14491. private _billboardMode;
  14492. /**
  14493. * Gets or sets the billboard mode. Default is 0.
  14494. *
  14495. * | Value | Type | Description |
  14496. * | --- | --- | --- |
  14497. * | 0 | BILLBOARDMODE_NONE | |
  14498. * | 1 | BILLBOARDMODE_X | |
  14499. * | 2 | BILLBOARDMODE_Y | |
  14500. * | 4 | BILLBOARDMODE_Z | |
  14501. * | 7 | BILLBOARDMODE_ALL | |
  14502. *
  14503. */
  14504. get billboardMode(): number;
  14505. set billboardMode(value: number);
  14506. private _preserveParentRotationForBillboard;
  14507. /**
  14508. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14509. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14510. */
  14511. get preserveParentRotationForBillboard(): boolean;
  14512. set preserveParentRotationForBillboard(value: boolean);
  14513. /**
  14514. * 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
  14515. */
  14516. scalingDeterminant: number;
  14517. private _infiniteDistance;
  14518. /**
  14519. * Gets or sets the distance of the object to max, often used by skybox
  14520. */
  14521. get infiniteDistance(): boolean;
  14522. set infiniteDistance(value: boolean);
  14523. /**
  14524. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14525. * By default the system will update normals to compensate
  14526. */
  14527. ignoreNonUniformScaling: boolean;
  14528. /**
  14529. * 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
  14530. */
  14531. reIntegrateRotationIntoRotationQuaternion: boolean;
  14532. /** @hidden */
  14533. _poseMatrix: Nullable<Matrix>;
  14534. /** @hidden */
  14535. _localMatrix: Matrix;
  14536. private _usePivotMatrix;
  14537. private _absolutePosition;
  14538. private _absoluteScaling;
  14539. private _absoluteRotationQuaternion;
  14540. private _pivotMatrix;
  14541. private _pivotMatrixInverse;
  14542. protected _postMultiplyPivotMatrix: boolean;
  14543. protected _isWorldMatrixFrozen: boolean;
  14544. /** @hidden */
  14545. _indexInSceneTransformNodesArray: number;
  14546. /**
  14547. * An event triggered after the world matrix is updated
  14548. */
  14549. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14550. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14551. /**
  14552. * Gets a string identifying the name of the class
  14553. * @returns "TransformNode" string
  14554. */
  14555. getClassName(): string;
  14556. /**
  14557. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14558. */
  14559. get position(): Vector3;
  14560. set position(newPosition: Vector3);
  14561. /**
  14562. * 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)).
  14563. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14564. */
  14565. get rotation(): Vector3;
  14566. set rotation(newRotation: Vector3);
  14567. /**
  14568. * 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)).
  14569. */
  14570. get scaling(): Vector3;
  14571. set scaling(newScaling: Vector3);
  14572. /**
  14573. * 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).
  14574. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14575. */
  14576. get rotationQuaternion(): Nullable<Quaternion>;
  14577. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14578. /**
  14579. * The forward direction of that transform in world space.
  14580. */
  14581. get forward(): Vector3;
  14582. /**
  14583. * The up direction of that transform in world space.
  14584. */
  14585. get up(): Vector3;
  14586. /**
  14587. * The right direction of that transform in world space.
  14588. */
  14589. get right(): Vector3;
  14590. /**
  14591. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14592. * @param matrix the matrix to copy the pose from
  14593. * @returns this TransformNode.
  14594. */
  14595. updatePoseMatrix(matrix: Matrix): TransformNode;
  14596. /**
  14597. * Returns the mesh Pose matrix.
  14598. * @returns the pose matrix
  14599. */
  14600. getPoseMatrix(): Matrix;
  14601. /** @hidden */
  14602. _isSynchronized(): boolean;
  14603. /** @hidden */
  14604. _initCache(): void;
  14605. /**
  14606. * Flag the transform node as dirty (Forcing it to update everything)
  14607. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14608. * @returns this transform node
  14609. */
  14610. markAsDirty(property: string): TransformNode;
  14611. /**
  14612. * Returns the current mesh absolute position.
  14613. * Returns a Vector3.
  14614. */
  14615. get absolutePosition(): Vector3;
  14616. /**
  14617. * Returns the current mesh absolute scaling.
  14618. * Returns a Vector3.
  14619. */
  14620. get absoluteScaling(): Vector3;
  14621. /**
  14622. * Returns the current mesh absolute rotation.
  14623. * Returns a Quaternion.
  14624. */
  14625. get absoluteRotationQuaternion(): Quaternion;
  14626. /**
  14627. * Sets a new matrix to apply before all other transformation
  14628. * @param matrix defines the transform matrix
  14629. * @returns the current TransformNode
  14630. */
  14631. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14632. /**
  14633. * Sets a new pivot matrix to the current node
  14634. * @param matrix defines the new pivot matrix to use
  14635. * @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
  14636. * @returns the current TransformNode
  14637. */
  14638. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14639. /**
  14640. * Returns the mesh pivot matrix.
  14641. * Default : Identity.
  14642. * @returns the matrix
  14643. */
  14644. getPivotMatrix(): Matrix;
  14645. /**
  14646. * Instantiate (when possible) or clone that node with its hierarchy
  14647. * @param newParent defines the new parent to use for the instance (or clone)
  14648. * @param options defines options to configure how copy is done
  14649. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14650. * @returns an instance (or a clone) of the current node with its hiearchy
  14651. */
  14652. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14653. doNotInstantiate: boolean;
  14654. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14655. /**
  14656. * Prevents the World matrix to be computed any longer
  14657. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14658. * @returns the TransformNode.
  14659. */
  14660. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14661. /**
  14662. * Allows back the World matrix computation.
  14663. * @returns the TransformNode.
  14664. */
  14665. unfreezeWorldMatrix(): this;
  14666. /**
  14667. * True if the World matrix has been frozen.
  14668. */
  14669. get isWorldMatrixFrozen(): boolean;
  14670. /**
  14671. * Retuns the mesh absolute position in the World.
  14672. * @returns a Vector3.
  14673. */
  14674. getAbsolutePosition(): Vector3;
  14675. /**
  14676. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14677. * @param absolutePosition the absolute position to set
  14678. * @returns the TransformNode.
  14679. */
  14680. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14681. /**
  14682. * Sets the mesh position in its local space.
  14683. * @param vector3 the position to set in localspace
  14684. * @returns the TransformNode.
  14685. */
  14686. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14687. /**
  14688. * Returns the mesh position in the local space from the current World matrix values.
  14689. * @returns a new Vector3.
  14690. */
  14691. getPositionExpressedInLocalSpace(): Vector3;
  14692. /**
  14693. * Translates the mesh along the passed Vector3 in its local space.
  14694. * @param vector3 the distance to translate in localspace
  14695. * @returns the TransformNode.
  14696. */
  14697. locallyTranslate(vector3: Vector3): TransformNode;
  14698. private static _lookAtVectorCache;
  14699. /**
  14700. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14701. * @param targetPoint the position (must be in same space as current mesh) to look at
  14702. * @param yawCor optional yaw (y-axis) correction in radians
  14703. * @param pitchCor optional pitch (x-axis) correction in radians
  14704. * @param rollCor optional roll (z-axis) correction in radians
  14705. * @param space the choosen space of the target
  14706. * @returns the TransformNode.
  14707. */
  14708. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14709. /**
  14710. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14711. * This Vector3 is expressed in the World space.
  14712. * @param localAxis axis to rotate
  14713. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14714. */
  14715. getDirection(localAxis: Vector3): Vector3;
  14716. /**
  14717. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14718. * localAxis is expressed in the mesh local space.
  14719. * result is computed in the Wordl space from the mesh World matrix.
  14720. * @param localAxis axis to rotate
  14721. * @param result the resulting transformnode
  14722. * @returns this TransformNode.
  14723. */
  14724. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14725. /**
  14726. * Sets this transform node rotation to the given local axis.
  14727. * @param localAxis the axis in local space
  14728. * @param yawCor optional yaw (y-axis) correction in radians
  14729. * @param pitchCor optional pitch (x-axis) correction in radians
  14730. * @param rollCor optional roll (z-axis) correction in radians
  14731. * @returns this TransformNode
  14732. */
  14733. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14734. /**
  14735. * Sets a new pivot point to the current node
  14736. * @param point defines the new pivot point to use
  14737. * @param space defines if the point is in world or local space (local by default)
  14738. * @returns the current TransformNode
  14739. */
  14740. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14741. /**
  14742. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14743. * @returns the pivot point
  14744. */
  14745. getPivotPoint(): Vector3;
  14746. /**
  14747. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14748. * @param result the vector3 to store the result
  14749. * @returns this TransformNode.
  14750. */
  14751. getPivotPointToRef(result: Vector3): TransformNode;
  14752. /**
  14753. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14754. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14755. */
  14756. getAbsolutePivotPoint(): Vector3;
  14757. /**
  14758. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14759. * @param result vector3 to store the result
  14760. * @returns this TransformNode.
  14761. */
  14762. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14763. /**
  14764. * Defines the passed node as the parent of the current node.
  14765. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14766. * @see https://doc.babylonjs.com/how_to/parenting
  14767. * @param node the node ot set as the parent
  14768. * @returns this TransformNode.
  14769. */
  14770. setParent(node: Nullable<Node>): TransformNode;
  14771. private _nonUniformScaling;
  14772. /**
  14773. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14774. */
  14775. get nonUniformScaling(): boolean;
  14776. /** @hidden */
  14777. _updateNonUniformScalingState(value: boolean): boolean;
  14778. /**
  14779. * Attach the current TransformNode to another TransformNode associated with a bone
  14780. * @param bone Bone affecting the TransformNode
  14781. * @param affectedTransformNode TransformNode associated with the bone
  14782. * @returns this object
  14783. */
  14784. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14785. /**
  14786. * Detach the transform node if its associated with a bone
  14787. * @returns this object
  14788. */
  14789. detachFromBone(): TransformNode;
  14790. private static _rotationAxisCache;
  14791. /**
  14792. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14793. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14794. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14795. * The passed axis is also normalized.
  14796. * @param axis the axis to rotate around
  14797. * @param amount the amount to rotate in radians
  14798. * @param space Space to rotate in (Default: local)
  14799. * @returns the TransformNode.
  14800. */
  14801. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14802. /**
  14803. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14804. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14805. * The passed axis is also normalized. .
  14806. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14807. * @param point the point to rotate around
  14808. * @param axis the axis to rotate around
  14809. * @param amount the amount to rotate in radians
  14810. * @returns the TransformNode
  14811. */
  14812. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14813. /**
  14814. * Translates the mesh along the axis vector for the passed distance in the given space.
  14815. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14816. * @param axis the axis to translate in
  14817. * @param distance the distance to translate
  14818. * @param space Space to rotate in (Default: local)
  14819. * @returns the TransformNode.
  14820. */
  14821. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14822. /**
  14823. * Adds a rotation step to the mesh current rotation.
  14824. * x, y, z are Euler angles expressed in radians.
  14825. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14826. * This means this rotation is made in the mesh local space only.
  14827. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14828. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14829. * ```javascript
  14830. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14831. * ```
  14832. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14833. * 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.
  14834. * @param x Rotation to add
  14835. * @param y Rotation to add
  14836. * @param z Rotation to add
  14837. * @returns the TransformNode.
  14838. */
  14839. addRotation(x: number, y: number, z: number): TransformNode;
  14840. /**
  14841. * @hidden
  14842. */
  14843. protected _getEffectiveParent(): Nullable<Node>;
  14844. /**
  14845. * Computes the world matrix of the node
  14846. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14847. * @returns the world matrix
  14848. */
  14849. computeWorldMatrix(force?: boolean): Matrix;
  14850. /**
  14851. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14852. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14853. */
  14854. resetLocalMatrix(independentOfChildren?: boolean): void;
  14855. protected _afterComputeWorldMatrix(): void;
  14856. /**
  14857. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14858. * @param func callback function to add
  14859. *
  14860. * @returns the TransformNode.
  14861. */
  14862. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14863. /**
  14864. * Removes a registered callback function.
  14865. * @param func callback function to remove
  14866. * @returns the TransformNode.
  14867. */
  14868. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14869. /**
  14870. * Gets the position of the current mesh in camera space
  14871. * @param camera defines the camera to use
  14872. * @returns a position
  14873. */
  14874. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14875. /**
  14876. * Returns the distance from the mesh to the active camera
  14877. * @param camera defines the camera to use
  14878. * @returns the distance
  14879. */
  14880. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14881. /**
  14882. * Clone the current transform node
  14883. * @param name Name of the new clone
  14884. * @param newParent New parent for the clone
  14885. * @param doNotCloneChildren Do not clone children hierarchy
  14886. * @returns the new transform node
  14887. */
  14888. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14889. /**
  14890. * Serializes the objects information.
  14891. * @param currentSerializationObject defines the object to serialize in
  14892. * @returns the serialized object
  14893. */
  14894. serialize(currentSerializationObject?: any): any;
  14895. /**
  14896. * Returns a new TransformNode object parsed from the source provided.
  14897. * @param parsedTransformNode is the source.
  14898. * @param scene the scne the object belongs to
  14899. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14900. * @returns a new TransformNode object parsed from the source provided.
  14901. */
  14902. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14903. /**
  14904. * Get all child-transformNodes of this node
  14905. * @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
  14906. * @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
  14907. * @returns an array of TransformNode
  14908. */
  14909. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14910. /**
  14911. * Releases resources associated with this transform node.
  14912. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14913. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14914. */
  14915. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14916. /**
  14917. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14918. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14919. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14920. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14921. * @returns the current mesh
  14922. */
  14923. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14924. private _syncAbsoluteScalingAndRotation;
  14925. }
  14926. }
  14927. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14928. import { Observable } from "babylonjs/Misc/observable";
  14929. import { Nullable } from "babylonjs/types";
  14930. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14931. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14932. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14933. import { Ray } from "babylonjs/Culling/ray";
  14934. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14935. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14936. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14937. /**
  14938. * Defines the types of pose enabled controllers that are supported
  14939. */
  14940. export enum PoseEnabledControllerType {
  14941. /**
  14942. * HTC Vive
  14943. */
  14944. VIVE = 0,
  14945. /**
  14946. * Oculus Rift
  14947. */
  14948. OCULUS = 1,
  14949. /**
  14950. * Windows mixed reality
  14951. */
  14952. WINDOWS = 2,
  14953. /**
  14954. * Samsung gear VR
  14955. */
  14956. GEAR_VR = 3,
  14957. /**
  14958. * Google Daydream
  14959. */
  14960. DAYDREAM = 4,
  14961. /**
  14962. * Generic
  14963. */
  14964. GENERIC = 5
  14965. }
  14966. /**
  14967. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14968. */
  14969. export interface MutableGamepadButton {
  14970. /**
  14971. * Value of the button/trigger
  14972. */
  14973. value: number;
  14974. /**
  14975. * If the button/trigger is currently touched
  14976. */
  14977. touched: boolean;
  14978. /**
  14979. * If the button/trigger is currently pressed
  14980. */
  14981. pressed: boolean;
  14982. }
  14983. /**
  14984. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14985. * @hidden
  14986. */
  14987. export interface ExtendedGamepadButton extends GamepadButton {
  14988. /**
  14989. * If the button/trigger is currently pressed
  14990. */
  14991. readonly pressed: boolean;
  14992. /**
  14993. * If the button/trigger is currently touched
  14994. */
  14995. readonly touched: boolean;
  14996. /**
  14997. * Value of the button/trigger
  14998. */
  14999. readonly value: number;
  15000. }
  15001. /** @hidden */
  15002. export interface _GamePadFactory {
  15003. /**
  15004. * Returns whether or not the current gamepad can be created for this type of controller.
  15005. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  15006. * @returns true if it can be created, otherwise false
  15007. */
  15008. canCreate(gamepadInfo: any): boolean;
  15009. /**
  15010. * Creates a new instance of the Gamepad.
  15011. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  15012. * @returns the new gamepad instance
  15013. */
  15014. create(gamepadInfo: any): Gamepad;
  15015. }
  15016. /**
  15017. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  15018. */
  15019. export class PoseEnabledControllerHelper {
  15020. /** @hidden */
  15021. static _ControllerFactories: _GamePadFactory[];
  15022. /** @hidden */
  15023. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  15024. /**
  15025. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  15026. * @param vrGamepad the gamepad to initialized
  15027. * @returns a vr controller of the type the gamepad identified as
  15028. */
  15029. static InitiateController(vrGamepad: any): Gamepad;
  15030. }
  15031. /**
  15032. * Defines the PoseEnabledController object that contains state of a vr capable controller
  15033. */
  15034. export class PoseEnabledController extends Gamepad implements PoseControlled {
  15035. /**
  15036. * If the controller is used in a webXR session
  15037. */
  15038. isXR: boolean;
  15039. private _deviceRoomPosition;
  15040. private _deviceRoomRotationQuaternion;
  15041. /**
  15042. * The device position in babylon space
  15043. */
  15044. devicePosition: Vector3;
  15045. /**
  15046. * The device rotation in babylon space
  15047. */
  15048. deviceRotationQuaternion: Quaternion;
  15049. /**
  15050. * The scale factor of the device in babylon space
  15051. */
  15052. deviceScaleFactor: number;
  15053. /**
  15054. * (Likely devicePosition should be used instead) The device position in its room space
  15055. */
  15056. position: Vector3;
  15057. /**
  15058. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  15059. */
  15060. rotationQuaternion: Quaternion;
  15061. /**
  15062. * The type of controller (Eg. Windows mixed reality)
  15063. */
  15064. controllerType: PoseEnabledControllerType;
  15065. protected _calculatedPosition: Vector3;
  15066. private _calculatedRotation;
  15067. /**
  15068. * The raw pose from the device
  15069. */
  15070. rawPose: DevicePose;
  15071. private _trackPosition;
  15072. private _maxRotationDistFromHeadset;
  15073. private _draggedRoomRotation;
  15074. /**
  15075. * @hidden
  15076. */
  15077. _disableTrackPosition(fixedPosition: Vector3): void;
  15078. /**
  15079. * Internal, the mesh attached to the controller
  15080. * @hidden
  15081. */
  15082. _mesh: Nullable<AbstractMesh>;
  15083. private _poseControlledCamera;
  15084. private _leftHandSystemQuaternion;
  15085. /**
  15086. * Internal, matrix used to convert room space to babylon space
  15087. * @hidden
  15088. */
  15089. _deviceToWorld: Matrix;
  15090. /**
  15091. * Node to be used when casting a ray from the controller
  15092. * @hidden
  15093. */
  15094. _pointingPoseNode: Nullable<TransformNode>;
  15095. /**
  15096. * Name of the child mesh that can be used to cast a ray from the controller
  15097. */
  15098. static readonly POINTING_POSE: string;
  15099. /**
  15100. * Creates a new PoseEnabledController from a gamepad
  15101. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  15102. */
  15103. constructor(browserGamepad: any);
  15104. private _workingMatrix;
  15105. /**
  15106. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  15107. */
  15108. update(): void;
  15109. /**
  15110. * Updates only the pose device and mesh without doing any button event checking
  15111. */
  15112. protected _updatePoseAndMesh(): void;
  15113. /**
  15114. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  15115. * @param poseData raw pose fromthe device
  15116. */
  15117. updateFromDevice(poseData: DevicePose): void;
  15118. /**
  15119. * @hidden
  15120. */
  15121. _meshAttachedObservable: Observable<AbstractMesh>;
  15122. /**
  15123. * Attaches a mesh to the controller
  15124. * @param mesh the mesh to be attached
  15125. */
  15126. attachToMesh(mesh: AbstractMesh): void;
  15127. /**
  15128. * Attaches the controllers mesh to a camera
  15129. * @param camera the camera the mesh should be attached to
  15130. */
  15131. attachToPoseControlledCamera(camera: TargetCamera): void;
  15132. /**
  15133. * Disposes of the controller
  15134. */
  15135. dispose(): void;
  15136. /**
  15137. * The mesh that is attached to the controller
  15138. */
  15139. get mesh(): Nullable<AbstractMesh>;
  15140. /**
  15141. * Gets the ray of the controller in the direction the controller is pointing
  15142. * @param length the length the resulting ray should be
  15143. * @returns a ray in the direction the controller is pointing
  15144. */
  15145. getForwardRay(length?: number): Ray;
  15146. }
  15147. }
  15148. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  15149. import { Observable } from "babylonjs/Misc/observable";
  15150. import { Scene } from "babylonjs/scene";
  15151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15152. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  15153. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  15154. import { Nullable } from "babylonjs/types";
  15155. /**
  15156. * Defines the WebVRController object that represents controllers tracked in 3D space
  15157. */
  15158. export abstract class WebVRController extends PoseEnabledController {
  15159. /**
  15160. * Internal, the default controller model for the controller
  15161. */
  15162. protected _defaultModel: Nullable<AbstractMesh>;
  15163. /**
  15164. * Fired when the trigger state has changed
  15165. */
  15166. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  15167. /**
  15168. * Fired when the main button state has changed
  15169. */
  15170. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  15171. /**
  15172. * Fired when the secondary button state has changed
  15173. */
  15174. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  15175. /**
  15176. * Fired when the pad state has changed
  15177. */
  15178. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  15179. /**
  15180. * Fired when controllers stick values have changed
  15181. */
  15182. onPadValuesChangedObservable: Observable<StickValues>;
  15183. /**
  15184. * Array of button availible on the controller
  15185. */
  15186. protected _buttons: Array<MutableGamepadButton>;
  15187. private _onButtonStateChange;
  15188. /**
  15189. * Fired when a controller button's state has changed
  15190. * @param callback the callback containing the button that was modified
  15191. */
  15192. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  15193. /**
  15194. * X and Y axis corresponding to the controllers joystick
  15195. */
  15196. pad: StickValues;
  15197. /**
  15198. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  15199. */
  15200. hand: string;
  15201. /**
  15202. * The default controller model for the controller
  15203. */
  15204. get defaultModel(): Nullable<AbstractMesh>;
  15205. /**
  15206. * Creates a new WebVRController from a gamepad
  15207. * @param vrGamepad the gamepad that the WebVRController should be created from
  15208. */
  15209. constructor(vrGamepad: any);
  15210. /**
  15211. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  15212. */
  15213. update(): void;
  15214. /**
  15215. * Function to be called when a button is modified
  15216. */
  15217. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  15218. /**
  15219. * Loads a mesh and attaches it to the controller
  15220. * @param scene the scene the mesh should be added to
  15221. * @param meshLoaded callback for when the mesh has been loaded
  15222. */
  15223. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  15224. private _setButtonValue;
  15225. private _changes;
  15226. private _checkChanges;
  15227. /**
  15228. * Disposes of th webVRCOntroller
  15229. */
  15230. dispose(): void;
  15231. }
  15232. }
  15233. declare module "babylonjs/Lights/hemisphericLight" {
  15234. import { Nullable } from "babylonjs/types";
  15235. import { Scene } from "babylonjs/scene";
  15236. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15237. import { Color3 } from "babylonjs/Maths/math.color";
  15238. import { Effect } from "babylonjs/Materials/effect";
  15239. import { Light } from "babylonjs/Lights/light";
  15240. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  15241. /**
  15242. * The HemisphericLight simulates the ambient environment light,
  15243. * so the passed direction is the light reflection direction, not the incoming direction.
  15244. */
  15245. export class HemisphericLight extends Light {
  15246. /**
  15247. * The groundColor is the light in the opposite direction to the one specified during creation.
  15248. * 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.
  15249. */
  15250. groundColor: Color3;
  15251. /**
  15252. * The light reflection direction, not the incoming direction.
  15253. */
  15254. direction: Vector3;
  15255. /**
  15256. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15257. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15258. * The HemisphericLight can't cast shadows.
  15259. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15260. * @param name The friendly name of the light
  15261. * @param direction The direction of the light reflection
  15262. * @param scene The scene the light belongs to
  15263. */
  15264. constructor(name: string, direction: Vector3, scene: Scene);
  15265. protected _buildUniformLayout(): void;
  15266. /**
  15267. * Returns the string "HemisphericLight".
  15268. * @return The class name
  15269. */
  15270. getClassName(): string;
  15271. /**
  15272. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15273. * Returns the updated direction.
  15274. * @param target The target the direction should point to
  15275. * @return The computed direction
  15276. */
  15277. setDirectionToTarget(target: Vector3): Vector3;
  15278. /**
  15279. * Returns the shadow generator associated to the light.
  15280. * @returns Always null for hemispheric lights because it does not support shadows.
  15281. */
  15282. getShadowGenerator(): Nullable<IShadowGenerator>;
  15283. /**
  15284. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15285. * @param effect The effect to update
  15286. * @param lightIndex The index of the light in the effect to update
  15287. * @returns The hemispheric light
  15288. */
  15289. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15290. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  15291. /**
  15292. * Computes the world matrix of the node
  15293. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15294. * @param useWasUpdatedFlag defines a reserved property
  15295. * @returns the world matrix
  15296. */
  15297. computeWorldMatrix(): Matrix;
  15298. /**
  15299. * Returns the integer 3.
  15300. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15301. */
  15302. getTypeID(): number;
  15303. /**
  15304. * Prepares the list of defines specific to the light type.
  15305. * @param defines the list of defines
  15306. * @param lightIndex defines the index of the light for the effect
  15307. */
  15308. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15309. }
  15310. }
  15311. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  15312. /** @hidden */
  15313. export var vrMultiviewToSingleviewPixelShader: {
  15314. name: string;
  15315. shader: string;
  15316. };
  15317. }
  15318. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15319. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15320. import { Scene } from "babylonjs/scene";
  15321. /**
  15322. * Renders to multiple views with a single draw call
  15323. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15324. */
  15325. export class MultiviewRenderTarget extends RenderTargetTexture {
  15326. /**
  15327. * Creates a multiview render target
  15328. * @param scene scene used with the render target
  15329. * @param size the size of the render target (used for each view)
  15330. */
  15331. constructor(scene: Scene, size?: number | {
  15332. width: number;
  15333. height: number;
  15334. } | {
  15335. ratio: number;
  15336. });
  15337. /**
  15338. * @hidden
  15339. * @param faceIndex the face index, if its a cube texture
  15340. */
  15341. _bindFrameBuffer(faceIndex?: number): void;
  15342. /**
  15343. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15344. * @returns the view count
  15345. */
  15346. getViewCount(): number;
  15347. }
  15348. }
  15349. declare module "babylonjs/Maths/math.frustum" {
  15350. import { Matrix } from "babylonjs/Maths/math.vector";
  15351. import { DeepImmutable } from "babylonjs/types";
  15352. import { Plane } from "babylonjs/Maths/math.plane";
  15353. /**
  15354. * Represents a camera frustum
  15355. */
  15356. export class Frustum {
  15357. /**
  15358. * Gets the planes representing the frustum
  15359. * @param transform matrix to be applied to the returned planes
  15360. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15361. */
  15362. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15363. /**
  15364. * Gets the near frustum plane transformed by the transform matrix
  15365. * @param transform transformation matrix to be applied to the resulting frustum plane
  15366. * @param frustumPlane the resuling frustum plane
  15367. */
  15368. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15369. /**
  15370. * Gets the far frustum plane transformed by the transform matrix
  15371. * @param transform transformation matrix to be applied to the resulting frustum plane
  15372. * @param frustumPlane the resuling frustum plane
  15373. */
  15374. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15375. /**
  15376. * Gets the left frustum plane transformed by the transform matrix
  15377. * @param transform transformation matrix to be applied to the resulting frustum plane
  15378. * @param frustumPlane the resuling frustum plane
  15379. */
  15380. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15381. /**
  15382. * Gets the right frustum plane transformed by the transform matrix
  15383. * @param transform transformation matrix to be applied to the resulting frustum plane
  15384. * @param frustumPlane the resuling frustum plane
  15385. */
  15386. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15387. /**
  15388. * Gets the top frustum plane transformed by the transform matrix
  15389. * @param transform transformation matrix to be applied to the resulting frustum plane
  15390. * @param frustumPlane the resuling frustum plane
  15391. */
  15392. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15393. /**
  15394. * Gets the bottom frustum plane transformed by the transform matrix
  15395. * @param transform transformation matrix to be applied to the resulting frustum plane
  15396. * @param frustumPlane the resuling frustum plane
  15397. */
  15398. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15399. /**
  15400. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15401. * @param transform transformation matrix to be applied to the resulting frustum planes
  15402. * @param frustumPlanes the resuling frustum planes
  15403. */
  15404. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15405. }
  15406. }
  15407. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15408. import { Camera } from "babylonjs/Cameras/camera";
  15409. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15410. import { Nullable } from "babylonjs/types";
  15411. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15412. import { Matrix } from "babylonjs/Maths/math.vector";
  15413. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15414. module "babylonjs/Engines/engine" {
  15415. interface Engine {
  15416. /**
  15417. * Creates a new multiview render target
  15418. * @param width defines the width of the texture
  15419. * @param height defines the height of the texture
  15420. * @returns the created multiview texture
  15421. */
  15422. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15423. /**
  15424. * Binds a multiview framebuffer to be drawn to
  15425. * @param multiviewTexture texture to bind
  15426. */
  15427. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15428. }
  15429. }
  15430. module "babylonjs/Cameras/camera" {
  15431. interface Camera {
  15432. /**
  15433. * @hidden
  15434. * 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)
  15435. */
  15436. _useMultiviewToSingleView: boolean;
  15437. /**
  15438. * @hidden
  15439. * 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)
  15440. */
  15441. _multiviewTexture: Nullable<RenderTargetTexture>;
  15442. /**
  15443. * @hidden
  15444. * ensures the multiview texture of the camera exists and has the specified width/height
  15445. * @param width height to set on the multiview texture
  15446. * @param height width to set on the multiview texture
  15447. */
  15448. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15449. }
  15450. }
  15451. module "babylonjs/scene" {
  15452. interface Scene {
  15453. /** @hidden */
  15454. _transformMatrixR: Matrix;
  15455. /** @hidden */
  15456. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15457. /** @hidden */
  15458. _createMultiviewUbo(): void;
  15459. /** @hidden */
  15460. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15461. /** @hidden */
  15462. _renderMultiviewToSingleView(camera: Camera): void;
  15463. }
  15464. }
  15465. }
  15466. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15467. import { Camera } from "babylonjs/Cameras/camera";
  15468. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15469. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15470. import "babylonjs/Engines/Extensions/engine.multiview";
  15471. /**
  15472. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15473. * This will not be used for webXR as it supports displaying texture arrays directly
  15474. */
  15475. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15476. /**
  15477. * Initializes a VRMultiviewToSingleview
  15478. * @param name name of the post process
  15479. * @param camera camera to be applied to
  15480. * @param scaleFactor scaling factor to the size of the output texture
  15481. */
  15482. constructor(name: string, camera: Camera, scaleFactor: number);
  15483. }
  15484. }
  15485. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15486. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15487. import { Nullable } from "babylonjs/types";
  15488. import { Size } from "babylonjs/Maths/math.size";
  15489. import { Observable } from "babylonjs/Misc/observable";
  15490. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  15491. /**
  15492. * Interface used to define additional presentation attributes
  15493. */
  15494. export interface IVRPresentationAttributes {
  15495. /**
  15496. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15497. */
  15498. highRefreshRate: boolean;
  15499. /**
  15500. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15501. */
  15502. foveationLevel: number;
  15503. }
  15504. module "babylonjs/Engines/engine" {
  15505. interface Engine {
  15506. /** @hidden */
  15507. _vrDisplay: any;
  15508. /** @hidden */
  15509. _vrSupported: boolean;
  15510. /** @hidden */
  15511. _oldSize: Size;
  15512. /** @hidden */
  15513. _oldHardwareScaleFactor: number;
  15514. /** @hidden */
  15515. _vrExclusivePointerMode: boolean;
  15516. /** @hidden */
  15517. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15518. /** @hidden */
  15519. _onVRDisplayPointerRestricted: () => void;
  15520. /** @hidden */
  15521. _onVRDisplayPointerUnrestricted: () => void;
  15522. /** @hidden */
  15523. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15524. /** @hidden */
  15525. _onVrDisplayDisconnect: Nullable<() => void>;
  15526. /** @hidden */
  15527. _onVrDisplayPresentChange: Nullable<() => void>;
  15528. /**
  15529. * Observable signaled when VR display mode changes
  15530. */
  15531. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15532. /**
  15533. * Observable signaled when VR request present is complete
  15534. */
  15535. onVRRequestPresentComplete: Observable<boolean>;
  15536. /**
  15537. * Observable signaled when VR request present starts
  15538. */
  15539. onVRRequestPresentStart: Observable<Engine>;
  15540. /**
  15541. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15542. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15543. */
  15544. isInVRExclusivePointerMode: boolean;
  15545. /**
  15546. * Gets a boolean indicating if a webVR device was detected
  15547. * @returns true if a webVR device was detected
  15548. */
  15549. isVRDevicePresent(): boolean;
  15550. /**
  15551. * Gets the current webVR device
  15552. * @returns the current webVR device (or null)
  15553. */
  15554. getVRDevice(): any;
  15555. /**
  15556. * Initializes a webVR display and starts listening to display change events
  15557. * The onVRDisplayChangedObservable will be notified upon these changes
  15558. * @returns A promise containing a VRDisplay and if vr is supported
  15559. */
  15560. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15561. /** @hidden */
  15562. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15563. /**
  15564. * Gets or sets the presentation attributes used to configure VR rendering
  15565. */
  15566. vrPresentationAttributes?: IVRPresentationAttributes;
  15567. /**
  15568. * Call this function to switch to webVR mode
  15569. * Will do nothing if webVR is not supported or if there is no webVR device
  15570. * @param options the webvr options provided to the camera. mainly used for multiview
  15571. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15572. */
  15573. enableVR(options: WebVROptions): void;
  15574. /** @hidden */
  15575. _onVRFullScreenTriggered(): void;
  15576. }
  15577. }
  15578. }
  15579. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15580. import { Nullable } from "babylonjs/types";
  15581. import { Observable } from "babylonjs/Misc/observable";
  15582. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15583. import { Scene } from "babylonjs/scene";
  15584. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15585. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15586. import { Node } from "babylonjs/node";
  15587. import { Ray } from "babylonjs/Culling/ray";
  15588. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15589. import "babylonjs/Engines/Extensions/engine.webVR";
  15590. /**
  15591. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15592. * IMPORTANT!! The data is right-hand data.
  15593. * @export
  15594. * @interface DevicePose
  15595. */
  15596. export interface DevicePose {
  15597. /**
  15598. * The position of the device, values in array are [x,y,z].
  15599. */
  15600. readonly position: Nullable<Float32Array>;
  15601. /**
  15602. * The linearVelocity of the device, values in array are [x,y,z].
  15603. */
  15604. readonly linearVelocity: Nullable<Float32Array>;
  15605. /**
  15606. * The linearAcceleration of the device, values in array are [x,y,z].
  15607. */
  15608. readonly linearAcceleration: Nullable<Float32Array>;
  15609. /**
  15610. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15611. */
  15612. readonly orientation: Nullable<Float32Array>;
  15613. /**
  15614. * The angularVelocity of the device, values in array are [x,y,z].
  15615. */
  15616. readonly angularVelocity: Nullable<Float32Array>;
  15617. /**
  15618. * The angularAcceleration of the device, values in array are [x,y,z].
  15619. */
  15620. readonly angularAcceleration: Nullable<Float32Array>;
  15621. }
  15622. /**
  15623. * Interface representing a pose controlled object in Babylon.
  15624. * A pose controlled object has both regular pose values as well as pose values
  15625. * from an external device such as a VR head mounted display
  15626. */
  15627. export interface PoseControlled {
  15628. /**
  15629. * The position of the object in babylon space.
  15630. */
  15631. position: Vector3;
  15632. /**
  15633. * The rotation quaternion of the object in babylon space.
  15634. */
  15635. rotationQuaternion: Quaternion;
  15636. /**
  15637. * The position of the device in babylon space.
  15638. */
  15639. devicePosition?: Vector3;
  15640. /**
  15641. * The rotation quaternion of the device in babylon space.
  15642. */
  15643. deviceRotationQuaternion: Quaternion;
  15644. /**
  15645. * The raw pose coming from the device.
  15646. */
  15647. rawPose: Nullable<DevicePose>;
  15648. /**
  15649. * The scale of the device to be used when translating from device space to babylon space.
  15650. */
  15651. deviceScaleFactor: number;
  15652. /**
  15653. * Updates the poseControlled values based on the input device pose.
  15654. * @param poseData the pose data to update the object with
  15655. */
  15656. updateFromDevice(poseData: DevicePose): void;
  15657. }
  15658. /**
  15659. * Set of options to customize the webVRCamera
  15660. */
  15661. export interface WebVROptions {
  15662. /**
  15663. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15664. */
  15665. trackPosition?: boolean;
  15666. /**
  15667. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15668. */
  15669. positionScale?: number;
  15670. /**
  15671. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15672. */
  15673. displayName?: string;
  15674. /**
  15675. * Should the native controller meshes be initialized. (default: true)
  15676. */
  15677. controllerMeshes?: boolean;
  15678. /**
  15679. * Creating a default HemiLight only on controllers. (default: true)
  15680. */
  15681. defaultLightingOnControllers?: boolean;
  15682. /**
  15683. * If you don't want to use the default VR button of the helper. (default: false)
  15684. */
  15685. useCustomVRButton?: boolean;
  15686. /**
  15687. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15688. */
  15689. customVRButton?: HTMLButtonElement;
  15690. /**
  15691. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15692. */
  15693. rayLength?: number;
  15694. /**
  15695. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15696. */
  15697. defaultHeight?: number;
  15698. /**
  15699. * If multiview should be used if availible (default: false)
  15700. */
  15701. useMultiview?: boolean;
  15702. }
  15703. /**
  15704. * This represents a WebVR camera.
  15705. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15706. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15707. */
  15708. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15709. private webVROptions;
  15710. /**
  15711. * @hidden
  15712. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15713. */
  15714. _vrDevice: any;
  15715. /**
  15716. * The rawPose of the vrDevice.
  15717. */
  15718. rawPose: Nullable<DevicePose>;
  15719. private _onVREnabled;
  15720. private _specsVersion;
  15721. private _attached;
  15722. private _frameData;
  15723. protected _descendants: Array<Node>;
  15724. private _deviceRoomPosition;
  15725. /** @hidden */
  15726. _deviceRoomRotationQuaternion: Quaternion;
  15727. private _standingMatrix;
  15728. /**
  15729. * Represents device position in babylon space.
  15730. */
  15731. devicePosition: Vector3;
  15732. /**
  15733. * Represents device rotation in babylon space.
  15734. */
  15735. deviceRotationQuaternion: Quaternion;
  15736. /**
  15737. * The scale of the device to be used when translating from device space to babylon space.
  15738. */
  15739. deviceScaleFactor: number;
  15740. private _deviceToWorld;
  15741. private _worldToDevice;
  15742. /**
  15743. * References to the webVR controllers for the vrDevice.
  15744. */
  15745. controllers: Array<WebVRController>;
  15746. /**
  15747. * Emits an event when a controller is attached.
  15748. */
  15749. onControllersAttachedObservable: Observable<WebVRController[]>;
  15750. /**
  15751. * Emits an event when a controller's mesh has been loaded;
  15752. */
  15753. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15754. /**
  15755. * Emits an event when the HMD's pose has been updated.
  15756. */
  15757. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15758. private _poseSet;
  15759. /**
  15760. * If the rig cameras be used as parent instead of this camera.
  15761. */
  15762. rigParenting: boolean;
  15763. private _lightOnControllers;
  15764. private _defaultHeight?;
  15765. /**
  15766. * Instantiates a WebVRFreeCamera.
  15767. * @param name The name of the WebVRFreeCamera
  15768. * @param position The starting anchor position for the camera
  15769. * @param scene The scene the camera belongs to
  15770. * @param webVROptions a set of customizable options for the webVRCamera
  15771. */
  15772. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15773. /**
  15774. * Gets the device distance from the ground in meters.
  15775. * @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.
  15776. */
  15777. deviceDistanceToRoomGround(): number;
  15778. /**
  15779. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15780. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15781. */
  15782. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15783. /**
  15784. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15785. * @returns A promise with a boolean set to if the standing matrix is supported.
  15786. */
  15787. useStandingMatrixAsync(): Promise<boolean>;
  15788. /**
  15789. * Disposes the camera
  15790. */
  15791. dispose(): void;
  15792. /**
  15793. * Gets a vrController by name.
  15794. * @param name The name of the controller to retreive
  15795. * @returns the controller matching the name specified or null if not found
  15796. */
  15797. getControllerByName(name: string): Nullable<WebVRController>;
  15798. private _leftController;
  15799. /**
  15800. * The controller corresponding to the users left hand.
  15801. */
  15802. get leftController(): Nullable<WebVRController>;
  15803. private _rightController;
  15804. /**
  15805. * The controller corresponding to the users right hand.
  15806. */
  15807. get rightController(): Nullable<WebVRController>;
  15808. /**
  15809. * Casts a ray forward from the vrCamera's gaze.
  15810. * @param length Length of the ray (default: 100)
  15811. * @returns the ray corresponding to the gaze
  15812. */
  15813. getForwardRay(length?: number): Ray;
  15814. /**
  15815. * @hidden
  15816. * Updates the camera based on device's frame data
  15817. */
  15818. _checkInputs(): void;
  15819. /**
  15820. * Updates the poseControlled values based on the input device pose.
  15821. * @param poseData Pose coming from the device
  15822. */
  15823. updateFromDevice(poseData: DevicePose): void;
  15824. private _htmlElementAttached;
  15825. private _detachIfAttached;
  15826. /**
  15827. * WebVR's attach control will start broadcasting frames to the device.
  15828. * Note that in certain browsers (chrome for example) this function must be called
  15829. * within a user-interaction callback. Example:
  15830. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15831. *
  15832. * @param element html element to attach the vrDevice to
  15833. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15834. */
  15835. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15836. /**
  15837. * Detaches the camera from the html element and disables VR
  15838. *
  15839. * @param element html element to detach from
  15840. */
  15841. detachControl(element: HTMLElement): void;
  15842. /**
  15843. * @returns the name of this class
  15844. */
  15845. getClassName(): string;
  15846. /**
  15847. * Calls resetPose on the vrDisplay
  15848. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15849. */
  15850. resetToCurrentRotation(): void;
  15851. /**
  15852. * @hidden
  15853. * Updates the rig cameras (left and right eye)
  15854. */
  15855. _updateRigCameras(): void;
  15856. private _workingVector;
  15857. private _oneVector;
  15858. private _workingMatrix;
  15859. private updateCacheCalled;
  15860. private _correctPositionIfNotTrackPosition;
  15861. /**
  15862. * @hidden
  15863. * Updates the cached values of the camera
  15864. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15865. */
  15866. _updateCache(ignoreParentClass?: boolean): void;
  15867. /**
  15868. * @hidden
  15869. * Get current device position in babylon world
  15870. */
  15871. _computeDevicePosition(): void;
  15872. /**
  15873. * Updates the current device position and rotation in the babylon world
  15874. */
  15875. update(): void;
  15876. /**
  15877. * @hidden
  15878. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15879. * @returns an identity matrix
  15880. */
  15881. _getViewMatrix(): Matrix;
  15882. private _tmpMatrix;
  15883. /**
  15884. * This function is called by the two RIG cameras.
  15885. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15886. * @hidden
  15887. */
  15888. _getWebVRViewMatrix(): Matrix;
  15889. /** @hidden */
  15890. _getWebVRProjectionMatrix(): Matrix;
  15891. private _onGamepadConnectedObserver;
  15892. private _onGamepadDisconnectedObserver;
  15893. private _updateCacheWhenTrackingDisabledObserver;
  15894. /**
  15895. * Initializes the controllers and their meshes
  15896. */
  15897. initControllers(): void;
  15898. }
  15899. }
  15900. declare module "babylonjs/PostProcesses/postProcess" {
  15901. import { Nullable } from "babylonjs/types";
  15902. import { SmartArray } from "babylonjs/Misc/smartArray";
  15903. import { Observable } from "babylonjs/Misc/observable";
  15904. import { Vector2 } from "babylonjs/Maths/math.vector";
  15905. import { Camera } from "babylonjs/Cameras/camera";
  15906. import { Effect } from "babylonjs/Materials/effect";
  15907. import "babylonjs/Shaders/postprocess.vertex";
  15908. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15909. import { Engine } from "babylonjs/Engines/engine";
  15910. import { Color4 } from "babylonjs/Maths/math.color";
  15911. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15912. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15913. /**
  15914. * Size options for a post process
  15915. */
  15916. export type PostProcessOptions = {
  15917. width: number;
  15918. height: number;
  15919. };
  15920. /**
  15921. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15922. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15923. */
  15924. export class PostProcess {
  15925. /** Name of the PostProcess. */
  15926. name: string;
  15927. /**
  15928. * Gets or sets the unique id of the post process
  15929. */
  15930. uniqueId: number;
  15931. /**
  15932. * Width of the texture to apply the post process on
  15933. */
  15934. width: number;
  15935. /**
  15936. * Height of the texture to apply the post process on
  15937. */
  15938. height: number;
  15939. /**
  15940. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15941. * @hidden
  15942. */
  15943. _outputTexture: Nullable<InternalTexture>;
  15944. /**
  15945. * Sampling mode used by the shader
  15946. * See https://doc.babylonjs.com/classes/3.1/texture
  15947. */
  15948. renderTargetSamplingMode: number;
  15949. /**
  15950. * Clear color to use when screen clearing
  15951. */
  15952. clearColor: Color4;
  15953. /**
  15954. * If the buffer needs to be cleared before applying the post process. (default: true)
  15955. * Should be set to false if shader will overwrite all previous pixels.
  15956. */
  15957. autoClear: boolean;
  15958. /**
  15959. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15960. */
  15961. alphaMode: number;
  15962. /**
  15963. * Sets the setAlphaBlendConstants of the babylon engine
  15964. */
  15965. alphaConstants: Color4;
  15966. /**
  15967. * Animations to be used for the post processing
  15968. */
  15969. animations: import("babylonjs/Animations/animation").Animation[];
  15970. /**
  15971. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15972. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15973. */
  15974. enablePixelPerfectMode: boolean;
  15975. /**
  15976. * Force the postprocess to be applied without taking in account viewport
  15977. */
  15978. forceFullscreenViewport: boolean;
  15979. /**
  15980. * List of inspectable custom properties (used by the Inspector)
  15981. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15982. */
  15983. inspectableCustomProperties: IInspectable[];
  15984. /**
  15985. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15986. *
  15987. * | Value | Type | Description |
  15988. * | ----- | ----------------------------------- | ----------- |
  15989. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15990. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15991. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15992. *
  15993. */
  15994. scaleMode: number;
  15995. /**
  15996. * Force textures to be a power of two (default: false)
  15997. */
  15998. alwaysForcePOT: boolean;
  15999. private _samples;
  16000. /**
  16001. * Number of sample textures (default: 1)
  16002. */
  16003. get samples(): number;
  16004. set samples(n: number);
  16005. /**
  16006. * Modify the scale of the post process to be the same as the viewport (default: false)
  16007. */
  16008. adaptScaleToCurrentViewport: boolean;
  16009. private _camera;
  16010. private _scene;
  16011. private _engine;
  16012. private _options;
  16013. private _reusable;
  16014. private _textureType;
  16015. private _textureFormat;
  16016. /**
  16017. * Smart array of input and output textures for the post process.
  16018. * @hidden
  16019. */
  16020. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  16021. /**
  16022. * The index in _textures that corresponds to the output texture.
  16023. * @hidden
  16024. */
  16025. _currentRenderTextureInd: number;
  16026. private _effect;
  16027. private _samplers;
  16028. private _fragmentUrl;
  16029. private _vertexUrl;
  16030. private _parameters;
  16031. private _scaleRatio;
  16032. protected _indexParameters: any;
  16033. private _shareOutputWithPostProcess;
  16034. private _texelSize;
  16035. private _forcedOutputTexture;
  16036. /**
  16037. * Returns the fragment url or shader name used in the post process.
  16038. * @returns the fragment url or name in the shader store.
  16039. */
  16040. getEffectName(): string;
  16041. /**
  16042. * An event triggered when the postprocess is activated.
  16043. */
  16044. onActivateObservable: Observable<Camera>;
  16045. private _onActivateObserver;
  16046. /**
  16047. * A function that is added to the onActivateObservable
  16048. */
  16049. set onActivate(callback: Nullable<(camera: Camera) => void>);
  16050. /**
  16051. * An event triggered when the postprocess changes its size.
  16052. */
  16053. onSizeChangedObservable: Observable<PostProcess>;
  16054. private _onSizeChangedObserver;
  16055. /**
  16056. * A function that is added to the onSizeChangedObservable
  16057. */
  16058. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  16059. /**
  16060. * An event triggered when the postprocess applies its effect.
  16061. */
  16062. onApplyObservable: Observable<Effect>;
  16063. private _onApplyObserver;
  16064. /**
  16065. * A function that is added to the onApplyObservable
  16066. */
  16067. set onApply(callback: (effect: Effect) => void);
  16068. /**
  16069. * An event triggered before rendering the postprocess
  16070. */
  16071. onBeforeRenderObservable: Observable<Effect>;
  16072. private _onBeforeRenderObserver;
  16073. /**
  16074. * A function that is added to the onBeforeRenderObservable
  16075. */
  16076. set onBeforeRender(callback: (effect: Effect) => void);
  16077. /**
  16078. * An event triggered after rendering the postprocess
  16079. */
  16080. onAfterRenderObservable: Observable<Effect>;
  16081. private _onAfterRenderObserver;
  16082. /**
  16083. * A function that is added to the onAfterRenderObservable
  16084. */
  16085. set onAfterRender(callback: (efect: Effect) => void);
  16086. /**
  16087. * 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
  16088. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  16089. */
  16090. get inputTexture(): InternalTexture;
  16091. set inputTexture(value: InternalTexture);
  16092. /**
  16093. * Gets the camera which post process is applied to.
  16094. * @returns The camera the post process is applied to.
  16095. */
  16096. getCamera(): Camera;
  16097. /**
  16098. * Gets the texel size of the postprocess.
  16099. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  16100. */
  16101. get texelSize(): Vector2;
  16102. /**
  16103. * Creates a new instance PostProcess
  16104. * @param name The name of the PostProcess.
  16105. * @param fragmentUrl The url of the fragment shader to be used.
  16106. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  16107. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  16108. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16109. * @param camera The camera to apply the render pass to.
  16110. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16111. * @param engine The engine which the post process will be applied. (default: current engine)
  16112. * @param reusable If the post process can be reused on the same frame. (default: false)
  16113. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  16114. * @param textureType Type of textures used when performing the post process. (default: 0)
  16115. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  16116. * @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
  16117. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  16118. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  16119. */
  16120. constructor(
  16121. /** Name of the PostProcess. */
  16122. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  16123. /**
  16124. * Gets a string idenfifying the name of the class
  16125. * @returns "PostProcess" string
  16126. */
  16127. getClassName(): string;
  16128. /**
  16129. * Gets the engine which this post process belongs to.
  16130. * @returns The engine the post process was enabled with.
  16131. */
  16132. getEngine(): Engine;
  16133. /**
  16134. * The effect that is created when initializing the post process.
  16135. * @returns The created effect corresponding the the postprocess.
  16136. */
  16137. getEffect(): Effect;
  16138. /**
  16139. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  16140. * @param postProcess The post process to share the output with.
  16141. * @returns This post process.
  16142. */
  16143. shareOutputWith(postProcess: PostProcess): PostProcess;
  16144. /**
  16145. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  16146. * This should be called if the post process that shares output with this post process is disabled/disposed.
  16147. */
  16148. useOwnOutput(): void;
  16149. /**
  16150. * Updates the effect with the current post process compile time values and recompiles the shader.
  16151. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16152. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16153. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16154. * @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
  16155. * @param onCompiled Called when the shader has been compiled.
  16156. * @param onError Called if there is an error when compiling a shader.
  16157. */
  16158. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16159. /**
  16160. * The post process is reusable if it can be used multiple times within one frame.
  16161. * @returns If the post process is reusable
  16162. */
  16163. isReusable(): boolean;
  16164. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  16165. markTextureDirty(): void;
  16166. /**
  16167. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  16168. * 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.
  16169. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  16170. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  16171. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  16172. * @returns The target texture that was bound to be written to.
  16173. */
  16174. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  16175. /**
  16176. * If the post process is supported.
  16177. */
  16178. get isSupported(): boolean;
  16179. /**
  16180. * The aspect ratio of the output texture.
  16181. */
  16182. get aspectRatio(): number;
  16183. /**
  16184. * Get a value indicating if the post-process is ready to be used
  16185. * @returns true if the post-process is ready (shader is compiled)
  16186. */
  16187. isReady(): boolean;
  16188. /**
  16189. * Binds all textures and uniforms to the shader, this will be run on every pass.
  16190. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  16191. */
  16192. apply(): Nullable<Effect>;
  16193. private _disposeTextures;
  16194. /**
  16195. * Disposes the post process.
  16196. * @param camera The camera to dispose the post process on.
  16197. */
  16198. dispose(camera?: Camera): void;
  16199. }
  16200. }
  16201. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  16202. /** @hidden */
  16203. export var kernelBlurVaryingDeclaration: {
  16204. name: string;
  16205. shader: string;
  16206. };
  16207. }
  16208. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  16209. /** @hidden */
  16210. export var kernelBlurFragment: {
  16211. name: string;
  16212. shader: string;
  16213. };
  16214. }
  16215. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  16216. /** @hidden */
  16217. export var kernelBlurFragment2: {
  16218. name: string;
  16219. shader: string;
  16220. };
  16221. }
  16222. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  16223. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16224. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  16225. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  16226. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  16227. /** @hidden */
  16228. export var kernelBlurPixelShader: {
  16229. name: string;
  16230. shader: string;
  16231. };
  16232. }
  16233. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  16234. /** @hidden */
  16235. export var kernelBlurVertex: {
  16236. name: string;
  16237. shader: string;
  16238. };
  16239. }
  16240. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  16241. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16242. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  16243. /** @hidden */
  16244. export var kernelBlurVertexShader: {
  16245. name: string;
  16246. shader: string;
  16247. };
  16248. }
  16249. declare module "babylonjs/PostProcesses/blurPostProcess" {
  16250. import { Vector2 } from "babylonjs/Maths/math.vector";
  16251. import { Nullable } from "babylonjs/types";
  16252. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  16253. import { Camera } from "babylonjs/Cameras/camera";
  16254. import { Effect } from "babylonjs/Materials/effect";
  16255. import { Engine } from "babylonjs/Engines/engine";
  16256. import "babylonjs/Shaders/kernelBlur.fragment";
  16257. import "babylonjs/Shaders/kernelBlur.vertex";
  16258. /**
  16259. * The Blur Post Process which blurs an image based on a kernel and direction.
  16260. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  16261. */
  16262. export class BlurPostProcess extends PostProcess {
  16263. /** The direction in which to blur the image. */
  16264. direction: Vector2;
  16265. private blockCompilation;
  16266. protected _kernel: number;
  16267. protected _idealKernel: number;
  16268. protected _packedFloat: boolean;
  16269. private _staticDefines;
  16270. /**
  16271. * Sets the length in pixels of the blur sample region
  16272. */
  16273. set kernel(v: number);
  16274. /**
  16275. * Gets the length in pixels of the blur sample region
  16276. */
  16277. get kernel(): number;
  16278. /**
  16279. * Sets wether or not the blur needs to unpack/repack floats
  16280. */
  16281. set packedFloat(v: boolean);
  16282. /**
  16283. * Gets wether or not the blur is unpacking/repacking floats
  16284. */
  16285. get packedFloat(): boolean;
  16286. /**
  16287. * Creates a new instance BlurPostProcess
  16288. * @param name The name of the effect.
  16289. * @param direction The direction in which to blur the image.
  16290. * @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.
  16291. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16292. * @param camera The camera to apply the render pass to.
  16293. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16294. * @param engine The engine which the post process will be applied. (default: current engine)
  16295. * @param reusable If the post process can be reused on the same frame. (default: false)
  16296. * @param textureType Type of textures used when performing the post process. (default: 0)
  16297. * @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)
  16298. */
  16299. constructor(name: string,
  16300. /** The direction in which to blur the image. */
  16301. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  16302. /**
  16303. * Updates the effect with the current post process compile time values and recompiles the shader.
  16304. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16305. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16306. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16307. * @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
  16308. * @param onCompiled Called when the shader has been compiled.
  16309. * @param onError Called if there is an error when compiling a shader.
  16310. */
  16311. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16312. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16313. /**
  16314. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  16315. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  16316. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  16317. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  16318. * The gaps between physical kernels are compensated for in the weighting of the samples
  16319. * @param idealKernel Ideal blur kernel.
  16320. * @return Nearest best kernel.
  16321. */
  16322. protected _nearestBestKernel(idealKernel: number): number;
  16323. /**
  16324. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  16325. * @param x The point on the Gaussian distribution to sample.
  16326. * @return the value of the Gaussian function at x.
  16327. */
  16328. protected _gaussianWeight(x: number): number;
  16329. /**
  16330. * Generates a string that can be used as a floating point number in GLSL.
  16331. * @param x Value to print.
  16332. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  16333. * @return GLSL float string.
  16334. */
  16335. protected _glslFloat(x: number, decimalFigures?: number): string;
  16336. }
  16337. }
  16338. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  16339. import { Scene } from "babylonjs/scene";
  16340. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16341. import { Plane } from "babylonjs/Maths/math.plane";
  16342. /**
  16343. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16344. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16345. * You can then easily use it as a reflectionTexture on a flat surface.
  16346. * In case the surface is not a plane, please consider relying on reflection probes.
  16347. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16348. */
  16349. export class MirrorTexture extends RenderTargetTexture {
  16350. private scene;
  16351. /**
  16352. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16353. * 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.
  16354. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16355. */
  16356. mirrorPlane: Plane;
  16357. /**
  16358. * Define the blur ratio used to blur the reflection if needed.
  16359. */
  16360. set blurRatio(value: number);
  16361. get blurRatio(): number;
  16362. /**
  16363. * Define the adaptive blur kernel used to blur the reflection if needed.
  16364. * This will autocompute the closest best match for the `blurKernel`
  16365. */
  16366. set adaptiveBlurKernel(value: number);
  16367. /**
  16368. * Define the blur kernel used to blur the reflection if needed.
  16369. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16370. */
  16371. set blurKernel(value: number);
  16372. /**
  16373. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16374. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16375. */
  16376. set blurKernelX(value: number);
  16377. get blurKernelX(): number;
  16378. /**
  16379. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16380. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16381. */
  16382. set blurKernelY(value: number);
  16383. get blurKernelY(): number;
  16384. private _autoComputeBlurKernel;
  16385. protected _onRatioRescale(): void;
  16386. private _updateGammaSpace;
  16387. private _imageProcessingConfigChangeObserver;
  16388. private _transformMatrix;
  16389. private _mirrorMatrix;
  16390. private _savedViewMatrix;
  16391. private _blurX;
  16392. private _blurY;
  16393. private _adaptiveBlurKernel;
  16394. private _blurKernelX;
  16395. private _blurKernelY;
  16396. private _blurRatio;
  16397. /**
  16398. * Instantiates a Mirror Texture.
  16399. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16400. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16401. * You can then easily use it as a reflectionTexture on a flat surface.
  16402. * In case the surface is not a plane, please consider relying on reflection probes.
  16403. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16404. * @param name
  16405. * @param size
  16406. * @param scene
  16407. * @param generateMipMaps
  16408. * @param type
  16409. * @param samplingMode
  16410. * @param generateDepthBuffer
  16411. */
  16412. constructor(name: string, size: number | {
  16413. width: number;
  16414. height: number;
  16415. } | {
  16416. ratio: number;
  16417. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16418. private _preparePostProcesses;
  16419. /**
  16420. * Clone the mirror texture.
  16421. * @returns the cloned texture
  16422. */
  16423. clone(): MirrorTexture;
  16424. /**
  16425. * Serialize the texture to a JSON representation you could use in Parse later on
  16426. * @returns the serialized JSON representation
  16427. */
  16428. serialize(): any;
  16429. /**
  16430. * Dispose the texture and release its associated resources.
  16431. */
  16432. dispose(): void;
  16433. }
  16434. }
  16435. declare module "babylonjs/Materials/Textures/texture" {
  16436. import { Observable } from "babylonjs/Misc/observable";
  16437. import { Nullable } from "babylonjs/types";
  16438. import { Matrix } from "babylonjs/Maths/math.vector";
  16439. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16440. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16441. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16442. import { Scene } from "babylonjs/scene";
  16443. /**
  16444. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16445. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16446. */
  16447. export class Texture extends BaseTexture {
  16448. /**
  16449. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16450. */
  16451. static SerializeBuffers: boolean;
  16452. /** @hidden */
  16453. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16454. /** @hidden */
  16455. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16456. /** @hidden */
  16457. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16458. /** nearest is mag = nearest and min = nearest and mip = linear */
  16459. static readonly NEAREST_SAMPLINGMODE: number;
  16460. /** nearest is mag = nearest and min = nearest and mip = linear */
  16461. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16462. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16463. static readonly BILINEAR_SAMPLINGMODE: number;
  16464. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16465. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16466. /** Trilinear is mag = linear and min = linear and mip = linear */
  16467. static readonly TRILINEAR_SAMPLINGMODE: number;
  16468. /** Trilinear is mag = linear and min = linear and mip = linear */
  16469. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16470. /** mag = nearest and min = nearest and mip = nearest */
  16471. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16472. /** mag = nearest and min = linear and mip = nearest */
  16473. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16474. /** mag = nearest and min = linear and mip = linear */
  16475. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16476. /** mag = nearest and min = linear and mip = none */
  16477. static readonly NEAREST_LINEAR: number;
  16478. /** mag = nearest and min = nearest and mip = none */
  16479. static readonly NEAREST_NEAREST: number;
  16480. /** mag = linear and min = nearest and mip = nearest */
  16481. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16482. /** mag = linear and min = nearest and mip = linear */
  16483. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16484. /** mag = linear and min = linear and mip = none */
  16485. static readonly LINEAR_LINEAR: number;
  16486. /** mag = linear and min = nearest and mip = none */
  16487. static readonly LINEAR_NEAREST: number;
  16488. /** Explicit coordinates mode */
  16489. static readonly EXPLICIT_MODE: number;
  16490. /** Spherical coordinates mode */
  16491. static readonly SPHERICAL_MODE: number;
  16492. /** Planar coordinates mode */
  16493. static readonly PLANAR_MODE: number;
  16494. /** Cubic coordinates mode */
  16495. static readonly CUBIC_MODE: number;
  16496. /** Projection coordinates mode */
  16497. static readonly PROJECTION_MODE: number;
  16498. /** Inverse Cubic coordinates mode */
  16499. static readonly SKYBOX_MODE: number;
  16500. /** Inverse Cubic coordinates mode */
  16501. static readonly INVCUBIC_MODE: number;
  16502. /** Equirectangular coordinates mode */
  16503. static readonly EQUIRECTANGULAR_MODE: number;
  16504. /** Equirectangular Fixed coordinates mode */
  16505. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16506. /** Equirectangular Fixed Mirrored coordinates mode */
  16507. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16508. /** Texture is not repeating outside of 0..1 UVs */
  16509. static readonly CLAMP_ADDRESSMODE: number;
  16510. /** Texture is repeating outside of 0..1 UVs */
  16511. static readonly WRAP_ADDRESSMODE: number;
  16512. /** Texture is repeating and mirrored */
  16513. static readonly MIRROR_ADDRESSMODE: number;
  16514. /**
  16515. * 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
  16516. */
  16517. static UseSerializedUrlIfAny: boolean;
  16518. /**
  16519. * Define the url of the texture.
  16520. */
  16521. url: Nullable<string>;
  16522. /**
  16523. * Define an offset on the texture to offset the u coordinates of the UVs
  16524. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16525. */
  16526. uOffset: number;
  16527. /**
  16528. * Define an offset on the texture to offset the v coordinates of the UVs
  16529. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16530. */
  16531. vOffset: number;
  16532. /**
  16533. * Define an offset on the texture to scale the u coordinates of the UVs
  16534. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16535. */
  16536. uScale: number;
  16537. /**
  16538. * Define an offset on the texture to scale the v coordinates of the UVs
  16539. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16540. */
  16541. vScale: number;
  16542. /**
  16543. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16544. * @see http://doc.babylonjs.com/how_to/more_materials
  16545. */
  16546. uAng: number;
  16547. /**
  16548. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16549. * @see http://doc.babylonjs.com/how_to/more_materials
  16550. */
  16551. vAng: number;
  16552. /**
  16553. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16554. * @see http://doc.babylonjs.com/how_to/more_materials
  16555. */
  16556. wAng: number;
  16557. /**
  16558. * Defines the center of rotation (U)
  16559. */
  16560. uRotationCenter: number;
  16561. /**
  16562. * Defines the center of rotation (V)
  16563. */
  16564. vRotationCenter: number;
  16565. /**
  16566. * Defines the center of rotation (W)
  16567. */
  16568. wRotationCenter: number;
  16569. /**
  16570. * Are mip maps generated for this texture or not.
  16571. */
  16572. get noMipmap(): boolean;
  16573. /**
  16574. * List of inspectable custom properties (used by the Inspector)
  16575. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16576. */
  16577. inspectableCustomProperties: Nullable<IInspectable[]>;
  16578. private _noMipmap;
  16579. /** @hidden */
  16580. _invertY: boolean;
  16581. private _rowGenerationMatrix;
  16582. private _cachedTextureMatrix;
  16583. private _projectionModeMatrix;
  16584. private _t0;
  16585. private _t1;
  16586. private _t2;
  16587. private _cachedUOffset;
  16588. private _cachedVOffset;
  16589. private _cachedUScale;
  16590. private _cachedVScale;
  16591. private _cachedUAng;
  16592. private _cachedVAng;
  16593. private _cachedWAng;
  16594. private _cachedProjectionMatrixId;
  16595. private _cachedCoordinatesMode;
  16596. /** @hidden */
  16597. protected _initialSamplingMode: number;
  16598. /** @hidden */
  16599. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16600. private _deleteBuffer;
  16601. protected _format: Nullable<number>;
  16602. private _delayedOnLoad;
  16603. private _delayedOnError;
  16604. private _mimeType?;
  16605. /**
  16606. * Observable triggered once the texture has been loaded.
  16607. */
  16608. onLoadObservable: Observable<Texture>;
  16609. protected _isBlocking: boolean;
  16610. /**
  16611. * Is the texture preventing material to render while loading.
  16612. * If false, a default texture will be used instead of the loading one during the preparation step.
  16613. */
  16614. set isBlocking(value: boolean);
  16615. get isBlocking(): boolean;
  16616. /**
  16617. * Get the current sampling mode associated with the texture.
  16618. */
  16619. get samplingMode(): number;
  16620. /**
  16621. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16622. */
  16623. get invertY(): boolean;
  16624. /**
  16625. * Instantiates a new texture.
  16626. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16627. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16628. * @param url defines the url of the picture to load as a texture
  16629. * @param scene defines the scene or engine the texture will belong to
  16630. * @param noMipmap defines if the texture will require mip maps or not
  16631. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16632. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16633. * @param onLoad defines a callback triggered when the texture has been loaded
  16634. * @param onError defines a callback triggered when an error occurred during the loading session
  16635. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16636. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16637. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16638. * @param mimeType defines an optional mime type information
  16639. */
  16640. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  16641. /**
  16642. * Update the url (and optional buffer) of this texture if url was null during construction.
  16643. * @param url the url of the texture
  16644. * @param buffer the buffer of the texture (defaults to null)
  16645. * @param onLoad callback called when the texture is loaded (defaults to null)
  16646. */
  16647. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16648. /**
  16649. * Finish the loading sequence of a texture flagged as delayed load.
  16650. * @hidden
  16651. */
  16652. delayLoad(): void;
  16653. private _prepareRowForTextureGeneration;
  16654. /**
  16655. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16656. * @returns the transform matrix of the texture.
  16657. */
  16658. getTextureMatrix(uBase?: number): Matrix;
  16659. /**
  16660. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16661. * @returns The reflection texture transform
  16662. */
  16663. getReflectionTextureMatrix(): Matrix;
  16664. /**
  16665. * Clones the texture.
  16666. * @returns the cloned texture
  16667. */
  16668. clone(): Texture;
  16669. /**
  16670. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16671. * @returns The JSON representation of the texture
  16672. */
  16673. serialize(): any;
  16674. /**
  16675. * Get the current class name of the texture useful for serialization or dynamic coding.
  16676. * @returns "Texture"
  16677. */
  16678. getClassName(): string;
  16679. /**
  16680. * Dispose the texture and release its associated resources.
  16681. */
  16682. dispose(): void;
  16683. /**
  16684. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16685. * @param parsedTexture Define the JSON representation of the texture
  16686. * @param scene Define the scene the parsed texture should be instantiated in
  16687. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16688. * @returns The parsed texture if successful
  16689. */
  16690. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16691. /**
  16692. * Creates a texture from its base 64 representation.
  16693. * @param data Define the base64 payload without the data: prefix
  16694. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16695. * @param scene Define the scene the texture should belong to
  16696. * @param noMipmap Forces the texture to not create mip map information if true
  16697. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16698. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16699. * @param onLoad define a callback triggered when the texture has been loaded
  16700. * @param onError define a callback triggered when an error occurred during the loading session
  16701. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16702. * @returns the created texture
  16703. */
  16704. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16705. /**
  16706. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16707. * @param data Define the base64 payload without the data: prefix
  16708. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16709. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16710. * @param scene Define the scene the texture should belong to
  16711. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16712. * @param noMipmap Forces the texture to not create mip map information if true
  16713. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16714. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16715. * @param onLoad define a callback triggered when the texture has been loaded
  16716. * @param onError define a callback triggered when an error occurred during the loading session
  16717. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16718. * @returns the created texture
  16719. */
  16720. 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;
  16721. }
  16722. }
  16723. declare module "babylonjs/PostProcesses/postProcessManager" {
  16724. import { Nullable } from "babylonjs/types";
  16725. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16726. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16727. import { Scene } from "babylonjs/scene";
  16728. /**
  16729. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16730. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16731. */
  16732. export class PostProcessManager {
  16733. private _scene;
  16734. private _indexBuffer;
  16735. private _vertexBuffers;
  16736. /**
  16737. * Creates a new instance PostProcess
  16738. * @param scene The scene that the post process is associated with.
  16739. */
  16740. constructor(scene: Scene);
  16741. private _prepareBuffers;
  16742. private _buildIndexBuffer;
  16743. /**
  16744. * Rebuilds the vertex buffers of the manager.
  16745. * @hidden
  16746. */
  16747. _rebuild(): void;
  16748. /**
  16749. * Prepares a frame to be run through a post process.
  16750. * @param sourceTexture The input texture to the post procesess. (default: null)
  16751. * @param postProcesses An array of post processes to be run. (default: null)
  16752. * @returns True if the post processes were able to be run.
  16753. * @hidden
  16754. */
  16755. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16756. /**
  16757. * Manually render a set of post processes to a texture.
  16758. * @param postProcesses An array of post processes to be run.
  16759. * @param targetTexture The target texture to render to.
  16760. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16761. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16762. * @param lodLevel defines which lod of the texture to render to
  16763. */
  16764. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16765. /**
  16766. * Finalize the result of the output of the postprocesses.
  16767. * @param doNotPresent If true the result will not be displayed to the screen.
  16768. * @param targetTexture The target texture to render to.
  16769. * @param faceIndex The index of the face to bind the target texture to.
  16770. * @param postProcesses The array of post processes to render.
  16771. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16772. * @hidden
  16773. */
  16774. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16775. /**
  16776. * Disposes of the post process manager.
  16777. */
  16778. dispose(): void;
  16779. }
  16780. }
  16781. declare module "babylonjs/Misc/gradients" {
  16782. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16783. /** Interface used by value gradients (color, factor, ...) */
  16784. export interface IValueGradient {
  16785. /**
  16786. * Gets or sets the gradient value (between 0 and 1)
  16787. */
  16788. gradient: number;
  16789. }
  16790. /** Class used to store color4 gradient */
  16791. export class ColorGradient implements IValueGradient {
  16792. /**
  16793. * Gets or sets the gradient value (between 0 and 1)
  16794. */
  16795. gradient: number;
  16796. /**
  16797. * Gets or sets first associated color
  16798. */
  16799. color1: Color4;
  16800. /**
  16801. * Gets or sets second associated color
  16802. */
  16803. color2?: Color4;
  16804. /**
  16805. * Will get a color picked randomly between color1 and color2.
  16806. * If color2 is undefined then color1 will be used
  16807. * @param result defines the target Color4 to store the result in
  16808. */
  16809. getColorToRef(result: Color4): void;
  16810. }
  16811. /** Class used to store color 3 gradient */
  16812. export class Color3Gradient implements IValueGradient {
  16813. /**
  16814. * Gets or sets the gradient value (between 0 and 1)
  16815. */
  16816. gradient: number;
  16817. /**
  16818. * Gets or sets the associated color
  16819. */
  16820. color: Color3;
  16821. }
  16822. /** Class used to store factor gradient */
  16823. export class FactorGradient implements IValueGradient {
  16824. /**
  16825. * Gets or sets the gradient value (between 0 and 1)
  16826. */
  16827. gradient: number;
  16828. /**
  16829. * Gets or sets first associated factor
  16830. */
  16831. factor1: number;
  16832. /**
  16833. * Gets or sets second associated factor
  16834. */
  16835. factor2?: number;
  16836. /**
  16837. * Will get a number picked randomly between factor1 and factor2.
  16838. * If factor2 is undefined then factor1 will be used
  16839. * @returns the picked number
  16840. */
  16841. getFactor(): number;
  16842. }
  16843. /**
  16844. * Helper used to simplify some generic gradient tasks
  16845. */
  16846. export class GradientHelper {
  16847. /**
  16848. * Gets the current gradient from an array of IValueGradient
  16849. * @param ratio defines the current ratio to get
  16850. * @param gradients defines the array of IValueGradient
  16851. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16852. */
  16853. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16854. }
  16855. }
  16856. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16857. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16858. import { Nullable } from "babylonjs/types";
  16859. module "babylonjs/Engines/thinEngine" {
  16860. interface ThinEngine {
  16861. /**
  16862. * Creates a dynamic texture
  16863. * @param width defines the width of the texture
  16864. * @param height defines the height of the texture
  16865. * @param generateMipMaps defines if the engine should generate the mip levels
  16866. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16867. * @returns the dynamic texture inside an InternalTexture
  16868. */
  16869. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16870. /**
  16871. * Update the content of a dynamic texture
  16872. * @param texture defines the texture to update
  16873. * @param canvas defines the canvas containing the source
  16874. * @param invertY defines if data must be stored with Y axis inverted
  16875. * @param premulAlpha defines if alpha is stored as premultiplied
  16876. * @param format defines the format of the data
  16877. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16878. */
  16879. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16880. }
  16881. }
  16882. }
  16883. declare module "babylonjs/Misc/canvasGenerator" {
  16884. /**
  16885. * Helper class used to generate a canvas to manipulate images
  16886. */
  16887. export class CanvasGenerator {
  16888. /**
  16889. * Create a new canvas (or offscreen canvas depending on the context)
  16890. * @param width defines the expected width
  16891. * @param height defines the expected height
  16892. * @return a new canvas or offscreen canvas
  16893. */
  16894. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16895. }
  16896. }
  16897. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16898. import { Scene } from "babylonjs/scene";
  16899. import { Texture } from "babylonjs/Materials/Textures/texture";
  16900. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16901. /**
  16902. * A class extending Texture allowing drawing on a texture
  16903. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16904. */
  16905. export class DynamicTexture extends Texture {
  16906. private _generateMipMaps;
  16907. private _canvas;
  16908. private _context;
  16909. private _engine;
  16910. /**
  16911. * Creates a DynamicTexture
  16912. * @param name defines the name of the texture
  16913. * @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
  16914. * @param scene defines the scene where you want the texture
  16915. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16916. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16917. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16918. */
  16919. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16920. /**
  16921. * Get the current class name of the texture useful for serialization or dynamic coding.
  16922. * @returns "DynamicTexture"
  16923. */
  16924. getClassName(): string;
  16925. /**
  16926. * Gets the current state of canRescale
  16927. */
  16928. get canRescale(): boolean;
  16929. private _recreate;
  16930. /**
  16931. * Scales the texture
  16932. * @param ratio the scale factor to apply to both width and height
  16933. */
  16934. scale(ratio: number): void;
  16935. /**
  16936. * Resizes the texture
  16937. * @param width the new width
  16938. * @param height the new height
  16939. */
  16940. scaleTo(width: number, height: number): void;
  16941. /**
  16942. * Gets the context of the canvas used by the texture
  16943. * @returns the canvas context of the dynamic texture
  16944. */
  16945. getContext(): CanvasRenderingContext2D;
  16946. /**
  16947. * Clears the texture
  16948. */
  16949. clear(): void;
  16950. /**
  16951. * Updates the texture
  16952. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16953. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16954. */
  16955. update(invertY?: boolean, premulAlpha?: boolean): void;
  16956. /**
  16957. * Draws text onto the texture
  16958. * @param text defines the text to be drawn
  16959. * @param x defines the placement of the text from the left
  16960. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16961. * @param font defines the font to be used with font-style, font-size, font-name
  16962. * @param color defines the color used for the text
  16963. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16964. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16965. * @param update defines whether texture is immediately update (default is true)
  16966. */
  16967. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16968. /**
  16969. * Clones the texture
  16970. * @returns the clone of the texture.
  16971. */
  16972. clone(): DynamicTexture;
  16973. /**
  16974. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16975. * @returns a serialized dynamic texture object
  16976. */
  16977. serialize(): any;
  16978. /** @hidden */
  16979. _rebuild(): void;
  16980. }
  16981. }
  16982. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16983. import { Scene } from "babylonjs/scene";
  16984. import { ISceneComponent } from "babylonjs/sceneComponent";
  16985. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16986. module "babylonjs/abstractScene" {
  16987. interface AbstractScene {
  16988. /**
  16989. * The list of procedural textures added to the scene
  16990. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16991. */
  16992. proceduralTextures: Array<ProceduralTexture>;
  16993. }
  16994. }
  16995. /**
  16996. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16997. * in a given scene.
  16998. */
  16999. export class ProceduralTextureSceneComponent implements ISceneComponent {
  17000. /**
  17001. * The component name helpfull to identify the component in the list of scene components.
  17002. */
  17003. readonly name: string;
  17004. /**
  17005. * The scene the component belongs to.
  17006. */
  17007. scene: Scene;
  17008. /**
  17009. * Creates a new instance of the component for the given scene
  17010. * @param scene Defines the scene to register the component in
  17011. */
  17012. constructor(scene: Scene);
  17013. /**
  17014. * Registers the component in a given scene
  17015. */
  17016. register(): void;
  17017. /**
  17018. * Rebuilds the elements related to this component in case of
  17019. * context lost for instance.
  17020. */
  17021. rebuild(): void;
  17022. /**
  17023. * Disposes the component and the associated ressources.
  17024. */
  17025. dispose(): void;
  17026. private _beforeClear;
  17027. }
  17028. }
  17029. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  17030. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17031. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17032. module "babylonjs/Engines/thinEngine" {
  17033. interface ThinEngine {
  17034. /**
  17035. * Creates a new render target cube texture
  17036. * @param size defines the size of the texture
  17037. * @param options defines the options used to create the texture
  17038. * @returns a new render target cube texture stored in an InternalTexture
  17039. */
  17040. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  17041. }
  17042. }
  17043. }
  17044. declare module "babylonjs/Shaders/procedural.vertex" {
  17045. /** @hidden */
  17046. export var proceduralVertexShader: {
  17047. name: string;
  17048. shader: string;
  17049. };
  17050. }
  17051. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  17052. import { Observable } from "babylonjs/Misc/observable";
  17053. import { Nullable } from "babylonjs/types";
  17054. import { Scene } from "babylonjs/scene";
  17055. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  17056. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17057. import { Effect } from "babylonjs/Materials/effect";
  17058. import { Texture } from "babylonjs/Materials/Textures/texture";
  17059. import "babylonjs/Engines/Extensions/engine.renderTarget";
  17060. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  17061. import "babylonjs/Shaders/procedural.vertex";
  17062. /**
  17063. * 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.
  17064. * This is the base class of any Procedural texture and contains most of the shareable code.
  17065. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  17066. */
  17067. export class ProceduralTexture extends Texture {
  17068. isCube: boolean;
  17069. /**
  17070. * Define if the texture is enabled or not (disabled texture will not render)
  17071. */
  17072. isEnabled: boolean;
  17073. /**
  17074. * Define if the texture must be cleared before rendering (default is true)
  17075. */
  17076. autoClear: boolean;
  17077. /**
  17078. * Callback called when the texture is generated
  17079. */
  17080. onGenerated: () => void;
  17081. /**
  17082. * Event raised when the texture is generated
  17083. */
  17084. onGeneratedObservable: Observable<ProceduralTexture>;
  17085. /** @hidden */
  17086. _generateMipMaps: boolean;
  17087. /** @hidden **/
  17088. _effect: Effect;
  17089. /** @hidden */
  17090. _textures: {
  17091. [key: string]: Texture;
  17092. };
  17093. private _size;
  17094. private _currentRefreshId;
  17095. private _frameId;
  17096. private _refreshRate;
  17097. private _vertexBuffers;
  17098. private _indexBuffer;
  17099. private _uniforms;
  17100. private _samplers;
  17101. private _fragment;
  17102. private _floats;
  17103. private _ints;
  17104. private _floatsArrays;
  17105. private _colors3;
  17106. private _colors4;
  17107. private _vectors2;
  17108. private _vectors3;
  17109. private _matrices;
  17110. private _fallbackTexture;
  17111. private _fallbackTextureUsed;
  17112. private _engine;
  17113. private _cachedDefines;
  17114. private _contentUpdateId;
  17115. private _contentData;
  17116. /**
  17117. * Instantiates a new procedural texture.
  17118. * 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.
  17119. * This is the base class of any Procedural texture and contains most of the shareable code.
  17120. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  17121. * @param name Define the name of the texture
  17122. * @param size Define the size of the texture to create
  17123. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  17124. * @param scene Define the scene the texture belongs to
  17125. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  17126. * @param generateMipMaps Define if the texture should creates mip maps or not
  17127. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  17128. */
  17129. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  17130. /**
  17131. * The effect that is created when initializing the post process.
  17132. * @returns The created effect corresponding the the postprocess.
  17133. */
  17134. getEffect(): Effect;
  17135. /**
  17136. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  17137. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  17138. */
  17139. getContent(): Nullable<ArrayBufferView>;
  17140. private _createIndexBuffer;
  17141. /** @hidden */
  17142. _rebuild(): void;
  17143. /**
  17144. * Resets the texture in order to recreate its associated resources.
  17145. * This can be called in case of context loss
  17146. */
  17147. reset(): void;
  17148. protected _getDefines(): string;
  17149. /**
  17150. * Is the texture ready to be used ? (rendered at least once)
  17151. * @returns true if ready, otherwise, false.
  17152. */
  17153. isReady(): boolean;
  17154. /**
  17155. * Resets the refresh counter of the texture and start bak from scratch.
  17156. * Could be useful to regenerate the texture if it is setup to render only once.
  17157. */
  17158. resetRefreshCounter(): void;
  17159. /**
  17160. * Set the fragment shader to use in order to render the texture.
  17161. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  17162. */
  17163. setFragment(fragment: any): void;
  17164. /**
  17165. * Define the refresh rate of the texture or the rendering frequency.
  17166. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17167. */
  17168. get refreshRate(): number;
  17169. set refreshRate(value: number);
  17170. /** @hidden */
  17171. _shouldRender(): boolean;
  17172. /**
  17173. * Get the size the texture is rendering at.
  17174. * @returns the size (texture is always squared)
  17175. */
  17176. getRenderSize(): number;
  17177. /**
  17178. * Resize the texture to new value.
  17179. * @param size Define the new size the texture should have
  17180. * @param generateMipMaps Define whether the new texture should create mip maps
  17181. */
  17182. resize(size: number, generateMipMaps: boolean): void;
  17183. private _checkUniform;
  17184. /**
  17185. * Set a texture in the shader program used to render.
  17186. * @param name Define the name of the uniform samplers as defined in the shader
  17187. * @param texture Define the texture to bind to this sampler
  17188. * @return the texture itself allowing "fluent" like uniform updates
  17189. */
  17190. setTexture(name: string, texture: Texture): ProceduralTexture;
  17191. /**
  17192. * Set a float in the shader.
  17193. * @param name Define the name of the uniform as defined in the shader
  17194. * @param value Define the value to give to the uniform
  17195. * @return the texture itself allowing "fluent" like uniform updates
  17196. */
  17197. setFloat(name: string, value: number): ProceduralTexture;
  17198. /**
  17199. * Set a int in the shader.
  17200. * @param name Define the name of the uniform as defined in the shader
  17201. * @param value Define the value to give to the uniform
  17202. * @return the texture itself allowing "fluent" like uniform updates
  17203. */
  17204. setInt(name: string, value: number): ProceduralTexture;
  17205. /**
  17206. * Set an array of floats in the shader.
  17207. * @param name Define the name of the uniform as defined in the shader
  17208. * @param value Define the value to give to the uniform
  17209. * @return the texture itself allowing "fluent" like uniform updates
  17210. */
  17211. setFloats(name: string, value: number[]): ProceduralTexture;
  17212. /**
  17213. * Set a vec3 in the shader from a Color3.
  17214. * @param name Define the name of the uniform as defined in the shader
  17215. * @param value Define the value to give to the uniform
  17216. * @return the texture itself allowing "fluent" like uniform updates
  17217. */
  17218. setColor3(name: string, value: Color3): ProceduralTexture;
  17219. /**
  17220. * Set a vec4 in the shader from a Color4.
  17221. * @param name Define the name of the uniform as defined in the shader
  17222. * @param value Define the value to give to the uniform
  17223. * @return the texture itself allowing "fluent" like uniform updates
  17224. */
  17225. setColor4(name: string, value: Color4): ProceduralTexture;
  17226. /**
  17227. * Set a vec2 in the shader from a Vector2.
  17228. * @param name Define the name of the uniform as defined in the shader
  17229. * @param value Define the value to give to the uniform
  17230. * @return the texture itself allowing "fluent" like uniform updates
  17231. */
  17232. setVector2(name: string, value: Vector2): ProceduralTexture;
  17233. /**
  17234. * Set a vec3 in the shader from a Vector3.
  17235. * @param name Define the name of the uniform as defined in the shader
  17236. * @param value Define the value to give to the uniform
  17237. * @return the texture itself allowing "fluent" like uniform updates
  17238. */
  17239. setVector3(name: string, value: Vector3): ProceduralTexture;
  17240. /**
  17241. * Set a mat4 in the shader from a MAtrix.
  17242. * @param name Define the name of the uniform as defined in the shader
  17243. * @param value Define the value to give to the uniform
  17244. * @return the texture itself allowing "fluent" like uniform updates
  17245. */
  17246. setMatrix(name: string, value: Matrix): ProceduralTexture;
  17247. /**
  17248. * Render the texture to its associated render target.
  17249. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  17250. */
  17251. render(useCameraPostProcess?: boolean): void;
  17252. /**
  17253. * Clone the texture.
  17254. * @returns the cloned texture
  17255. */
  17256. clone(): ProceduralTexture;
  17257. /**
  17258. * Dispose the texture and release its asoociated resources.
  17259. */
  17260. dispose(): void;
  17261. }
  17262. }
  17263. declare module "babylonjs/Particles/baseParticleSystem" {
  17264. import { Nullable } from "babylonjs/types";
  17265. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  17266. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17267. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  17268. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  17269. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  17270. import { Scene } from "babylonjs/scene";
  17271. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  17272. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  17273. import { Texture } from "babylonjs/Materials/Textures/texture";
  17274. import { Color4 } from "babylonjs/Maths/math.color";
  17275. import { Animation } from "babylonjs/Animations/animation";
  17276. /**
  17277. * This represents the base class for particle system in Babylon.
  17278. * 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.
  17279. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17280. * @example https://doc.babylonjs.com/babylon101/particles
  17281. */
  17282. export class BaseParticleSystem {
  17283. /**
  17284. * Source color is added to the destination color without alpha affecting the result
  17285. */
  17286. static BLENDMODE_ONEONE: number;
  17287. /**
  17288. * Blend current color and particle color using particle’s alpha
  17289. */
  17290. static BLENDMODE_STANDARD: number;
  17291. /**
  17292. * Add current color and particle color multiplied by particle’s alpha
  17293. */
  17294. static BLENDMODE_ADD: number;
  17295. /**
  17296. * Multiply current color with particle color
  17297. */
  17298. static BLENDMODE_MULTIPLY: number;
  17299. /**
  17300. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  17301. */
  17302. static BLENDMODE_MULTIPLYADD: number;
  17303. /**
  17304. * List of animations used by the particle system.
  17305. */
  17306. animations: Animation[];
  17307. /**
  17308. * The id of the Particle system.
  17309. */
  17310. id: string;
  17311. /**
  17312. * The friendly name of the Particle system.
  17313. */
  17314. name: string;
  17315. /**
  17316. * The rendering group used by the Particle system to chose when to render.
  17317. */
  17318. renderingGroupId: number;
  17319. /**
  17320. * The emitter represents the Mesh or position we are attaching the particle system to.
  17321. */
  17322. emitter: Nullable<AbstractMesh | Vector3>;
  17323. /**
  17324. * The maximum number of particles to emit per frame
  17325. */
  17326. emitRate: number;
  17327. /**
  17328. * If you want to launch only a few particles at once, that can be done, as well.
  17329. */
  17330. manualEmitCount: number;
  17331. /**
  17332. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17333. */
  17334. updateSpeed: number;
  17335. /**
  17336. * The amount of time the particle system is running (depends of the overall update speed).
  17337. */
  17338. targetStopDuration: number;
  17339. /**
  17340. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17341. */
  17342. disposeOnStop: boolean;
  17343. /**
  17344. * Minimum power of emitting particles.
  17345. */
  17346. minEmitPower: number;
  17347. /**
  17348. * Maximum power of emitting particles.
  17349. */
  17350. maxEmitPower: number;
  17351. /**
  17352. * Minimum life time of emitting particles.
  17353. */
  17354. minLifeTime: number;
  17355. /**
  17356. * Maximum life time of emitting particles.
  17357. */
  17358. maxLifeTime: number;
  17359. /**
  17360. * Minimum Size of emitting particles.
  17361. */
  17362. minSize: number;
  17363. /**
  17364. * Maximum Size of emitting particles.
  17365. */
  17366. maxSize: number;
  17367. /**
  17368. * Minimum scale of emitting particles on X axis.
  17369. */
  17370. minScaleX: number;
  17371. /**
  17372. * Maximum scale of emitting particles on X axis.
  17373. */
  17374. maxScaleX: number;
  17375. /**
  17376. * Minimum scale of emitting particles on Y axis.
  17377. */
  17378. minScaleY: number;
  17379. /**
  17380. * Maximum scale of emitting particles on Y axis.
  17381. */
  17382. maxScaleY: number;
  17383. /**
  17384. * Gets or sets the minimal initial rotation in radians.
  17385. */
  17386. minInitialRotation: number;
  17387. /**
  17388. * Gets or sets the maximal initial rotation in radians.
  17389. */
  17390. maxInitialRotation: number;
  17391. /**
  17392. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17393. */
  17394. minAngularSpeed: number;
  17395. /**
  17396. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17397. */
  17398. maxAngularSpeed: number;
  17399. /**
  17400. * The texture used to render each particle. (this can be a spritesheet)
  17401. */
  17402. particleTexture: Nullable<Texture>;
  17403. /**
  17404. * The layer mask we are rendering the particles through.
  17405. */
  17406. layerMask: number;
  17407. /**
  17408. * This can help using your own shader to render the particle system.
  17409. * The according effect will be created
  17410. */
  17411. customShader: any;
  17412. /**
  17413. * By default particle system starts as soon as they are created. This prevents the
  17414. * automatic start to happen and let you decide when to start emitting particles.
  17415. */
  17416. preventAutoStart: boolean;
  17417. private _noiseTexture;
  17418. /**
  17419. * Gets or sets a texture used to add random noise to particle positions
  17420. */
  17421. get noiseTexture(): Nullable<ProceduralTexture>;
  17422. set noiseTexture(value: Nullable<ProceduralTexture>);
  17423. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17424. noiseStrength: Vector3;
  17425. /**
  17426. * Callback triggered when the particle animation is ending.
  17427. */
  17428. onAnimationEnd: Nullable<() => void>;
  17429. /**
  17430. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17431. */
  17432. blendMode: number;
  17433. /**
  17434. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17435. * to override the particles.
  17436. */
  17437. forceDepthWrite: boolean;
  17438. /** 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 */
  17439. preWarmCycles: number;
  17440. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17441. preWarmStepOffset: number;
  17442. /**
  17443. * 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)
  17444. */
  17445. spriteCellChangeSpeed: number;
  17446. /**
  17447. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17448. */
  17449. startSpriteCellID: number;
  17450. /**
  17451. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17452. */
  17453. endSpriteCellID: number;
  17454. /**
  17455. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17456. */
  17457. spriteCellWidth: number;
  17458. /**
  17459. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17460. */
  17461. spriteCellHeight: number;
  17462. /**
  17463. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17464. */
  17465. spriteRandomStartCell: boolean;
  17466. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17467. translationPivot: Vector2;
  17468. /** @hidden */
  17469. protected _isAnimationSheetEnabled: boolean;
  17470. /**
  17471. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17472. */
  17473. beginAnimationOnStart: boolean;
  17474. /**
  17475. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17476. */
  17477. beginAnimationFrom: number;
  17478. /**
  17479. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17480. */
  17481. beginAnimationTo: number;
  17482. /**
  17483. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17484. */
  17485. beginAnimationLoop: boolean;
  17486. /**
  17487. * Gets or sets a world offset applied to all particles
  17488. */
  17489. worldOffset: Vector3;
  17490. /**
  17491. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17492. */
  17493. get isAnimationSheetEnabled(): boolean;
  17494. set isAnimationSheetEnabled(value: boolean);
  17495. /**
  17496. * Get hosting scene
  17497. * @returns the scene
  17498. */
  17499. getScene(): Scene;
  17500. /**
  17501. * You can use gravity if you want to give an orientation to your particles.
  17502. */
  17503. gravity: Vector3;
  17504. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17505. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17506. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17507. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17508. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17509. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17510. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17511. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17512. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17513. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17514. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17515. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17516. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17517. /**
  17518. * Defines the delay in milliseconds before starting the system (0 by default)
  17519. */
  17520. startDelay: number;
  17521. /**
  17522. * Gets the current list of drag gradients.
  17523. * You must use addDragGradient and removeDragGradient to udpate this list
  17524. * @returns the list of drag gradients
  17525. */
  17526. getDragGradients(): Nullable<Array<FactorGradient>>;
  17527. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17528. limitVelocityDamping: number;
  17529. /**
  17530. * Gets the current list of limit velocity gradients.
  17531. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17532. * @returns the list of limit velocity gradients
  17533. */
  17534. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17535. /**
  17536. * Gets the current list of color gradients.
  17537. * You must use addColorGradient and removeColorGradient to udpate this list
  17538. * @returns the list of color gradients
  17539. */
  17540. getColorGradients(): Nullable<Array<ColorGradient>>;
  17541. /**
  17542. * Gets the current list of size gradients.
  17543. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17544. * @returns the list of size gradients
  17545. */
  17546. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17547. /**
  17548. * Gets the current list of color remap gradients.
  17549. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17550. * @returns the list of color remap gradients
  17551. */
  17552. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17553. /**
  17554. * Gets the current list of alpha remap gradients.
  17555. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17556. * @returns the list of alpha remap gradients
  17557. */
  17558. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17559. /**
  17560. * Gets the current list of life time gradients.
  17561. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17562. * @returns the list of life time gradients
  17563. */
  17564. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17565. /**
  17566. * Gets the current list of angular speed gradients.
  17567. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17568. * @returns the list of angular speed gradients
  17569. */
  17570. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17571. /**
  17572. * Gets the current list of velocity gradients.
  17573. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17574. * @returns the list of velocity gradients
  17575. */
  17576. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17577. /**
  17578. * Gets the current list of start size gradients.
  17579. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17580. * @returns the list of start size gradients
  17581. */
  17582. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17583. /**
  17584. * Gets the current list of emit rate gradients.
  17585. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17586. * @returns the list of emit rate gradients
  17587. */
  17588. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17589. /**
  17590. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17591. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17592. */
  17593. get direction1(): Vector3;
  17594. set direction1(value: Vector3);
  17595. /**
  17596. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17597. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17598. */
  17599. get direction2(): Vector3;
  17600. set direction2(value: Vector3);
  17601. /**
  17602. * 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.
  17603. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17604. */
  17605. get minEmitBox(): Vector3;
  17606. set minEmitBox(value: Vector3);
  17607. /**
  17608. * 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.
  17609. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17610. */
  17611. get maxEmitBox(): Vector3;
  17612. set maxEmitBox(value: Vector3);
  17613. /**
  17614. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17615. */
  17616. color1: Color4;
  17617. /**
  17618. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17619. */
  17620. color2: Color4;
  17621. /**
  17622. * Color the particle will have at the end of its lifetime
  17623. */
  17624. colorDead: Color4;
  17625. /**
  17626. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17627. */
  17628. textureMask: Color4;
  17629. /**
  17630. * The particle emitter type defines the emitter used by the particle system.
  17631. * It can be for example box, sphere, or cone...
  17632. */
  17633. particleEmitterType: IParticleEmitterType;
  17634. /** @hidden */
  17635. _isSubEmitter: boolean;
  17636. /**
  17637. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17638. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17639. */
  17640. billboardMode: number;
  17641. protected _isBillboardBased: boolean;
  17642. /**
  17643. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17644. */
  17645. get isBillboardBased(): boolean;
  17646. set isBillboardBased(value: boolean);
  17647. /**
  17648. * The scene the particle system belongs to.
  17649. */
  17650. protected _scene: Scene;
  17651. /**
  17652. * Local cache of defines for image processing.
  17653. */
  17654. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17655. /**
  17656. * Default configuration related to image processing available in the standard Material.
  17657. */
  17658. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17659. /**
  17660. * Gets the image processing configuration used either in this material.
  17661. */
  17662. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17663. /**
  17664. * Sets the Default image processing configuration used either in the this material.
  17665. *
  17666. * If sets to null, the scene one is in use.
  17667. */
  17668. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17669. /**
  17670. * Attaches a new image processing configuration to the Standard Material.
  17671. * @param configuration
  17672. */
  17673. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17674. /** @hidden */
  17675. protected _reset(): void;
  17676. /** @hidden */
  17677. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17678. /**
  17679. * Instantiates a particle system.
  17680. * 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.
  17681. * @param name The name of the particle system
  17682. */
  17683. constructor(name: string);
  17684. /**
  17685. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17686. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17687. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17688. * @returns the emitter
  17689. */
  17690. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17691. /**
  17692. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17693. * @param radius The radius of the hemisphere to emit from
  17694. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17695. * @returns the emitter
  17696. */
  17697. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17698. /**
  17699. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17700. * @param radius The radius of the sphere to emit from
  17701. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17702. * @returns the emitter
  17703. */
  17704. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17705. /**
  17706. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17707. * @param radius The radius of the sphere to emit from
  17708. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17709. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17710. * @returns the emitter
  17711. */
  17712. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17713. /**
  17714. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17715. * @param radius The radius of the emission cylinder
  17716. * @param height The height of the emission cylinder
  17717. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17718. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17719. * @returns the emitter
  17720. */
  17721. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17722. /**
  17723. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17724. * @param radius The radius of the cylinder to emit from
  17725. * @param height The height of the emission cylinder
  17726. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17727. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17728. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17729. * @returns the emitter
  17730. */
  17731. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17732. /**
  17733. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17734. * @param radius The radius of the cone to emit from
  17735. * @param angle The base angle of the cone
  17736. * @returns the emitter
  17737. */
  17738. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17739. /**
  17740. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17741. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17742. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17743. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17744. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17745. * @returns the emitter
  17746. */
  17747. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17748. }
  17749. }
  17750. declare module "babylonjs/Particles/subEmitter" {
  17751. import { Scene } from "babylonjs/scene";
  17752. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17753. /**
  17754. * Type of sub emitter
  17755. */
  17756. export enum SubEmitterType {
  17757. /**
  17758. * Attached to the particle over it's lifetime
  17759. */
  17760. ATTACHED = 0,
  17761. /**
  17762. * Created when the particle dies
  17763. */
  17764. END = 1
  17765. }
  17766. /**
  17767. * Sub emitter class used to emit particles from an existing particle
  17768. */
  17769. export class SubEmitter {
  17770. /**
  17771. * the particle system to be used by the sub emitter
  17772. */
  17773. particleSystem: ParticleSystem;
  17774. /**
  17775. * Type of the submitter (Default: END)
  17776. */
  17777. type: SubEmitterType;
  17778. /**
  17779. * 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)
  17780. * Note: This only is supported when using an emitter of type Mesh
  17781. */
  17782. inheritDirection: boolean;
  17783. /**
  17784. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17785. */
  17786. inheritedVelocityAmount: number;
  17787. /**
  17788. * Creates a sub emitter
  17789. * @param particleSystem the particle system to be used by the sub emitter
  17790. */
  17791. constructor(
  17792. /**
  17793. * the particle system to be used by the sub emitter
  17794. */
  17795. particleSystem: ParticleSystem);
  17796. /**
  17797. * Clones the sub emitter
  17798. * @returns the cloned sub emitter
  17799. */
  17800. clone(): SubEmitter;
  17801. /**
  17802. * Serialize current object to a JSON object
  17803. * @returns the serialized object
  17804. */
  17805. serialize(): any;
  17806. /** @hidden */
  17807. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17808. /**
  17809. * Creates a new SubEmitter from a serialized JSON version
  17810. * @param serializationObject defines the JSON object to read from
  17811. * @param scene defines the hosting scene
  17812. * @param rootUrl defines the rootUrl for data loading
  17813. * @returns a new SubEmitter
  17814. */
  17815. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17816. /** Release associated resources */
  17817. dispose(): void;
  17818. }
  17819. }
  17820. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17821. /** @hidden */
  17822. export var imageProcessingDeclaration: {
  17823. name: string;
  17824. shader: string;
  17825. };
  17826. }
  17827. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17828. /** @hidden */
  17829. export var imageProcessingFunctions: {
  17830. name: string;
  17831. shader: string;
  17832. };
  17833. }
  17834. declare module "babylonjs/Shaders/particles.fragment" {
  17835. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17836. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17837. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17838. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17839. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17840. /** @hidden */
  17841. export var particlesPixelShader: {
  17842. name: string;
  17843. shader: string;
  17844. };
  17845. }
  17846. declare module "babylonjs/Shaders/particles.vertex" {
  17847. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17848. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17849. /** @hidden */
  17850. export var particlesVertexShader: {
  17851. name: string;
  17852. shader: string;
  17853. };
  17854. }
  17855. declare module "babylonjs/Particles/particleSystem" {
  17856. import { Nullable } from "babylonjs/types";
  17857. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17858. import { Observable } from "babylonjs/Misc/observable";
  17859. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17860. import { Effect } from "babylonjs/Materials/effect";
  17861. import { Scene, IDisposable } from "babylonjs/scene";
  17862. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17863. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17864. import { Particle } from "babylonjs/Particles/particle";
  17865. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17866. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17867. import "babylonjs/Shaders/particles.fragment";
  17868. import "babylonjs/Shaders/particles.vertex";
  17869. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17870. /**
  17871. * This represents a particle system in Babylon.
  17872. * 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.
  17873. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17874. * @example https://doc.babylonjs.com/babylon101/particles
  17875. */
  17876. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17877. /**
  17878. * Billboard mode will only apply to Y axis
  17879. */
  17880. static readonly BILLBOARDMODE_Y: number;
  17881. /**
  17882. * Billboard mode will apply to all axes
  17883. */
  17884. static readonly BILLBOARDMODE_ALL: number;
  17885. /**
  17886. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17887. */
  17888. static readonly BILLBOARDMODE_STRETCHED: number;
  17889. /**
  17890. * This function can be defined to provide custom update for active particles.
  17891. * This function will be called instead of regular update (age, position, color, etc.).
  17892. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17893. */
  17894. updateFunction: (particles: Particle[]) => void;
  17895. private _emitterWorldMatrix;
  17896. /**
  17897. * This function can be defined to specify initial direction for every new particle.
  17898. * It by default use the emitterType defined function
  17899. */
  17900. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17901. /**
  17902. * This function can be defined to specify initial position for every new particle.
  17903. * It by default use the emitterType defined function
  17904. */
  17905. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17906. /**
  17907. * @hidden
  17908. */
  17909. _inheritedVelocityOffset: Vector3;
  17910. /**
  17911. * An event triggered when the system is disposed
  17912. */
  17913. onDisposeObservable: Observable<ParticleSystem>;
  17914. private _onDisposeObserver;
  17915. /**
  17916. * Sets a callback that will be triggered when the system is disposed
  17917. */
  17918. set onDispose(callback: () => void);
  17919. private _particles;
  17920. private _epsilon;
  17921. private _capacity;
  17922. private _stockParticles;
  17923. private _newPartsExcess;
  17924. private _vertexData;
  17925. private _vertexBuffer;
  17926. private _vertexBuffers;
  17927. private _spriteBuffer;
  17928. private _indexBuffer;
  17929. private _effect;
  17930. private _customEffect;
  17931. private _cachedDefines;
  17932. private _scaledColorStep;
  17933. private _colorDiff;
  17934. private _scaledDirection;
  17935. private _scaledGravity;
  17936. private _currentRenderId;
  17937. private _alive;
  17938. private _useInstancing;
  17939. private _started;
  17940. private _stopped;
  17941. private _actualFrame;
  17942. private _scaledUpdateSpeed;
  17943. private _vertexBufferSize;
  17944. /** @hidden */
  17945. _currentEmitRateGradient: Nullable<FactorGradient>;
  17946. /** @hidden */
  17947. _currentEmitRate1: number;
  17948. /** @hidden */
  17949. _currentEmitRate2: number;
  17950. /** @hidden */
  17951. _currentStartSizeGradient: Nullable<FactorGradient>;
  17952. /** @hidden */
  17953. _currentStartSize1: number;
  17954. /** @hidden */
  17955. _currentStartSize2: number;
  17956. private readonly _rawTextureWidth;
  17957. private _rampGradientsTexture;
  17958. private _useRampGradients;
  17959. /** Gets or sets a boolean indicating that ramp gradients must be used
  17960. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17961. */
  17962. get useRampGradients(): boolean;
  17963. set useRampGradients(value: boolean);
  17964. /**
  17965. * 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.
  17966. * 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: [])
  17967. */
  17968. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17969. private _subEmitters;
  17970. /**
  17971. * @hidden
  17972. * If the particle systems emitter should be disposed when the particle system is disposed
  17973. */
  17974. _disposeEmitterOnDispose: boolean;
  17975. /**
  17976. * The current active Sub-systems, this property is used by the root particle system only.
  17977. */
  17978. activeSubSystems: Array<ParticleSystem>;
  17979. private _rootParticleSystem;
  17980. /**
  17981. * Gets the current list of active particles
  17982. */
  17983. get particles(): Particle[];
  17984. /**
  17985. * Returns the string "ParticleSystem"
  17986. * @returns a string containing the class name
  17987. */
  17988. getClassName(): string;
  17989. /**
  17990. * Instantiates a particle system.
  17991. * 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.
  17992. * @param name The name of the particle system
  17993. * @param capacity The max number of particles alive at the same time
  17994. * @param scene The scene the particle system belongs to
  17995. * @param customEffect a custom effect used to change the way particles are rendered by default
  17996. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17997. * @param epsilon Offset used to render the particles
  17998. */
  17999. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  18000. private _addFactorGradient;
  18001. private _removeFactorGradient;
  18002. /**
  18003. * Adds a new life time gradient
  18004. * @param gradient defines the gradient to use (between 0 and 1)
  18005. * @param factor defines the life time factor to affect to the specified gradient
  18006. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18007. * @returns the current particle system
  18008. */
  18009. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18010. /**
  18011. * Remove a specific life time gradient
  18012. * @param gradient defines the gradient to remove
  18013. * @returns the current particle system
  18014. */
  18015. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18016. /**
  18017. * Adds a new size gradient
  18018. * @param gradient defines the gradient to use (between 0 and 1)
  18019. * @param factor defines the size factor to affect to the specified gradient
  18020. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18021. * @returns the current particle system
  18022. */
  18023. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18024. /**
  18025. * Remove a specific size gradient
  18026. * @param gradient defines the gradient to remove
  18027. * @returns the current particle system
  18028. */
  18029. removeSizeGradient(gradient: number): IParticleSystem;
  18030. /**
  18031. * Adds a new color remap gradient
  18032. * @param gradient defines the gradient to use (between 0 and 1)
  18033. * @param min defines the color remap minimal range
  18034. * @param max defines the color remap maximal range
  18035. * @returns the current particle system
  18036. */
  18037. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18038. /**
  18039. * Remove a specific color remap gradient
  18040. * @param gradient defines the gradient to remove
  18041. * @returns the current particle system
  18042. */
  18043. removeColorRemapGradient(gradient: number): IParticleSystem;
  18044. /**
  18045. * Adds a new alpha remap gradient
  18046. * @param gradient defines the gradient to use (between 0 and 1)
  18047. * @param min defines the alpha remap minimal range
  18048. * @param max defines the alpha remap maximal range
  18049. * @returns the current particle system
  18050. */
  18051. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18052. /**
  18053. * Remove a specific alpha remap gradient
  18054. * @param gradient defines the gradient to remove
  18055. * @returns the current particle system
  18056. */
  18057. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  18058. /**
  18059. * Adds a new angular speed gradient
  18060. * @param gradient defines the gradient to use (between 0 and 1)
  18061. * @param factor defines the angular speed to affect to the specified gradient
  18062. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18063. * @returns the current particle system
  18064. */
  18065. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18066. /**
  18067. * Remove a specific angular speed gradient
  18068. * @param gradient defines the gradient to remove
  18069. * @returns the current particle system
  18070. */
  18071. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18072. /**
  18073. * Adds a new velocity gradient
  18074. * @param gradient defines the gradient to use (between 0 and 1)
  18075. * @param factor defines the velocity to affect to the specified gradient
  18076. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18077. * @returns the current particle system
  18078. */
  18079. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18080. /**
  18081. * Remove a specific velocity gradient
  18082. * @param gradient defines the gradient to remove
  18083. * @returns the current particle system
  18084. */
  18085. removeVelocityGradient(gradient: number): IParticleSystem;
  18086. /**
  18087. * Adds a new limit velocity gradient
  18088. * @param gradient defines the gradient to use (between 0 and 1)
  18089. * @param factor defines the limit velocity value to affect to the specified gradient
  18090. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18091. * @returns the current particle system
  18092. */
  18093. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18094. /**
  18095. * Remove a specific limit velocity gradient
  18096. * @param gradient defines the gradient to remove
  18097. * @returns the current particle system
  18098. */
  18099. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18100. /**
  18101. * Adds a new drag gradient
  18102. * @param gradient defines the gradient to use (between 0 and 1)
  18103. * @param factor defines the drag value to affect to the specified gradient
  18104. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18105. * @returns the current particle system
  18106. */
  18107. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18108. /**
  18109. * Remove a specific drag gradient
  18110. * @param gradient defines the gradient to remove
  18111. * @returns the current particle system
  18112. */
  18113. removeDragGradient(gradient: number): IParticleSystem;
  18114. /**
  18115. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18116. * @param gradient defines the gradient to use (between 0 and 1)
  18117. * @param factor defines the emit rate value to affect to the specified gradient
  18118. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18119. * @returns the current particle system
  18120. */
  18121. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18122. /**
  18123. * Remove a specific emit rate gradient
  18124. * @param gradient defines the gradient to remove
  18125. * @returns the current particle system
  18126. */
  18127. removeEmitRateGradient(gradient: number): IParticleSystem;
  18128. /**
  18129. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18130. * @param gradient defines the gradient to use (between 0 and 1)
  18131. * @param factor defines the start size value to affect to the specified gradient
  18132. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18133. * @returns the current particle system
  18134. */
  18135. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18136. /**
  18137. * Remove a specific start size gradient
  18138. * @param gradient defines the gradient to remove
  18139. * @returns the current particle system
  18140. */
  18141. removeStartSizeGradient(gradient: number): IParticleSystem;
  18142. private _createRampGradientTexture;
  18143. /**
  18144. * Gets the current list of ramp gradients.
  18145. * You must use addRampGradient and removeRampGradient to udpate this list
  18146. * @returns the list of ramp gradients
  18147. */
  18148. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18149. /**
  18150. * Adds a new ramp gradient used to remap particle colors
  18151. * @param gradient defines the gradient to use (between 0 and 1)
  18152. * @param color defines the color to affect to the specified gradient
  18153. * @returns the current particle system
  18154. */
  18155. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  18156. /**
  18157. * Remove a specific ramp gradient
  18158. * @param gradient defines the gradient to remove
  18159. * @returns the current particle system
  18160. */
  18161. removeRampGradient(gradient: number): ParticleSystem;
  18162. /**
  18163. * Adds a new color gradient
  18164. * @param gradient defines the gradient to use (between 0 and 1)
  18165. * @param color1 defines the color to affect to the specified gradient
  18166. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18167. * @returns this particle system
  18168. */
  18169. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18170. /**
  18171. * Remove a specific color gradient
  18172. * @param gradient defines the gradient to remove
  18173. * @returns this particle system
  18174. */
  18175. removeColorGradient(gradient: number): IParticleSystem;
  18176. private _fetchR;
  18177. protected _reset(): void;
  18178. private _resetEffect;
  18179. private _createVertexBuffers;
  18180. private _createIndexBuffer;
  18181. /**
  18182. * Gets the maximum number of particles active at the same time.
  18183. * @returns The max number of active particles.
  18184. */
  18185. getCapacity(): number;
  18186. /**
  18187. * Gets whether there are still active particles in the system.
  18188. * @returns True if it is alive, otherwise false.
  18189. */
  18190. isAlive(): boolean;
  18191. /**
  18192. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18193. * @returns True if it has been started, otherwise false.
  18194. */
  18195. isStarted(): boolean;
  18196. private _prepareSubEmitterInternalArray;
  18197. /**
  18198. * Starts the particle system and begins to emit
  18199. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  18200. */
  18201. start(delay?: number): void;
  18202. /**
  18203. * Stops the particle system.
  18204. * @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.
  18205. */
  18206. stop(stopSubEmitters?: boolean): void;
  18207. /**
  18208. * Remove all active particles
  18209. */
  18210. reset(): void;
  18211. /**
  18212. * @hidden (for internal use only)
  18213. */
  18214. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  18215. /**
  18216. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  18217. * Its lifetime will start back at 0.
  18218. */
  18219. recycleParticle: (particle: Particle) => void;
  18220. private _stopSubEmitters;
  18221. private _createParticle;
  18222. private _removeFromRoot;
  18223. private _emitFromParticle;
  18224. private _update;
  18225. /** @hidden */
  18226. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  18227. /** @hidden */
  18228. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  18229. /** @hidden */
  18230. private _getEffect;
  18231. /**
  18232. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18233. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  18234. */
  18235. animate(preWarmOnly?: boolean): void;
  18236. private _appendParticleVertices;
  18237. /**
  18238. * Rebuilds the particle system.
  18239. */
  18240. rebuild(): void;
  18241. /**
  18242. * Is this system ready to be used/rendered
  18243. * @return true if the system is ready
  18244. */
  18245. isReady(): boolean;
  18246. private _render;
  18247. /**
  18248. * Renders the particle system in its current state.
  18249. * @returns the current number of particles
  18250. */
  18251. render(): number;
  18252. /**
  18253. * Disposes the particle system and free the associated resources
  18254. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18255. */
  18256. dispose(disposeTexture?: boolean): void;
  18257. /**
  18258. * Clones the particle system.
  18259. * @param name The name of the cloned object
  18260. * @param newEmitter The new emitter to use
  18261. * @returns the cloned particle system
  18262. */
  18263. clone(name: string, newEmitter: any): ParticleSystem;
  18264. /**
  18265. * Serializes the particle system to a JSON object.
  18266. * @returns the JSON object
  18267. */
  18268. serialize(): any;
  18269. /** @hidden */
  18270. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  18271. /** @hidden */
  18272. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  18273. /**
  18274. * Parses a JSON object to create a particle system.
  18275. * @param parsedParticleSystem The JSON object to parse
  18276. * @param scene The scene to create the particle system in
  18277. * @param rootUrl The root url to use to load external dependencies like texture
  18278. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  18279. * @returns the Parsed particle system
  18280. */
  18281. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  18282. }
  18283. }
  18284. declare module "babylonjs/Particles/particle" {
  18285. import { Nullable } from "babylonjs/types";
  18286. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  18287. import { Color4 } from "babylonjs/Maths/math.color";
  18288. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  18289. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  18290. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  18291. /**
  18292. * A particle represents one of the element emitted by a particle system.
  18293. * This is mainly define by its coordinates, direction, velocity and age.
  18294. */
  18295. export class Particle {
  18296. /**
  18297. * The particle system the particle belongs to.
  18298. */
  18299. particleSystem: ParticleSystem;
  18300. private static _Count;
  18301. /**
  18302. * Unique ID of the particle
  18303. */
  18304. id: number;
  18305. /**
  18306. * The world position of the particle in the scene.
  18307. */
  18308. position: Vector3;
  18309. /**
  18310. * The world direction of the particle in the scene.
  18311. */
  18312. direction: Vector3;
  18313. /**
  18314. * The color of the particle.
  18315. */
  18316. color: Color4;
  18317. /**
  18318. * The color change of the particle per step.
  18319. */
  18320. colorStep: Color4;
  18321. /**
  18322. * Defines how long will the life of the particle be.
  18323. */
  18324. lifeTime: number;
  18325. /**
  18326. * The current age of the particle.
  18327. */
  18328. age: number;
  18329. /**
  18330. * The current size of the particle.
  18331. */
  18332. size: number;
  18333. /**
  18334. * The current scale of the particle.
  18335. */
  18336. scale: Vector2;
  18337. /**
  18338. * The current angle of the particle.
  18339. */
  18340. angle: number;
  18341. /**
  18342. * Defines how fast is the angle changing.
  18343. */
  18344. angularSpeed: number;
  18345. /**
  18346. * Defines the cell index used by the particle to be rendered from a sprite.
  18347. */
  18348. cellIndex: number;
  18349. /**
  18350. * The information required to support color remapping
  18351. */
  18352. remapData: Vector4;
  18353. /** @hidden */
  18354. _randomCellOffset?: number;
  18355. /** @hidden */
  18356. _initialDirection: Nullable<Vector3>;
  18357. /** @hidden */
  18358. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18359. /** @hidden */
  18360. _initialStartSpriteCellID: number;
  18361. /** @hidden */
  18362. _initialEndSpriteCellID: number;
  18363. /** @hidden */
  18364. _currentColorGradient: Nullable<ColorGradient>;
  18365. /** @hidden */
  18366. _currentColor1: Color4;
  18367. /** @hidden */
  18368. _currentColor2: Color4;
  18369. /** @hidden */
  18370. _currentSizeGradient: Nullable<FactorGradient>;
  18371. /** @hidden */
  18372. _currentSize1: number;
  18373. /** @hidden */
  18374. _currentSize2: number;
  18375. /** @hidden */
  18376. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18377. /** @hidden */
  18378. _currentAngularSpeed1: number;
  18379. /** @hidden */
  18380. _currentAngularSpeed2: number;
  18381. /** @hidden */
  18382. _currentVelocityGradient: Nullable<FactorGradient>;
  18383. /** @hidden */
  18384. _currentVelocity1: number;
  18385. /** @hidden */
  18386. _currentVelocity2: number;
  18387. /** @hidden */
  18388. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18389. /** @hidden */
  18390. _currentLimitVelocity1: number;
  18391. /** @hidden */
  18392. _currentLimitVelocity2: number;
  18393. /** @hidden */
  18394. _currentDragGradient: Nullable<FactorGradient>;
  18395. /** @hidden */
  18396. _currentDrag1: number;
  18397. /** @hidden */
  18398. _currentDrag2: number;
  18399. /** @hidden */
  18400. _randomNoiseCoordinates1: Vector3;
  18401. /** @hidden */
  18402. _randomNoiseCoordinates2: Vector3;
  18403. /**
  18404. * Creates a new instance Particle
  18405. * @param particleSystem the particle system the particle belongs to
  18406. */
  18407. constructor(
  18408. /**
  18409. * The particle system the particle belongs to.
  18410. */
  18411. particleSystem: ParticleSystem);
  18412. private updateCellInfoFromSystem;
  18413. /**
  18414. * Defines how the sprite cell index is updated for the particle
  18415. */
  18416. updateCellIndex(): void;
  18417. /** @hidden */
  18418. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18419. /** @hidden */
  18420. _inheritParticleInfoToSubEmitters(): void;
  18421. /** @hidden */
  18422. _reset(): void;
  18423. /**
  18424. * Copy the properties of particle to another one.
  18425. * @param other the particle to copy the information to.
  18426. */
  18427. copyTo(other: Particle): void;
  18428. }
  18429. }
  18430. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18431. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18432. import { Effect } from "babylonjs/Materials/effect";
  18433. import { Particle } from "babylonjs/Particles/particle";
  18434. /**
  18435. * Particle emitter represents a volume emitting particles.
  18436. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18437. */
  18438. export interface IParticleEmitterType {
  18439. /**
  18440. * Called by the particle System when the direction is computed for the created particle.
  18441. * @param worldMatrix is the world matrix of the particle system
  18442. * @param directionToUpdate is the direction vector to update with the result
  18443. * @param particle is the particle we are computed the direction for
  18444. */
  18445. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18446. /**
  18447. * Called by the particle System when the position is computed for the created particle.
  18448. * @param worldMatrix is the world matrix of the particle system
  18449. * @param positionToUpdate is the position vector to update with the result
  18450. * @param particle is the particle we are computed the position for
  18451. */
  18452. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18453. /**
  18454. * Clones the current emitter and returns a copy of it
  18455. * @returns the new emitter
  18456. */
  18457. clone(): IParticleEmitterType;
  18458. /**
  18459. * Called by the GPUParticleSystem to setup the update shader
  18460. * @param effect defines the update shader
  18461. */
  18462. applyToShader(effect: Effect): void;
  18463. /**
  18464. * Returns a string to use to update the GPU particles update shader
  18465. * @returns the effect defines string
  18466. */
  18467. getEffectDefines(): string;
  18468. /**
  18469. * Returns a string representing the class name
  18470. * @returns a string containing the class name
  18471. */
  18472. getClassName(): string;
  18473. /**
  18474. * Serializes the particle system to a JSON object.
  18475. * @returns the JSON object
  18476. */
  18477. serialize(): any;
  18478. /**
  18479. * Parse properties from a JSON object
  18480. * @param serializationObject defines the JSON object
  18481. */
  18482. parse(serializationObject: any): void;
  18483. }
  18484. }
  18485. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18486. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18487. import { Effect } from "babylonjs/Materials/effect";
  18488. import { Particle } from "babylonjs/Particles/particle";
  18489. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18490. /**
  18491. * Particle emitter emitting particles from the inside of a box.
  18492. * It emits the particles randomly between 2 given directions.
  18493. */
  18494. export class BoxParticleEmitter implements IParticleEmitterType {
  18495. /**
  18496. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18497. */
  18498. direction1: Vector3;
  18499. /**
  18500. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18501. */
  18502. direction2: Vector3;
  18503. /**
  18504. * 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.
  18505. */
  18506. minEmitBox: Vector3;
  18507. /**
  18508. * 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.
  18509. */
  18510. maxEmitBox: Vector3;
  18511. /**
  18512. * Creates a new instance BoxParticleEmitter
  18513. */
  18514. constructor();
  18515. /**
  18516. * Called by the particle System when the direction is computed for the created particle.
  18517. * @param worldMatrix is the world matrix of the particle system
  18518. * @param directionToUpdate is the direction vector to update with the result
  18519. * @param particle is the particle we are computed the direction for
  18520. */
  18521. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18522. /**
  18523. * Called by the particle System when the position is computed for the created particle.
  18524. * @param worldMatrix is the world matrix of the particle system
  18525. * @param positionToUpdate is the position vector to update with the result
  18526. * @param particle is the particle we are computed the position for
  18527. */
  18528. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18529. /**
  18530. * Clones the current emitter and returns a copy of it
  18531. * @returns the new emitter
  18532. */
  18533. clone(): BoxParticleEmitter;
  18534. /**
  18535. * Called by the GPUParticleSystem to setup the update shader
  18536. * @param effect defines the update shader
  18537. */
  18538. applyToShader(effect: Effect): void;
  18539. /**
  18540. * Returns a string to use to update the GPU particles update shader
  18541. * @returns a string containng the defines string
  18542. */
  18543. getEffectDefines(): string;
  18544. /**
  18545. * Returns the string "BoxParticleEmitter"
  18546. * @returns a string containing the class name
  18547. */
  18548. getClassName(): string;
  18549. /**
  18550. * Serializes the particle system to a JSON object.
  18551. * @returns the JSON object
  18552. */
  18553. serialize(): any;
  18554. /**
  18555. * Parse properties from a JSON object
  18556. * @param serializationObject defines the JSON object
  18557. */
  18558. parse(serializationObject: any): void;
  18559. }
  18560. }
  18561. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18562. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18563. import { Effect } from "babylonjs/Materials/effect";
  18564. import { Particle } from "babylonjs/Particles/particle";
  18565. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18566. /**
  18567. * Particle emitter emitting particles from the inside of a cone.
  18568. * It emits the particles alongside the cone volume from the base to the particle.
  18569. * The emission direction might be randomized.
  18570. */
  18571. export class ConeParticleEmitter implements IParticleEmitterType {
  18572. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18573. directionRandomizer: number;
  18574. private _radius;
  18575. private _angle;
  18576. private _height;
  18577. /**
  18578. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18579. */
  18580. radiusRange: number;
  18581. /**
  18582. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18583. */
  18584. heightRange: number;
  18585. /**
  18586. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18587. */
  18588. emitFromSpawnPointOnly: boolean;
  18589. /**
  18590. * Gets or sets the radius of the emission cone
  18591. */
  18592. get radius(): number;
  18593. set radius(value: number);
  18594. /**
  18595. * Gets or sets the angle of the emission cone
  18596. */
  18597. get angle(): number;
  18598. set angle(value: number);
  18599. private _buildHeight;
  18600. /**
  18601. * Creates a new instance ConeParticleEmitter
  18602. * @param radius the radius of the emission cone (1 by default)
  18603. * @param angle the cone base angle (PI by default)
  18604. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18605. */
  18606. constructor(radius?: number, angle?: number,
  18607. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18608. directionRandomizer?: number);
  18609. /**
  18610. * Called by the particle System when the direction is computed for the created particle.
  18611. * @param worldMatrix is the world matrix of the particle system
  18612. * @param directionToUpdate is the direction vector to update with the result
  18613. * @param particle is the particle we are computed the direction for
  18614. */
  18615. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18616. /**
  18617. * Called by the particle System when the position is computed for the created particle.
  18618. * @param worldMatrix is the world matrix of the particle system
  18619. * @param positionToUpdate is the position vector to update with the result
  18620. * @param particle is the particle we are computed the position for
  18621. */
  18622. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18623. /**
  18624. * Clones the current emitter and returns a copy of it
  18625. * @returns the new emitter
  18626. */
  18627. clone(): ConeParticleEmitter;
  18628. /**
  18629. * Called by the GPUParticleSystem to setup the update shader
  18630. * @param effect defines the update shader
  18631. */
  18632. applyToShader(effect: Effect): void;
  18633. /**
  18634. * Returns a string to use to update the GPU particles update shader
  18635. * @returns a string containng the defines string
  18636. */
  18637. getEffectDefines(): string;
  18638. /**
  18639. * Returns the string "ConeParticleEmitter"
  18640. * @returns a string containing the class name
  18641. */
  18642. getClassName(): string;
  18643. /**
  18644. * Serializes the particle system to a JSON object.
  18645. * @returns the JSON object
  18646. */
  18647. serialize(): any;
  18648. /**
  18649. * Parse properties from a JSON object
  18650. * @param serializationObject defines the JSON object
  18651. */
  18652. parse(serializationObject: any): void;
  18653. }
  18654. }
  18655. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18656. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18657. import { Effect } from "babylonjs/Materials/effect";
  18658. import { Particle } from "babylonjs/Particles/particle";
  18659. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18660. /**
  18661. * Particle emitter emitting particles from the inside of a cylinder.
  18662. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18663. */
  18664. export class CylinderParticleEmitter implements IParticleEmitterType {
  18665. /**
  18666. * The radius of the emission cylinder.
  18667. */
  18668. radius: number;
  18669. /**
  18670. * The height of the emission cylinder.
  18671. */
  18672. height: number;
  18673. /**
  18674. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18675. */
  18676. radiusRange: number;
  18677. /**
  18678. * How much to randomize the particle direction [0-1].
  18679. */
  18680. directionRandomizer: number;
  18681. /**
  18682. * Creates a new instance CylinderParticleEmitter
  18683. * @param radius the radius of the emission cylinder (1 by default)
  18684. * @param height the height of the emission cylinder (1 by default)
  18685. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18686. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18687. */
  18688. constructor(
  18689. /**
  18690. * The radius of the emission cylinder.
  18691. */
  18692. radius?: number,
  18693. /**
  18694. * The height of the emission cylinder.
  18695. */
  18696. height?: number,
  18697. /**
  18698. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18699. */
  18700. radiusRange?: number,
  18701. /**
  18702. * How much to randomize the particle direction [0-1].
  18703. */
  18704. directionRandomizer?: number);
  18705. /**
  18706. * Called by the particle System when the direction is computed for the created particle.
  18707. * @param worldMatrix is the world matrix of the particle system
  18708. * @param directionToUpdate is the direction vector to update with the result
  18709. * @param particle is the particle we are computed the direction for
  18710. */
  18711. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18712. /**
  18713. * Called by the particle System when the position is computed for the created particle.
  18714. * @param worldMatrix is the world matrix of the particle system
  18715. * @param positionToUpdate is the position vector to update with the result
  18716. * @param particle is the particle we are computed the position for
  18717. */
  18718. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18719. /**
  18720. * Clones the current emitter and returns a copy of it
  18721. * @returns the new emitter
  18722. */
  18723. clone(): CylinderParticleEmitter;
  18724. /**
  18725. * Called by the GPUParticleSystem to setup the update shader
  18726. * @param effect defines the update shader
  18727. */
  18728. applyToShader(effect: Effect): void;
  18729. /**
  18730. * Returns a string to use to update the GPU particles update shader
  18731. * @returns a string containng the defines string
  18732. */
  18733. getEffectDefines(): string;
  18734. /**
  18735. * Returns the string "CylinderParticleEmitter"
  18736. * @returns a string containing the class name
  18737. */
  18738. getClassName(): string;
  18739. /**
  18740. * Serializes the particle system to a JSON object.
  18741. * @returns the JSON object
  18742. */
  18743. serialize(): any;
  18744. /**
  18745. * Parse properties from a JSON object
  18746. * @param serializationObject defines the JSON object
  18747. */
  18748. parse(serializationObject: any): void;
  18749. }
  18750. /**
  18751. * Particle emitter emitting particles from the inside of a cylinder.
  18752. * It emits the particles randomly between two vectors.
  18753. */
  18754. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18755. /**
  18756. * The min limit of the emission direction.
  18757. */
  18758. direction1: Vector3;
  18759. /**
  18760. * The max limit of the emission direction.
  18761. */
  18762. direction2: Vector3;
  18763. /**
  18764. * Creates a new instance CylinderDirectedParticleEmitter
  18765. * @param radius the radius of the emission cylinder (1 by default)
  18766. * @param height the height of the emission cylinder (1 by default)
  18767. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18768. * @param direction1 the min limit of the emission direction (up vector by default)
  18769. * @param direction2 the max limit of the emission direction (up vector by default)
  18770. */
  18771. constructor(radius?: number, height?: number, radiusRange?: number,
  18772. /**
  18773. * The min limit of the emission direction.
  18774. */
  18775. direction1?: Vector3,
  18776. /**
  18777. * The max limit of the emission direction.
  18778. */
  18779. direction2?: Vector3);
  18780. /**
  18781. * Called by the particle System when the direction is computed for the created particle.
  18782. * @param worldMatrix is the world matrix of the particle system
  18783. * @param directionToUpdate is the direction vector to update with the result
  18784. * @param particle is the particle we are computed the direction for
  18785. */
  18786. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18787. /**
  18788. * Clones the current emitter and returns a copy of it
  18789. * @returns the new emitter
  18790. */
  18791. clone(): CylinderDirectedParticleEmitter;
  18792. /**
  18793. * Called by the GPUParticleSystem to setup the update shader
  18794. * @param effect defines the update shader
  18795. */
  18796. applyToShader(effect: Effect): void;
  18797. /**
  18798. * Returns a string to use to update the GPU particles update shader
  18799. * @returns a string containng the defines string
  18800. */
  18801. getEffectDefines(): string;
  18802. /**
  18803. * Returns the string "CylinderDirectedParticleEmitter"
  18804. * @returns a string containing the class name
  18805. */
  18806. getClassName(): string;
  18807. /**
  18808. * Serializes the particle system to a JSON object.
  18809. * @returns the JSON object
  18810. */
  18811. serialize(): any;
  18812. /**
  18813. * Parse properties from a JSON object
  18814. * @param serializationObject defines the JSON object
  18815. */
  18816. parse(serializationObject: any): void;
  18817. }
  18818. }
  18819. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18820. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18821. import { Effect } from "babylonjs/Materials/effect";
  18822. import { Particle } from "babylonjs/Particles/particle";
  18823. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18824. /**
  18825. * Particle emitter emitting particles from the inside of a hemisphere.
  18826. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18827. */
  18828. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18829. /**
  18830. * The radius of the emission hemisphere.
  18831. */
  18832. radius: number;
  18833. /**
  18834. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18835. */
  18836. radiusRange: number;
  18837. /**
  18838. * How much to randomize the particle direction [0-1].
  18839. */
  18840. directionRandomizer: number;
  18841. /**
  18842. * Creates a new instance HemisphericParticleEmitter
  18843. * @param radius the radius of the emission hemisphere (1 by default)
  18844. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18845. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18846. */
  18847. constructor(
  18848. /**
  18849. * The radius of the emission hemisphere.
  18850. */
  18851. radius?: number,
  18852. /**
  18853. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18854. */
  18855. radiusRange?: number,
  18856. /**
  18857. * How much to randomize the particle direction [0-1].
  18858. */
  18859. directionRandomizer?: number);
  18860. /**
  18861. * Called by the particle System when the direction is computed for the created particle.
  18862. * @param worldMatrix is the world matrix of the particle system
  18863. * @param directionToUpdate is the direction vector to update with the result
  18864. * @param particle is the particle we are computed the direction for
  18865. */
  18866. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18867. /**
  18868. * Called by the particle System when the position is computed for the created particle.
  18869. * @param worldMatrix is the world matrix of the particle system
  18870. * @param positionToUpdate is the position vector to update with the result
  18871. * @param particle is the particle we are computed the position for
  18872. */
  18873. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18874. /**
  18875. * Clones the current emitter and returns a copy of it
  18876. * @returns the new emitter
  18877. */
  18878. clone(): HemisphericParticleEmitter;
  18879. /**
  18880. * Called by the GPUParticleSystem to setup the update shader
  18881. * @param effect defines the update shader
  18882. */
  18883. applyToShader(effect: Effect): void;
  18884. /**
  18885. * Returns a string to use to update the GPU particles update shader
  18886. * @returns a string containng the defines string
  18887. */
  18888. getEffectDefines(): string;
  18889. /**
  18890. * Returns the string "HemisphericParticleEmitter"
  18891. * @returns a string containing the class name
  18892. */
  18893. getClassName(): string;
  18894. /**
  18895. * Serializes the particle system to a JSON object.
  18896. * @returns the JSON object
  18897. */
  18898. serialize(): any;
  18899. /**
  18900. * Parse properties from a JSON object
  18901. * @param serializationObject defines the JSON object
  18902. */
  18903. parse(serializationObject: any): void;
  18904. }
  18905. }
  18906. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18907. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18908. import { Effect } from "babylonjs/Materials/effect";
  18909. import { Particle } from "babylonjs/Particles/particle";
  18910. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18911. /**
  18912. * Particle emitter emitting particles from a point.
  18913. * It emits the particles randomly between 2 given directions.
  18914. */
  18915. export class PointParticleEmitter implements IParticleEmitterType {
  18916. /**
  18917. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18918. */
  18919. direction1: Vector3;
  18920. /**
  18921. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18922. */
  18923. direction2: Vector3;
  18924. /**
  18925. * Creates a new instance PointParticleEmitter
  18926. */
  18927. constructor();
  18928. /**
  18929. * Called by the particle System when the direction is computed for the created particle.
  18930. * @param worldMatrix is the world matrix of the particle system
  18931. * @param directionToUpdate is the direction vector to update with the result
  18932. * @param particle is the particle we are computed the direction for
  18933. */
  18934. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18935. /**
  18936. * Called by the particle System when the position is computed for the created particle.
  18937. * @param worldMatrix is the world matrix of the particle system
  18938. * @param positionToUpdate is the position vector to update with the result
  18939. * @param particle is the particle we are computed the position for
  18940. */
  18941. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18942. /**
  18943. * Clones the current emitter and returns a copy of it
  18944. * @returns the new emitter
  18945. */
  18946. clone(): PointParticleEmitter;
  18947. /**
  18948. * Called by the GPUParticleSystem to setup the update shader
  18949. * @param effect defines the update shader
  18950. */
  18951. applyToShader(effect: Effect): void;
  18952. /**
  18953. * Returns a string to use to update the GPU particles update shader
  18954. * @returns a string containng the defines string
  18955. */
  18956. getEffectDefines(): string;
  18957. /**
  18958. * Returns the string "PointParticleEmitter"
  18959. * @returns a string containing the class name
  18960. */
  18961. getClassName(): string;
  18962. /**
  18963. * Serializes the particle system to a JSON object.
  18964. * @returns the JSON object
  18965. */
  18966. serialize(): any;
  18967. /**
  18968. * Parse properties from a JSON object
  18969. * @param serializationObject defines the JSON object
  18970. */
  18971. parse(serializationObject: any): void;
  18972. }
  18973. }
  18974. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18975. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18976. import { Effect } from "babylonjs/Materials/effect";
  18977. import { Particle } from "babylonjs/Particles/particle";
  18978. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18979. /**
  18980. * Particle emitter emitting particles from the inside of a sphere.
  18981. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18982. */
  18983. export class SphereParticleEmitter implements IParticleEmitterType {
  18984. /**
  18985. * The radius of the emission sphere.
  18986. */
  18987. radius: number;
  18988. /**
  18989. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18990. */
  18991. radiusRange: number;
  18992. /**
  18993. * How much to randomize the particle direction [0-1].
  18994. */
  18995. directionRandomizer: number;
  18996. /**
  18997. * Creates a new instance SphereParticleEmitter
  18998. * @param radius the radius of the emission sphere (1 by default)
  18999. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19000. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  19001. */
  19002. constructor(
  19003. /**
  19004. * The radius of the emission sphere.
  19005. */
  19006. radius?: number,
  19007. /**
  19008. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  19009. */
  19010. radiusRange?: number,
  19011. /**
  19012. * How much to randomize the particle direction [0-1].
  19013. */
  19014. directionRandomizer?: number);
  19015. /**
  19016. * Called by the particle System when the direction is computed for the created particle.
  19017. * @param worldMatrix is the world matrix of the particle system
  19018. * @param directionToUpdate is the direction vector to update with the result
  19019. * @param particle is the particle we are computed the direction for
  19020. */
  19021. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  19022. /**
  19023. * Called by the particle System when the position is computed for the created particle.
  19024. * @param worldMatrix is the world matrix of the particle system
  19025. * @param positionToUpdate is the position vector to update with the result
  19026. * @param particle is the particle we are computed the position for
  19027. */
  19028. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  19029. /**
  19030. * Clones the current emitter and returns a copy of it
  19031. * @returns the new emitter
  19032. */
  19033. clone(): SphereParticleEmitter;
  19034. /**
  19035. * Called by the GPUParticleSystem to setup the update shader
  19036. * @param effect defines the update shader
  19037. */
  19038. applyToShader(effect: Effect): void;
  19039. /**
  19040. * Returns a string to use to update the GPU particles update shader
  19041. * @returns a string containng the defines string
  19042. */
  19043. getEffectDefines(): string;
  19044. /**
  19045. * Returns the string "SphereParticleEmitter"
  19046. * @returns a string containing the class name
  19047. */
  19048. getClassName(): string;
  19049. /**
  19050. * Serializes the particle system to a JSON object.
  19051. * @returns the JSON object
  19052. */
  19053. serialize(): any;
  19054. /**
  19055. * Parse properties from a JSON object
  19056. * @param serializationObject defines the JSON object
  19057. */
  19058. parse(serializationObject: any): void;
  19059. }
  19060. /**
  19061. * Particle emitter emitting particles from the inside of a sphere.
  19062. * It emits the particles randomly between two vectors.
  19063. */
  19064. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  19065. /**
  19066. * The min limit of the emission direction.
  19067. */
  19068. direction1: Vector3;
  19069. /**
  19070. * The max limit of the emission direction.
  19071. */
  19072. direction2: Vector3;
  19073. /**
  19074. * Creates a new instance SphereDirectedParticleEmitter
  19075. * @param radius the radius of the emission sphere (1 by default)
  19076. * @param direction1 the min limit of the emission direction (up vector by default)
  19077. * @param direction2 the max limit of the emission direction (up vector by default)
  19078. */
  19079. constructor(radius?: number,
  19080. /**
  19081. * The min limit of the emission direction.
  19082. */
  19083. direction1?: Vector3,
  19084. /**
  19085. * The max limit of the emission direction.
  19086. */
  19087. direction2?: Vector3);
  19088. /**
  19089. * Called by the particle System when the direction is computed for the created particle.
  19090. * @param worldMatrix is the world matrix of the particle system
  19091. * @param directionToUpdate is the direction vector to update with the result
  19092. * @param particle is the particle we are computed the direction for
  19093. */
  19094. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  19095. /**
  19096. * Clones the current emitter and returns a copy of it
  19097. * @returns the new emitter
  19098. */
  19099. clone(): SphereDirectedParticleEmitter;
  19100. /**
  19101. * Called by the GPUParticleSystem to setup the update shader
  19102. * @param effect defines the update shader
  19103. */
  19104. applyToShader(effect: Effect): void;
  19105. /**
  19106. * Returns a string to use to update the GPU particles update shader
  19107. * @returns a string containng the defines string
  19108. */
  19109. getEffectDefines(): string;
  19110. /**
  19111. * Returns the string "SphereDirectedParticleEmitter"
  19112. * @returns a string containing the class name
  19113. */
  19114. getClassName(): string;
  19115. /**
  19116. * Serializes the particle system to a JSON object.
  19117. * @returns the JSON object
  19118. */
  19119. serialize(): any;
  19120. /**
  19121. * Parse properties from a JSON object
  19122. * @param serializationObject defines the JSON object
  19123. */
  19124. parse(serializationObject: any): void;
  19125. }
  19126. }
  19127. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  19128. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19129. import { Effect } from "babylonjs/Materials/effect";
  19130. import { Particle } from "babylonjs/Particles/particle";
  19131. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  19132. import { Nullable } from "babylonjs/types";
  19133. /**
  19134. * Particle emitter emitting particles from a custom list of positions.
  19135. */
  19136. export class CustomParticleEmitter implements IParticleEmitterType {
  19137. /**
  19138. * Gets or sets the position generator that will create the inital position of each particle.
  19139. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  19140. */
  19141. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  19142. /**
  19143. * Gets or sets the destination generator that will create the final destination of each particle.
  19144. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  19145. */
  19146. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  19147. /**
  19148. * Creates a new instance CustomParticleEmitter
  19149. */
  19150. constructor();
  19151. /**
  19152. * Called by the particle System when the direction is computed for the created particle.
  19153. * @param worldMatrix is the world matrix of the particle system
  19154. * @param directionToUpdate is the direction vector to update with the result
  19155. * @param particle is the particle we are computed the direction for
  19156. */
  19157. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  19158. /**
  19159. * Called by the particle System when the position is computed for the created particle.
  19160. * @param worldMatrix is the world matrix of the particle system
  19161. * @param positionToUpdate is the position vector to update with the result
  19162. * @param particle is the particle we are computed the position for
  19163. */
  19164. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  19165. /**
  19166. * Clones the current emitter and returns a copy of it
  19167. * @returns the new emitter
  19168. */
  19169. clone(): CustomParticleEmitter;
  19170. /**
  19171. * Called by the GPUParticleSystem to setup the update shader
  19172. * @param effect defines the update shader
  19173. */
  19174. applyToShader(effect: Effect): void;
  19175. /**
  19176. * Returns a string to use to update the GPU particles update shader
  19177. * @returns a string containng the defines string
  19178. */
  19179. getEffectDefines(): string;
  19180. /**
  19181. * Returns the string "PointParticleEmitter"
  19182. * @returns a string containing the class name
  19183. */
  19184. getClassName(): string;
  19185. /**
  19186. * Serializes the particle system to a JSON object.
  19187. * @returns the JSON object
  19188. */
  19189. serialize(): any;
  19190. /**
  19191. * Parse properties from a JSON object
  19192. * @param serializationObject defines the JSON object
  19193. */
  19194. parse(serializationObject: any): void;
  19195. }
  19196. }
  19197. declare module "babylonjs/Particles/EmitterTypes/index" {
  19198. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  19199. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  19200. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  19201. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  19202. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  19203. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  19204. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  19205. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  19206. }
  19207. declare module "babylonjs/Particles/IParticleSystem" {
  19208. import { Nullable } from "babylonjs/types";
  19209. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  19210. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19212. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19213. import { Texture } from "babylonjs/Materials/Textures/texture";
  19214. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  19215. import { Scene } from "babylonjs/scene";
  19216. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  19217. import { Animation } from "babylonjs/Animations/animation";
  19218. /**
  19219. * Interface representing a particle system in Babylon.js.
  19220. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  19221. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  19222. */
  19223. export interface IParticleSystem {
  19224. /**
  19225. * List of animations used by the particle system.
  19226. */
  19227. animations: Animation[];
  19228. /**
  19229. * The id of the Particle system.
  19230. */
  19231. id: string;
  19232. /**
  19233. * The name of the Particle system.
  19234. */
  19235. name: string;
  19236. /**
  19237. * The emitter represents the Mesh or position we are attaching the particle system to.
  19238. */
  19239. emitter: Nullable<AbstractMesh | Vector3>;
  19240. /**
  19241. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19242. */
  19243. isBillboardBased: boolean;
  19244. /**
  19245. * The rendering group used by the Particle system to chose when to render.
  19246. */
  19247. renderingGroupId: number;
  19248. /**
  19249. * The layer mask we are rendering the particles through.
  19250. */
  19251. layerMask: number;
  19252. /**
  19253. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19254. */
  19255. updateSpeed: number;
  19256. /**
  19257. * The amount of time the particle system is running (depends of the overall update speed).
  19258. */
  19259. targetStopDuration: number;
  19260. /**
  19261. * The texture used to render each particle. (this can be a spritesheet)
  19262. */
  19263. particleTexture: Nullable<Texture>;
  19264. /**
  19265. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  19266. */
  19267. blendMode: number;
  19268. /**
  19269. * Minimum life time of emitting particles.
  19270. */
  19271. minLifeTime: number;
  19272. /**
  19273. * Maximum life time of emitting particles.
  19274. */
  19275. maxLifeTime: number;
  19276. /**
  19277. * Minimum Size of emitting particles.
  19278. */
  19279. minSize: number;
  19280. /**
  19281. * Maximum Size of emitting particles.
  19282. */
  19283. maxSize: number;
  19284. /**
  19285. * Minimum scale of emitting particles on X axis.
  19286. */
  19287. minScaleX: number;
  19288. /**
  19289. * Maximum scale of emitting particles on X axis.
  19290. */
  19291. maxScaleX: number;
  19292. /**
  19293. * Minimum scale of emitting particles on Y axis.
  19294. */
  19295. minScaleY: number;
  19296. /**
  19297. * Maximum scale of emitting particles on Y axis.
  19298. */
  19299. maxScaleY: number;
  19300. /**
  19301. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19302. */
  19303. color1: Color4;
  19304. /**
  19305. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19306. */
  19307. color2: Color4;
  19308. /**
  19309. * Color the particle will have at the end of its lifetime.
  19310. */
  19311. colorDead: Color4;
  19312. /**
  19313. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  19314. */
  19315. emitRate: number;
  19316. /**
  19317. * You can use gravity if you want to give an orientation to your particles.
  19318. */
  19319. gravity: Vector3;
  19320. /**
  19321. * Minimum power of emitting particles.
  19322. */
  19323. minEmitPower: number;
  19324. /**
  19325. * Maximum power of emitting particles.
  19326. */
  19327. maxEmitPower: number;
  19328. /**
  19329. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19330. */
  19331. minAngularSpeed: number;
  19332. /**
  19333. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19334. */
  19335. maxAngularSpeed: number;
  19336. /**
  19337. * Gets or sets the minimal initial rotation in radians.
  19338. */
  19339. minInitialRotation: number;
  19340. /**
  19341. * Gets or sets the maximal initial rotation in radians.
  19342. */
  19343. maxInitialRotation: number;
  19344. /**
  19345. * The particle emitter type defines the emitter used by the particle system.
  19346. * It can be for example box, sphere, or cone...
  19347. */
  19348. particleEmitterType: Nullable<IParticleEmitterType>;
  19349. /**
  19350. * Defines the delay in milliseconds before starting the system (0 by default)
  19351. */
  19352. startDelay: number;
  19353. /**
  19354. * 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
  19355. */
  19356. preWarmCycles: number;
  19357. /**
  19358. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  19359. */
  19360. preWarmStepOffset: number;
  19361. /**
  19362. * 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)
  19363. */
  19364. spriteCellChangeSpeed: number;
  19365. /**
  19366. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19367. */
  19368. startSpriteCellID: number;
  19369. /**
  19370. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19371. */
  19372. endSpriteCellID: number;
  19373. /**
  19374. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19375. */
  19376. spriteCellWidth: number;
  19377. /**
  19378. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19379. */
  19380. spriteCellHeight: number;
  19381. /**
  19382. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19383. */
  19384. spriteRandomStartCell: boolean;
  19385. /**
  19386. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  19387. */
  19388. isAnimationSheetEnabled: boolean;
  19389. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19390. translationPivot: Vector2;
  19391. /**
  19392. * Gets or sets a texture used to add random noise to particle positions
  19393. */
  19394. noiseTexture: Nullable<BaseTexture>;
  19395. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19396. noiseStrength: Vector3;
  19397. /**
  19398. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19399. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19400. */
  19401. billboardMode: number;
  19402. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19403. limitVelocityDamping: number;
  19404. /**
  19405. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19406. */
  19407. beginAnimationOnStart: boolean;
  19408. /**
  19409. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19410. */
  19411. beginAnimationFrom: number;
  19412. /**
  19413. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19414. */
  19415. beginAnimationTo: number;
  19416. /**
  19417. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19418. */
  19419. beginAnimationLoop: boolean;
  19420. /**
  19421. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19422. */
  19423. disposeOnStop: boolean;
  19424. /**
  19425. * Gets the maximum number of particles active at the same time.
  19426. * @returns The max number of active particles.
  19427. */
  19428. getCapacity(): number;
  19429. /**
  19430. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19431. * @returns True if it has been started, otherwise false.
  19432. */
  19433. isStarted(): boolean;
  19434. /**
  19435. * Animates the particle system for this frame.
  19436. */
  19437. animate(): void;
  19438. /**
  19439. * Renders the particle system in its current state.
  19440. * @returns the current number of particles
  19441. */
  19442. render(): number;
  19443. /**
  19444. * Dispose the particle system and frees its associated resources.
  19445. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19446. */
  19447. dispose(disposeTexture?: boolean): void;
  19448. /**
  19449. * Clones the particle system.
  19450. * @param name The name of the cloned object
  19451. * @param newEmitter The new emitter to use
  19452. * @returns the cloned particle system
  19453. */
  19454. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19455. /**
  19456. * Serializes the particle system to a JSON object.
  19457. * @returns the JSON object
  19458. */
  19459. serialize(): any;
  19460. /**
  19461. * Rebuild the particle system
  19462. */
  19463. rebuild(): void;
  19464. /**
  19465. * Starts the particle system and begins to emit
  19466. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19467. */
  19468. start(delay?: number): void;
  19469. /**
  19470. * Stops the particle system.
  19471. */
  19472. stop(): void;
  19473. /**
  19474. * Remove all active particles
  19475. */
  19476. reset(): void;
  19477. /**
  19478. * Is this system ready to be used/rendered
  19479. * @return true if the system is ready
  19480. */
  19481. isReady(): boolean;
  19482. /**
  19483. * Adds a new color gradient
  19484. * @param gradient defines the gradient to use (between 0 and 1)
  19485. * @param color1 defines the color to affect to the specified gradient
  19486. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19487. * @returns the current particle system
  19488. */
  19489. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19490. /**
  19491. * Remove a specific color gradient
  19492. * @param gradient defines the gradient to remove
  19493. * @returns the current particle system
  19494. */
  19495. removeColorGradient(gradient: number): IParticleSystem;
  19496. /**
  19497. * Adds a new size gradient
  19498. * @param gradient defines the gradient to use (between 0 and 1)
  19499. * @param factor defines the size factor to affect to the specified gradient
  19500. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19501. * @returns the current particle system
  19502. */
  19503. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19504. /**
  19505. * Remove a specific size gradient
  19506. * @param gradient defines the gradient to remove
  19507. * @returns the current particle system
  19508. */
  19509. removeSizeGradient(gradient: number): IParticleSystem;
  19510. /**
  19511. * Gets the current list of color gradients.
  19512. * You must use addColorGradient and removeColorGradient to udpate this list
  19513. * @returns the list of color gradients
  19514. */
  19515. getColorGradients(): Nullable<Array<ColorGradient>>;
  19516. /**
  19517. * Gets the current list of size gradients.
  19518. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19519. * @returns the list of size gradients
  19520. */
  19521. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19522. /**
  19523. * Gets the current list of angular speed gradients.
  19524. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19525. * @returns the list of angular speed gradients
  19526. */
  19527. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19528. /**
  19529. * Adds a new angular speed gradient
  19530. * @param gradient defines the gradient to use (between 0 and 1)
  19531. * @param factor defines the angular speed to affect to the specified gradient
  19532. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19533. * @returns the current particle system
  19534. */
  19535. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19536. /**
  19537. * Remove a specific angular speed gradient
  19538. * @param gradient defines the gradient to remove
  19539. * @returns the current particle system
  19540. */
  19541. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19542. /**
  19543. * Gets the current list of velocity gradients.
  19544. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19545. * @returns the list of velocity gradients
  19546. */
  19547. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19548. /**
  19549. * Adds a new velocity gradient
  19550. * @param gradient defines the gradient to use (between 0 and 1)
  19551. * @param factor defines the velocity to affect to the specified gradient
  19552. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19553. * @returns the current particle system
  19554. */
  19555. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19556. /**
  19557. * Remove a specific velocity gradient
  19558. * @param gradient defines the gradient to remove
  19559. * @returns the current particle system
  19560. */
  19561. removeVelocityGradient(gradient: number): IParticleSystem;
  19562. /**
  19563. * Gets the current list of limit velocity gradients.
  19564. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19565. * @returns the list of limit velocity gradients
  19566. */
  19567. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19568. /**
  19569. * Adds a new limit velocity gradient
  19570. * @param gradient defines the gradient to use (between 0 and 1)
  19571. * @param factor defines the limit velocity to affect to the specified gradient
  19572. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19573. * @returns the current particle system
  19574. */
  19575. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19576. /**
  19577. * Remove a specific limit velocity gradient
  19578. * @param gradient defines the gradient to remove
  19579. * @returns the current particle system
  19580. */
  19581. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19582. /**
  19583. * Adds a new drag gradient
  19584. * @param gradient defines the gradient to use (between 0 and 1)
  19585. * @param factor defines the drag to affect to the specified gradient
  19586. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19587. * @returns the current particle system
  19588. */
  19589. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19590. /**
  19591. * Remove a specific drag gradient
  19592. * @param gradient defines the gradient to remove
  19593. * @returns the current particle system
  19594. */
  19595. removeDragGradient(gradient: number): IParticleSystem;
  19596. /**
  19597. * Gets the current list of drag gradients.
  19598. * You must use addDragGradient and removeDragGradient to udpate this list
  19599. * @returns the list of drag gradients
  19600. */
  19601. getDragGradients(): Nullable<Array<FactorGradient>>;
  19602. /**
  19603. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19604. * @param gradient defines the gradient to use (between 0 and 1)
  19605. * @param factor defines the emit rate to affect to the specified gradient
  19606. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19607. * @returns the current particle system
  19608. */
  19609. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19610. /**
  19611. * Remove a specific emit rate gradient
  19612. * @param gradient defines the gradient to remove
  19613. * @returns the current particle system
  19614. */
  19615. removeEmitRateGradient(gradient: number): IParticleSystem;
  19616. /**
  19617. * Gets the current list of emit rate gradients.
  19618. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19619. * @returns the list of emit rate gradients
  19620. */
  19621. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19622. /**
  19623. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19624. * @param gradient defines the gradient to use (between 0 and 1)
  19625. * @param factor defines the start size to affect to the specified gradient
  19626. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19627. * @returns the current particle system
  19628. */
  19629. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19630. /**
  19631. * Remove a specific start size gradient
  19632. * @param gradient defines the gradient to remove
  19633. * @returns the current particle system
  19634. */
  19635. removeStartSizeGradient(gradient: number): IParticleSystem;
  19636. /**
  19637. * Gets the current list of start size gradients.
  19638. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19639. * @returns the list of start size gradients
  19640. */
  19641. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19642. /**
  19643. * Adds a new life time gradient
  19644. * @param gradient defines the gradient to use (between 0 and 1)
  19645. * @param factor defines the life time factor to affect to the specified gradient
  19646. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19647. * @returns the current particle system
  19648. */
  19649. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19650. /**
  19651. * Remove a specific life time gradient
  19652. * @param gradient defines the gradient to remove
  19653. * @returns the current particle system
  19654. */
  19655. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19656. /**
  19657. * Gets the current list of life time gradients.
  19658. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19659. * @returns the list of life time gradients
  19660. */
  19661. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19662. /**
  19663. * Gets the current list of color gradients.
  19664. * You must use addColorGradient and removeColorGradient to udpate this list
  19665. * @returns the list of color gradients
  19666. */
  19667. getColorGradients(): Nullable<Array<ColorGradient>>;
  19668. /**
  19669. * Adds a new ramp gradient used to remap particle colors
  19670. * @param gradient defines the gradient to use (between 0 and 1)
  19671. * @param color defines the color to affect to the specified gradient
  19672. * @returns the current particle system
  19673. */
  19674. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19675. /**
  19676. * Gets the current list of ramp gradients.
  19677. * You must use addRampGradient and removeRampGradient to udpate this list
  19678. * @returns the list of ramp gradients
  19679. */
  19680. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19681. /** Gets or sets a boolean indicating that ramp gradients must be used
  19682. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19683. */
  19684. useRampGradients: boolean;
  19685. /**
  19686. * Adds a new color remap gradient
  19687. * @param gradient defines the gradient to use (between 0 and 1)
  19688. * @param min defines the color remap minimal range
  19689. * @param max defines the color remap maximal range
  19690. * @returns the current particle system
  19691. */
  19692. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19693. /**
  19694. * Gets the current list of color remap gradients.
  19695. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19696. * @returns the list of color remap gradients
  19697. */
  19698. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19699. /**
  19700. * Adds a new alpha remap gradient
  19701. * @param gradient defines the gradient to use (between 0 and 1)
  19702. * @param min defines the alpha remap minimal range
  19703. * @param max defines the alpha remap maximal range
  19704. * @returns the current particle system
  19705. */
  19706. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19707. /**
  19708. * Gets the current list of alpha remap gradients.
  19709. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19710. * @returns the list of alpha remap gradients
  19711. */
  19712. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19713. /**
  19714. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19715. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19716. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19717. * @returns the emitter
  19718. */
  19719. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19720. /**
  19721. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19722. * @param radius The radius of the hemisphere to emit from
  19723. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19724. * @returns the emitter
  19725. */
  19726. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19727. /**
  19728. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19729. * @param radius The radius of the sphere to emit from
  19730. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19731. * @returns the emitter
  19732. */
  19733. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19734. /**
  19735. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19736. * @param radius The radius of the sphere to emit from
  19737. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19738. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19739. * @returns the emitter
  19740. */
  19741. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19742. /**
  19743. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19744. * @param radius The radius of the emission cylinder
  19745. * @param height The height of the emission cylinder
  19746. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19747. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19748. * @returns the emitter
  19749. */
  19750. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19751. /**
  19752. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19753. * @param radius The radius of the cylinder to emit from
  19754. * @param height The height of the emission cylinder
  19755. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19756. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19757. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19758. * @returns the emitter
  19759. */
  19760. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19761. /**
  19762. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19763. * @param radius The radius of the cone to emit from
  19764. * @param angle The base angle of the cone
  19765. * @returns the emitter
  19766. */
  19767. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19768. /**
  19769. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19770. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19771. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19772. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19773. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19774. * @returns the emitter
  19775. */
  19776. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19777. /**
  19778. * Get hosting scene
  19779. * @returns the scene
  19780. */
  19781. getScene(): Scene;
  19782. }
  19783. }
  19784. declare module "babylonjs/Meshes/instancedMesh" {
  19785. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19786. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19787. import { Camera } from "babylonjs/Cameras/camera";
  19788. import { Node } from "babylonjs/node";
  19789. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19790. import { Mesh } from "babylonjs/Meshes/mesh";
  19791. import { Material } from "babylonjs/Materials/material";
  19792. import { Skeleton } from "babylonjs/Bones/skeleton";
  19793. import { Light } from "babylonjs/Lights/light";
  19794. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19795. /**
  19796. * Creates an instance based on a source mesh.
  19797. */
  19798. export class InstancedMesh extends AbstractMesh {
  19799. private _sourceMesh;
  19800. private _currentLOD;
  19801. /** @hidden */
  19802. _indexInSourceMeshInstanceArray: number;
  19803. constructor(name: string, source: Mesh);
  19804. /**
  19805. * Returns the string "InstancedMesh".
  19806. */
  19807. getClassName(): string;
  19808. /** Gets the list of lights affecting that mesh */
  19809. get lightSources(): Light[];
  19810. _resyncLightSources(): void;
  19811. _resyncLightSource(light: Light): void;
  19812. _removeLightSource(light: Light, dispose: boolean): void;
  19813. /**
  19814. * If the source mesh receives shadows
  19815. */
  19816. get receiveShadows(): boolean;
  19817. /**
  19818. * The material of the source mesh
  19819. */
  19820. get material(): Nullable<Material>;
  19821. /**
  19822. * Visibility of the source mesh
  19823. */
  19824. get visibility(): number;
  19825. /**
  19826. * Skeleton of the source mesh
  19827. */
  19828. get skeleton(): Nullable<Skeleton>;
  19829. /**
  19830. * Rendering ground id of the source mesh
  19831. */
  19832. get renderingGroupId(): number;
  19833. set renderingGroupId(value: number);
  19834. /**
  19835. * Returns the total number of vertices (integer).
  19836. */
  19837. getTotalVertices(): number;
  19838. /**
  19839. * Returns a positive integer : the total number of indices in this mesh geometry.
  19840. * @returns the numner of indices or zero if the mesh has no geometry.
  19841. */
  19842. getTotalIndices(): number;
  19843. /**
  19844. * The source mesh of the instance
  19845. */
  19846. get sourceMesh(): Mesh;
  19847. /**
  19848. * Is this node ready to be used/rendered
  19849. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19850. * @return {boolean} is it ready
  19851. */
  19852. isReady(completeCheck?: boolean): boolean;
  19853. /**
  19854. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19855. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19856. * @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.
  19857. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19858. */
  19859. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19860. /**
  19861. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19862. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19863. * The `data` are either a numeric array either a Float32Array.
  19864. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19865. * 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).
  19866. * Note that a new underlying VertexBuffer object is created each call.
  19867. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19868. *
  19869. * Possible `kind` values :
  19870. * - VertexBuffer.PositionKind
  19871. * - VertexBuffer.UVKind
  19872. * - VertexBuffer.UV2Kind
  19873. * - VertexBuffer.UV3Kind
  19874. * - VertexBuffer.UV4Kind
  19875. * - VertexBuffer.UV5Kind
  19876. * - VertexBuffer.UV6Kind
  19877. * - VertexBuffer.ColorKind
  19878. * - VertexBuffer.MatricesIndicesKind
  19879. * - VertexBuffer.MatricesIndicesExtraKind
  19880. * - VertexBuffer.MatricesWeightsKind
  19881. * - VertexBuffer.MatricesWeightsExtraKind
  19882. *
  19883. * Returns the Mesh.
  19884. */
  19885. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19886. /**
  19887. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19888. * If the mesh has no geometry, it is simply returned as it is.
  19889. * The `data` are either a numeric array either a Float32Array.
  19890. * No new underlying VertexBuffer object is created.
  19891. * 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.
  19892. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19893. *
  19894. * Possible `kind` values :
  19895. * - VertexBuffer.PositionKind
  19896. * - VertexBuffer.UVKind
  19897. * - VertexBuffer.UV2Kind
  19898. * - VertexBuffer.UV3Kind
  19899. * - VertexBuffer.UV4Kind
  19900. * - VertexBuffer.UV5Kind
  19901. * - VertexBuffer.UV6Kind
  19902. * - VertexBuffer.ColorKind
  19903. * - VertexBuffer.MatricesIndicesKind
  19904. * - VertexBuffer.MatricesIndicesExtraKind
  19905. * - VertexBuffer.MatricesWeightsKind
  19906. * - VertexBuffer.MatricesWeightsExtraKind
  19907. *
  19908. * Returns the Mesh.
  19909. */
  19910. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19911. /**
  19912. * Sets the mesh indices.
  19913. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19914. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19915. * This method creates a new index buffer each call.
  19916. * Returns the Mesh.
  19917. */
  19918. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19919. /**
  19920. * Boolean : True if the mesh owns the requested kind of data.
  19921. */
  19922. isVerticesDataPresent(kind: string): boolean;
  19923. /**
  19924. * Returns an array of indices (IndicesArray).
  19925. */
  19926. getIndices(): Nullable<IndicesArray>;
  19927. get _positions(): Nullable<Vector3[]>;
  19928. /**
  19929. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19930. * This means the mesh underlying bounding box and sphere are recomputed.
  19931. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19932. * @returns the current mesh
  19933. */
  19934. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19935. /** @hidden */
  19936. _preActivate(): InstancedMesh;
  19937. /** @hidden */
  19938. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19939. /** @hidden */
  19940. _postActivate(): void;
  19941. getWorldMatrix(): Matrix;
  19942. get isAnInstance(): boolean;
  19943. /**
  19944. * Returns the current associated LOD AbstractMesh.
  19945. */
  19946. getLOD(camera: Camera): AbstractMesh;
  19947. /** @hidden */
  19948. _syncSubMeshes(): InstancedMesh;
  19949. /** @hidden */
  19950. _generatePointsArray(): boolean;
  19951. /**
  19952. * Creates a new InstancedMesh from the current mesh.
  19953. * - name (string) : the cloned mesh name
  19954. * - newParent (optional Node) : the optional Node to parent the clone to.
  19955. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19956. *
  19957. * Returns the clone.
  19958. */
  19959. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  19960. /**
  19961. * Disposes the InstancedMesh.
  19962. * Returns nothing.
  19963. */
  19964. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19965. }
  19966. module "babylonjs/Meshes/mesh" {
  19967. interface Mesh {
  19968. /**
  19969. * Register a custom buffer that will be instanced
  19970. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19971. * @param kind defines the buffer kind
  19972. * @param stride defines the stride in floats
  19973. */
  19974. registerInstancedBuffer(kind: string, stride: number): void;
  19975. /** @hidden */
  19976. _userInstancedBuffersStorage: {
  19977. data: {
  19978. [key: string]: Float32Array;
  19979. };
  19980. sizes: {
  19981. [key: string]: number;
  19982. };
  19983. vertexBuffers: {
  19984. [key: string]: Nullable<VertexBuffer>;
  19985. };
  19986. strides: {
  19987. [key: string]: number;
  19988. };
  19989. };
  19990. }
  19991. }
  19992. module "babylonjs/Meshes/abstractMesh" {
  19993. interface AbstractMesh {
  19994. /**
  19995. * Object used to store instanced buffers defined by user
  19996. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19997. */
  19998. instancedBuffers: {
  19999. [key: string]: any;
  20000. };
  20001. }
  20002. }
  20003. }
  20004. declare module "babylonjs/Materials/shaderMaterial" {
  20005. import { Scene } from "babylonjs/scene";
  20006. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  20007. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20008. import { Mesh } from "babylonjs/Meshes/mesh";
  20009. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  20010. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20011. import { Texture } from "babylonjs/Materials/Textures/texture";
  20012. import { Material } from "babylonjs/Materials/material";
  20013. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  20014. /**
  20015. * Defines the options associated with the creation of a shader material.
  20016. */
  20017. export interface IShaderMaterialOptions {
  20018. /**
  20019. * Does the material work in alpha blend mode
  20020. */
  20021. needAlphaBlending: boolean;
  20022. /**
  20023. * Does the material work in alpha test mode
  20024. */
  20025. needAlphaTesting: boolean;
  20026. /**
  20027. * The list of attribute names used in the shader
  20028. */
  20029. attributes: string[];
  20030. /**
  20031. * The list of unifrom names used in the shader
  20032. */
  20033. uniforms: string[];
  20034. /**
  20035. * The list of UBO names used in the shader
  20036. */
  20037. uniformBuffers: string[];
  20038. /**
  20039. * The list of sampler names used in the shader
  20040. */
  20041. samplers: string[];
  20042. /**
  20043. * The list of defines used in the shader
  20044. */
  20045. defines: string[];
  20046. }
  20047. /**
  20048. * 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.
  20049. *
  20050. * This returned material effects how the mesh will look based on the code in the shaders.
  20051. *
  20052. * @see http://doc.babylonjs.com/how_to/shader_material
  20053. */
  20054. export class ShaderMaterial extends Material {
  20055. private _shaderPath;
  20056. private _options;
  20057. private _textures;
  20058. private _textureArrays;
  20059. private _floats;
  20060. private _ints;
  20061. private _floatsArrays;
  20062. private _colors3;
  20063. private _colors3Arrays;
  20064. private _colors4;
  20065. private _colors4Arrays;
  20066. private _vectors2;
  20067. private _vectors3;
  20068. private _vectors4;
  20069. private _matrices;
  20070. private _matrixArrays;
  20071. private _matrices3x3;
  20072. private _matrices2x2;
  20073. private _vectors2Arrays;
  20074. private _vectors3Arrays;
  20075. private _vectors4Arrays;
  20076. private _cachedWorldViewMatrix;
  20077. private _cachedWorldViewProjectionMatrix;
  20078. private _renderId;
  20079. private _multiview;
  20080. /**
  20081. * Instantiate a new shader material.
  20082. * 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.
  20083. * This returned material effects how the mesh will look based on the code in the shaders.
  20084. * @see http://doc.babylonjs.com/how_to/shader_material
  20085. * @param name Define the name of the material in the scene
  20086. * @param scene Define the scene the material belongs to
  20087. * @param shaderPath Defines the route to the shader code in one of three ways:
  20088. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  20089. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  20090. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  20091. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  20092. * @param options Define the options used to create the shader
  20093. */
  20094. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  20095. /**
  20096. * Gets the shader path used to define the shader code
  20097. * It can be modified to trigger a new compilation
  20098. */
  20099. get shaderPath(): any;
  20100. /**
  20101. * Sets the shader path used to define the shader code
  20102. * It can be modified to trigger a new compilation
  20103. */
  20104. set shaderPath(shaderPath: any);
  20105. /**
  20106. * Gets the options used to compile the shader.
  20107. * They can be modified to trigger a new compilation
  20108. */
  20109. get options(): IShaderMaterialOptions;
  20110. /**
  20111. * Gets the current class name of the material e.g. "ShaderMaterial"
  20112. * Mainly use in serialization.
  20113. * @returns the class name
  20114. */
  20115. getClassName(): string;
  20116. /**
  20117. * Specifies if the material will require alpha blending
  20118. * @returns a boolean specifying if alpha blending is needed
  20119. */
  20120. needAlphaBlending(): boolean;
  20121. /**
  20122. * Specifies if this material should be rendered in alpha test mode
  20123. * @returns a boolean specifying if an alpha test is needed.
  20124. */
  20125. needAlphaTesting(): boolean;
  20126. private _checkUniform;
  20127. /**
  20128. * Set a texture in the shader.
  20129. * @param name Define the name of the uniform samplers as defined in the shader
  20130. * @param texture Define the texture to bind to this sampler
  20131. * @return the material itself allowing "fluent" like uniform updates
  20132. */
  20133. setTexture(name: string, texture: Texture): ShaderMaterial;
  20134. /**
  20135. * Set a texture array in the shader.
  20136. * @param name Define the name of the uniform sampler array as defined in the shader
  20137. * @param textures Define the list of textures to bind to this sampler
  20138. * @return the material itself allowing "fluent" like uniform updates
  20139. */
  20140. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  20141. /**
  20142. * Set a float in the shader.
  20143. * @param name Define the name of the uniform as defined in the shader
  20144. * @param value Define the value to give to the uniform
  20145. * @return the material itself allowing "fluent" like uniform updates
  20146. */
  20147. setFloat(name: string, value: number): ShaderMaterial;
  20148. /**
  20149. * Set a int in the shader.
  20150. * @param name Define the name of the uniform as defined in the shader
  20151. * @param value Define the value to give to the uniform
  20152. * @return the material itself allowing "fluent" like uniform updates
  20153. */
  20154. setInt(name: string, value: number): ShaderMaterial;
  20155. /**
  20156. * Set an array of floats in the shader.
  20157. * @param name Define the name of the uniform as defined in the shader
  20158. * @param value Define the value to give to the uniform
  20159. * @return the material itself allowing "fluent" like uniform updates
  20160. */
  20161. setFloats(name: string, value: number[]): ShaderMaterial;
  20162. /**
  20163. * Set a vec3 in the shader from a Color3.
  20164. * @param name Define the name of the uniform as defined in the shader
  20165. * @param value Define the value to give to the uniform
  20166. * @return the material itself allowing "fluent" like uniform updates
  20167. */
  20168. setColor3(name: string, value: Color3): ShaderMaterial;
  20169. /**
  20170. * Set a vec3 array in the shader from a Color3 array.
  20171. * @param name Define the name of the uniform as defined in the shader
  20172. * @param value Define the value to give to the uniform
  20173. * @return the material itself allowing "fluent" like uniform updates
  20174. */
  20175. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  20176. /**
  20177. * Set a vec4 in the shader from a Color4.
  20178. * @param name Define the name of the uniform as defined in the shader
  20179. * @param value Define the value to give to the uniform
  20180. * @return the material itself allowing "fluent" like uniform updates
  20181. */
  20182. setColor4(name: string, value: Color4): ShaderMaterial;
  20183. /**
  20184. * Set a vec4 array in the shader from a Color4 array.
  20185. * @param name Define the name of the uniform as defined in the shader
  20186. * @param value Define the value to give to the uniform
  20187. * @return the material itself allowing "fluent" like uniform updates
  20188. */
  20189. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  20190. /**
  20191. * Set a vec2 in the shader from a Vector2.
  20192. * @param name Define the name of the uniform as defined in the shader
  20193. * @param value Define the value to give to the uniform
  20194. * @return the material itself allowing "fluent" like uniform updates
  20195. */
  20196. setVector2(name: string, value: Vector2): ShaderMaterial;
  20197. /**
  20198. * Set a vec3 in the shader from a Vector3.
  20199. * @param name Define the name of the uniform as defined in the shader
  20200. * @param value Define the value to give to the uniform
  20201. * @return the material itself allowing "fluent" like uniform updates
  20202. */
  20203. setVector3(name: string, value: Vector3): ShaderMaterial;
  20204. /**
  20205. * Set a vec4 in the shader from a Vector4.
  20206. * @param name Define the name of the uniform as defined in the shader
  20207. * @param value Define the value to give to the uniform
  20208. * @return the material itself allowing "fluent" like uniform updates
  20209. */
  20210. setVector4(name: string, value: Vector4): ShaderMaterial;
  20211. /**
  20212. * Set a mat4 in the shader from a Matrix.
  20213. * @param name Define the name of the uniform as defined in the shader
  20214. * @param value Define the value to give to the uniform
  20215. * @return the material itself allowing "fluent" like uniform updates
  20216. */
  20217. setMatrix(name: string, value: Matrix): ShaderMaterial;
  20218. /**
  20219. * Set a float32Array in the shader from a matrix array.
  20220. * @param name Define the name of the uniform as defined in the shader
  20221. * @param value Define the value to give to the uniform
  20222. * @return the material itself allowing "fluent" like uniform updates
  20223. */
  20224. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  20225. /**
  20226. * Set a mat3 in the shader from a Float32Array.
  20227. * @param name Define the name of the uniform as defined in the shader
  20228. * @param value Define the value to give to the uniform
  20229. * @return the material itself allowing "fluent" like uniform updates
  20230. */
  20231. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  20232. /**
  20233. * Set a mat2 in the shader from a Float32Array.
  20234. * @param name Define the name of the uniform as defined in the shader
  20235. * @param value Define the value to give to the uniform
  20236. * @return the material itself allowing "fluent" like uniform updates
  20237. */
  20238. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  20239. /**
  20240. * Set a vec2 array in the shader from a number array.
  20241. * @param name Define the name of the uniform as defined in the shader
  20242. * @param value Define the value to give to the uniform
  20243. * @return the material itself allowing "fluent" like uniform updates
  20244. */
  20245. setArray2(name: string, value: number[]): ShaderMaterial;
  20246. /**
  20247. * Set a vec3 array in the shader from a number array.
  20248. * @param name Define the name of the uniform as defined in the shader
  20249. * @param value Define the value to give to the uniform
  20250. * @return the material itself allowing "fluent" like uniform updates
  20251. */
  20252. setArray3(name: string, value: number[]): ShaderMaterial;
  20253. /**
  20254. * Set a vec4 array in the shader from a number array.
  20255. * @param name Define the name of the uniform as defined in the shader
  20256. * @param value Define the value to give to the uniform
  20257. * @return the material itself allowing "fluent" like uniform updates
  20258. */
  20259. setArray4(name: string, value: number[]): ShaderMaterial;
  20260. private _checkCache;
  20261. /**
  20262. * Specifies that the submesh is ready to be used
  20263. * @param mesh defines the mesh to check
  20264. * @param subMesh defines which submesh to check
  20265. * @param useInstances specifies that instances should be used
  20266. * @returns a boolean indicating that the submesh is ready or not
  20267. */
  20268. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20269. /**
  20270. * Checks if the material is ready to render the requested mesh
  20271. * @param mesh Define the mesh to render
  20272. * @param useInstances Define whether or not the material is used with instances
  20273. * @returns true if ready, otherwise false
  20274. */
  20275. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20276. /**
  20277. * Binds the world matrix to the material
  20278. * @param world defines the world transformation matrix
  20279. */
  20280. bindOnlyWorldMatrix(world: Matrix): void;
  20281. /**
  20282. * Binds the material to the mesh
  20283. * @param world defines the world transformation matrix
  20284. * @param mesh defines the mesh to bind the material to
  20285. */
  20286. bind(world: Matrix, mesh?: Mesh): void;
  20287. /**
  20288. * Gets the active textures from the material
  20289. * @returns an array of textures
  20290. */
  20291. getActiveTextures(): BaseTexture[];
  20292. /**
  20293. * Specifies if the material uses a texture
  20294. * @param texture defines the texture to check against the material
  20295. * @returns a boolean specifying if the material uses the texture
  20296. */
  20297. hasTexture(texture: BaseTexture): boolean;
  20298. /**
  20299. * Makes a duplicate of the material, and gives it a new name
  20300. * @param name defines the new name for the duplicated material
  20301. * @returns the cloned material
  20302. */
  20303. clone(name: string): ShaderMaterial;
  20304. /**
  20305. * Disposes the material
  20306. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20307. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20308. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20309. */
  20310. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20311. /**
  20312. * Serializes this material in a JSON representation
  20313. * @returns the serialized material object
  20314. */
  20315. serialize(): any;
  20316. /**
  20317. * Creates a shader material from parsed shader material data
  20318. * @param source defines the JSON represnetation of the material
  20319. * @param scene defines the hosting scene
  20320. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20321. * @returns a new material
  20322. */
  20323. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  20324. }
  20325. }
  20326. declare module "babylonjs/Shaders/color.fragment" {
  20327. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20328. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20329. /** @hidden */
  20330. export var colorPixelShader: {
  20331. name: string;
  20332. shader: string;
  20333. };
  20334. }
  20335. declare module "babylonjs/Shaders/color.vertex" {
  20336. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  20337. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20338. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  20339. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  20340. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  20341. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20342. /** @hidden */
  20343. export var colorVertexShader: {
  20344. name: string;
  20345. shader: string;
  20346. };
  20347. }
  20348. declare module "babylonjs/Meshes/linesMesh" {
  20349. import { Nullable } from "babylonjs/types";
  20350. import { Scene } from "babylonjs/scene";
  20351. import { Color3 } from "babylonjs/Maths/math.color";
  20352. import { Node } from "babylonjs/node";
  20353. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20354. import { Mesh } from "babylonjs/Meshes/mesh";
  20355. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20356. import { Effect } from "babylonjs/Materials/effect";
  20357. import { Material } from "babylonjs/Materials/material";
  20358. import "babylonjs/Shaders/color.fragment";
  20359. import "babylonjs/Shaders/color.vertex";
  20360. /**
  20361. * Line mesh
  20362. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  20363. */
  20364. export class LinesMesh extends Mesh {
  20365. /**
  20366. * If vertex color should be applied to the mesh
  20367. */
  20368. readonly useVertexColor?: boolean | undefined;
  20369. /**
  20370. * If vertex alpha should be applied to the mesh
  20371. */
  20372. readonly useVertexAlpha?: boolean | undefined;
  20373. /**
  20374. * Color of the line (Default: White)
  20375. */
  20376. color: Color3;
  20377. /**
  20378. * Alpha of the line (Default: 1)
  20379. */
  20380. alpha: number;
  20381. /**
  20382. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20383. * This margin is expressed in world space coordinates, so its value may vary.
  20384. * Default value is 0.1
  20385. */
  20386. intersectionThreshold: number;
  20387. private _colorShader;
  20388. private color4;
  20389. /**
  20390. * Creates a new LinesMesh
  20391. * @param name defines the name
  20392. * @param scene defines the hosting scene
  20393. * @param parent defines the parent mesh if any
  20394. * @param source defines the optional source LinesMesh used to clone data from
  20395. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20396. * When false, achieved by calling a clone(), also passing False.
  20397. * This will make creation of children, recursive.
  20398. * @param useVertexColor defines if this LinesMesh supports vertex color
  20399. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  20400. */
  20401. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  20402. /**
  20403. * If vertex color should be applied to the mesh
  20404. */
  20405. useVertexColor?: boolean | undefined,
  20406. /**
  20407. * If vertex alpha should be applied to the mesh
  20408. */
  20409. useVertexAlpha?: boolean | undefined);
  20410. private _addClipPlaneDefine;
  20411. private _removeClipPlaneDefine;
  20412. isReady(): boolean;
  20413. /**
  20414. * Returns the string "LineMesh"
  20415. */
  20416. getClassName(): string;
  20417. /**
  20418. * @hidden
  20419. */
  20420. get material(): Material;
  20421. /**
  20422. * @hidden
  20423. */
  20424. set material(value: Material);
  20425. /**
  20426. * @hidden
  20427. */
  20428. get checkCollisions(): boolean;
  20429. /** @hidden */
  20430. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20431. /** @hidden */
  20432. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20433. /**
  20434. * Disposes of the line mesh
  20435. * @param doNotRecurse If children should be disposed
  20436. */
  20437. dispose(doNotRecurse?: boolean): void;
  20438. /**
  20439. * Returns a new LineMesh object cloned from the current one.
  20440. */
  20441. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  20442. /**
  20443. * Creates a new InstancedLinesMesh object from the mesh model.
  20444. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20445. * @param name defines the name of the new instance
  20446. * @returns a new InstancedLinesMesh
  20447. */
  20448. createInstance(name: string): InstancedLinesMesh;
  20449. }
  20450. /**
  20451. * Creates an instance based on a source LinesMesh
  20452. */
  20453. export class InstancedLinesMesh extends InstancedMesh {
  20454. /**
  20455. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20456. * This margin is expressed in world space coordinates, so its value may vary.
  20457. * Initilized with the intersectionThreshold value of the source LinesMesh
  20458. */
  20459. intersectionThreshold: number;
  20460. constructor(name: string, source: LinesMesh);
  20461. /**
  20462. * Returns the string "InstancedLinesMesh".
  20463. */
  20464. getClassName(): string;
  20465. }
  20466. }
  20467. declare module "babylonjs/Shaders/line.fragment" {
  20468. /** @hidden */
  20469. export var linePixelShader: {
  20470. name: string;
  20471. shader: string;
  20472. };
  20473. }
  20474. declare module "babylonjs/Shaders/line.vertex" {
  20475. /** @hidden */
  20476. export var lineVertexShader: {
  20477. name: string;
  20478. shader: string;
  20479. };
  20480. }
  20481. declare module "babylonjs/Rendering/edgesRenderer" {
  20482. import { Nullable } from "babylonjs/types";
  20483. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20484. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20485. import { Vector3 } from "babylonjs/Maths/math.vector";
  20486. import { IDisposable } from "babylonjs/scene";
  20487. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20488. import "babylonjs/Shaders/line.fragment";
  20489. import "babylonjs/Shaders/line.vertex";
  20490. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20491. module "babylonjs/Meshes/abstractMesh" {
  20492. interface AbstractMesh {
  20493. /**
  20494. * Gets the edgesRenderer associated with the mesh
  20495. */
  20496. edgesRenderer: Nullable<EdgesRenderer>;
  20497. }
  20498. }
  20499. module "babylonjs/Meshes/linesMesh" {
  20500. interface LinesMesh {
  20501. /**
  20502. * Enables the edge rendering mode on the mesh.
  20503. * This mode makes the mesh edges visible
  20504. * @param epsilon defines the maximal distance between two angles to detect a face
  20505. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20506. * @returns the currentAbstractMesh
  20507. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20508. */
  20509. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20510. }
  20511. }
  20512. module "babylonjs/Meshes/linesMesh" {
  20513. interface InstancedLinesMesh {
  20514. /**
  20515. * Enables the edge rendering mode on the mesh.
  20516. * This mode makes the mesh edges visible
  20517. * @param epsilon defines the maximal distance between two angles to detect a face
  20518. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20519. * @returns the current InstancedLinesMesh
  20520. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20521. */
  20522. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20523. }
  20524. }
  20525. /**
  20526. * Defines the minimum contract an Edges renderer should follow.
  20527. */
  20528. export interface IEdgesRenderer extends IDisposable {
  20529. /**
  20530. * Gets or sets a boolean indicating if the edgesRenderer is active
  20531. */
  20532. isEnabled: boolean;
  20533. /**
  20534. * Renders the edges of the attached mesh,
  20535. */
  20536. render(): void;
  20537. /**
  20538. * Checks wether or not the edges renderer is ready to render.
  20539. * @return true if ready, otherwise false.
  20540. */
  20541. isReady(): boolean;
  20542. }
  20543. /**
  20544. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20545. */
  20546. export class EdgesRenderer implements IEdgesRenderer {
  20547. /**
  20548. * Define the size of the edges with an orthographic camera
  20549. */
  20550. edgesWidthScalerForOrthographic: number;
  20551. /**
  20552. * Define the size of the edges with a perspective camera
  20553. */
  20554. edgesWidthScalerForPerspective: number;
  20555. protected _source: AbstractMesh;
  20556. protected _linesPositions: number[];
  20557. protected _linesNormals: number[];
  20558. protected _linesIndices: number[];
  20559. protected _epsilon: number;
  20560. protected _indicesCount: number;
  20561. protected _lineShader: ShaderMaterial;
  20562. protected _ib: DataBuffer;
  20563. protected _buffers: {
  20564. [key: string]: Nullable<VertexBuffer>;
  20565. };
  20566. protected _checkVerticesInsteadOfIndices: boolean;
  20567. private _meshRebuildObserver;
  20568. private _meshDisposeObserver;
  20569. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20570. isEnabled: boolean;
  20571. /**
  20572. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20573. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20574. * @param source Mesh used to create edges
  20575. * @param epsilon sum of angles in adjacency to check for edge
  20576. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20577. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20578. */
  20579. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20580. protected _prepareRessources(): void;
  20581. /** @hidden */
  20582. _rebuild(): void;
  20583. /**
  20584. * Releases the required resources for the edges renderer
  20585. */
  20586. dispose(): void;
  20587. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20588. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20589. /**
  20590. * Checks if the pair of p0 and p1 is en edge
  20591. * @param faceIndex
  20592. * @param edge
  20593. * @param faceNormals
  20594. * @param p0
  20595. * @param p1
  20596. * @private
  20597. */
  20598. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20599. /**
  20600. * push line into the position, normal and index buffer
  20601. * @protected
  20602. */
  20603. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20604. /**
  20605. * Generates lines edges from adjacencjes
  20606. * @private
  20607. */
  20608. _generateEdgesLines(): void;
  20609. /**
  20610. * Checks wether or not the edges renderer is ready to render.
  20611. * @return true if ready, otherwise false.
  20612. */
  20613. isReady(): boolean;
  20614. /**
  20615. * Renders the edges of the attached mesh,
  20616. */
  20617. render(): void;
  20618. }
  20619. /**
  20620. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20621. */
  20622. export class LineEdgesRenderer extends EdgesRenderer {
  20623. /**
  20624. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20625. * @param source LineMesh used to generate edges
  20626. * @param epsilon not important (specified angle for edge detection)
  20627. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20628. */
  20629. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20630. /**
  20631. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20632. */
  20633. _generateEdgesLines(): void;
  20634. }
  20635. }
  20636. declare module "babylonjs/Rendering/renderingGroup" {
  20637. import { SmartArray } from "babylonjs/Misc/smartArray";
  20638. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20640. import { Nullable } from "babylonjs/types";
  20641. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20642. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20643. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20644. import { Material } from "babylonjs/Materials/material";
  20645. import { Scene } from "babylonjs/scene";
  20646. /**
  20647. * This represents the object necessary to create a rendering group.
  20648. * This is exclusively used and created by the rendering manager.
  20649. * To modify the behavior, you use the available helpers in your scene or meshes.
  20650. * @hidden
  20651. */
  20652. export class RenderingGroup {
  20653. index: number;
  20654. private static _zeroVector;
  20655. private _scene;
  20656. private _opaqueSubMeshes;
  20657. private _transparentSubMeshes;
  20658. private _alphaTestSubMeshes;
  20659. private _depthOnlySubMeshes;
  20660. private _particleSystems;
  20661. private _spriteManagers;
  20662. private _opaqueSortCompareFn;
  20663. private _alphaTestSortCompareFn;
  20664. private _transparentSortCompareFn;
  20665. private _renderOpaque;
  20666. private _renderAlphaTest;
  20667. private _renderTransparent;
  20668. /** @hidden */
  20669. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20670. onBeforeTransparentRendering: () => void;
  20671. /**
  20672. * Set the opaque sort comparison function.
  20673. * If null the sub meshes will be render in the order they were created
  20674. */
  20675. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20676. /**
  20677. * Set the alpha test sort comparison function.
  20678. * If null the sub meshes will be render in the order they were created
  20679. */
  20680. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20681. /**
  20682. * Set the transparent sort comparison function.
  20683. * If null the sub meshes will be render in the order they were created
  20684. */
  20685. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20686. /**
  20687. * Creates a new rendering group.
  20688. * @param index The rendering group index
  20689. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20690. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20691. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20692. */
  20693. 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>);
  20694. /**
  20695. * Render all the sub meshes contained in the group.
  20696. * @param customRenderFunction Used to override the default render behaviour of the group.
  20697. * @returns true if rendered some submeshes.
  20698. */
  20699. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20700. /**
  20701. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20702. * @param subMeshes The submeshes to render
  20703. */
  20704. private renderOpaqueSorted;
  20705. /**
  20706. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20707. * @param subMeshes The submeshes to render
  20708. */
  20709. private renderAlphaTestSorted;
  20710. /**
  20711. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20712. * @param subMeshes The submeshes to render
  20713. */
  20714. private renderTransparentSorted;
  20715. /**
  20716. * Renders the submeshes in a specified order.
  20717. * @param subMeshes The submeshes to sort before render
  20718. * @param sortCompareFn The comparison function use to sort
  20719. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20720. * @param transparent Specifies to activate blending if true
  20721. */
  20722. private static renderSorted;
  20723. /**
  20724. * Renders the submeshes in the order they were dispatched (no sort applied).
  20725. * @param subMeshes The submeshes to render
  20726. */
  20727. private static renderUnsorted;
  20728. /**
  20729. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20730. * are rendered back to front if in the same alpha index.
  20731. *
  20732. * @param a The first submesh
  20733. * @param b The second submesh
  20734. * @returns The result of the comparison
  20735. */
  20736. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20737. /**
  20738. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20739. * are rendered back to front.
  20740. *
  20741. * @param a The first submesh
  20742. * @param b The second submesh
  20743. * @returns The result of the comparison
  20744. */
  20745. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20746. /**
  20747. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20748. * are rendered front to back (prevent overdraw).
  20749. *
  20750. * @param a The first submesh
  20751. * @param b The second submesh
  20752. * @returns The result of the comparison
  20753. */
  20754. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20755. /**
  20756. * Resets the different lists of submeshes to prepare a new frame.
  20757. */
  20758. prepare(): void;
  20759. dispose(): void;
  20760. /**
  20761. * Inserts the submesh in its correct queue depending on its material.
  20762. * @param subMesh The submesh to dispatch
  20763. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20764. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20765. */
  20766. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20767. dispatchSprites(spriteManager: ISpriteManager): void;
  20768. dispatchParticles(particleSystem: IParticleSystem): void;
  20769. private _renderParticles;
  20770. private _renderSprites;
  20771. }
  20772. }
  20773. declare module "babylonjs/Rendering/renderingManager" {
  20774. import { Nullable } from "babylonjs/types";
  20775. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20776. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20777. import { SmartArray } from "babylonjs/Misc/smartArray";
  20778. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20779. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20780. import { Material } from "babylonjs/Materials/material";
  20781. import { Scene } from "babylonjs/scene";
  20782. import { Camera } from "babylonjs/Cameras/camera";
  20783. /**
  20784. * Interface describing the different options available in the rendering manager
  20785. * regarding Auto Clear between groups.
  20786. */
  20787. export interface IRenderingManagerAutoClearSetup {
  20788. /**
  20789. * Defines whether or not autoclear is enable.
  20790. */
  20791. autoClear: boolean;
  20792. /**
  20793. * Defines whether or not to autoclear the depth buffer.
  20794. */
  20795. depth: boolean;
  20796. /**
  20797. * Defines whether or not to autoclear the stencil buffer.
  20798. */
  20799. stencil: boolean;
  20800. }
  20801. /**
  20802. * This class is used by the onRenderingGroupObservable
  20803. */
  20804. export class RenderingGroupInfo {
  20805. /**
  20806. * The Scene that being rendered
  20807. */
  20808. scene: Scene;
  20809. /**
  20810. * The camera currently used for the rendering pass
  20811. */
  20812. camera: Nullable<Camera>;
  20813. /**
  20814. * The ID of the renderingGroup being processed
  20815. */
  20816. renderingGroupId: number;
  20817. }
  20818. /**
  20819. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20820. * It is enable to manage the different groups as well as the different necessary sort functions.
  20821. * This should not be used directly aside of the few static configurations
  20822. */
  20823. export class RenderingManager {
  20824. /**
  20825. * The max id used for rendering groups (not included)
  20826. */
  20827. static MAX_RENDERINGGROUPS: number;
  20828. /**
  20829. * The min id used for rendering groups (included)
  20830. */
  20831. static MIN_RENDERINGGROUPS: number;
  20832. /**
  20833. * Used to globally prevent autoclearing scenes.
  20834. */
  20835. static AUTOCLEAR: boolean;
  20836. /**
  20837. * @hidden
  20838. */
  20839. _useSceneAutoClearSetup: boolean;
  20840. private _scene;
  20841. private _renderingGroups;
  20842. private _depthStencilBufferAlreadyCleaned;
  20843. private _autoClearDepthStencil;
  20844. private _customOpaqueSortCompareFn;
  20845. private _customAlphaTestSortCompareFn;
  20846. private _customTransparentSortCompareFn;
  20847. private _renderingGroupInfo;
  20848. /**
  20849. * Instantiates a new rendering group for a particular scene
  20850. * @param scene Defines the scene the groups belongs to
  20851. */
  20852. constructor(scene: Scene);
  20853. private _clearDepthStencilBuffer;
  20854. /**
  20855. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20856. * @hidden
  20857. */
  20858. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20859. /**
  20860. * Resets the different information of the group to prepare a new frame
  20861. * @hidden
  20862. */
  20863. reset(): void;
  20864. /**
  20865. * Dispose and release the group and its associated resources.
  20866. * @hidden
  20867. */
  20868. dispose(): void;
  20869. /**
  20870. * Clear the info related to rendering groups preventing retention points during dispose.
  20871. */
  20872. freeRenderingGroups(): void;
  20873. private _prepareRenderingGroup;
  20874. /**
  20875. * Add a sprite manager to the rendering manager in order to render it this frame.
  20876. * @param spriteManager Define the sprite manager to render
  20877. */
  20878. dispatchSprites(spriteManager: ISpriteManager): void;
  20879. /**
  20880. * Add a particle system to the rendering manager in order to render it this frame.
  20881. * @param particleSystem Define the particle system to render
  20882. */
  20883. dispatchParticles(particleSystem: IParticleSystem): void;
  20884. /**
  20885. * Add a submesh to the manager in order to render it this frame
  20886. * @param subMesh The submesh to dispatch
  20887. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20888. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20889. */
  20890. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20891. /**
  20892. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20893. * This allowed control for front to back rendering or reversly depending of the special needs.
  20894. *
  20895. * @param renderingGroupId The rendering group id corresponding to its index
  20896. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20897. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20898. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20899. */
  20900. 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;
  20901. /**
  20902. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20903. *
  20904. * @param renderingGroupId The rendering group id corresponding to its index
  20905. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20906. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20907. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20908. */
  20909. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20910. /**
  20911. * Gets the current auto clear configuration for one rendering group of the rendering
  20912. * manager.
  20913. * @param index the rendering group index to get the information for
  20914. * @returns The auto clear setup for the requested rendering group
  20915. */
  20916. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20917. }
  20918. }
  20919. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20920. import { Observable } from "babylonjs/Misc/observable";
  20921. import { SmartArray } from "babylonjs/Misc/smartArray";
  20922. import { Nullable, Immutable } from "babylonjs/types";
  20923. import { Camera } from "babylonjs/Cameras/camera";
  20924. import { Scene } from "babylonjs/scene";
  20925. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20926. import { Color4 } from "babylonjs/Maths/math.color";
  20927. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20929. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20930. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20931. import { Texture } from "babylonjs/Materials/Textures/texture";
  20932. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20933. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20934. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20935. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20936. import { Engine } from "babylonjs/Engines/engine";
  20937. /**
  20938. * This Helps creating a texture that will be created from a camera in your scene.
  20939. * It is basically a dynamic texture that could be used to create special effects for instance.
  20940. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20941. */
  20942. export class RenderTargetTexture extends Texture {
  20943. isCube: boolean;
  20944. /**
  20945. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20946. */
  20947. static readonly REFRESHRATE_RENDER_ONCE: number;
  20948. /**
  20949. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20950. */
  20951. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20952. /**
  20953. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20954. * the central point of your effect and can save a lot of performances.
  20955. */
  20956. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20957. /**
  20958. * Use this predicate to dynamically define the list of mesh you want to render.
  20959. * If set, the renderList property will be overwritten.
  20960. */
  20961. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20962. private _renderList;
  20963. /**
  20964. * Use this list to define the list of mesh you want to render.
  20965. */
  20966. get renderList(): Nullable<Array<AbstractMesh>>;
  20967. set renderList(value: Nullable<Array<AbstractMesh>>);
  20968. /**
  20969. * Use this function to overload the renderList array at rendering time.
  20970. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20971. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20972. * the cube (if the RTT is a cube, else layerOrFace=0).
  20973. * The renderList passed to the function is the current render list (the one that will be used if the function returns null)
  20974. */
  20975. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>) => Nullable<Array<AbstractMesh>>;
  20976. private _hookArray;
  20977. /**
  20978. * Define if particles should be rendered in your texture.
  20979. */
  20980. renderParticles: boolean;
  20981. /**
  20982. * Define if sprites should be rendered in your texture.
  20983. */
  20984. renderSprites: boolean;
  20985. /**
  20986. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20987. */
  20988. coordinatesMode: number;
  20989. /**
  20990. * Define the camera used to render the texture.
  20991. */
  20992. activeCamera: Nullable<Camera>;
  20993. /**
  20994. * Override the render function of the texture with your own one.
  20995. */
  20996. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20997. /**
  20998. * Define if camera post processes should be use while rendering the texture.
  20999. */
  21000. useCameraPostProcesses: boolean;
  21001. /**
  21002. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21003. */
  21004. ignoreCameraViewport: boolean;
  21005. private _postProcessManager;
  21006. private _postProcesses;
  21007. private _resizeObserver;
  21008. /**
  21009. * An event triggered when the texture is unbind.
  21010. */
  21011. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21012. /**
  21013. * An event triggered when the texture is unbind.
  21014. */
  21015. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21016. private _onAfterUnbindObserver;
  21017. /**
  21018. * Set a after unbind callback in the texture.
  21019. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21020. */
  21021. set onAfterUnbind(callback: () => void);
  21022. /**
  21023. * An event triggered before rendering the texture
  21024. */
  21025. onBeforeRenderObservable: Observable<number>;
  21026. private _onBeforeRenderObserver;
  21027. /**
  21028. * Set a before render callback in the texture.
  21029. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21030. */
  21031. set onBeforeRender(callback: (faceIndex: number) => void);
  21032. /**
  21033. * An event triggered after rendering the texture
  21034. */
  21035. onAfterRenderObservable: Observable<number>;
  21036. private _onAfterRenderObserver;
  21037. /**
  21038. * Set a after render callback in the texture.
  21039. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21040. */
  21041. set onAfterRender(callback: (faceIndex: number) => void);
  21042. /**
  21043. * An event triggered after the texture clear
  21044. */
  21045. onClearObservable: Observable<Engine>;
  21046. private _onClearObserver;
  21047. /**
  21048. * Set a clear callback in the texture.
  21049. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21050. */
  21051. set onClear(callback: (Engine: Engine) => void);
  21052. /**
  21053. * An event triggered when the texture is resized.
  21054. */
  21055. onResizeObservable: Observable<RenderTargetTexture>;
  21056. /**
  21057. * Define the clear color of the Render Target if it should be different from the scene.
  21058. */
  21059. clearColor: Color4;
  21060. protected _size: number | {
  21061. width: number;
  21062. height: number;
  21063. layers?: number;
  21064. };
  21065. protected _initialSizeParameter: number | {
  21066. width: number;
  21067. height: number;
  21068. } | {
  21069. ratio: number;
  21070. };
  21071. protected _sizeRatio: Nullable<number>;
  21072. /** @hidden */
  21073. _generateMipMaps: boolean;
  21074. protected _renderingManager: RenderingManager;
  21075. /** @hidden */
  21076. _waitingRenderList: string[];
  21077. protected _doNotChangeAspectRatio: boolean;
  21078. protected _currentRefreshId: number;
  21079. protected _refreshRate: number;
  21080. protected _textureMatrix: Matrix;
  21081. protected _samples: number;
  21082. protected _renderTargetOptions: RenderTargetCreationOptions;
  21083. /**
  21084. * Gets render target creation options that were used.
  21085. */
  21086. get renderTargetOptions(): RenderTargetCreationOptions;
  21087. protected _engine: Engine;
  21088. protected _onRatioRescale(): void;
  21089. /**
  21090. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21091. * It must define where the camera used to render the texture is set
  21092. */
  21093. boundingBoxPosition: Vector3;
  21094. private _boundingBoxSize;
  21095. /**
  21096. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21097. * When defined, the cubemap will switch to local mode
  21098. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21099. * @example https://www.babylonjs-playground.com/#RNASML
  21100. */
  21101. set boundingBoxSize(value: Vector3);
  21102. get boundingBoxSize(): Vector3;
  21103. /**
  21104. * In case the RTT has been created with a depth texture, get the associated
  21105. * depth texture.
  21106. * Otherwise, return null.
  21107. */
  21108. get depthStencilTexture(): Nullable<InternalTexture>;
  21109. /**
  21110. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21111. * or used a shadow, depth texture...
  21112. * @param name The friendly name of the texture
  21113. * @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)
  21114. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21115. * @param generateMipMaps True if mip maps need to be generated after render.
  21116. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21117. * @param type The type of the buffer in the RTT (int, half float, float...)
  21118. * @param isCube True if a cube texture needs to be created
  21119. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21120. * @param generateDepthBuffer True to generate a depth buffer
  21121. * @param generateStencilBuffer True to generate a stencil buffer
  21122. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21123. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21124. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21125. */
  21126. constructor(name: string, size: number | {
  21127. width: number;
  21128. height: number;
  21129. layers?: number;
  21130. } | {
  21131. ratio: number;
  21132. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21133. /**
  21134. * Creates a depth stencil texture.
  21135. * This is only available in WebGL 2 or with the depth texture extension available.
  21136. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21137. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21138. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21139. */
  21140. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21141. private _processSizeParameter;
  21142. /**
  21143. * Define the number of samples to use in case of MSAA.
  21144. * It defaults to one meaning no MSAA has been enabled.
  21145. */
  21146. get samples(): number;
  21147. set samples(value: number);
  21148. /**
  21149. * Resets the refresh counter of the texture and start bak from scratch.
  21150. * Could be useful to regenerate the texture if it is setup to render only once.
  21151. */
  21152. resetRefreshCounter(): void;
  21153. /**
  21154. * Define the refresh rate of the texture or the rendering frequency.
  21155. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21156. */
  21157. get refreshRate(): number;
  21158. set refreshRate(value: number);
  21159. /**
  21160. * Adds a post process to the render target rendering passes.
  21161. * @param postProcess define the post process to add
  21162. */
  21163. addPostProcess(postProcess: PostProcess): void;
  21164. /**
  21165. * Clear all the post processes attached to the render target
  21166. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21167. */
  21168. clearPostProcesses(dispose?: boolean): void;
  21169. /**
  21170. * Remove one of the post process from the list of attached post processes to the texture
  21171. * @param postProcess define the post process to remove from the list
  21172. */
  21173. removePostProcess(postProcess: PostProcess): void;
  21174. /** @hidden */
  21175. _shouldRender(): boolean;
  21176. /**
  21177. * Gets the actual render size of the texture.
  21178. * @returns the width of the render size
  21179. */
  21180. getRenderSize(): number;
  21181. /**
  21182. * Gets the actual render width of the texture.
  21183. * @returns the width of the render size
  21184. */
  21185. getRenderWidth(): number;
  21186. /**
  21187. * Gets the actual render height of the texture.
  21188. * @returns the height of the render size
  21189. */
  21190. getRenderHeight(): number;
  21191. /**
  21192. * Gets the actual number of layers of the texture.
  21193. * @returns the number of layers
  21194. */
  21195. getRenderLayers(): number;
  21196. /**
  21197. * Get if the texture can be rescaled or not.
  21198. */
  21199. get canRescale(): boolean;
  21200. /**
  21201. * Resize the texture using a ratio.
  21202. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21203. */
  21204. scale(ratio: number): void;
  21205. /**
  21206. * Get the texture reflection matrix used to rotate/transform the reflection.
  21207. * @returns the reflection matrix
  21208. */
  21209. getReflectionTextureMatrix(): Matrix;
  21210. /**
  21211. * Resize the texture to a new desired size.
  21212. * Be carrefull as it will recreate all the data in the new texture.
  21213. * @param size Define the new size. It can be:
  21214. * - a number for squared texture,
  21215. * - an object containing { width: number, height: number }
  21216. * - or an object containing a ratio { ratio: number }
  21217. */
  21218. resize(size: number | {
  21219. width: number;
  21220. height: number;
  21221. } | {
  21222. ratio: number;
  21223. }): void;
  21224. private _defaultRenderListPrepared;
  21225. /**
  21226. * Renders all the objects from the render list into the texture.
  21227. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21228. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21229. */
  21230. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21231. private _bestReflectionRenderTargetDimension;
  21232. private _prepareRenderingManager;
  21233. /**
  21234. * @hidden
  21235. * @param faceIndex face index to bind to if this is a cubetexture
  21236. * @param layer defines the index of the texture to bind in the array
  21237. */
  21238. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21239. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21240. private renderToTarget;
  21241. /**
  21242. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21243. * This allowed control for front to back rendering or reversly depending of the special needs.
  21244. *
  21245. * @param renderingGroupId The rendering group id corresponding to its index
  21246. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21247. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21248. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21249. */
  21250. 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;
  21251. /**
  21252. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21253. *
  21254. * @param renderingGroupId The rendering group id corresponding to its index
  21255. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21256. */
  21257. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21258. /**
  21259. * Clones the texture.
  21260. * @returns the cloned texture
  21261. */
  21262. clone(): RenderTargetTexture;
  21263. /**
  21264. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21265. * @returns The JSON representation of the texture
  21266. */
  21267. serialize(): any;
  21268. /**
  21269. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21270. */
  21271. disposeFramebufferObjects(): void;
  21272. /**
  21273. * Dispose the texture and release its associated resources.
  21274. */
  21275. dispose(): void;
  21276. /** @hidden */
  21277. _rebuild(): void;
  21278. /**
  21279. * Clear the info related to rendering groups preventing retention point in material dispose.
  21280. */
  21281. freeRenderingGroups(): void;
  21282. /**
  21283. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21284. * @returns the view count
  21285. */
  21286. getViewCount(): number;
  21287. }
  21288. }
  21289. declare module "babylonjs/Materials/material" {
  21290. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21291. import { SmartArray } from "babylonjs/Misc/smartArray";
  21292. import { Observable } from "babylonjs/Misc/observable";
  21293. import { Nullable } from "babylonjs/types";
  21294. import { Scene } from "babylonjs/scene";
  21295. import { Matrix } from "babylonjs/Maths/math.vector";
  21296. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21298. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21299. import { Effect } from "babylonjs/Materials/effect";
  21300. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21301. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21302. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21303. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21304. import { Mesh } from "babylonjs/Meshes/mesh";
  21305. import { Animation } from "babylonjs/Animations/animation";
  21306. /**
  21307. * Options for compiling materials.
  21308. */
  21309. export interface IMaterialCompilationOptions {
  21310. /**
  21311. * Defines whether clip planes are enabled.
  21312. */
  21313. clipPlane: boolean;
  21314. /**
  21315. * Defines whether instances are enabled.
  21316. */
  21317. useInstances: boolean;
  21318. }
  21319. /**
  21320. * Base class for the main features of a material in Babylon.js
  21321. */
  21322. export class Material implements IAnimatable {
  21323. /**
  21324. * Returns the triangle fill mode
  21325. */
  21326. static readonly TriangleFillMode: number;
  21327. /**
  21328. * Returns the wireframe mode
  21329. */
  21330. static readonly WireFrameFillMode: number;
  21331. /**
  21332. * Returns the point fill mode
  21333. */
  21334. static readonly PointFillMode: number;
  21335. /**
  21336. * Returns the point list draw mode
  21337. */
  21338. static readonly PointListDrawMode: number;
  21339. /**
  21340. * Returns the line list draw mode
  21341. */
  21342. static readonly LineListDrawMode: number;
  21343. /**
  21344. * Returns the line loop draw mode
  21345. */
  21346. static readonly LineLoopDrawMode: number;
  21347. /**
  21348. * Returns the line strip draw mode
  21349. */
  21350. static readonly LineStripDrawMode: number;
  21351. /**
  21352. * Returns the triangle strip draw mode
  21353. */
  21354. static readonly TriangleStripDrawMode: number;
  21355. /**
  21356. * Returns the triangle fan draw mode
  21357. */
  21358. static readonly TriangleFanDrawMode: number;
  21359. /**
  21360. * Stores the clock-wise side orientation
  21361. */
  21362. static readonly ClockWiseSideOrientation: number;
  21363. /**
  21364. * Stores the counter clock-wise side orientation
  21365. */
  21366. static readonly CounterClockWiseSideOrientation: number;
  21367. /**
  21368. * The dirty texture flag value
  21369. */
  21370. static readonly TextureDirtyFlag: number;
  21371. /**
  21372. * The dirty light flag value
  21373. */
  21374. static readonly LightDirtyFlag: number;
  21375. /**
  21376. * The dirty fresnel flag value
  21377. */
  21378. static readonly FresnelDirtyFlag: number;
  21379. /**
  21380. * The dirty attribute flag value
  21381. */
  21382. static readonly AttributesDirtyFlag: number;
  21383. /**
  21384. * The dirty misc flag value
  21385. */
  21386. static readonly MiscDirtyFlag: number;
  21387. /**
  21388. * The all dirty flag value
  21389. */
  21390. static readonly AllDirtyFlag: number;
  21391. /**
  21392. * The ID of the material
  21393. */
  21394. id: string;
  21395. /**
  21396. * Gets or sets the unique id of the material
  21397. */
  21398. uniqueId: number;
  21399. /**
  21400. * The name of the material
  21401. */
  21402. name: string;
  21403. /**
  21404. * Gets or sets user defined metadata
  21405. */
  21406. metadata: any;
  21407. /**
  21408. * For internal use only. Please do not use.
  21409. */
  21410. reservedDataStore: any;
  21411. /**
  21412. * Specifies if the ready state should be checked on each call
  21413. */
  21414. checkReadyOnEveryCall: boolean;
  21415. /**
  21416. * Specifies if the ready state should be checked once
  21417. */
  21418. checkReadyOnlyOnce: boolean;
  21419. /**
  21420. * The state of the material
  21421. */
  21422. state: string;
  21423. /**
  21424. * The alpha value of the material
  21425. */
  21426. protected _alpha: number;
  21427. /**
  21428. * List of inspectable custom properties (used by the Inspector)
  21429. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21430. */
  21431. inspectableCustomProperties: IInspectable[];
  21432. /**
  21433. * Sets the alpha value of the material
  21434. */
  21435. set alpha(value: number);
  21436. /**
  21437. * Gets the alpha value of the material
  21438. */
  21439. get alpha(): number;
  21440. /**
  21441. * Specifies if back face culling is enabled
  21442. */
  21443. protected _backFaceCulling: boolean;
  21444. /**
  21445. * Sets the back-face culling state
  21446. */
  21447. set backFaceCulling(value: boolean);
  21448. /**
  21449. * Gets the back-face culling state
  21450. */
  21451. get backFaceCulling(): boolean;
  21452. /**
  21453. * Stores the value for side orientation
  21454. */
  21455. sideOrientation: number;
  21456. /**
  21457. * Callback triggered when the material is compiled
  21458. */
  21459. onCompiled: Nullable<(effect: Effect) => void>;
  21460. /**
  21461. * Callback triggered when an error occurs
  21462. */
  21463. onError: Nullable<(effect: Effect, errors: string) => void>;
  21464. /**
  21465. * Callback triggered to get the render target textures
  21466. */
  21467. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21468. /**
  21469. * Gets a boolean indicating that current material needs to register RTT
  21470. */
  21471. get hasRenderTargetTextures(): boolean;
  21472. /**
  21473. * Specifies if the material should be serialized
  21474. */
  21475. doNotSerialize: boolean;
  21476. /**
  21477. * @hidden
  21478. */
  21479. _storeEffectOnSubMeshes: boolean;
  21480. /**
  21481. * Stores the animations for the material
  21482. */
  21483. animations: Nullable<Array<Animation>>;
  21484. /**
  21485. * An event triggered when the material is disposed
  21486. */
  21487. onDisposeObservable: Observable<Material>;
  21488. /**
  21489. * An observer which watches for dispose events
  21490. */
  21491. private _onDisposeObserver;
  21492. private _onUnBindObservable;
  21493. /**
  21494. * Called during a dispose event
  21495. */
  21496. set onDispose(callback: () => void);
  21497. private _onBindObservable;
  21498. /**
  21499. * An event triggered when the material is bound
  21500. */
  21501. get onBindObservable(): Observable<AbstractMesh>;
  21502. /**
  21503. * An observer which watches for bind events
  21504. */
  21505. private _onBindObserver;
  21506. /**
  21507. * Called during a bind event
  21508. */
  21509. set onBind(callback: (Mesh: AbstractMesh) => void);
  21510. /**
  21511. * An event triggered when the material is unbound
  21512. */
  21513. get onUnBindObservable(): Observable<Material>;
  21514. /**
  21515. * Stores the value of the alpha mode
  21516. */
  21517. private _alphaMode;
  21518. /**
  21519. * Sets the value of the alpha mode.
  21520. *
  21521. * | Value | Type | Description |
  21522. * | --- | --- | --- |
  21523. * | 0 | ALPHA_DISABLE | |
  21524. * | 1 | ALPHA_ADD | |
  21525. * | 2 | ALPHA_COMBINE | |
  21526. * | 3 | ALPHA_SUBTRACT | |
  21527. * | 4 | ALPHA_MULTIPLY | |
  21528. * | 5 | ALPHA_MAXIMIZED | |
  21529. * | 6 | ALPHA_ONEONE | |
  21530. * | 7 | ALPHA_PREMULTIPLIED | |
  21531. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21532. * | 9 | ALPHA_INTERPOLATE | |
  21533. * | 10 | ALPHA_SCREENMODE | |
  21534. *
  21535. */
  21536. set alphaMode(value: number);
  21537. /**
  21538. * Gets the value of the alpha mode
  21539. */
  21540. get alphaMode(): number;
  21541. /**
  21542. * Stores the state of the need depth pre-pass value
  21543. */
  21544. private _needDepthPrePass;
  21545. /**
  21546. * Sets the need depth pre-pass value
  21547. */
  21548. set needDepthPrePass(value: boolean);
  21549. /**
  21550. * Gets the depth pre-pass value
  21551. */
  21552. get needDepthPrePass(): boolean;
  21553. /**
  21554. * Specifies if depth writing should be disabled
  21555. */
  21556. disableDepthWrite: boolean;
  21557. /**
  21558. * Specifies if depth writing should be forced
  21559. */
  21560. forceDepthWrite: boolean;
  21561. /**
  21562. * Specifies the depth function that should be used. 0 means the default engine function
  21563. */
  21564. depthFunction: number;
  21565. /**
  21566. * Specifies if there should be a separate pass for culling
  21567. */
  21568. separateCullingPass: boolean;
  21569. /**
  21570. * Stores the state specifing if fog should be enabled
  21571. */
  21572. private _fogEnabled;
  21573. /**
  21574. * Sets the state for enabling fog
  21575. */
  21576. set fogEnabled(value: boolean);
  21577. /**
  21578. * Gets the value of the fog enabled state
  21579. */
  21580. get fogEnabled(): boolean;
  21581. /**
  21582. * Stores the size of points
  21583. */
  21584. pointSize: number;
  21585. /**
  21586. * Stores the z offset value
  21587. */
  21588. zOffset: number;
  21589. /**
  21590. * Gets a value specifying if wireframe mode is enabled
  21591. */
  21592. get wireframe(): boolean;
  21593. /**
  21594. * Sets the state of wireframe mode
  21595. */
  21596. set wireframe(value: boolean);
  21597. /**
  21598. * Gets the value specifying if point clouds are enabled
  21599. */
  21600. get pointsCloud(): boolean;
  21601. /**
  21602. * Sets the state of point cloud mode
  21603. */
  21604. set pointsCloud(value: boolean);
  21605. /**
  21606. * Gets the material fill mode
  21607. */
  21608. get fillMode(): number;
  21609. /**
  21610. * Sets the material fill mode
  21611. */
  21612. set fillMode(value: number);
  21613. /**
  21614. * @hidden
  21615. * Stores the effects for the material
  21616. */
  21617. _effect: Nullable<Effect>;
  21618. /**
  21619. * Specifies if uniform buffers should be used
  21620. */
  21621. private _useUBO;
  21622. /**
  21623. * Stores a reference to the scene
  21624. */
  21625. private _scene;
  21626. /**
  21627. * Stores the fill mode state
  21628. */
  21629. private _fillMode;
  21630. /**
  21631. * Specifies if the depth write state should be cached
  21632. */
  21633. private _cachedDepthWriteState;
  21634. /**
  21635. * Specifies if the depth function state should be cached
  21636. */
  21637. private _cachedDepthFunctionState;
  21638. /**
  21639. * Stores the uniform buffer
  21640. */
  21641. protected _uniformBuffer: UniformBuffer;
  21642. /** @hidden */
  21643. _indexInSceneMaterialArray: number;
  21644. /** @hidden */
  21645. meshMap: Nullable<{
  21646. [id: string]: AbstractMesh | undefined;
  21647. }>;
  21648. /**
  21649. * Creates a material instance
  21650. * @param name defines the name of the material
  21651. * @param scene defines the scene to reference
  21652. * @param doNotAdd specifies if the material should be added to the scene
  21653. */
  21654. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21655. /**
  21656. * Returns a string representation of the current material
  21657. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21658. * @returns a string with material information
  21659. */
  21660. toString(fullDetails?: boolean): string;
  21661. /**
  21662. * Gets the class name of the material
  21663. * @returns a string with the class name of the material
  21664. */
  21665. getClassName(): string;
  21666. /**
  21667. * Specifies if updates for the material been locked
  21668. */
  21669. get isFrozen(): boolean;
  21670. /**
  21671. * Locks updates for the material
  21672. */
  21673. freeze(): void;
  21674. /**
  21675. * Unlocks updates for the material
  21676. */
  21677. unfreeze(): void;
  21678. /**
  21679. * Specifies if the material is ready to be used
  21680. * @param mesh defines the mesh to check
  21681. * @param useInstances specifies if instances should be used
  21682. * @returns a boolean indicating if the material is ready to be used
  21683. */
  21684. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21685. /**
  21686. * Specifies that the submesh is ready to be used
  21687. * @param mesh defines the mesh to check
  21688. * @param subMesh defines which submesh to check
  21689. * @param useInstances specifies that instances should be used
  21690. * @returns a boolean indicating that the submesh is ready or not
  21691. */
  21692. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21693. /**
  21694. * Returns the material effect
  21695. * @returns the effect associated with the material
  21696. */
  21697. getEffect(): Nullable<Effect>;
  21698. /**
  21699. * Returns the current scene
  21700. * @returns a Scene
  21701. */
  21702. getScene(): Scene;
  21703. /**
  21704. * Specifies if the material will require alpha blending
  21705. * @returns a boolean specifying if alpha blending is needed
  21706. */
  21707. needAlphaBlending(): boolean;
  21708. /**
  21709. * Specifies if the mesh will require alpha blending
  21710. * @param mesh defines the mesh to check
  21711. * @returns a boolean specifying if alpha blending is needed for the mesh
  21712. */
  21713. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21714. /**
  21715. * Specifies if this material should be rendered in alpha test mode
  21716. * @returns a boolean specifying if an alpha test is needed.
  21717. */
  21718. needAlphaTesting(): boolean;
  21719. /**
  21720. * Gets the texture used for the alpha test
  21721. * @returns the texture to use for alpha testing
  21722. */
  21723. getAlphaTestTexture(): Nullable<BaseTexture>;
  21724. /**
  21725. * Marks the material to indicate that it needs to be re-calculated
  21726. */
  21727. markDirty(): void;
  21728. /** @hidden */
  21729. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21730. /**
  21731. * Binds the material to the mesh
  21732. * @param world defines the world transformation matrix
  21733. * @param mesh defines the mesh to bind the material to
  21734. */
  21735. bind(world: Matrix, mesh?: Mesh): void;
  21736. /**
  21737. * Binds the submesh to the material
  21738. * @param world defines the world transformation matrix
  21739. * @param mesh defines the mesh containing the submesh
  21740. * @param subMesh defines the submesh to bind the material to
  21741. */
  21742. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21743. /**
  21744. * Binds the world matrix to the material
  21745. * @param world defines the world transformation matrix
  21746. */
  21747. bindOnlyWorldMatrix(world: Matrix): void;
  21748. /**
  21749. * Binds the scene's uniform buffer to the effect.
  21750. * @param effect defines the effect to bind to the scene uniform buffer
  21751. * @param sceneUbo defines the uniform buffer storing scene data
  21752. */
  21753. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21754. /**
  21755. * Binds the view matrix to the effect
  21756. * @param effect defines the effect to bind the view matrix to
  21757. */
  21758. bindView(effect: Effect): void;
  21759. /**
  21760. * Binds the view projection matrix to the effect
  21761. * @param effect defines the effect to bind the view projection matrix to
  21762. */
  21763. bindViewProjection(effect: Effect): void;
  21764. /**
  21765. * Specifies if material alpha testing should be turned on for the mesh
  21766. * @param mesh defines the mesh to check
  21767. */
  21768. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21769. /**
  21770. * Processes to execute after binding the material to a mesh
  21771. * @param mesh defines the rendered mesh
  21772. */
  21773. protected _afterBind(mesh?: Mesh): void;
  21774. /**
  21775. * Unbinds the material from the mesh
  21776. */
  21777. unbind(): void;
  21778. /**
  21779. * Gets the active textures from the material
  21780. * @returns an array of textures
  21781. */
  21782. getActiveTextures(): BaseTexture[];
  21783. /**
  21784. * Specifies if the material uses a texture
  21785. * @param texture defines the texture to check against the material
  21786. * @returns a boolean specifying if the material uses the texture
  21787. */
  21788. hasTexture(texture: BaseTexture): boolean;
  21789. /**
  21790. * Makes a duplicate of the material, and gives it a new name
  21791. * @param name defines the new name for the duplicated material
  21792. * @returns the cloned material
  21793. */
  21794. clone(name: string): Nullable<Material>;
  21795. /**
  21796. * Gets the meshes bound to the material
  21797. * @returns an array of meshes bound to the material
  21798. */
  21799. getBindedMeshes(): AbstractMesh[];
  21800. /**
  21801. * Force shader compilation
  21802. * @param mesh defines the mesh associated with this material
  21803. * @param onCompiled defines a function to execute once the material is compiled
  21804. * @param options defines the options to configure the compilation
  21805. * @param onError defines a function to execute if the material fails compiling
  21806. */
  21807. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21808. /**
  21809. * Force shader compilation
  21810. * @param mesh defines the mesh that will use this material
  21811. * @param options defines additional options for compiling the shaders
  21812. * @returns a promise that resolves when the compilation completes
  21813. */
  21814. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21815. private static readonly _AllDirtyCallBack;
  21816. private static readonly _ImageProcessingDirtyCallBack;
  21817. private static readonly _TextureDirtyCallBack;
  21818. private static readonly _FresnelDirtyCallBack;
  21819. private static readonly _MiscDirtyCallBack;
  21820. private static readonly _LightsDirtyCallBack;
  21821. private static readonly _AttributeDirtyCallBack;
  21822. private static _FresnelAndMiscDirtyCallBack;
  21823. private static _TextureAndMiscDirtyCallBack;
  21824. private static readonly _DirtyCallbackArray;
  21825. private static readonly _RunDirtyCallBacks;
  21826. /**
  21827. * Marks a define in the material to indicate that it needs to be re-computed
  21828. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21829. */
  21830. markAsDirty(flag: number): void;
  21831. /**
  21832. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21833. * @param func defines a function which checks material defines against the submeshes
  21834. */
  21835. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21836. /**
  21837. * Indicates that we need to re-calculated for all submeshes
  21838. */
  21839. protected _markAllSubMeshesAsAllDirty(): void;
  21840. /**
  21841. * Indicates that image processing needs to be re-calculated for all submeshes
  21842. */
  21843. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21844. /**
  21845. * Indicates that textures need to be re-calculated for all submeshes
  21846. */
  21847. protected _markAllSubMeshesAsTexturesDirty(): void;
  21848. /**
  21849. * Indicates that fresnel needs to be re-calculated for all submeshes
  21850. */
  21851. protected _markAllSubMeshesAsFresnelDirty(): void;
  21852. /**
  21853. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21854. */
  21855. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21856. /**
  21857. * Indicates that lights need to be re-calculated for all submeshes
  21858. */
  21859. protected _markAllSubMeshesAsLightsDirty(): void;
  21860. /**
  21861. * Indicates that attributes need to be re-calculated for all submeshes
  21862. */
  21863. protected _markAllSubMeshesAsAttributesDirty(): void;
  21864. /**
  21865. * Indicates that misc needs to be re-calculated for all submeshes
  21866. */
  21867. protected _markAllSubMeshesAsMiscDirty(): void;
  21868. /**
  21869. * Indicates that textures and misc need to be re-calculated for all submeshes
  21870. */
  21871. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21872. /**
  21873. * Disposes the material
  21874. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21875. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21876. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21877. */
  21878. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21879. /** @hidden */
  21880. private releaseVertexArrayObject;
  21881. /**
  21882. * Serializes this material
  21883. * @returns the serialized material object
  21884. */
  21885. serialize(): any;
  21886. /**
  21887. * Creates a material from parsed material data
  21888. * @param parsedMaterial defines parsed material data
  21889. * @param scene defines the hosting scene
  21890. * @param rootUrl defines the root URL to use to load textures
  21891. * @returns a new material
  21892. */
  21893. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21894. }
  21895. }
  21896. declare module "babylonjs/Materials/multiMaterial" {
  21897. import { Nullable } from "babylonjs/types";
  21898. import { Scene } from "babylonjs/scene";
  21899. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21900. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21901. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21902. import { Material } from "babylonjs/Materials/material";
  21903. /**
  21904. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21905. * separate meshes. This can be use to improve performances.
  21906. * @see http://doc.babylonjs.com/how_to/multi_materials
  21907. */
  21908. export class MultiMaterial extends Material {
  21909. private _subMaterials;
  21910. /**
  21911. * Gets or Sets the list of Materials used within the multi material.
  21912. * They need to be ordered according to the submeshes order in the associated mesh
  21913. */
  21914. get subMaterials(): Nullable<Material>[];
  21915. set subMaterials(value: Nullable<Material>[]);
  21916. /**
  21917. * Function used to align with Node.getChildren()
  21918. * @returns the list of Materials used within the multi material
  21919. */
  21920. getChildren(): Nullable<Material>[];
  21921. /**
  21922. * Instantiates a new Multi Material
  21923. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21924. * separate meshes. This can be use to improve performances.
  21925. * @see http://doc.babylonjs.com/how_to/multi_materials
  21926. * @param name Define the name in the scene
  21927. * @param scene Define the scene the material belongs to
  21928. */
  21929. constructor(name: string, scene: Scene);
  21930. private _hookArray;
  21931. /**
  21932. * Get one of the submaterial by its index in the submaterials array
  21933. * @param index The index to look the sub material at
  21934. * @returns The Material if the index has been defined
  21935. */
  21936. getSubMaterial(index: number): Nullable<Material>;
  21937. /**
  21938. * Get the list of active textures for the whole sub materials list.
  21939. * @returns All the textures that will be used during the rendering
  21940. */
  21941. getActiveTextures(): BaseTexture[];
  21942. /**
  21943. * Gets the current class name of the material e.g. "MultiMaterial"
  21944. * Mainly use in serialization.
  21945. * @returns the class name
  21946. */
  21947. getClassName(): string;
  21948. /**
  21949. * Checks if the material is ready to render the requested sub mesh
  21950. * @param mesh Define the mesh the submesh belongs to
  21951. * @param subMesh Define the sub mesh to look readyness for
  21952. * @param useInstances Define whether or not the material is used with instances
  21953. * @returns true if ready, otherwise false
  21954. */
  21955. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21956. /**
  21957. * Clones the current material and its related sub materials
  21958. * @param name Define the name of the newly cloned material
  21959. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21960. * @returns the cloned material
  21961. */
  21962. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21963. /**
  21964. * Serializes the materials into a JSON representation.
  21965. * @returns the JSON representation
  21966. */
  21967. serialize(): any;
  21968. /**
  21969. * Dispose the material and release its associated resources
  21970. * @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)
  21971. * @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)
  21972. * @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)
  21973. */
  21974. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21975. /**
  21976. * Creates a MultiMaterial from parsed MultiMaterial data.
  21977. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21978. * @param scene defines the hosting scene
  21979. * @returns a new MultiMaterial
  21980. */
  21981. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21982. }
  21983. }
  21984. declare module "babylonjs/Meshes/subMesh" {
  21985. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21986. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21987. import { Engine } from "babylonjs/Engines/engine";
  21988. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21989. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21990. import { Effect } from "babylonjs/Materials/effect";
  21991. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21992. import { Plane } from "babylonjs/Maths/math.plane";
  21993. import { Collider } from "babylonjs/Collisions/collider";
  21994. import { Material } from "babylonjs/Materials/material";
  21995. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21997. import { Mesh } from "babylonjs/Meshes/mesh";
  21998. import { Ray } from "babylonjs/Culling/ray";
  21999. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22000. /**
  22001. * Base class for submeshes
  22002. */
  22003. export class BaseSubMesh {
  22004. /** @hidden */
  22005. _materialDefines: Nullable<MaterialDefines>;
  22006. /** @hidden */
  22007. _materialEffect: Nullable<Effect>;
  22008. /**
  22009. * Gets material defines used by the effect associated to the sub mesh
  22010. */
  22011. get materialDefines(): Nullable<MaterialDefines>;
  22012. /**
  22013. * Sets material defines used by the effect associated to the sub mesh
  22014. */
  22015. set materialDefines(defines: Nullable<MaterialDefines>);
  22016. /**
  22017. * Gets associated effect
  22018. */
  22019. get effect(): Nullable<Effect>;
  22020. /**
  22021. * Sets associated effect (effect used to render this submesh)
  22022. * @param effect defines the effect to associate with
  22023. * @param defines defines the set of defines used to compile this effect
  22024. */
  22025. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22026. }
  22027. /**
  22028. * Defines a subdivision inside a mesh
  22029. */
  22030. export class SubMesh extends BaseSubMesh implements ICullable {
  22031. /** the material index to use */
  22032. materialIndex: number;
  22033. /** vertex index start */
  22034. verticesStart: number;
  22035. /** vertices count */
  22036. verticesCount: number;
  22037. /** index start */
  22038. indexStart: number;
  22039. /** indices count */
  22040. indexCount: number;
  22041. /** @hidden */
  22042. _linesIndexCount: number;
  22043. private _mesh;
  22044. private _renderingMesh;
  22045. private _boundingInfo;
  22046. private _linesIndexBuffer;
  22047. /** @hidden */
  22048. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22049. /** @hidden */
  22050. _trianglePlanes: Plane[];
  22051. /** @hidden */
  22052. _lastColliderTransformMatrix: Nullable<Matrix>;
  22053. /** @hidden */
  22054. _renderId: number;
  22055. /** @hidden */
  22056. _alphaIndex: number;
  22057. /** @hidden */
  22058. _distanceToCamera: number;
  22059. /** @hidden */
  22060. _id: number;
  22061. private _currentMaterial;
  22062. /**
  22063. * Add a new submesh to a mesh
  22064. * @param materialIndex defines the material index to use
  22065. * @param verticesStart defines vertex index start
  22066. * @param verticesCount defines vertices count
  22067. * @param indexStart defines index start
  22068. * @param indexCount defines indices count
  22069. * @param mesh defines the parent mesh
  22070. * @param renderingMesh defines an optional rendering mesh
  22071. * @param createBoundingBox defines if bounding box should be created for this submesh
  22072. * @returns the new submesh
  22073. */
  22074. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22075. /**
  22076. * Creates a new submesh
  22077. * @param materialIndex defines the material index to use
  22078. * @param verticesStart defines vertex index start
  22079. * @param verticesCount defines vertices count
  22080. * @param indexStart defines index start
  22081. * @param indexCount defines indices count
  22082. * @param mesh defines the parent mesh
  22083. * @param renderingMesh defines an optional rendering mesh
  22084. * @param createBoundingBox defines if bounding box should be created for this submesh
  22085. */
  22086. constructor(
  22087. /** the material index to use */
  22088. materialIndex: number,
  22089. /** vertex index start */
  22090. verticesStart: number,
  22091. /** vertices count */
  22092. verticesCount: number,
  22093. /** index start */
  22094. indexStart: number,
  22095. /** indices count */
  22096. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22097. /**
  22098. * Returns true if this submesh covers the entire parent mesh
  22099. * @ignorenaming
  22100. */
  22101. get IsGlobal(): boolean;
  22102. /**
  22103. * Returns the submesh BoudingInfo object
  22104. * @returns current bounding info (or mesh's one if the submesh is global)
  22105. */
  22106. getBoundingInfo(): BoundingInfo;
  22107. /**
  22108. * Sets the submesh BoundingInfo
  22109. * @param boundingInfo defines the new bounding info to use
  22110. * @returns the SubMesh
  22111. */
  22112. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22113. /**
  22114. * Returns the mesh of the current submesh
  22115. * @return the parent mesh
  22116. */
  22117. getMesh(): AbstractMesh;
  22118. /**
  22119. * Returns the rendering mesh of the submesh
  22120. * @returns the rendering mesh (could be different from parent mesh)
  22121. */
  22122. getRenderingMesh(): Mesh;
  22123. /**
  22124. * Returns the submesh material
  22125. * @returns null or the current material
  22126. */
  22127. getMaterial(): Nullable<Material>;
  22128. /**
  22129. * Sets a new updated BoundingInfo object to the submesh
  22130. * @param data defines an optional position array to use to determine the bounding info
  22131. * @returns the SubMesh
  22132. */
  22133. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22134. /** @hidden */
  22135. _checkCollision(collider: Collider): boolean;
  22136. /**
  22137. * Updates the submesh BoundingInfo
  22138. * @param world defines the world matrix to use to update the bounding info
  22139. * @returns the submesh
  22140. */
  22141. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22142. /**
  22143. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22144. * @param frustumPlanes defines the frustum planes
  22145. * @returns true if the submesh is intersecting with the frustum
  22146. */
  22147. isInFrustum(frustumPlanes: Plane[]): boolean;
  22148. /**
  22149. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22150. * @param frustumPlanes defines the frustum planes
  22151. * @returns true if the submesh is inside the frustum
  22152. */
  22153. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22154. /**
  22155. * Renders the submesh
  22156. * @param enableAlphaMode defines if alpha needs to be used
  22157. * @returns the submesh
  22158. */
  22159. render(enableAlphaMode: boolean): SubMesh;
  22160. /**
  22161. * @hidden
  22162. */
  22163. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22164. /**
  22165. * Checks if the submesh intersects with a ray
  22166. * @param ray defines the ray to test
  22167. * @returns true is the passed ray intersects the submesh bounding box
  22168. */
  22169. canIntersects(ray: Ray): boolean;
  22170. /**
  22171. * Intersects current submesh with a ray
  22172. * @param ray defines the ray to test
  22173. * @param positions defines mesh's positions array
  22174. * @param indices defines mesh's indices array
  22175. * @param fastCheck defines if only bounding info should be used
  22176. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22177. * @returns intersection info or null if no intersection
  22178. */
  22179. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22180. /** @hidden */
  22181. private _intersectLines;
  22182. /** @hidden */
  22183. private _intersectUnIndexedLines;
  22184. /** @hidden */
  22185. private _intersectTriangles;
  22186. /** @hidden */
  22187. private _intersectUnIndexedTriangles;
  22188. /** @hidden */
  22189. _rebuild(): void;
  22190. /**
  22191. * Creates a new submesh from the passed mesh
  22192. * @param newMesh defines the new hosting mesh
  22193. * @param newRenderingMesh defines an optional rendering mesh
  22194. * @returns the new submesh
  22195. */
  22196. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22197. /**
  22198. * Release associated resources
  22199. */
  22200. dispose(): void;
  22201. /**
  22202. * Gets the class name
  22203. * @returns the string "SubMesh".
  22204. */
  22205. getClassName(): string;
  22206. /**
  22207. * Creates a new submesh from indices data
  22208. * @param materialIndex the index of the main mesh material
  22209. * @param startIndex the index where to start the copy in the mesh indices array
  22210. * @param indexCount the number of indices to copy then from the startIndex
  22211. * @param mesh the main mesh to create the submesh from
  22212. * @param renderingMesh the optional rendering mesh
  22213. * @returns a new submesh
  22214. */
  22215. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22216. }
  22217. }
  22218. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22219. /**
  22220. * Class used to represent data loading progression
  22221. */
  22222. export class SceneLoaderFlags {
  22223. private static _ForceFullSceneLoadingForIncremental;
  22224. private static _ShowLoadingScreen;
  22225. private static _CleanBoneMatrixWeights;
  22226. private static _loggingLevel;
  22227. /**
  22228. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22229. */
  22230. static get ForceFullSceneLoadingForIncremental(): boolean;
  22231. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22232. /**
  22233. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22234. */
  22235. static get ShowLoadingScreen(): boolean;
  22236. static set ShowLoadingScreen(value: boolean);
  22237. /**
  22238. * Defines the current logging level (while loading the scene)
  22239. * @ignorenaming
  22240. */
  22241. static get loggingLevel(): number;
  22242. static set loggingLevel(value: number);
  22243. /**
  22244. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22245. */
  22246. static get CleanBoneMatrixWeights(): boolean;
  22247. static set CleanBoneMatrixWeights(value: boolean);
  22248. }
  22249. }
  22250. declare module "babylonjs/Meshes/geometry" {
  22251. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22252. import { Scene } from "babylonjs/scene";
  22253. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22254. import { Engine } from "babylonjs/Engines/engine";
  22255. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22256. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22257. import { Effect } from "babylonjs/Materials/effect";
  22258. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22259. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22260. import { Mesh } from "babylonjs/Meshes/mesh";
  22261. /**
  22262. * Class used to store geometry data (vertex buffers + index buffer)
  22263. */
  22264. export class Geometry implements IGetSetVerticesData {
  22265. /**
  22266. * Gets or sets the ID of the geometry
  22267. */
  22268. id: string;
  22269. /**
  22270. * Gets or sets the unique ID of the geometry
  22271. */
  22272. uniqueId: number;
  22273. /**
  22274. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22275. */
  22276. delayLoadState: number;
  22277. /**
  22278. * Gets the file containing the data to load when running in delay load state
  22279. */
  22280. delayLoadingFile: Nullable<string>;
  22281. /**
  22282. * Callback called when the geometry is updated
  22283. */
  22284. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22285. private _scene;
  22286. private _engine;
  22287. private _meshes;
  22288. private _totalVertices;
  22289. /** @hidden */
  22290. _indices: IndicesArray;
  22291. /** @hidden */
  22292. _vertexBuffers: {
  22293. [key: string]: VertexBuffer;
  22294. };
  22295. private _isDisposed;
  22296. private _extend;
  22297. private _boundingBias;
  22298. /** @hidden */
  22299. _delayInfo: Array<string>;
  22300. private _indexBuffer;
  22301. private _indexBufferIsUpdatable;
  22302. /** @hidden */
  22303. _boundingInfo: Nullable<BoundingInfo>;
  22304. /** @hidden */
  22305. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22306. /** @hidden */
  22307. _softwareSkinningFrameId: number;
  22308. private _vertexArrayObjects;
  22309. private _updatable;
  22310. /** @hidden */
  22311. _positions: Nullable<Vector3[]>;
  22312. /**
  22313. * 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
  22314. */
  22315. get boundingBias(): Vector2;
  22316. /**
  22317. * 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
  22318. */
  22319. set boundingBias(value: Vector2);
  22320. /**
  22321. * Static function used to attach a new empty geometry to a mesh
  22322. * @param mesh defines the mesh to attach the geometry to
  22323. * @returns the new Geometry
  22324. */
  22325. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22326. /**
  22327. * Creates a new geometry
  22328. * @param id defines the unique ID
  22329. * @param scene defines the hosting scene
  22330. * @param vertexData defines the VertexData used to get geometry data
  22331. * @param updatable defines if geometry must be updatable (false by default)
  22332. * @param mesh defines the mesh that will be associated with the geometry
  22333. */
  22334. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22335. /**
  22336. * Gets the current extend of the geometry
  22337. */
  22338. get extend(): {
  22339. minimum: Vector3;
  22340. maximum: Vector3;
  22341. };
  22342. /**
  22343. * Gets the hosting scene
  22344. * @returns the hosting Scene
  22345. */
  22346. getScene(): Scene;
  22347. /**
  22348. * Gets the hosting engine
  22349. * @returns the hosting Engine
  22350. */
  22351. getEngine(): Engine;
  22352. /**
  22353. * Defines if the geometry is ready to use
  22354. * @returns true if the geometry is ready to be used
  22355. */
  22356. isReady(): boolean;
  22357. /**
  22358. * Gets a value indicating that the geometry should not be serialized
  22359. */
  22360. get doNotSerialize(): boolean;
  22361. /** @hidden */
  22362. _rebuild(): void;
  22363. /**
  22364. * Affects all geometry data in one call
  22365. * @param vertexData defines the geometry data
  22366. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22367. */
  22368. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22369. /**
  22370. * Set specific vertex data
  22371. * @param kind defines the data kind (Position, normal, etc...)
  22372. * @param data defines the vertex data to use
  22373. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22374. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22375. */
  22376. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22377. /**
  22378. * Removes a specific vertex data
  22379. * @param kind defines the data kind (Position, normal, etc...)
  22380. */
  22381. removeVerticesData(kind: string): void;
  22382. /**
  22383. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22384. * @param buffer defines the vertex buffer to use
  22385. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22386. */
  22387. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22388. /**
  22389. * Update a specific vertex buffer
  22390. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22391. * It will do nothing if the buffer is not updatable
  22392. * @param kind defines the data kind (Position, normal, etc...)
  22393. * @param data defines the data to use
  22394. * @param offset defines the offset in the target buffer where to store the data
  22395. * @param useBytes set to true if the offset is in bytes
  22396. */
  22397. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22398. /**
  22399. * Update a specific vertex buffer
  22400. * This function will create a new buffer if the current one is not updatable
  22401. * @param kind defines the data kind (Position, normal, etc...)
  22402. * @param data defines the data to use
  22403. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22404. */
  22405. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22406. private _updateBoundingInfo;
  22407. /** @hidden */
  22408. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22409. /**
  22410. * Gets total number of vertices
  22411. * @returns the total number of vertices
  22412. */
  22413. getTotalVertices(): number;
  22414. /**
  22415. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22416. * @param kind defines the data kind (Position, normal, etc...)
  22417. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22418. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22419. * @returns a float array containing vertex data
  22420. */
  22421. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22422. /**
  22423. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22424. * @param kind defines the data kind (Position, normal, etc...)
  22425. * @returns true if the vertex buffer with the specified kind is updatable
  22426. */
  22427. isVertexBufferUpdatable(kind: string): boolean;
  22428. /**
  22429. * Gets a specific vertex buffer
  22430. * @param kind defines the data kind (Position, normal, etc...)
  22431. * @returns a VertexBuffer
  22432. */
  22433. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22434. /**
  22435. * Returns all vertex buffers
  22436. * @return an object holding all vertex buffers indexed by kind
  22437. */
  22438. getVertexBuffers(): Nullable<{
  22439. [key: string]: VertexBuffer;
  22440. }>;
  22441. /**
  22442. * Gets a boolean indicating if specific vertex buffer is present
  22443. * @param kind defines the data kind (Position, normal, etc...)
  22444. * @returns true if data is present
  22445. */
  22446. isVerticesDataPresent(kind: string): boolean;
  22447. /**
  22448. * Gets a list of all attached data kinds (Position, normal, etc...)
  22449. * @returns a list of string containing all kinds
  22450. */
  22451. getVerticesDataKinds(): string[];
  22452. /**
  22453. * Update index buffer
  22454. * @param indices defines the indices to store in the index buffer
  22455. * @param offset defines the offset in the target buffer where to store the data
  22456. * @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)
  22457. */
  22458. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22459. /**
  22460. * Creates a new index buffer
  22461. * @param indices defines the indices to store in the index buffer
  22462. * @param totalVertices defines the total number of vertices (could be null)
  22463. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22464. */
  22465. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22466. /**
  22467. * Return the total number of indices
  22468. * @returns the total number of indices
  22469. */
  22470. getTotalIndices(): number;
  22471. /**
  22472. * Gets the index buffer array
  22473. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22474. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22475. * @returns the index buffer array
  22476. */
  22477. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22478. /**
  22479. * Gets the index buffer
  22480. * @return the index buffer
  22481. */
  22482. getIndexBuffer(): Nullable<DataBuffer>;
  22483. /** @hidden */
  22484. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22485. /**
  22486. * Release the associated resources for a specific mesh
  22487. * @param mesh defines the source mesh
  22488. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22489. */
  22490. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22491. /**
  22492. * Apply current geometry to a given mesh
  22493. * @param mesh defines the mesh to apply geometry to
  22494. */
  22495. applyToMesh(mesh: Mesh): void;
  22496. private _updateExtend;
  22497. private _applyToMesh;
  22498. private notifyUpdate;
  22499. /**
  22500. * Load the geometry if it was flagged as delay loaded
  22501. * @param scene defines the hosting scene
  22502. * @param onLoaded defines a callback called when the geometry is loaded
  22503. */
  22504. load(scene: Scene, onLoaded?: () => void): void;
  22505. private _queueLoad;
  22506. /**
  22507. * Invert the geometry to move from a right handed system to a left handed one.
  22508. */
  22509. toLeftHanded(): void;
  22510. /** @hidden */
  22511. _resetPointsArrayCache(): void;
  22512. /** @hidden */
  22513. _generatePointsArray(): boolean;
  22514. /**
  22515. * Gets a value indicating if the geometry is disposed
  22516. * @returns true if the geometry was disposed
  22517. */
  22518. isDisposed(): boolean;
  22519. private _disposeVertexArrayObjects;
  22520. /**
  22521. * Free all associated resources
  22522. */
  22523. dispose(): void;
  22524. /**
  22525. * Clone the current geometry into a new geometry
  22526. * @param id defines the unique ID of the new geometry
  22527. * @returns a new geometry object
  22528. */
  22529. copy(id: string): Geometry;
  22530. /**
  22531. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22532. * @return a JSON representation of the current geometry data (without the vertices data)
  22533. */
  22534. serialize(): any;
  22535. private toNumberArray;
  22536. /**
  22537. * Serialize all vertices data into a JSON oject
  22538. * @returns a JSON representation of the current geometry data
  22539. */
  22540. serializeVerticeData(): any;
  22541. /**
  22542. * Extracts a clone of a mesh geometry
  22543. * @param mesh defines the source mesh
  22544. * @param id defines the unique ID of the new geometry object
  22545. * @returns the new geometry object
  22546. */
  22547. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22548. /**
  22549. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22550. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22551. * Be aware Math.random() could cause collisions, but:
  22552. * "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"
  22553. * @returns a string containing a new GUID
  22554. */
  22555. static RandomId(): string;
  22556. /** @hidden */
  22557. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22558. private static _CleanMatricesWeights;
  22559. /**
  22560. * Create a new geometry from persisted data (Using .babylon file format)
  22561. * @param parsedVertexData defines the persisted data
  22562. * @param scene defines the hosting scene
  22563. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22564. * @returns the new geometry object
  22565. */
  22566. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22567. }
  22568. }
  22569. declare module "babylonjs/Meshes/mesh.vertexData" {
  22570. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22571. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22572. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22573. import { Geometry } from "babylonjs/Meshes/geometry";
  22574. import { Mesh } from "babylonjs/Meshes/mesh";
  22575. /**
  22576. * Define an interface for all classes that will get and set the data on vertices
  22577. */
  22578. export interface IGetSetVerticesData {
  22579. /**
  22580. * Gets a boolean indicating if specific vertex data is present
  22581. * @param kind defines the vertex data kind to use
  22582. * @returns true is data kind is present
  22583. */
  22584. isVerticesDataPresent(kind: string): boolean;
  22585. /**
  22586. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22587. * @param kind defines the data kind (Position, normal, etc...)
  22588. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22589. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22590. * @returns a float array containing vertex data
  22591. */
  22592. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22593. /**
  22594. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22595. * @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.
  22596. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22597. * @returns the indices array or an empty array if the mesh has no geometry
  22598. */
  22599. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22600. /**
  22601. * Set specific vertex data
  22602. * @param kind defines the data kind (Position, normal, etc...)
  22603. * @param data defines the vertex data to use
  22604. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22605. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22606. */
  22607. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22608. /**
  22609. * Update a specific associated vertex buffer
  22610. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22611. * - VertexBuffer.PositionKind
  22612. * - VertexBuffer.UVKind
  22613. * - VertexBuffer.UV2Kind
  22614. * - VertexBuffer.UV3Kind
  22615. * - VertexBuffer.UV4Kind
  22616. * - VertexBuffer.UV5Kind
  22617. * - VertexBuffer.UV6Kind
  22618. * - VertexBuffer.ColorKind
  22619. * - VertexBuffer.MatricesIndicesKind
  22620. * - VertexBuffer.MatricesIndicesExtraKind
  22621. * - VertexBuffer.MatricesWeightsKind
  22622. * - VertexBuffer.MatricesWeightsExtraKind
  22623. * @param data defines the data source
  22624. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22625. * @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)
  22626. */
  22627. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22628. /**
  22629. * Creates a new index buffer
  22630. * @param indices defines the indices to store in the index buffer
  22631. * @param totalVertices defines the total number of vertices (could be null)
  22632. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22633. */
  22634. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22635. }
  22636. /**
  22637. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22638. */
  22639. export class VertexData {
  22640. /**
  22641. * Mesh side orientation : usually the external or front surface
  22642. */
  22643. static readonly FRONTSIDE: number;
  22644. /**
  22645. * Mesh side orientation : usually the internal or back surface
  22646. */
  22647. static readonly BACKSIDE: number;
  22648. /**
  22649. * Mesh side orientation : both internal and external or front and back surfaces
  22650. */
  22651. static readonly DOUBLESIDE: number;
  22652. /**
  22653. * Mesh side orientation : by default, `FRONTSIDE`
  22654. */
  22655. static readonly DEFAULTSIDE: number;
  22656. /**
  22657. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22658. */
  22659. positions: Nullable<FloatArray>;
  22660. /**
  22661. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22662. */
  22663. normals: Nullable<FloatArray>;
  22664. /**
  22665. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22666. */
  22667. tangents: Nullable<FloatArray>;
  22668. /**
  22669. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22670. */
  22671. uvs: Nullable<FloatArray>;
  22672. /**
  22673. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22674. */
  22675. uvs2: Nullable<FloatArray>;
  22676. /**
  22677. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22678. */
  22679. uvs3: Nullable<FloatArray>;
  22680. /**
  22681. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22682. */
  22683. uvs4: Nullable<FloatArray>;
  22684. /**
  22685. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22686. */
  22687. uvs5: Nullable<FloatArray>;
  22688. /**
  22689. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22690. */
  22691. uvs6: Nullable<FloatArray>;
  22692. /**
  22693. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22694. */
  22695. colors: Nullable<FloatArray>;
  22696. /**
  22697. * 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).
  22698. */
  22699. matricesIndices: Nullable<FloatArray>;
  22700. /**
  22701. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22702. */
  22703. matricesWeights: Nullable<FloatArray>;
  22704. /**
  22705. * An array extending the number of possible indices
  22706. */
  22707. matricesIndicesExtra: Nullable<FloatArray>;
  22708. /**
  22709. * An array extending the number of possible weights when the number of indices is extended
  22710. */
  22711. matricesWeightsExtra: Nullable<FloatArray>;
  22712. /**
  22713. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22714. */
  22715. indices: Nullable<IndicesArray>;
  22716. /**
  22717. * Uses the passed data array to set the set the values for the specified kind of data
  22718. * @param data a linear array of floating numbers
  22719. * @param kind the type of data that is being set, eg positions, colors etc
  22720. */
  22721. set(data: FloatArray, kind: string): void;
  22722. /**
  22723. * Associates the vertexData to the passed Mesh.
  22724. * Sets it as updatable or not (default `false`)
  22725. * @param mesh the mesh the vertexData is applied to
  22726. * @param updatable when used and having the value true allows new data to update the vertexData
  22727. * @returns the VertexData
  22728. */
  22729. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22730. /**
  22731. * Associates the vertexData to the passed Geometry.
  22732. * Sets it as updatable or not (default `false`)
  22733. * @param geometry the geometry the vertexData is applied to
  22734. * @param updatable when used and having the value true allows new data to update the vertexData
  22735. * @returns VertexData
  22736. */
  22737. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22738. /**
  22739. * Updates the associated mesh
  22740. * @param mesh the mesh to be updated
  22741. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22742. * @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
  22743. * @returns VertexData
  22744. */
  22745. updateMesh(mesh: Mesh): VertexData;
  22746. /**
  22747. * Updates the associated geometry
  22748. * @param geometry the geometry to be updated
  22749. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22750. * @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
  22751. * @returns VertexData.
  22752. */
  22753. updateGeometry(geometry: Geometry): VertexData;
  22754. private _applyTo;
  22755. private _update;
  22756. /**
  22757. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22758. * @param matrix the transforming matrix
  22759. * @returns the VertexData
  22760. */
  22761. transform(matrix: Matrix): VertexData;
  22762. /**
  22763. * Merges the passed VertexData into the current one
  22764. * @param other the VertexData to be merged into the current one
  22765. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22766. * @returns the modified VertexData
  22767. */
  22768. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22769. private _mergeElement;
  22770. private _validate;
  22771. /**
  22772. * Serializes the VertexData
  22773. * @returns a serialized object
  22774. */
  22775. serialize(): any;
  22776. /**
  22777. * Extracts the vertexData from a mesh
  22778. * @param mesh the mesh from which to extract the VertexData
  22779. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22780. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22781. * @returns the object VertexData associated to the passed mesh
  22782. */
  22783. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22784. /**
  22785. * Extracts the vertexData from the geometry
  22786. * @param geometry the geometry from which to extract the VertexData
  22787. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22788. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22789. * @returns the object VertexData associated to the passed mesh
  22790. */
  22791. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22792. private static _ExtractFrom;
  22793. /**
  22794. * Creates the VertexData for a Ribbon
  22795. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22796. * * pathArray array of paths, each of which an array of successive Vector3
  22797. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22798. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22799. * * 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
  22800. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22801. * * 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)
  22802. * * 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)
  22803. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22804. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22805. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22806. * @returns the VertexData of the ribbon
  22807. */
  22808. static CreateRibbon(options: {
  22809. pathArray: Vector3[][];
  22810. closeArray?: boolean;
  22811. closePath?: boolean;
  22812. offset?: number;
  22813. sideOrientation?: number;
  22814. frontUVs?: Vector4;
  22815. backUVs?: Vector4;
  22816. invertUV?: boolean;
  22817. uvs?: Vector2[];
  22818. colors?: Color4[];
  22819. }): VertexData;
  22820. /**
  22821. * Creates the VertexData for a box
  22822. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22823. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22824. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22825. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22826. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22827. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22828. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22829. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22830. * * 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)
  22831. * * 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)
  22832. * @returns the VertexData of the box
  22833. */
  22834. static CreateBox(options: {
  22835. size?: number;
  22836. width?: number;
  22837. height?: number;
  22838. depth?: number;
  22839. faceUV?: Vector4[];
  22840. faceColors?: Color4[];
  22841. sideOrientation?: number;
  22842. frontUVs?: Vector4;
  22843. backUVs?: Vector4;
  22844. }): VertexData;
  22845. /**
  22846. * Creates the VertexData for a tiled box
  22847. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22848. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22849. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22850. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22851. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22852. * @returns the VertexData of the box
  22853. */
  22854. static CreateTiledBox(options: {
  22855. pattern?: number;
  22856. width?: number;
  22857. height?: number;
  22858. depth?: number;
  22859. tileSize?: number;
  22860. tileWidth?: number;
  22861. tileHeight?: number;
  22862. alignHorizontal?: number;
  22863. alignVertical?: number;
  22864. faceUV?: Vector4[];
  22865. faceColors?: Color4[];
  22866. sideOrientation?: number;
  22867. }): VertexData;
  22868. /**
  22869. * Creates the VertexData for a tiled plane
  22870. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22871. * * pattern a limited pattern arrangement depending on the number
  22872. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22873. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22874. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22875. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22876. * * 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)
  22877. * * 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)
  22878. * @returns the VertexData of the tiled plane
  22879. */
  22880. static CreateTiledPlane(options: {
  22881. pattern?: number;
  22882. tileSize?: number;
  22883. tileWidth?: number;
  22884. tileHeight?: number;
  22885. size?: number;
  22886. width?: number;
  22887. height?: number;
  22888. alignHorizontal?: number;
  22889. alignVertical?: number;
  22890. sideOrientation?: number;
  22891. frontUVs?: Vector4;
  22892. backUVs?: Vector4;
  22893. }): VertexData;
  22894. /**
  22895. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22896. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22897. * * segments sets the number of horizontal strips optional, default 32
  22898. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22899. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22900. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22901. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22902. * * 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
  22903. * * 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
  22904. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22905. * * 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)
  22906. * * 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)
  22907. * @returns the VertexData of the ellipsoid
  22908. */
  22909. static CreateSphere(options: {
  22910. segments?: number;
  22911. diameter?: number;
  22912. diameterX?: number;
  22913. diameterY?: number;
  22914. diameterZ?: number;
  22915. arc?: number;
  22916. slice?: number;
  22917. sideOrientation?: number;
  22918. frontUVs?: Vector4;
  22919. backUVs?: Vector4;
  22920. }): VertexData;
  22921. /**
  22922. * Creates the VertexData for a cylinder, cone or prism
  22923. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22924. * * height sets the height (y direction) of the cylinder, optional, default 2
  22925. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22926. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22927. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22928. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22929. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22930. * * 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
  22931. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22932. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22933. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22934. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22935. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22936. * * 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)
  22937. * * 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)
  22938. * @returns the VertexData of the cylinder, cone or prism
  22939. */
  22940. static CreateCylinder(options: {
  22941. height?: number;
  22942. diameterTop?: number;
  22943. diameterBottom?: number;
  22944. diameter?: number;
  22945. tessellation?: number;
  22946. subdivisions?: number;
  22947. arc?: number;
  22948. faceColors?: Color4[];
  22949. faceUV?: Vector4[];
  22950. hasRings?: boolean;
  22951. enclose?: boolean;
  22952. sideOrientation?: number;
  22953. frontUVs?: Vector4;
  22954. backUVs?: Vector4;
  22955. }): VertexData;
  22956. /**
  22957. * Creates the VertexData for a torus
  22958. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22959. * * diameter the diameter of the torus, optional default 1
  22960. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22961. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22962. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22963. * * 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)
  22964. * * 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)
  22965. * @returns the VertexData of the torus
  22966. */
  22967. static CreateTorus(options: {
  22968. diameter?: number;
  22969. thickness?: number;
  22970. tessellation?: number;
  22971. sideOrientation?: number;
  22972. frontUVs?: Vector4;
  22973. backUVs?: Vector4;
  22974. }): VertexData;
  22975. /**
  22976. * Creates the VertexData of the LineSystem
  22977. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22978. * - lines an array of lines, each line being an array of successive Vector3
  22979. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22980. * @returns the VertexData of the LineSystem
  22981. */
  22982. static CreateLineSystem(options: {
  22983. lines: Vector3[][];
  22984. colors?: Nullable<Color4[][]>;
  22985. }): VertexData;
  22986. /**
  22987. * Create the VertexData for a DashedLines
  22988. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22989. * - points an array successive Vector3
  22990. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22991. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22992. * - dashNb the intended total number of dashes, optional, default 200
  22993. * @returns the VertexData for the DashedLines
  22994. */
  22995. static CreateDashedLines(options: {
  22996. points: Vector3[];
  22997. dashSize?: number;
  22998. gapSize?: number;
  22999. dashNb?: number;
  23000. }): VertexData;
  23001. /**
  23002. * Creates the VertexData for a Ground
  23003. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23004. * - width the width (x direction) of the ground, optional, default 1
  23005. * - height the height (z direction) of the ground, optional, default 1
  23006. * - subdivisions the number of subdivisions per side, optional, default 1
  23007. * @returns the VertexData of the Ground
  23008. */
  23009. static CreateGround(options: {
  23010. width?: number;
  23011. height?: number;
  23012. subdivisions?: number;
  23013. subdivisionsX?: number;
  23014. subdivisionsY?: number;
  23015. }): VertexData;
  23016. /**
  23017. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23018. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23019. * * xmin the ground minimum X coordinate, optional, default -1
  23020. * * zmin the ground minimum Z coordinate, optional, default -1
  23021. * * xmax the ground maximum X coordinate, optional, default 1
  23022. * * zmax the ground maximum Z coordinate, optional, default 1
  23023. * * 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}
  23024. * * 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}
  23025. * @returns the VertexData of the TiledGround
  23026. */
  23027. static CreateTiledGround(options: {
  23028. xmin: number;
  23029. zmin: number;
  23030. xmax: number;
  23031. zmax: number;
  23032. subdivisions?: {
  23033. w: number;
  23034. h: number;
  23035. };
  23036. precision?: {
  23037. w: number;
  23038. h: number;
  23039. };
  23040. }): VertexData;
  23041. /**
  23042. * Creates the VertexData of the Ground designed from a heightmap
  23043. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23044. * * width the width (x direction) of the ground
  23045. * * height the height (z direction) of the ground
  23046. * * subdivisions the number of subdivisions per side
  23047. * * minHeight the minimum altitude on the ground, optional, default 0
  23048. * * maxHeight the maximum altitude on the ground, optional default 1
  23049. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23050. * * buffer the array holding the image color data
  23051. * * bufferWidth the width of image
  23052. * * bufferHeight the height of image
  23053. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23054. * @returns the VertexData of the Ground designed from a heightmap
  23055. */
  23056. static CreateGroundFromHeightMap(options: {
  23057. width: number;
  23058. height: number;
  23059. subdivisions: number;
  23060. minHeight: number;
  23061. maxHeight: number;
  23062. colorFilter: Color3;
  23063. buffer: Uint8Array;
  23064. bufferWidth: number;
  23065. bufferHeight: number;
  23066. alphaFilter: number;
  23067. }): VertexData;
  23068. /**
  23069. * Creates the VertexData for a Plane
  23070. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23071. * * size sets the width and height of the plane to the value of size, optional default 1
  23072. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23073. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23074. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23075. * * 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)
  23076. * * 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)
  23077. * @returns the VertexData of the box
  23078. */
  23079. static CreatePlane(options: {
  23080. size?: number;
  23081. width?: number;
  23082. height?: number;
  23083. sideOrientation?: number;
  23084. frontUVs?: Vector4;
  23085. backUVs?: Vector4;
  23086. }): VertexData;
  23087. /**
  23088. * Creates the VertexData of the Disc or regular Polygon
  23089. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23090. * * radius the radius of the disc, optional default 0.5
  23091. * * tessellation the number of polygon sides, optional, default 64
  23092. * * 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
  23093. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23094. * * 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)
  23095. * * 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)
  23096. * @returns the VertexData of the box
  23097. */
  23098. static CreateDisc(options: {
  23099. radius?: number;
  23100. tessellation?: number;
  23101. arc?: number;
  23102. sideOrientation?: number;
  23103. frontUVs?: Vector4;
  23104. backUVs?: Vector4;
  23105. }): VertexData;
  23106. /**
  23107. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23108. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23109. * @param polygon a mesh built from polygonTriangulation.build()
  23110. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23111. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23112. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23113. * @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)
  23114. * @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)
  23115. * @returns the VertexData of the Polygon
  23116. */
  23117. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23118. /**
  23119. * Creates the VertexData of the IcoSphere
  23120. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23121. * * radius the radius of the IcoSphere, optional default 1
  23122. * * radiusX allows stretching in the x direction, optional, default radius
  23123. * * radiusY allows stretching in the y direction, optional, default radius
  23124. * * radiusZ allows stretching in the z direction, optional, default radius
  23125. * * flat when true creates a flat shaded mesh, optional, default true
  23126. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23127. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23128. * * 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)
  23129. * * 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)
  23130. * @returns the VertexData of the IcoSphere
  23131. */
  23132. static CreateIcoSphere(options: {
  23133. radius?: number;
  23134. radiusX?: number;
  23135. radiusY?: number;
  23136. radiusZ?: number;
  23137. flat?: boolean;
  23138. subdivisions?: number;
  23139. sideOrientation?: number;
  23140. frontUVs?: Vector4;
  23141. backUVs?: Vector4;
  23142. }): VertexData;
  23143. /**
  23144. * Creates the VertexData for a Polyhedron
  23145. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23146. * * type provided types are:
  23147. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23148. * * 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)
  23149. * * size the size of the IcoSphere, optional default 1
  23150. * * sizeX allows stretching in the x direction, optional, default size
  23151. * * sizeY allows stretching in the y direction, optional, default size
  23152. * * sizeZ allows stretching in the z direction, optional, default size
  23153. * * 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
  23154. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23155. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23156. * * flat when true creates a flat shaded mesh, optional, default true
  23157. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23158. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23159. * * 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)
  23160. * * 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)
  23161. * @returns the VertexData of the Polyhedron
  23162. */
  23163. static CreatePolyhedron(options: {
  23164. type?: number;
  23165. size?: number;
  23166. sizeX?: number;
  23167. sizeY?: number;
  23168. sizeZ?: number;
  23169. custom?: any;
  23170. faceUV?: Vector4[];
  23171. faceColors?: Color4[];
  23172. flat?: boolean;
  23173. sideOrientation?: number;
  23174. frontUVs?: Vector4;
  23175. backUVs?: Vector4;
  23176. }): VertexData;
  23177. /**
  23178. * Creates the VertexData for a TorusKnot
  23179. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23180. * * radius the radius of the torus knot, optional, default 2
  23181. * * tube the thickness of the tube, optional, default 0.5
  23182. * * radialSegments the number of sides on each tube segments, optional, default 32
  23183. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23184. * * p the number of windings around the z axis, optional, default 2
  23185. * * q the number of windings around the x axis, optional, default 3
  23186. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23187. * * 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)
  23188. * * 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)
  23189. * @returns the VertexData of the Torus Knot
  23190. */
  23191. static CreateTorusKnot(options: {
  23192. radius?: number;
  23193. tube?: number;
  23194. radialSegments?: number;
  23195. tubularSegments?: number;
  23196. p?: number;
  23197. q?: number;
  23198. sideOrientation?: number;
  23199. frontUVs?: Vector4;
  23200. backUVs?: Vector4;
  23201. }): VertexData;
  23202. /**
  23203. * Compute normals for given positions and indices
  23204. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23205. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23206. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23207. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23208. * * facetNormals : optional array of facet normals (vector3)
  23209. * * facetPositions : optional array of facet positions (vector3)
  23210. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23211. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23212. * * bInfo : optional bounding info, required for facetPartitioning computation
  23213. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23214. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23215. * * useRightHandedSystem: optional boolean to for right handed system computation
  23216. * * depthSort : optional boolean to enable the facet depth sort computation
  23217. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23218. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23219. */
  23220. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23221. facetNormals?: any;
  23222. facetPositions?: any;
  23223. facetPartitioning?: any;
  23224. ratio?: number;
  23225. bInfo?: any;
  23226. bbSize?: Vector3;
  23227. subDiv?: any;
  23228. useRightHandedSystem?: boolean;
  23229. depthSort?: boolean;
  23230. distanceTo?: Vector3;
  23231. depthSortedFacets?: any;
  23232. }): void;
  23233. /** @hidden */
  23234. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23235. /**
  23236. * Applies VertexData created from the imported parameters to the geometry
  23237. * @param parsedVertexData the parsed data from an imported file
  23238. * @param geometry the geometry to apply the VertexData to
  23239. */
  23240. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23241. }
  23242. }
  23243. declare module "babylonjs/Morph/morphTarget" {
  23244. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23245. import { Observable } from "babylonjs/Misc/observable";
  23246. import { Nullable, FloatArray } from "babylonjs/types";
  23247. import { Scene } from "babylonjs/scene";
  23248. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23249. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23250. /**
  23251. * Defines a target to use with MorphTargetManager
  23252. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23253. */
  23254. export class MorphTarget implements IAnimatable {
  23255. /** defines the name of the target */
  23256. name: string;
  23257. /**
  23258. * Gets or sets the list of animations
  23259. */
  23260. animations: import("babylonjs/Animations/animation").Animation[];
  23261. private _scene;
  23262. private _positions;
  23263. private _normals;
  23264. private _tangents;
  23265. private _uvs;
  23266. private _influence;
  23267. private _uniqueId;
  23268. /**
  23269. * Observable raised when the influence changes
  23270. */
  23271. onInfluenceChanged: Observable<boolean>;
  23272. /** @hidden */
  23273. _onDataLayoutChanged: Observable<void>;
  23274. /**
  23275. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23276. */
  23277. get influence(): number;
  23278. set influence(influence: number);
  23279. /**
  23280. * Gets or sets the id of the morph Target
  23281. */
  23282. id: string;
  23283. private _animationPropertiesOverride;
  23284. /**
  23285. * Gets or sets the animation properties override
  23286. */
  23287. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23288. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23289. /**
  23290. * Creates a new MorphTarget
  23291. * @param name defines the name of the target
  23292. * @param influence defines the influence to use
  23293. * @param scene defines the scene the morphtarget belongs to
  23294. */
  23295. constructor(
  23296. /** defines the name of the target */
  23297. name: string, influence?: number, scene?: Nullable<Scene>);
  23298. /**
  23299. * Gets the unique ID of this manager
  23300. */
  23301. get uniqueId(): number;
  23302. /**
  23303. * Gets a boolean defining if the target contains position data
  23304. */
  23305. get hasPositions(): boolean;
  23306. /**
  23307. * Gets a boolean defining if the target contains normal data
  23308. */
  23309. get hasNormals(): boolean;
  23310. /**
  23311. * Gets a boolean defining if the target contains tangent data
  23312. */
  23313. get hasTangents(): boolean;
  23314. /**
  23315. * Gets a boolean defining if the target contains texture coordinates data
  23316. */
  23317. get hasUVs(): boolean;
  23318. /**
  23319. * Affects position data to this target
  23320. * @param data defines the position data to use
  23321. */
  23322. setPositions(data: Nullable<FloatArray>): void;
  23323. /**
  23324. * Gets the position data stored in this target
  23325. * @returns a FloatArray containing the position data (or null if not present)
  23326. */
  23327. getPositions(): Nullable<FloatArray>;
  23328. /**
  23329. * Affects normal data to this target
  23330. * @param data defines the normal data to use
  23331. */
  23332. setNormals(data: Nullable<FloatArray>): void;
  23333. /**
  23334. * Gets the normal data stored in this target
  23335. * @returns a FloatArray containing the normal data (or null if not present)
  23336. */
  23337. getNormals(): Nullable<FloatArray>;
  23338. /**
  23339. * Affects tangent data to this target
  23340. * @param data defines the tangent data to use
  23341. */
  23342. setTangents(data: Nullable<FloatArray>): void;
  23343. /**
  23344. * Gets the tangent data stored in this target
  23345. * @returns a FloatArray containing the tangent data (or null if not present)
  23346. */
  23347. getTangents(): Nullable<FloatArray>;
  23348. /**
  23349. * Affects texture coordinates data to this target
  23350. * @param data defines the texture coordinates data to use
  23351. */
  23352. setUVs(data: Nullable<FloatArray>): void;
  23353. /**
  23354. * Gets the texture coordinates data stored in this target
  23355. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23356. */
  23357. getUVs(): Nullable<FloatArray>;
  23358. /**
  23359. * Clone the current target
  23360. * @returns a new MorphTarget
  23361. */
  23362. clone(): MorphTarget;
  23363. /**
  23364. * Serializes the current target into a Serialization object
  23365. * @returns the serialized object
  23366. */
  23367. serialize(): any;
  23368. /**
  23369. * Returns the string "MorphTarget"
  23370. * @returns "MorphTarget"
  23371. */
  23372. getClassName(): string;
  23373. /**
  23374. * Creates a new target from serialized data
  23375. * @param serializationObject defines the serialized data to use
  23376. * @returns a new MorphTarget
  23377. */
  23378. static Parse(serializationObject: any): MorphTarget;
  23379. /**
  23380. * Creates a MorphTarget from mesh data
  23381. * @param mesh defines the source mesh
  23382. * @param name defines the name to use for the new target
  23383. * @param influence defines the influence to attach to the target
  23384. * @returns a new MorphTarget
  23385. */
  23386. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23387. }
  23388. }
  23389. declare module "babylonjs/Morph/morphTargetManager" {
  23390. import { Nullable } from "babylonjs/types";
  23391. import { Scene } from "babylonjs/scene";
  23392. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23393. /**
  23394. * This class is used to deform meshes using morphing between different targets
  23395. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23396. */
  23397. export class MorphTargetManager {
  23398. private _targets;
  23399. private _targetInfluenceChangedObservers;
  23400. private _targetDataLayoutChangedObservers;
  23401. private _activeTargets;
  23402. private _scene;
  23403. private _influences;
  23404. private _supportsNormals;
  23405. private _supportsTangents;
  23406. private _supportsUVs;
  23407. private _vertexCount;
  23408. private _uniqueId;
  23409. private _tempInfluences;
  23410. /**
  23411. * Gets or sets a boolean indicating if normals must be morphed
  23412. */
  23413. enableNormalMorphing: boolean;
  23414. /**
  23415. * Gets or sets a boolean indicating if tangents must be morphed
  23416. */
  23417. enableTangentMorphing: boolean;
  23418. /**
  23419. * Gets or sets a boolean indicating if UV must be morphed
  23420. */
  23421. enableUVMorphing: boolean;
  23422. /**
  23423. * Creates a new MorphTargetManager
  23424. * @param scene defines the current scene
  23425. */
  23426. constructor(scene?: Nullable<Scene>);
  23427. /**
  23428. * Gets the unique ID of this manager
  23429. */
  23430. get uniqueId(): number;
  23431. /**
  23432. * Gets the number of vertices handled by this manager
  23433. */
  23434. get vertexCount(): number;
  23435. /**
  23436. * Gets a boolean indicating if this manager supports morphing of normals
  23437. */
  23438. get supportsNormals(): boolean;
  23439. /**
  23440. * Gets a boolean indicating if this manager supports morphing of tangents
  23441. */
  23442. get supportsTangents(): boolean;
  23443. /**
  23444. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23445. */
  23446. get supportsUVs(): boolean;
  23447. /**
  23448. * Gets the number of targets stored in this manager
  23449. */
  23450. get numTargets(): number;
  23451. /**
  23452. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23453. */
  23454. get numInfluencers(): number;
  23455. /**
  23456. * Gets the list of influences (one per target)
  23457. */
  23458. get influences(): Float32Array;
  23459. /**
  23460. * Gets the active target at specified index. An active target is a target with an influence > 0
  23461. * @param index defines the index to check
  23462. * @returns the requested target
  23463. */
  23464. getActiveTarget(index: number): MorphTarget;
  23465. /**
  23466. * Gets the target at specified index
  23467. * @param index defines the index to check
  23468. * @returns the requested target
  23469. */
  23470. getTarget(index: number): MorphTarget;
  23471. /**
  23472. * Add a new target to this manager
  23473. * @param target defines the target to add
  23474. */
  23475. addTarget(target: MorphTarget): void;
  23476. /**
  23477. * Removes a target from the manager
  23478. * @param target defines the target to remove
  23479. */
  23480. removeTarget(target: MorphTarget): void;
  23481. /**
  23482. * Clone the current manager
  23483. * @returns a new MorphTargetManager
  23484. */
  23485. clone(): MorphTargetManager;
  23486. /**
  23487. * Serializes the current manager into a Serialization object
  23488. * @returns the serialized object
  23489. */
  23490. serialize(): any;
  23491. private _syncActiveTargets;
  23492. /**
  23493. * Syncrhonize the targets with all the meshes using this morph target manager
  23494. */
  23495. synchronize(): void;
  23496. /**
  23497. * Creates a new MorphTargetManager from serialized data
  23498. * @param serializationObject defines the serialized data
  23499. * @param scene defines the hosting scene
  23500. * @returns the new MorphTargetManager
  23501. */
  23502. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23503. }
  23504. }
  23505. declare module "babylonjs/Meshes/meshLODLevel" {
  23506. import { Mesh } from "babylonjs/Meshes/mesh";
  23507. import { Nullable } from "babylonjs/types";
  23508. /**
  23509. * Class used to represent a specific level of detail of a mesh
  23510. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23511. */
  23512. export class MeshLODLevel {
  23513. /** Defines the distance where this level should start being displayed */
  23514. distance: number;
  23515. /** Defines the mesh to use to render this level */
  23516. mesh: Nullable<Mesh>;
  23517. /**
  23518. * Creates a new LOD level
  23519. * @param distance defines the distance where this level should star being displayed
  23520. * @param mesh defines the mesh to use to render this level
  23521. */
  23522. constructor(
  23523. /** Defines the distance where this level should start being displayed */
  23524. distance: number,
  23525. /** Defines the mesh to use to render this level */
  23526. mesh: Nullable<Mesh>);
  23527. }
  23528. }
  23529. declare module "babylonjs/Meshes/groundMesh" {
  23530. import { Scene } from "babylonjs/scene";
  23531. import { Vector3 } from "babylonjs/Maths/math.vector";
  23532. import { Mesh } from "babylonjs/Meshes/mesh";
  23533. /**
  23534. * Mesh representing the gorund
  23535. */
  23536. export class GroundMesh extends Mesh {
  23537. /** If octree should be generated */
  23538. generateOctree: boolean;
  23539. private _heightQuads;
  23540. /** @hidden */
  23541. _subdivisionsX: number;
  23542. /** @hidden */
  23543. _subdivisionsY: number;
  23544. /** @hidden */
  23545. _width: number;
  23546. /** @hidden */
  23547. _height: number;
  23548. /** @hidden */
  23549. _minX: number;
  23550. /** @hidden */
  23551. _maxX: number;
  23552. /** @hidden */
  23553. _minZ: number;
  23554. /** @hidden */
  23555. _maxZ: number;
  23556. constructor(name: string, scene: Scene);
  23557. /**
  23558. * "GroundMesh"
  23559. * @returns "GroundMesh"
  23560. */
  23561. getClassName(): string;
  23562. /**
  23563. * The minimum of x and y subdivisions
  23564. */
  23565. get subdivisions(): number;
  23566. /**
  23567. * X subdivisions
  23568. */
  23569. get subdivisionsX(): number;
  23570. /**
  23571. * Y subdivisions
  23572. */
  23573. get subdivisionsY(): number;
  23574. /**
  23575. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23576. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23577. * @param chunksCount the number of subdivisions for x and y
  23578. * @param octreeBlocksSize (Default: 32)
  23579. */
  23580. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23581. /**
  23582. * Returns a height (y) value in the Worl system :
  23583. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23584. * @param x x coordinate
  23585. * @param z z coordinate
  23586. * @returns the ground y position if (x, z) are outside the ground surface.
  23587. */
  23588. getHeightAtCoordinates(x: number, z: number): number;
  23589. /**
  23590. * Returns a normalized vector (Vector3) orthogonal to the ground
  23591. * at the ground coordinates (x, z) expressed in the World system.
  23592. * @param x x coordinate
  23593. * @param z z coordinate
  23594. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23595. */
  23596. getNormalAtCoordinates(x: number, z: number): Vector3;
  23597. /**
  23598. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23599. * at the ground coordinates (x, z) expressed in the World system.
  23600. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23601. * @param x x coordinate
  23602. * @param z z coordinate
  23603. * @param ref vector to store the result
  23604. * @returns the GroundMesh.
  23605. */
  23606. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23607. /**
  23608. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23609. * if the ground has been updated.
  23610. * This can be used in the render loop.
  23611. * @returns the GroundMesh.
  23612. */
  23613. updateCoordinateHeights(): GroundMesh;
  23614. private _getFacetAt;
  23615. private _initHeightQuads;
  23616. private _computeHeightQuads;
  23617. /**
  23618. * Serializes this ground mesh
  23619. * @param serializationObject object to write serialization to
  23620. */
  23621. serialize(serializationObject: any): void;
  23622. /**
  23623. * Parses a serialized ground mesh
  23624. * @param parsedMesh the serialized mesh
  23625. * @param scene the scene to create the ground mesh in
  23626. * @returns the created ground mesh
  23627. */
  23628. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23629. }
  23630. }
  23631. declare module "babylonjs/Physics/physicsJoint" {
  23632. import { Vector3 } from "babylonjs/Maths/math.vector";
  23633. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23634. /**
  23635. * Interface for Physics-Joint data
  23636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23637. */
  23638. export interface PhysicsJointData {
  23639. /**
  23640. * The main pivot of the joint
  23641. */
  23642. mainPivot?: Vector3;
  23643. /**
  23644. * The connected pivot of the joint
  23645. */
  23646. connectedPivot?: Vector3;
  23647. /**
  23648. * The main axis of the joint
  23649. */
  23650. mainAxis?: Vector3;
  23651. /**
  23652. * The connected axis of the joint
  23653. */
  23654. connectedAxis?: Vector3;
  23655. /**
  23656. * The collision of the joint
  23657. */
  23658. collision?: boolean;
  23659. /**
  23660. * Native Oimo/Cannon/Energy data
  23661. */
  23662. nativeParams?: any;
  23663. }
  23664. /**
  23665. * This is a holder class for the physics joint created by the physics plugin
  23666. * It holds a set of functions to control the underlying joint
  23667. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23668. */
  23669. export class PhysicsJoint {
  23670. /**
  23671. * The type of the physics joint
  23672. */
  23673. type: number;
  23674. /**
  23675. * The data for the physics joint
  23676. */
  23677. jointData: PhysicsJointData;
  23678. private _physicsJoint;
  23679. protected _physicsPlugin: IPhysicsEnginePlugin;
  23680. /**
  23681. * Initializes the physics joint
  23682. * @param type The type of the physics joint
  23683. * @param jointData The data for the physics joint
  23684. */
  23685. constructor(
  23686. /**
  23687. * The type of the physics joint
  23688. */
  23689. type: number,
  23690. /**
  23691. * The data for the physics joint
  23692. */
  23693. jointData: PhysicsJointData);
  23694. /**
  23695. * Gets the physics joint
  23696. */
  23697. get physicsJoint(): any;
  23698. /**
  23699. * Sets the physics joint
  23700. */
  23701. set physicsJoint(newJoint: any);
  23702. /**
  23703. * Sets the physics plugin
  23704. */
  23705. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23706. /**
  23707. * Execute a function that is physics-plugin specific.
  23708. * @param {Function} func the function that will be executed.
  23709. * It accepts two parameters: the physics world and the physics joint
  23710. */
  23711. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23712. /**
  23713. * Distance-Joint type
  23714. */
  23715. static DistanceJoint: number;
  23716. /**
  23717. * Hinge-Joint type
  23718. */
  23719. static HingeJoint: number;
  23720. /**
  23721. * Ball-and-Socket joint type
  23722. */
  23723. static BallAndSocketJoint: number;
  23724. /**
  23725. * Wheel-Joint type
  23726. */
  23727. static WheelJoint: number;
  23728. /**
  23729. * Slider-Joint type
  23730. */
  23731. static SliderJoint: number;
  23732. /**
  23733. * Prismatic-Joint type
  23734. */
  23735. static PrismaticJoint: number;
  23736. /**
  23737. * Universal-Joint type
  23738. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23739. */
  23740. static UniversalJoint: number;
  23741. /**
  23742. * Hinge-Joint 2 type
  23743. */
  23744. static Hinge2Joint: number;
  23745. /**
  23746. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23747. */
  23748. static PointToPointJoint: number;
  23749. /**
  23750. * Spring-Joint type
  23751. */
  23752. static SpringJoint: number;
  23753. /**
  23754. * Lock-Joint type
  23755. */
  23756. static LockJoint: number;
  23757. }
  23758. /**
  23759. * A class representing a physics distance joint
  23760. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23761. */
  23762. export class DistanceJoint extends PhysicsJoint {
  23763. /**
  23764. *
  23765. * @param jointData The data for the Distance-Joint
  23766. */
  23767. constructor(jointData: DistanceJointData);
  23768. /**
  23769. * Update the predefined distance.
  23770. * @param maxDistance The maximum preferred distance
  23771. * @param minDistance The minimum preferred distance
  23772. */
  23773. updateDistance(maxDistance: number, minDistance?: number): void;
  23774. }
  23775. /**
  23776. * Represents a Motor-Enabled Joint
  23777. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23778. */
  23779. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23780. /**
  23781. * Initializes the Motor-Enabled Joint
  23782. * @param type The type of the joint
  23783. * @param jointData The physica joint data for the joint
  23784. */
  23785. constructor(type: number, jointData: PhysicsJointData);
  23786. /**
  23787. * Set the motor values.
  23788. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23789. * @param force the force to apply
  23790. * @param maxForce max force for this motor.
  23791. */
  23792. setMotor(force?: number, maxForce?: number): void;
  23793. /**
  23794. * Set the motor's limits.
  23795. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23796. * @param upperLimit The upper limit of the motor
  23797. * @param lowerLimit The lower limit of the motor
  23798. */
  23799. setLimit(upperLimit: number, lowerLimit?: number): void;
  23800. }
  23801. /**
  23802. * This class represents a single physics Hinge-Joint
  23803. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23804. */
  23805. export class HingeJoint extends MotorEnabledJoint {
  23806. /**
  23807. * Initializes the Hinge-Joint
  23808. * @param jointData The joint data for the Hinge-Joint
  23809. */
  23810. constructor(jointData: PhysicsJointData);
  23811. /**
  23812. * Set the motor values.
  23813. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23814. * @param {number} force the force to apply
  23815. * @param {number} maxForce max force for this motor.
  23816. */
  23817. setMotor(force?: number, maxForce?: number): void;
  23818. /**
  23819. * Set the motor's limits.
  23820. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23821. * @param upperLimit The upper limit of the motor
  23822. * @param lowerLimit The lower limit of the motor
  23823. */
  23824. setLimit(upperLimit: number, lowerLimit?: number): void;
  23825. }
  23826. /**
  23827. * This class represents a dual hinge physics joint (same as wheel joint)
  23828. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23829. */
  23830. export class Hinge2Joint extends MotorEnabledJoint {
  23831. /**
  23832. * Initializes the Hinge2-Joint
  23833. * @param jointData The joint data for the Hinge2-Joint
  23834. */
  23835. constructor(jointData: PhysicsJointData);
  23836. /**
  23837. * Set the motor values.
  23838. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23839. * @param {number} targetSpeed the speed the motor is to reach
  23840. * @param {number} maxForce max force for this motor.
  23841. * @param {motorIndex} the motor's index, 0 or 1.
  23842. */
  23843. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23844. /**
  23845. * Set the motor limits.
  23846. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23847. * @param {number} upperLimit the upper limit
  23848. * @param {number} lowerLimit lower limit
  23849. * @param {motorIndex} the motor's index, 0 or 1.
  23850. */
  23851. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23852. }
  23853. /**
  23854. * Interface for a motor enabled joint
  23855. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23856. */
  23857. export interface IMotorEnabledJoint {
  23858. /**
  23859. * Physics joint
  23860. */
  23861. physicsJoint: any;
  23862. /**
  23863. * Sets the motor of the motor-enabled joint
  23864. * @param force The force of the motor
  23865. * @param maxForce The maximum force of the motor
  23866. * @param motorIndex The index of the motor
  23867. */
  23868. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23869. /**
  23870. * Sets the limit of the motor
  23871. * @param upperLimit The upper limit of the motor
  23872. * @param lowerLimit The lower limit of the motor
  23873. * @param motorIndex The index of the motor
  23874. */
  23875. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23876. }
  23877. /**
  23878. * Joint data for a Distance-Joint
  23879. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23880. */
  23881. export interface DistanceJointData extends PhysicsJointData {
  23882. /**
  23883. * Max distance the 2 joint objects can be apart
  23884. */
  23885. maxDistance: number;
  23886. }
  23887. /**
  23888. * Joint data from a spring joint
  23889. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23890. */
  23891. export interface SpringJointData extends PhysicsJointData {
  23892. /**
  23893. * Length of the spring
  23894. */
  23895. length: number;
  23896. /**
  23897. * Stiffness of the spring
  23898. */
  23899. stiffness: number;
  23900. /**
  23901. * Damping of the spring
  23902. */
  23903. damping: number;
  23904. /** this callback will be called when applying the force to the impostors. */
  23905. forceApplicationCallback: () => void;
  23906. }
  23907. }
  23908. declare module "babylonjs/Physics/physicsRaycastResult" {
  23909. import { Vector3 } from "babylonjs/Maths/math.vector";
  23910. /**
  23911. * Holds the data for the raycast result
  23912. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23913. */
  23914. export class PhysicsRaycastResult {
  23915. private _hasHit;
  23916. private _hitDistance;
  23917. private _hitNormalWorld;
  23918. private _hitPointWorld;
  23919. private _rayFromWorld;
  23920. private _rayToWorld;
  23921. /**
  23922. * Gets if there was a hit
  23923. */
  23924. get hasHit(): boolean;
  23925. /**
  23926. * Gets the distance from the hit
  23927. */
  23928. get hitDistance(): number;
  23929. /**
  23930. * Gets the hit normal/direction in the world
  23931. */
  23932. get hitNormalWorld(): Vector3;
  23933. /**
  23934. * Gets the hit point in the world
  23935. */
  23936. get hitPointWorld(): Vector3;
  23937. /**
  23938. * Gets the ray "start point" of the ray in the world
  23939. */
  23940. get rayFromWorld(): Vector3;
  23941. /**
  23942. * Gets the ray "end point" of the ray in the world
  23943. */
  23944. get rayToWorld(): Vector3;
  23945. /**
  23946. * Sets the hit data (normal & point in world space)
  23947. * @param hitNormalWorld defines the normal in world space
  23948. * @param hitPointWorld defines the point in world space
  23949. */
  23950. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23951. /**
  23952. * Sets the distance from the start point to the hit point
  23953. * @param distance
  23954. */
  23955. setHitDistance(distance: number): void;
  23956. /**
  23957. * Calculates the distance manually
  23958. */
  23959. calculateHitDistance(): void;
  23960. /**
  23961. * Resets all the values to default
  23962. * @param from The from point on world space
  23963. * @param to The to point on world space
  23964. */
  23965. reset(from?: Vector3, to?: Vector3): void;
  23966. }
  23967. /**
  23968. * Interface for the size containing width and height
  23969. */
  23970. interface IXYZ {
  23971. /**
  23972. * X
  23973. */
  23974. x: number;
  23975. /**
  23976. * Y
  23977. */
  23978. y: number;
  23979. /**
  23980. * Z
  23981. */
  23982. z: number;
  23983. }
  23984. }
  23985. declare module "babylonjs/Physics/IPhysicsEngine" {
  23986. import { Nullable } from "babylonjs/types";
  23987. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23989. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23990. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23991. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23992. /**
  23993. * Interface used to describe a physics joint
  23994. */
  23995. export interface PhysicsImpostorJoint {
  23996. /** Defines the main impostor to which the joint is linked */
  23997. mainImpostor: PhysicsImpostor;
  23998. /** Defines the impostor that is connected to the main impostor using this joint */
  23999. connectedImpostor: PhysicsImpostor;
  24000. /** Defines the joint itself */
  24001. joint: PhysicsJoint;
  24002. }
  24003. /** @hidden */
  24004. export interface IPhysicsEnginePlugin {
  24005. world: any;
  24006. name: string;
  24007. setGravity(gravity: Vector3): void;
  24008. setTimeStep(timeStep: number): void;
  24009. getTimeStep(): number;
  24010. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24011. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24012. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24013. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24014. removePhysicsBody(impostor: PhysicsImpostor): void;
  24015. generateJoint(joint: PhysicsImpostorJoint): void;
  24016. removeJoint(joint: PhysicsImpostorJoint): void;
  24017. isSupported(): boolean;
  24018. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24019. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24020. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24021. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24022. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24023. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24024. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24025. getBodyMass(impostor: PhysicsImpostor): number;
  24026. getBodyFriction(impostor: PhysicsImpostor): number;
  24027. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24028. getBodyRestitution(impostor: PhysicsImpostor): number;
  24029. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24030. getBodyPressure?(impostor: PhysicsImpostor): number;
  24031. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  24032. getBodyStiffness?(impostor: PhysicsImpostor): number;
  24033. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  24034. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  24035. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  24036. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  24037. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  24038. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24039. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24040. sleepBody(impostor: PhysicsImpostor): void;
  24041. wakeUpBody(impostor: PhysicsImpostor): void;
  24042. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24043. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24044. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24045. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24046. getRadius(impostor: PhysicsImpostor): number;
  24047. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24048. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24049. dispose(): void;
  24050. }
  24051. /**
  24052. * Interface used to define a physics engine
  24053. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  24054. */
  24055. export interface IPhysicsEngine {
  24056. /**
  24057. * Gets the gravity vector used by the simulation
  24058. */
  24059. gravity: Vector3;
  24060. /**
  24061. * Sets the gravity vector used by the simulation
  24062. * @param gravity defines the gravity vector to use
  24063. */
  24064. setGravity(gravity: Vector3): void;
  24065. /**
  24066. * Set the time step of the physics engine.
  24067. * Default is 1/60.
  24068. * To slow it down, enter 1/600 for example.
  24069. * To speed it up, 1/30
  24070. * @param newTimeStep the new timestep to apply to this world.
  24071. */
  24072. setTimeStep(newTimeStep: number): void;
  24073. /**
  24074. * Get the time step of the physics engine.
  24075. * @returns the current time step
  24076. */
  24077. getTimeStep(): number;
  24078. /**
  24079. * Set the sub time step of the physics engine.
  24080. * Default is 0 meaning there is no sub steps
  24081. * To increase physics resolution precision, set a small value (like 1 ms)
  24082. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24083. */
  24084. setSubTimeStep(subTimeStep: number): void;
  24085. /**
  24086. * Get the sub time step of the physics engine.
  24087. * @returns the current sub time step
  24088. */
  24089. getSubTimeStep(): number;
  24090. /**
  24091. * Release all resources
  24092. */
  24093. dispose(): void;
  24094. /**
  24095. * Gets the name of the current physics plugin
  24096. * @returns the name of the plugin
  24097. */
  24098. getPhysicsPluginName(): string;
  24099. /**
  24100. * Adding a new impostor for the impostor tracking.
  24101. * This will be done by the impostor itself.
  24102. * @param impostor the impostor to add
  24103. */
  24104. addImpostor(impostor: PhysicsImpostor): void;
  24105. /**
  24106. * Remove an impostor from the engine.
  24107. * This impostor and its mesh will not longer be updated by the physics engine.
  24108. * @param impostor the impostor to remove
  24109. */
  24110. removeImpostor(impostor: PhysicsImpostor): void;
  24111. /**
  24112. * Add a joint to the physics engine
  24113. * @param mainImpostor defines the main impostor to which the joint is added.
  24114. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24115. * @param joint defines the joint that will connect both impostors.
  24116. */
  24117. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24118. /**
  24119. * Removes a joint from the simulation
  24120. * @param mainImpostor defines the impostor used with the joint
  24121. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24122. * @param joint defines the joint to remove
  24123. */
  24124. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24125. /**
  24126. * Gets the current plugin used to run the simulation
  24127. * @returns current plugin
  24128. */
  24129. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24130. /**
  24131. * Gets the list of physic impostors
  24132. * @returns an array of PhysicsImpostor
  24133. */
  24134. getImpostors(): Array<PhysicsImpostor>;
  24135. /**
  24136. * Gets the impostor for a physics enabled object
  24137. * @param object defines the object impersonated by the impostor
  24138. * @returns the PhysicsImpostor or null if not found
  24139. */
  24140. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24141. /**
  24142. * Gets the impostor for a physics body object
  24143. * @param body defines physics body used by the impostor
  24144. * @returns the PhysicsImpostor or null if not found
  24145. */
  24146. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24147. /**
  24148. * Does a raycast in the physics world
  24149. * @param from when should the ray start?
  24150. * @param to when should the ray end?
  24151. * @returns PhysicsRaycastResult
  24152. */
  24153. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24154. /**
  24155. * Called by the scene. No need to call it.
  24156. * @param delta defines the timespam between frames
  24157. */
  24158. _step(delta: number): void;
  24159. }
  24160. }
  24161. declare module "babylonjs/Physics/physicsImpostor" {
  24162. import { Nullable, IndicesArray } from "babylonjs/types";
  24163. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24164. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24165. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24166. import { Scene } from "babylonjs/scene";
  24167. import { Bone } from "babylonjs/Bones/bone";
  24168. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24169. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24170. import { Space } from "babylonjs/Maths/math.axis";
  24171. /**
  24172. * The interface for the physics imposter parameters
  24173. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24174. */
  24175. export interface PhysicsImpostorParameters {
  24176. /**
  24177. * The mass of the physics imposter
  24178. */
  24179. mass: number;
  24180. /**
  24181. * The friction of the physics imposter
  24182. */
  24183. friction?: number;
  24184. /**
  24185. * The coefficient of restitution of the physics imposter
  24186. */
  24187. restitution?: number;
  24188. /**
  24189. * The native options of the physics imposter
  24190. */
  24191. nativeOptions?: any;
  24192. /**
  24193. * Specifies if the parent should be ignored
  24194. */
  24195. ignoreParent?: boolean;
  24196. /**
  24197. * Specifies if bi-directional transformations should be disabled
  24198. */
  24199. disableBidirectionalTransformation?: boolean;
  24200. /**
  24201. * The pressure inside the physics imposter, soft object only
  24202. */
  24203. pressure?: number;
  24204. /**
  24205. * The stiffness the physics imposter, soft object only
  24206. */
  24207. stiffness?: number;
  24208. /**
  24209. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24210. */
  24211. velocityIterations?: number;
  24212. /**
  24213. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24214. */
  24215. positionIterations?: number;
  24216. /**
  24217. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24218. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24219. * Add to fix multiple points
  24220. */
  24221. fixedPoints?: number;
  24222. /**
  24223. * The collision margin around a soft object
  24224. */
  24225. margin?: number;
  24226. /**
  24227. * The collision margin around a soft object
  24228. */
  24229. damping?: number;
  24230. /**
  24231. * The path for a rope based on an extrusion
  24232. */
  24233. path?: any;
  24234. /**
  24235. * The shape of an extrusion used for a rope based on an extrusion
  24236. */
  24237. shape?: any;
  24238. }
  24239. /**
  24240. * Interface for a physics-enabled object
  24241. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24242. */
  24243. export interface IPhysicsEnabledObject {
  24244. /**
  24245. * The position of the physics-enabled object
  24246. */
  24247. position: Vector3;
  24248. /**
  24249. * The rotation of the physics-enabled object
  24250. */
  24251. rotationQuaternion: Nullable<Quaternion>;
  24252. /**
  24253. * The scale of the physics-enabled object
  24254. */
  24255. scaling: Vector3;
  24256. /**
  24257. * The rotation of the physics-enabled object
  24258. */
  24259. rotation?: Vector3;
  24260. /**
  24261. * The parent of the physics-enabled object
  24262. */
  24263. parent?: any;
  24264. /**
  24265. * The bounding info of the physics-enabled object
  24266. * @returns The bounding info of the physics-enabled object
  24267. */
  24268. getBoundingInfo(): BoundingInfo;
  24269. /**
  24270. * Computes the world matrix
  24271. * @param force Specifies if the world matrix should be computed by force
  24272. * @returns A world matrix
  24273. */
  24274. computeWorldMatrix(force: boolean): Matrix;
  24275. /**
  24276. * Gets the world matrix
  24277. * @returns A world matrix
  24278. */
  24279. getWorldMatrix?(): Matrix;
  24280. /**
  24281. * Gets the child meshes
  24282. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24283. * @returns An array of abstract meshes
  24284. */
  24285. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24286. /**
  24287. * Gets the vertex data
  24288. * @param kind The type of vertex data
  24289. * @returns A nullable array of numbers, or a float32 array
  24290. */
  24291. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24292. /**
  24293. * Gets the indices from the mesh
  24294. * @returns A nullable array of index arrays
  24295. */
  24296. getIndices?(): Nullable<IndicesArray>;
  24297. /**
  24298. * Gets the scene from the mesh
  24299. * @returns the indices array or null
  24300. */
  24301. getScene?(): Scene;
  24302. /**
  24303. * Gets the absolute position from the mesh
  24304. * @returns the absolute position
  24305. */
  24306. getAbsolutePosition(): Vector3;
  24307. /**
  24308. * Gets the absolute pivot point from the mesh
  24309. * @returns the absolute pivot point
  24310. */
  24311. getAbsolutePivotPoint(): Vector3;
  24312. /**
  24313. * Rotates the mesh
  24314. * @param axis The axis of rotation
  24315. * @param amount The amount of rotation
  24316. * @param space The space of the rotation
  24317. * @returns The rotation transform node
  24318. */
  24319. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24320. /**
  24321. * Translates the mesh
  24322. * @param axis The axis of translation
  24323. * @param distance The distance of translation
  24324. * @param space The space of the translation
  24325. * @returns The transform node
  24326. */
  24327. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24328. /**
  24329. * Sets the absolute position of the mesh
  24330. * @param absolutePosition The absolute position of the mesh
  24331. * @returns The transform node
  24332. */
  24333. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24334. /**
  24335. * Gets the class name of the mesh
  24336. * @returns The class name
  24337. */
  24338. getClassName(): string;
  24339. }
  24340. /**
  24341. * Represents a physics imposter
  24342. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24343. */
  24344. export class PhysicsImpostor {
  24345. /**
  24346. * The physics-enabled object used as the physics imposter
  24347. */
  24348. object: IPhysicsEnabledObject;
  24349. /**
  24350. * The type of the physics imposter
  24351. */
  24352. type: number;
  24353. private _options;
  24354. private _scene?;
  24355. /**
  24356. * The default object size of the imposter
  24357. */
  24358. static DEFAULT_OBJECT_SIZE: Vector3;
  24359. /**
  24360. * The identity quaternion of the imposter
  24361. */
  24362. static IDENTITY_QUATERNION: Quaternion;
  24363. /** @hidden */
  24364. _pluginData: any;
  24365. private _physicsEngine;
  24366. private _physicsBody;
  24367. private _bodyUpdateRequired;
  24368. private _onBeforePhysicsStepCallbacks;
  24369. private _onAfterPhysicsStepCallbacks;
  24370. /** @hidden */
  24371. _onPhysicsCollideCallbacks: Array<{
  24372. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24373. otherImpostors: Array<PhysicsImpostor>;
  24374. }>;
  24375. private _deltaPosition;
  24376. private _deltaRotation;
  24377. private _deltaRotationConjugated;
  24378. /** @hidden */
  24379. _isFromLine: boolean;
  24380. private _parent;
  24381. private _isDisposed;
  24382. private static _tmpVecs;
  24383. private static _tmpQuat;
  24384. /**
  24385. * Specifies if the physics imposter is disposed
  24386. */
  24387. get isDisposed(): boolean;
  24388. /**
  24389. * Gets the mass of the physics imposter
  24390. */
  24391. get mass(): number;
  24392. set mass(value: number);
  24393. /**
  24394. * Gets the coefficient of friction
  24395. */
  24396. get friction(): number;
  24397. /**
  24398. * Sets the coefficient of friction
  24399. */
  24400. set friction(value: number);
  24401. /**
  24402. * Gets the coefficient of restitution
  24403. */
  24404. get restitution(): number;
  24405. /**
  24406. * Sets the coefficient of restitution
  24407. */
  24408. set restitution(value: number);
  24409. /**
  24410. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24411. */
  24412. get pressure(): number;
  24413. /**
  24414. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24415. */
  24416. set pressure(value: number);
  24417. /**
  24418. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24419. */
  24420. get stiffness(): number;
  24421. /**
  24422. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24423. */
  24424. set stiffness(value: number);
  24425. /**
  24426. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24427. */
  24428. get velocityIterations(): number;
  24429. /**
  24430. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24431. */
  24432. set velocityIterations(value: number);
  24433. /**
  24434. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24435. */
  24436. get positionIterations(): number;
  24437. /**
  24438. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24439. */
  24440. set positionIterations(value: number);
  24441. /**
  24442. * The unique id of the physics imposter
  24443. * set by the physics engine when adding this impostor to the array
  24444. */
  24445. uniqueId: number;
  24446. /**
  24447. * @hidden
  24448. */
  24449. soft: boolean;
  24450. /**
  24451. * @hidden
  24452. */
  24453. segments: number;
  24454. private _joints;
  24455. /**
  24456. * Initializes the physics imposter
  24457. * @param object The physics-enabled object used as the physics imposter
  24458. * @param type The type of the physics imposter
  24459. * @param _options The options for the physics imposter
  24460. * @param _scene The Babylon scene
  24461. */
  24462. constructor(
  24463. /**
  24464. * The physics-enabled object used as the physics imposter
  24465. */
  24466. object: IPhysicsEnabledObject,
  24467. /**
  24468. * The type of the physics imposter
  24469. */
  24470. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24471. /**
  24472. * This function will completly initialize this impostor.
  24473. * It will create a new body - but only if this mesh has no parent.
  24474. * If it has, this impostor will not be used other than to define the impostor
  24475. * of the child mesh.
  24476. * @hidden
  24477. */
  24478. _init(): void;
  24479. private _getPhysicsParent;
  24480. /**
  24481. * Should a new body be generated.
  24482. * @returns boolean specifying if body initialization is required
  24483. */
  24484. isBodyInitRequired(): boolean;
  24485. /**
  24486. * Sets the updated scaling
  24487. * @param updated Specifies if the scaling is updated
  24488. */
  24489. setScalingUpdated(): void;
  24490. /**
  24491. * Force a regeneration of this or the parent's impostor's body.
  24492. * Use under cautious - This will remove all joints already implemented.
  24493. */
  24494. forceUpdate(): void;
  24495. /**
  24496. * Gets the body that holds this impostor. Either its own, or its parent.
  24497. */
  24498. get physicsBody(): any;
  24499. /**
  24500. * Get the parent of the physics imposter
  24501. * @returns Physics imposter or null
  24502. */
  24503. get parent(): Nullable<PhysicsImpostor>;
  24504. /**
  24505. * Sets the parent of the physics imposter
  24506. */
  24507. set parent(value: Nullable<PhysicsImpostor>);
  24508. /**
  24509. * Set the physics body. Used mainly by the physics engine/plugin
  24510. */
  24511. set physicsBody(physicsBody: any);
  24512. /**
  24513. * Resets the update flags
  24514. */
  24515. resetUpdateFlags(): void;
  24516. /**
  24517. * Gets the object extend size
  24518. * @returns the object extend size
  24519. */
  24520. getObjectExtendSize(): Vector3;
  24521. /**
  24522. * Gets the object center
  24523. * @returns The object center
  24524. */
  24525. getObjectCenter(): Vector3;
  24526. /**
  24527. * Get a specific parameter from the options parameters
  24528. * @param paramName The object parameter name
  24529. * @returns The object parameter
  24530. */
  24531. getParam(paramName: string): any;
  24532. /**
  24533. * Sets a specific parameter in the options given to the physics plugin
  24534. * @param paramName The parameter name
  24535. * @param value The value of the parameter
  24536. */
  24537. setParam(paramName: string, value: number): void;
  24538. /**
  24539. * Specifically change the body's mass option. Won't recreate the physics body object
  24540. * @param mass The mass of the physics imposter
  24541. */
  24542. setMass(mass: number): void;
  24543. /**
  24544. * Gets the linear velocity
  24545. * @returns linear velocity or null
  24546. */
  24547. getLinearVelocity(): Nullable<Vector3>;
  24548. /**
  24549. * Sets the linear velocity
  24550. * @param velocity linear velocity or null
  24551. */
  24552. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24553. /**
  24554. * Gets the angular velocity
  24555. * @returns angular velocity or null
  24556. */
  24557. getAngularVelocity(): Nullable<Vector3>;
  24558. /**
  24559. * Sets the angular velocity
  24560. * @param velocity The velocity or null
  24561. */
  24562. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24563. /**
  24564. * Execute a function with the physics plugin native code
  24565. * Provide a function the will have two variables - the world object and the physics body object
  24566. * @param func The function to execute with the physics plugin native code
  24567. */
  24568. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24569. /**
  24570. * Register a function that will be executed before the physics world is stepping forward
  24571. * @param func The function to execute before the physics world is stepped forward
  24572. */
  24573. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24574. /**
  24575. * Unregister a function that will be executed before the physics world is stepping forward
  24576. * @param func The function to execute before the physics world is stepped forward
  24577. */
  24578. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24579. /**
  24580. * Register a function that will be executed after the physics step
  24581. * @param func The function to execute after physics step
  24582. */
  24583. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24584. /**
  24585. * Unregisters a function that will be executed after the physics step
  24586. * @param func The function to execute after physics step
  24587. */
  24588. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24589. /**
  24590. * register a function that will be executed when this impostor collides against a different body
  24591. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24592. * @param func Callback that is executed on collision
  24593. */
  24594. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24595. /**
  24596. * Unregisters the physics imposter on contact
  24597. * @param collideAgainst The physics object to collide against
  24598. * @param func Callback to execute on collision
  24599. */
  24600. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24601. private _tmpQuat;
  24602. private _tmpQuat2;
  24603. /**
  24604. * Get the parent rotation
  24605. * @returns The parent rotation
  24606. */
  24607. getParentsRotation(): Quaternion;
  24608. /**
  24609. * this function is executed by the physics engine.
  24610. */
  24611. beforeStep: () => void;
  24612. /**
  24613. * this function is executed by the physics engine
  24614. */
  24615. afterStep: () => void;
  24616. /**
  24617. * Legacy collision detection event support
  24618. */
  24619. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24620. /**
  24621. * event and body object due to cannon's event-based architecture.
  24622. */
  24623. onCollide: (e: {
  24624. body: any;
  24625. }) => void;
  24626. /**
  24627. * Apply a force
  24628. * @param force The force to apply
  24629. * @param contactPoint The contact point for the force
  24630. * @returns The physics imposter
  24631. */
  24632. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24633. /**
  24634. * Apply an impulse
  24635. * @param force The impulse force
  24636. * @param contactPoint The contact point for the impulse force
  24637. * @returns The physics imposter
  24638. */
  24639. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24640. /**
  24641. * A help function to create a joint
  24642. * @param otherImpostor A physics imposter used to create a joint
  24643. * @param jointType The type of joint
  24644. * @param jointData The data for the joint
  24645. * @returns The physics imposter
  24646. */
  24647. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24648. /**
  24649. * Add a joint to this impostor with a different impostor
  24650. * @param otherImpostor A physics imposter used to add a joint
  24651. * @param joint The joint to add
  24652. * @returns The physics imposter
  24653. */
  24654. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24655. /**
  24656. * Add an anchor to a cloth impostor
  24657. * @param otherImpostor rigid impostor to anchor to
  24658. * @param width ratio across width from 0 to 1
  24659. * @param height ratio up height from 0 to 1
  24660. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24661. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24662. * @returns impostor the soft imposter
  24663. */
  24664. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24665. /**
  24666. * Add a hook to a rope impostor
  24667. * @param otherImpostor rigid impostor to anchor to
  24668. * @param length ratio across rope from 0 to 1
  24669. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24670. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24671. * @returns impostor the rope imposter
  24672. */
  24673. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24674. /**
  24675. * Will keep this body still, in a sleep mode.
  24676. * @returns the physics imposter
  24677. */
  24678. sleep(): PhysicsImpostor;
  24679. /**
  24680. * Wake the body up.
  24681. * @returns The physics imposter
  24682. */
  24683. wakeUp(): PhysicsImpostor;
  24684. /**
  24685. * Clones the physics imposter
  24686. * @param newObject The physics imposter clones to this physics-enabled object
  24687. * @returns A nullable physics imposter
  24688. */
  24689. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24690. /**
  24691. * Disposes the physics imposter
  24692. */
  24693. dispose(): void;
  24694. /**
  24695. * Sets the delta position
  24696. * @param position The delta position amount
  24697. */
  24698. setDeltaPosition(position: Vector3): void;
  24699. /**
  24700. * Sets the delta rotation
  24701. * @param rotation The delta rotation amount
  24702. */
  24703. setDeltaRotation(rotation: Quaternion): void;
  24704. /**
  24705. * Gets the box size of the physics imposter and stores the result in the input parameter
  24706. * @param result Stores the box size
  24707. * @returns The physics imposter
  24708. */
  24709. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24710. /**
  24711. * Gets the radius of the physics imposter
  24712. * @returns Radius of the physics imposter
  24713. */
  24714. getRadius(): number;
  24715. /**
  24716. * Sync a bone with this impostor
  24717. * @param bone The bone to sync to the impostor.
  24718. * @param boneMesh The mesh that the bone is influencing.
  24719. * @param jointPivot The pivot of the joint / bone in local space.
  24720. * @param distToJoint Optional distance from the impostor to the joint.
  24721. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24722. */
  24723. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24724. /**
  24725. * Sync impostor to a bone
  24726. * @param bone The bone that the impostor will be synced to.
  24727. * @param boneMesh The mesh that the bone is influencing.
  24728. * @param jointPivot The pivot of the joint / bone in local space.
  24729. * @param distToJoint Optional distance from the impostor to the joint.
  24730. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24731. * @param boneAxis Optional vector3 axis the bone is aligned with
  24732. */
  24733. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24734. /**
  24735. * No-Imposter type
  24736. */
  24737. static NoImpostor: number;
  24738. /**
  24739. * Sphere-Imposter type
  24740. */
  24741. static SphereImpostor: number;
  24742. /**
  24743. * Box-Imposter type
  24744. */
  24745. static BoxImpostor: number;
  24746. /**
  24747. * Plane-Imposter type
  24748. */
  24749. static PlaneImpostor: number;
  24750. /**
  24751. * Mesh-imposter type
  24752. */
  24753. static MeshImpostor: number;
  24754. /**
  24755. * Capsule-Impostor type (Ammo.js plugin only)
  24756. */
  24757. static CapsuleImpostor: number;
  24758. /**
  24759. * Cylinder-Imposter type
  24760. */
  24761. static CylinderImpostor: number;
  24762. /**
  24763. * Particle-Imposter type
  24764. */
  24765. static ParticleImpostor: number;
  24766. /**
  24767. * Heightmap-Imposter type
  24768. */
  24769. static HeightmapImpostor: number;
  24770. /**
  24771. * ConvexHull-Impostor type (Ammo.js plugin only)
  24772. */
  24773. static ConvexHullImpostor: number;
  24774. /**
  24775. * Custom-Imposter type (Ammo.js plugin only)
  24776. */
  24777. static CustomImpostor: number;
  24778. /**
  24779. * Rope-Imposter type
  24780. */
  24781. static RopeImpostor: number;
  24782. /**
  24783. * Cloth-Imposter type
  24784. */
  24785. static ClothImpostor: number;
  24786. /**
  24787. * Softbody-Imposter type
  24788. */
  24789. static SoftbodyImpostor: number;
  24790. }
  24791. }
  24792. declare module "babylonjs/Meshes/mesh" {
  24793. import { Observable } from "babylonjs/Misc/observable";
  24794. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24795. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24796. import { Camera } from "babylonjs/Cameras/camera";
  24797. import { Scene } from "babylonjs/scene";
  24798. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24799. import { Color4 } from "babylonjs/Maths/math.color";
  24800. import { Engine } from "babylonjs/Engines/engine";
  24801. import { Node } from "babylonjs/node";
  24802. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24803. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24804. import { Buffer } from "babylonjs/Meshes/buffer";
  24805. import { Geometry } from "babylonjs/Meshes/geometry";
  24806. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24807. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24808. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24809. import { Effect } from "babylonjs/Materials/effect";
  24810. import { Material } from "babylonjs/Materials/material";
  24811. import { Skeleton } from "babylonjs/Bones/skeleton";
  24812. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24813. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24814. import { Path3D } from "babylonjs/Maths/math.path";
  24815. import { Plane } from "babylonjs/Maths/math.plane";
  24816. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24817. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24818. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24819. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24820. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24821. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24822. /**
  24823. * @hidden
  24824. **/
  24825. export class _CreationDataStorage {
  24826. closePath?: boolean;
  24827. closeArray?: boolean;
  24828. idx: number[];
  24829. dashSize: number;
  24830. gapSize: number;
  24831. path3D: Path3D;
  24832. pathArray: Vector3[][];
  24833. arc: number;
  24834. radius: number;
  24835. cap: number;
  24836. tessellation: number;
  24837. }
  24838. /**
  24839. * @hidden
  24840. **/
  24841. class _InstanceDataStorage {
  24842. visibleInstances: any;
  24843. batchCache: _InstancesBatch;
  24844. instancesBufferSize: number;
  24845. instancesBuffer: Nullable<Buffer>;
  24846. instancesData: Float32Array;
  24847. overridenInstanceCount: number;
  24848. isFrozen: boolean;
  24849. previousBatch: Nullable<_InstancesBatch>;
  24850. hardwareInstancedRendering: boolean;
  24851. sideOrientation: number;
  24852. manualUpdate: boolean;
  24853. }
  24854. /**
  24855. * @hidden
  24856. **/
  24857. export class _InstancesBatch {
  24858. mustReturn: boolean;
  24859. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24860. renderSelf: boolean[];
  24861. hardwareInstancedRendering: boolean[];
  24862. }
  24863. /**
  24864. * Class used to represent renderable models
  24865. */
  24866. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24867. /**
  24868. * Mesh side orientation : usually the external or front surface
  24869. */
  24870. static readonly FRONTSIDE: number;
  24871. /**
  24872. * Mesh side orientation : usually the internal or back surface
  24873. */
  24874. static readonly BACKSIDE: number;
  24875. /**
  24876. * Mesh side orientation : both internal and external or front and back surfaces
  24877. */
  24878. static readonly DOUBLESIDE: number;
  24879. /**
  24880. * Mesh side orientation : by default, `FRONTSIDE`
  24881. */
  24882. static readonly DEFAULTSIDE: number;
  24883. /**
  24884. * Mesh cap setting : no cap
  24885. */
  24886. static readonly NO_CAP: number;
  24887. /**
  24888. * Mesh cap setting : one cap at the beginning of the mesh
  24889. */
  24890. static readonly CAP_START: number;
  24891. /**
  24892. * Mesh cap setting : one cap at the end of the mesh
  24893. */
  24894. static readonly CAP_END: number;
  24895. /**
  24896. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24897. */
  24898. static readonly CAP_ALL: number;
  24899. /**
  24900. * Mesh pattern setting : no flip or rotate
  24901. */
  24902. static readonly NO_FLIP: number;
  24903. /**
  24904. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24905. */
  24906. static readonly FLIP_TILE: number;
  24907. /**
  24908. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24909. */
  24910. static readonly ROTATE_TILE: number;
  24911. /**
  24912. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24913. */
  24914. static readonly FLIP_ROW: number;
  24915. /**
  24916. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24917. */
  24918. static readonly ROTATE_ROW: number;
  24919. /**
  24920. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24921. */
  24922. static readonly FLIP_N_ROTATE_TILE: number;
  24923. /**
  24924. * Mesh pattern setting : rotate pattern and rotate
  24925. */
  24926. static readonly FLIP_N_ROTATE_ROW: number;
  24927. /**
  24928. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24929. */
  24930. static readonly CENTER: number;
  24931. /**
  24932. * Mesh tile positioning : part tiles on left
  24933. */
  24934. static readonly LEFT: number;
  24935. /**
  24936. * Mesh tile positioning : part tiles on right
  24937. */
  24938. static readonly RIGHT: number;
  24939. /**
  24940. * Mesh tile positioning : part tiles on top
  24941. */
  24942. static readonly TOP: number;
  24943. /**
  24944. * Mesh tile positioning : part tiles on bottom
  24945. */
  24946. static readonly BOTTOM: number;
  24947. /**
  24948. * Gets the default side orientation.
  24949. * @param orientation the orientation to value to attempt to get
  24950. * @returns the default orientation
  24951. * @hidden
  24952. */
  24953. static _GetDefaultSideOrientation(orientation?: number): number;
  24954. private _internalMeshDataInfo;
  24955. /**
  24956. * An event triggered before rendering the mesh
  24957. */
  24958. get onBeforeRenderObservable(): Observable<Mesh>;
  24959. /**
  24960. * An event triggered before binding the mesh
  24961. */
  24962. get onBeforeBindObservable(): Observable<Mesh>;
  24963. /**
  24964. * An event triggered after rendering the mesh
  24965. */
  24966. get onAfterRenderObservable(): Observable<Mesh>;
  24967. /**
  24968. * An event triggered before drawing the mesh
  24969. */
  24970. get onBeforeDrawObservable(): Observable<Mesh>;
  24971. private _onBeforeDrawObserver;
  24972. /**
  24973. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24974. */
  24975. set onBeforeDraw(callback: () => void);
  24976. get hasInstances(): boolean;
  24977. /**
  24978. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24979. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24980. */
  24981. delayLoadState: number;
  24982. /**
  24983. * Gets the list of instances created from this mesh
  24984. * it is not supposed to be modified manually.
  24985. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24986. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24987. */
  24988. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24989. /**
  24990. * Gets the file containing delay loading data for this mesh
  24991. */
  24992. delayLoadingFile: string;
  24993. /** @hidden */
  24994. _binaryInfo: any;
  24995. /**
  24996. * User defined function used to change how LOD level selection is done
  24997. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24998. */
  24999. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25000. /**
  25001. * Gets or sets the morph target manager
  25002. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25003. */
  25004. get morphTargetManager(): Nullable<MorphTargetManager>;
  25005. set morphTargetManager(value: Nullable<MorphTargetManager>);
  25006. /** @hidden */
  25007. _creationDataStorage: Nullable<_CreationDataStorage>;
  25008. /** @hidden */
  25009. _geometry: Nullable<Geometry>;
  25010. /** @hidden */
  25011. _delayInfo: Array<string>;
  25012. /** @hidden */
  25013. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  25014. /** @hidden */
  25015. _instanceDataStorage: _InstanceDataStorage;
  25016. private _effectiveMaterial;
  25017. /** @hidden */
  25018. _shouldGenerateFlatShading: boolean;
  25019. /** @hidden */
  25020. _originalBuilderSideOrientation: number;
  25021. /**
  25022. * Use this property to change the original side orientation defined at construction time
  25023. */
  25024. overrideMaterialSideOrientation: Nullable<number>;
  25025. /**
  25026. * Gets the source mesh (the one used to clone this one from)
  25027. */
  25028. get source(): Nullable<Mesh>;
  25029. /**
  25030. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25031. */
  25032. get isUnIndexed(): boolean;
  25033. set isUnIndexed(value: boolean);
  25034. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  25035. get worldMatrixInstancedBuffer(): Float32Array;
  25036. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  25037. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  25038. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  25039. /**
  25040. * @constructor
  25041. * @param name The value used by scene.getMeshByName() to do a lookup.
  25042. * @param scene The scene to add this mesh to.
  25043. * @param parent The parent of this mesh, if it has one
  25044. * @param source An optional Mesh from which geometry is shared, cloned.
  25045. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25046. * When false, achieved by calling a clone(), also passing False.
  25047. * This will make creation of children, recursive.
  25048. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25049. */
  25050. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25051. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25052. doNotInstantiate: boolean;
  25053. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25054. /**
  25055. * Gets the class name
  25056. * @returns the string "Mesh".
  25057. */
  25058. getClassName(): string;
  25059. /** @hidden */
  25060. get _isMesh(): boolean;
  25061. /**
  25062. * Returns a description of this mesh
  25063. * @param fullDetails define if full details about this mesh must be used
  25064. * @returns a descriptive string representing this mesh
  25065. */
  25066. toString(fullDetails?: boolean): string;
  25067. /** @hidden */
  25068. _unBindEffect(): void;
  25069. /**
  25070. * Gets a boolean indicating if this mesh has LOD
  25071. */
  25072. get hasLODLevels(): boolean;
  25073. /**
  25074. * Gets the list of MeshLODLevel associated with the current mesh
  25075. * @returns an array of MeshLODLevel
  25076. */
  25077. getLODLevels(): MeshLODLevel[];
  25078. private _sortLODLevels;
  25079. /**
  25080. * Add a mesh as LOD level triggered at the given distance.
  25081. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25082. * @param distance The distance from the center of the object to show this level
  25083. * @param mesh The mesh to be added as LOD level (can be null)
  25084. * @return This mesh (for chaining)
  25085. */
  25086. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25087. /**
  25088. * Returns the LOD level mesh at the passed distance or null if not found.
  25089. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25090. * @param distance The distance from the center of the object to show this level
  25091. * @returns a Mesh or `null`
  25092. */
  25093. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25094. /**
  25095. * Remove a mesh from the LOD array
  25096. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25097. * @param mesh defines the mesh to be removed
  25098. * @return This mesh (for chaining)
  25099. */
  25100. removeLODLevel(mesh: Mesh): Mesh;
  25101. /**
  25102. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25103. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25104. * @param camera defines the camera to use to compute distance
  25105. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25106. * @return This mesh (for chaining)
  25107. */
  25108. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25109. /**
  25110. * Gets the mesh internal Geometry object
  25111. */
  25112. get geometry(): Nullable<Geometry>;
  25113. /**
  25114. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25115. * @returns the total number of vertices
  25116. */
  25117. getTotalVertices(): number;
  25118. /**
  25119. * Returns the content of an associated vertex buffer
  25120. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25121. * - VertexBuffer.PositionKind
  25122. * - VertexBuffer.UVKind
  25123. * - VertexBuffer.UV2Kind
  25124. * - VertexBuffer.UV3Kind
  25125. * - VertexBuffer.UV4Kind
  25126. * - VertexBuffer.UV5Kind
  25127. * - VertexBuffer.UV6Kind
  25128. * - VertexBuffer.ColorKind
  25129. * - VertexBuffer.MatricesIndicesKind
  25130. * - VertexBuffer.MatricesIndicesExtraKind
  25131. * - VertexBuffer.MatricesWeightsKind
  25132. * - VertexBuffer.MatricesWeightsExtraKind
  25133. * @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
  25134. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25135. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25136. */
  25137. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25138. /**
  25139. * Returns the mesh VertexBuffer object from the requested `kind`
  25140. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25141. * - VertexBuffer.PositionKind
  25142. * - VertexBuffer.NormalKind
  25143. * - VertexBuffer.UVKind
  25144. * - VertexBuffer.UV2Kind
  25145. * - VertexBuffer.UV3Kind
  25146. * - VertexBuffer.UV4Kind
  25147. * - VertexBuffer.UV5Kind
  25148. * - VertexBuffer.UV6Kind
  25149. * - VertexBuffer.ColorKind
  25150. * - VertexBuffer.MatricesIndicesKind
  25151. * - VertexBuffer.MatricesIndicesExtraKind
  25152. * - VertexBuffer.MatricesWeightsKind
  25153. * - VertexBuffer.MatricesWeightsExtraKind
  25154. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25155. */
  25156. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25157. /**
  25158. * Tests if a specific vertex buffer is associated with this mesh
  25159. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25160. * - VertexBuffer.PositionKind
  25161. * - VertexBuffer.NormalKind
  25162. * - VertexBuffer.UVKind
  25163. * - VertexBuffer.UV2Kind
  25164. * - VertexBuffer.UV3Kind
  25165. * - VertexBuffer.UV4Kind
  25166. * - VertexBuffer.UV5Kind
  25167. * - VertexBuffer.UV6Kind
  25168. * - VertexBuffer.ColorKind
  25169. * - VertexBuffer.MatricesIndicesKind
  25170. * - VertexBuffer.MatricesIndicesExtraKind
  25171. * - VertexBuffer.MatricesWeightsKind
  25172. * - VertexBuffer.MatricesWeightsExtraKind
  25173. * @returns a boolean
  25174. */
  25175. isVerticesDataPresent(kind: string): boolean;
  25176. /**
  25177. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25178. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25179. * - VertexBuffer.PositionKind
  25180. * - VertexBuffer.UVKind
  25181. * - VertexBuffer.UV2Kind
  25182. * - VertexBuffer.UV3Kind
  25183. * - VertexBuffer.UV4Kind
  25184. * - VertexBuffer.UV5Kind
  25185. * - VertexBuffer.UV6Kind
  25186. * - VertexBuffer.ColorKind
  25187. * - VertexBuffer.MatricesIndicesKind
  25188. * - VertexBuffer.MatricesIndicesExtraKind
  25189. * - VertexBuffer.MatricesWeightsKind
  25190. * - VertexBuffer.MatricesWeightsExtraKind
  25191. * @returns a boolean
  25192. */
  25193. isVertexBufferUpdatable(kind: string): boolean;
  25194. /**
  25195. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25196. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25197. * - VertexBuffer.PositionKind
  25198. * - VertexBuffer.NormalKind
  25199. * - VertexBuffer.UVKind
  25200. * - VertexBuffer.UV2Kind
  25201. * - VertexBuffer.UV3Kind
  25202. * - VertexBuffer.UV4Kind
  25203. * - VertexBuffer.UV5Kind
  25204. * - VertexBuffer.UV6Kind
  25205. * - VertexBuffer.ColorKind
  25206. * - VertexBuffer.MatricesIndicesKind
  25207. * - VertexBuffer.MatricesIndicesExtraKind
  25208. * - VertexBuffer.MatricesWeightsKind
  25209. * - VertexBuffer.MatricesWeightsExtraKind
  25210. * @returns an array of strings
  25211. */
  25212. getVerticesDataKinds(): string[];
  25213. /**
  25214. * Returns a positive integer : the total number of indices in this mesh geometry.
  25215. * @returns the numner of indices or zero if the mesh has no geometry.
  25216. */
  25217. getTotalIndices(): number;
  25218. /**
  25219. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25220. * @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.
  25221. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25222. * @returns the indices array or an empty array if the mesh has no geometry
  25223. */
  25224. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25225. get isBlocked(): boolean;
  25226. /**
  25227. * Determine if the current mesh is ready to be rendered
  25228. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25229. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25230. * @returns true if all associated assets are ready (material, textures, shaders)
  25231. */
  25232. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25233. /**
  25234. * 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.
  25235. */
  25236. get areNormalsFrozen(): boolean;
  25237. /**
  25238. * 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.
  25239. * @returns the current mesh
  25240. */
  25241. freezeNormals(): Mesh;
  25242. /**
  25243. * 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
  25244. * @returns the current mesh
  25245. */
  25246. unfreezeNormals(): Mesh;
  25247. /**
  25248. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25249. */
  25250. set overridenInstanceCount(count: number);
  25251. /** @hidden */
  25252. _preActivate(): Mesh;
  25253. /** @hidden */
  25254. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25255. /** @hidden */
  25256. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25257. /**
  25258. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25259. * This means the mesh underlying bounding box and sphere are recomputed.
  25260. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25261. * @returns the current mesh
  25262. */
  25263. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25264. /** @hidden */
  25265. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25266. /**
  25267. * This function will subdivide the mesh into multiple submeshes
  25268. * @param count defines the expected number of submeshes
  25269. */
  25270. subdivide(count: number): void;
  25271. /**
  25272. * Copy a FloatArray into a specific associated vertex buffer
  25273. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25274. * - VertexBuffer.PositionKind
  25275. * - VertexBuffer.UVKind
  25276. * - VertexBuffer.UV2Kind
  25277. * - VertexBuffer.UV3Kind
  25278. * - VertexBuffer.UV4Kind
  25279. * - VertexBuffer.UV5Kind
  25280. * - VertexBuffer.UV6Kind
  25281. * - VertexBuffer.ColorKind
  25282. * - VertexBuffer.MatricesIndicesKind
  25283. * - VertexBuffer.MatricesIndicesExtraKind
  25284. * - VertexBuffer.MatricesWeightsKind
  25285. * - VertexBuffer.MatricesWeightsExtraKind
  25286. * @param data defines the data source
  25287. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25288. * @param stride defines the data stride size (can be null)
  25289. * @returns the current mesh
  25290. */
  25291. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25292. /**
  25293. * Delete a vertex buffer associated with this mesh
  25294. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25295. * - VertexBuffer.PositionKind
  25296. * - VertexBuffer.UVKind
  25297. * - VertexBuffer.UV2Kind
  25298. * - VertexBuffer.UV3Kind
  25299. * - VertexBuffer.UV4Kind
  25300. * - VertexBuffer.UV5Kind
  25301. * - VertexBuffer.UV6Kind
  25302. * - VertexBuffer.ColorKind
  25303. * - VertexBuffer.MatricesIndicesKind
  25304. * - VertexBuffer.MatricesIndicesExtraKind
  25305. * - VertexBuffer.MatricesWeightsKind
  25306. * - VertexBuffer.MatricesWeightsExtraKind
  25307. */
  25308. removeVerticesData(kind: string): void;
  25309. /**
  25310. * Flags an associated vertex buffer as updatable
  25311. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25312. * - VertexBuffer.PositionKind
  25313. * - VertexBuffer.UVKind
  25314. * - VertexBuffer.UV2Kind
  25315. * - VertexBuffer.UV3Kind
  25316. * - VertexBuffer.UV4Kind
  25317. * - VertexBuffer.UV5Kind
  25318. * - VertexBuffer.UV6Kind
  25319. * - VertexBuffer.ColorKind
  25320. * - VertexBuffer.MatricesIndicesKind
  25321. * - VertexBuffer.MatricesIndicesExtraKind
  25322. * - VertexBuffer.MatricesWeightsKind
  25323. * - VertexBuffer.MatricesWeightsExtraKind
  25324. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25325. */
  25326. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25327. /**
  25328. * Sets the mesh global Vertex Buffer
  25329. * @param buffer defines the buffer to use
  25330. * @returns the current mesh
  25331. */
  25332. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25333. /**
  25334. * Update a specific associated vertex buffer
  25335. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25336. * - VertexBuffer.PositionKind
  25337. * - VertexBuffer.UVKind
  25338. * - VertexBuffer.UV2Kind
  25339. * - VertexBuffer.UV3Kind
  25340. * - VertexBuffer.UV4Kind
  25341. * - VertexBuffer.UV5Kind
  25342. * - VertexBuffer.UV6Kind
  25343. * - VertexBuffer.ColorKind
  25344. * - VertexBuffer.MatricesIndicesKind
  25345. * - VertexBuffer.MatricesIndicesExtraKind
  25346. * - VertexBuffer.MatricesWeightsKind
  25347. * - VertexBuffer.MatricesWeightsExtraKind
  25348. * @param data defines the data source
  25349. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25350. * @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)
  25351. * @returns the current mesh
  25352. */
  25353. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25354. /**
  25355. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25356. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25357. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25358. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25359. * @returns the current mesh
  25360. */
  25361. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25362. /**
  25363. * Creates a un-shared specific occurence of the geometry for the mesh.
  25364. * @returns the current mesh
  25365. */
  25366. makeGeometryUnique(): Mesh;
  25367. /**
  25368. * Set the index buffer of this mesh
  25369. * @param indices defines the source data
  25370. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25371. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25372. * @returns the current mesh
  25373. */
  25374. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25375. /**
  25376. * Update the current index buffer
  25377. * @param indices defines the source data
  25378. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25379. * @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)
  25380. * @returns the current mesh
  25381. */
  25382. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25383. /**
  25384. * Invert the geometry to move from a right handed system to a left handed one.
  25385. * @returns the current mesh
  25386. */
  25387. toLeftHanded(): Mesh;
  25388. /** @hidden */
  25389. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25390. /** @hidden */
  25391. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25392. /**
  25393. * Registers for this mesh a javascript function called just before the rendering process
  25394. * @param func defines the function to call before rendering this mesh
  25395. * @returns the current mesh
  25396. */
  25397. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25398. /**
  25399. * Disposes a previously registered javascript function called before the rendering
  25400. * @param func defines the function to remove
  25401. * @returns the current mesh
  25402. */
  25403. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25404. /**
  25405. * Registers for this mesh a javascript function called just after the rendering is complete
  25406. * @param func defines the function to call after rendering this mesh
  25407. * @returns the current mesh
  25408. */
  25409. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25410. /**
  25411. * Disposes a previously registered javascript function called after the rendering.
  25412. * @param func defines the function to remove
  25413. * @returns the current mesh
  25414. */
  25415. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25416. /** @hidden */
  25417. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25418. /** @hidden */
  25419. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25420. /** @hidden */
  25421. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25422. /** @hidden */
  25423. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25424. /** @hidden */
  25425. _rebuild(): void;
  25426. /** @hidden */
  25427. _freeze(): void;
  25428. /** @hidden */
  25429. _unFreeze(): void;
  25430. /**
  25431. * 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
  25432. * @param subMesh defines the subMesh to render
  25433. * @param enableAlphaMode defines if alpha mode can be changed
  25434. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25435. * @returns the current mesh
  25436. */
  25437. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25438. private _onBeforeDraw;
  25439. /**
  25440. * Renormalize the mesh and patch it up if there are no weights
  25441. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25442. * However in the case of zero weights then we set just a single influence to 1.
  25443. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25444. */
  25445. cleanMatrixWeights(): void;
  25446. private normalizeSkinFourWeights;
  25447. private normalizeSkinWeightsAndExtra;
  25448. /**
  25449. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25450. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25451. * the user know there was an issue with importing the mesh
  25452. * @returns a validation object with skinned, valid and report string
  25453. */
  25454. validateSkinning(): {
  25455. skinned: boolean;
  25456. valid: boolean;
  25457. report: string;
  25458. };
  25459. /** @hidden */
  25460. _checkDelayState(): Mesh;
  25461. private _queueLoad;
  25462. /**
  25463. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25464. * A mesh is in the frustum if its bounding box intersects the frustum
  25465. * @param frustumPlanes defines the frustum to test
  25466. * @returns true if the mesh is in the frustum planes
  25467. */
  25468. isInFrustum(frustumPlanes: Plane[]): boolean;
  25469. /**
  25470. * Sets the mesh material by the material or multiMaterial `id` property
  25471. * @param id is a string identifying the material or the multiMaterial
  25472. * @returns the current mesh
  25473. */
  25474. setMaterialByID(id: string): Mesh;
  25475. /**
  25476. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25477. * @returns an array of IAnimatable
  25478. */
  25479. getAnimatables(): IAnimatable[];
  25480. /**
  25481. * Modifies the mesh geometry according to the passed transformation matrix.
  25482. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25483. * The mesh normals are modified using the same transformation.
  25484. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25485. * @param transform defines the transform matrix to use
  25486. * @see http://doc.babylonjs.com/resources/baking_transformations
  25487. * @returns the current mesh
  25488. */
  25489. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25490. /**
  25491. * Modifies the mesh geometry according to its own current World Matrix.
  25492. * The mesh World Matrix is then reset.
  25493. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25494. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25495. * @see http://doc.babylonjs.com/resources/baking_transformations
  25496. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25497. * @returns the current mesh
  25498. */
  25499. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25500. /** @hidden */
  25501. get _positions(): Nullable<Vector3[]>;
  25502. /** @hidden */
  25503. _resetPointsArrayCache(): Mesh;
  25504. /** @hidden */
  25505. _generatePointsArray(): boolean;
  25506. /**
  25507. * Returns a new Mesh object generated from the current mesh properties.
  25508. * This method must not get confused with createInstance()
  25509. * @param name is a string, the name given to the new mesh
  25510. * @param newParent can be any Node object (default `null`)
  25511. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25512. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25513. * @returns a new mesh
  25514. */
  25515. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25516. /**
  25517. * Releases resources associated with this mesh.
  25518. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25519. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25520. */
  25521. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25522. /** @hidden */
  25523. _disposeInstanceSpecificData(): void;
  25524. /**
  25525. * Modifies the mesh geometry according to a displacement map.
  25526. * 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.
  25527. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25528. * @param url is a string, the URL from the image file is to be downloaded.
  25529. * @param minHeight is the lower limit of the displacement.
  25530. * @param maxHeight is the upper limit of the displacement.
  25531. * @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.
  25532. * @param uvOffset is an optional vector2 used to offset UV.
  25533. * @param uvScale is an optional vector2 used to scale UV.
  25534. * @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.
  25535. * @returns the Mesh.
  25536. */
  25537. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25538. /**
  25539. * Modifies the mesh geometry according to a displacementMap buffer.
  25540. * 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.
  25541. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25542. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25543. * @param heightMapWidth is the width of the buffer image.
  25544. * @param heightMapHeight is the height of the buffer image.
  25545. * @param minHeight is the lower limit of the displacement.
  25546. * @param maxHeight is the upper limit of the displacement.
  25547. * @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.
  25548. * @param uvOffset is an optional vector2 used to offset UV.
  25549. * @param uvScale is an optional vector2 used to scale UV.
  25550. * @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.
  25551. * @returns the Mesh.
  25552. */
  25553. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25554. /**
  25555. * Modify the mesh to get a flat shading rendering.
  25556. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25557. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25558. * @returns current mesh
  25559. */
  25560. convertToFlatShadedMesh(): Mesh;
  25561. /**
  25562. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25563. * In other words, more vertices, no more indices and a single bigger VBO.
  25564. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25565. * @returns current mesh
  25566. */
  25567. convertToUnIndexedMesh(): Mesh;
  25568. /**
  25569. * Inverses facet orientations.
  25570. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25571. * @param flipNormals will also inverts the normals
  25572. * @returns current mesh
  25573. */
  25574. flipFaces(flipNormals?: boolean): Mesh;
  25575. /**
  25576. * Increase the number of facets and hence vertices in a mesh
  25577. * Vertex normals are interpolated from existing vertex normals
  25578. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25579. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25580. */
  25581. increaseVertices(numberPerEdge: number): void;
  25582. /**
  25583. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25584. * This will undo any application of covertToFlatShadedMesh
  25585. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25586. */
  25587. forceSharedVertices(): void;
  25588. /** @hidden */
  25589. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25590. /** @hidden */
  25591. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25592. /**
  25593. * Creates a new InstancedMesh object from the mesh model.
  25594. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25595. * @param name defines the name of the new instance
  25596. * @returns a new InstancedMesh
  25597. */
  25598. createInstance(name: string): InstancedMesh;
  25599. /**
  25600. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25601. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25602. * @returns the current mesh
  25603. */
  25604. synchronizeInstances(): Mesh;
  25605. /**
  25606. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25607. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25608. * This should be used together with the simplification to avoid disappearing triangles.
  25609. * @param successCallback an optional success callback to be called after the optimization finished.
  25610. * @returns the current mesh
  25611. */
  25612. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25613. /**
  25614. * Serialize current mesh
  25615. * @param serializationObject defines the object which will receive the serialization data
  25616. */
  25617. serialize(serializationObject: any): void;
  25618. /** @hidden */
  25619. _syncGeometryWithMorphTargetManager(): void;
  25620. /** @hidden */
  25621. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25622. /**
  25623. * Returns a new Mesh object parsed from the source provided.
  25624. * @param parsedMesh is the source
  25625. * @param scene defines the hosting scene
  25626. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25627. * @returns a new Mesh
  25628. */
  25629. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25630. /**
  25631. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25632. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25633. * @param name defines the name of the mesh to create
  25634. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25635. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25636. * @param closePath creates a seam between the first and the last points of each path of the path array
  25637. * @param offset is taken in account only if the `pathArray` is containing a single path
  25638. * @param scene defines the hosting scene
  25639. * @param updatable defines if the mesh must be flagged as updatable
  25640. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25641. * @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)
  25642. * @returns a new Mesh
  25643. */
  25644. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25645. /**
  25646. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25647. * @param name defines the name of the mesh to create
  25648. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25649. * @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
  25650. * @param scene defines the hosting scene
  25651. * @param updatable defines if the mesh must be flagged as updatable
  25652. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25653. * @returns a new Mesh
  25654. */
  25655. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25656. /**
  25657. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25658. * @param name defines the name of the mesh to create
  25659. * @param size sets the size (float) of each box side (default 1)
  25660. * @param scene defines the hosting scene
  25661. * @param updatable defines if the mesh must be flagged as updatable
  25662. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25663. * @returns a new Mesh
  25664. */
  25665. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25666. /**
  25667. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25668. * @param name defines the name of the mesh to create
  25669. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25670. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25671. * @param scene defines the hosting scene
  25672. * @param updatable defines if the mesh must be flagged as updatable
  25673. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25674. * @returns a new Mesh
  25675. */
  25676. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25677. /**
  25678. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25679. * @param name defines the name of the mesh to create
  25680. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25681. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25682. * @param scene defines the hosting scene
  25683. * @returns a new Mesh
  25684. */
  25685. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25686. /**
  25687. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25688. * @param name defines the name of the mesh to create
  25689. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25690. * @param diameterTop set the top cap diameter (floats, default 1)
  25691. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25692. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25693. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25694. * @param scene defines the hosting scene
  25695. * @param updatable defines if the mesh must be flagged as updatable
  25696. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25697. * @returns a new Mesh
  25698. */
  25699. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25700. /**
  25701. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25702. * @param name defines the name of the mesh to create
  25703. * @param diameter sets the diameter size (float) of the torus (default 1)
  25704. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25705. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25706. * @param scene defines the hosting scene
  25707. * @param updatable defines if the mesh must be flagged as updatable
  25708. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25709. * @returns a new Mesh
  25710. */
  25711. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25712. /**
  25713. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25714. * @param name defines the name of the mesh to create
  25715. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25716. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25717. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25718. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25719. * @param p the number of windings on X axis (positive integers, default 2)
  25720. * @param q the number of windings on Y axis (positive integers, default 3)
  25721. * @param scene defines the hosting scene
  25722. * @param updatable defines if the mesh must be flagged as updatable
  25723. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25724. * @returns a new Mesh
  25725. */
  25726. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25727. /**
  25728. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25729. * @param name defines the name of the mesh to create
  25730. * @param points is an array successive Vector3
  25731. * @param scene defines the hosting scene
  25732. * @param updatable defines if the mesh must be flagged as updatable
  25733. * @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).
  25734. * @returns a new Mesh
  25735. */
  25736. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25737. /**
  25738. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25739. * @param name defines the name of the mesh to create
  25740. * @param points is an array successive Vector3
  25741. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25742. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25743. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25744. * @param scene defines the hosting scene
  25745. * @param updatable defines if the mesh must be flagged as updatable
  25746. * @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)
  25747. * @returns a new Mesh
  25748. */
  25749. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25750. /**
  25751. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25752. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25753. * 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.
  25754. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25755. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25756. * Remember you can only change the shape positions, not their number when updating a polygon.
  25757. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25758. * @param name defines the name of the mesh to create
  25759. * @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
  25760. * @param scene defines the hosting scene
  25761. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25762. * @param updatable defines if the mesh must be flagged as updatable
  25763. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25764. * @param earcutInjection can be used to inject your own earcut reference
  25765. * @returns a new Mesh
  25766. */
  25767. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25768. /**
  25769. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25770. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25771. * @param name defines the name of the mesh to create
  25772. * @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
  25773. * @param depth defines the height of extrusion
  25774. * @param scene defines the hosting scene
  25775. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25776. * @param updatable defines if the mesh must be flagged as updatable
  25777. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25778. * @param earcutInjection can be used to inject your own earcut reference
  25779. * @returns a new Mesh
  25780. */
  25781. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25782. /**
  25783. * Creates an extruded shape mesh.
  25784. * 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
  25785. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25786. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25787. * @param name defines the name of the mesh to create
  25788. * @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
  25789. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25790. * @param scale is the value to scale the shape
  25791. * @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
  25792. * @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
  25793. * @param scene defines the hosting scene
  25794. * @param updatable defines if the mesh must be flagged as updatable
  25795. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25796. * @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)
  25797. * @returns a new Mesh
  25798. */
  25799. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25800. /**
  25801. * Creates an custom extruded shape mesh.
  25802. * The custom extrusion is a parametric shape.
  25803. * It has no predefined shape. Its final shape will depend on the input parameters.
  25804. * Please consider using the same method from the MeshBuilder class instead
  25805. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25806. * @param name defines the name of the mesh to create
  25807. * @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
  25808. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25809. * @param scaleFunction is a custom Javascript function called on each path point
  25810. * @param rotationFunction is a custom Javascript function called on each path point
  25811. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25812. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25813. * @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
  25814. * @param scene defines the hosting scene
  25815. * @param updatable defines if the mesh must be flagged as updatable
  25816. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25817. * @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)
  25818. * @returns a new Mesh
  25819. */
  25820. 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;
  25821. /**
  25822. * Creates lathe mesh.
  25823. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25824. * Please consider using the same method from the MeshBuilder class instead
  25825. * @param name defines the name of the mesh to create
  25826. * @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
  25827. * @param radius is the radius value of the lathe
  25828. * @param tessellation is the side number of the lathe.
  25829. * @param scene defines the hosting scene
  25830. * @param updatable defines if the mesh must be flagged as updatable
  25831. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25832. * @returns a new Mesh
  25833. */
  25834. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25835. /**
  25836. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25837. * @param name defines the name of the mesh to create
  25838. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25839. * @param scene defines the hosting scene
  25840. * @param updatable defines if the mesh must be flagged as updatable
  25841. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25842. * @returns a new Mesh
  25843. */
  25844. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25845. /**
  25846. * Creates a ground mesh.
  25847. * Please consider using the same method from the MeshBuilder class instead
  25848. * @param name defines the name of the mesh to create
  25849. * @param width set the width of the ground
  25850. * @param height set the height of the ground
  25851. * @param subdivisions sets the number of subdivisions per side
  25852. * @param scene defines the hosting scene
  25853. * @param updatable defines if the mesh must be flagged as updatable
  25854. * @returns a new Mesh
  25855. */
  25856. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25857. /**
  25858. * Creates a tiled ground mesh.
  25859. * Please consider using the same method from the MeshBuilder class instead
  25860. * @param name defines the name of the mesh to create
  25861. * @param xmin set the ground minimum X coordinate
  25862. * @param zmin set the ground minimum Y coordinate
  25863. * @param xmax set the ground maximum X coordinate
  25864. * @param zmax set the ground maximum Z coordinate
  25865. * @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
  25866. * @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
  25867. * @param scene defines the hosting scene
  25868. * @param updatable defines if the mesh must be flagged as updatable
  25869. * @returns a new Mesh
  25870. */
  25871. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25872. w: number;
  25873. h: number;
  25874. }, precision: {
  25875. w: number;
  25876. h: number;
  25877. }, scene: Scene, updatable?: boolean): Mesh;
  25878. /**
  25879. * Creates a ground mesh from a height map.
  25880. * Please consider using the same method from the MeshBuilder class instead
  25881. * @see http://doc.babylonjs.com/babylon101/height_map
  25882. * @param name defines the name of the mesh to create
  25883. * @param url sets the URL of the height map image resource
  25884. * @param width set the ground width size
  25885. * @param height set the ground height size
  25886. * @param subdivisions sets the number of subdivision per side
  25887. * @param minHeight is the minimum altitude on the ground
  25888. * @param maxHeight is the maximum altitude on the ground
  25889. * @param scene defines the hosting scene
  25890. * @param updatable defines if the mesh must be flagged as updatable
  25891. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25892. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25893. * @returns a new Mesh
  25894. */
  25895. 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;
  25896. /**
  25897. * Creates a tube mesh.
  25898. * The tube is a parametric shape.
  25899. * It has no predefined shape. Its final shape will depend on the input parameters.
  25900. * Please consider using the same method from the MeshBuilder class instead
  25901. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25902. * @param name defines the name of the mesh to create
  25903. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25904. * @param radius sets the tube radius size
  25905. * @param tessellation is the number of sides on the tubular surface
  25906. * @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
  25907. * @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
  25908. * @param scene defines the hosting scene
  25909. * @param updatable defines if the mesh must be flagged as updatable
  25910. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25911. * @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)
  25912. * @returns a new Mesh
  25913. */
  25914. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25915. (i: number, distance: number): number;
  25916. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25917. /**
  25918. * Creates a polyhedron mesh.
  25919. * Please consider using the same method from the MeshBuilder class instead.
  25920. * * 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
  25921. * * The parameter `size` (positive float, default 1) sets the polygon size
  25922. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25923. * * 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`
  25924. * * 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
  25925. * * 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)`)
  25926. * * 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
  25927. * * 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
  25928. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25929. * * 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
  25930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25931. * @param name defines the name of the mesh to create
  25932. * @param options defines the options used to create the mesh
  25933. * @param scene defines the hosting scene
  25934. * @returns a new Mesh
  25935. */
  25936. static CreatePolyhedron(name: string, options: {
  25937. type?: number;
  25938. size?: number;
  25939. sizeX?: number;
  25940. sizeY?: number;
  25941. sizeZ?: number;
  25942. custom?: any;
  25943. faceUV?: Vector4[];
  25944. faceColors?: Color4[];
  25945. updatable?: boolean;
  25946. sideOrientation?: number;
  25947. }, scene: Scene): Mesh;
  25948. /**
  25949. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25950. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25951. * * 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`)
  25952. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25953. * * 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
  25954. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25955. * * 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
  25956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25957. * @param name defines the name of the mesh
  25958. * @param options defines the options used to create the mesh
  25959. * @param scene defines the hosting scene
  25960. * @returns a new Mesh
  25961. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25962. */
  25963. static CreateIcoSphere(name: string, options: {
  25964. radius?: number;
  25965. flat?: boolean;
  25966. subdivisions?: number;
  25967. sideOrientation?: number;
  25968. updatable?: boolean;
  25969. }, scene: Scene): Mesh;
  25970. /**
  25971. * Creates a decal mesh.
  25972. * Please consider using the same method from the MeshBuilder class instead.
  25973. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25974. * @param name defines the name of the mesh
  25975. * @param sourceMesh defines the mesh receiving the decal
  25976. * @param position sets the position of the decal in world coordinates
  25977. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25978. * @param size sets the decal scaling
  25979. * @param angle sets the angle to rotate the decal
  25980. * @returns a new Mesh
  25981. */
  25982. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25983. /**
  25984. * Prepare internal position array for software CPU skinning
  25985. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25986. */
  25987. setPositionsForCPUSkinning(): Float32Array;
  25988. /**
  25989. * Prepare internal normal array for software CPU skinning
  25990. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25991. */
  25992. setNormalsForCPUSkinning(): Float32Array;
  25993. /**
  25994. * Updates the vertex buffer by applying transformation from the bones
  25995. * @param skeleton defines the skeleton to apply to current mesh
  25996. * @returns the current mesh
  25997. */
  25998. applySkeleton(skeleton: Skeleton): Mesh;
  25999. /**
  26000. * 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
  26001. * @param meshes defines the list of meshes to scan
  26002. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26003. */
  26004. static MinMax(meshes: AbstractMesh[]): {
  26005. min: Vector3;
  26006. max: Vector3;
  26007. };
  26008. /**
  26009. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26010. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26011. * @returns a vector3
  26012. */
  26013. static Center(meshesOrMinMaxVector: {
  26014. min: Vector3;
  26015. max: Vector3;
  26016. } | AbstractMesh[]): Vector3;
  26017. /**
  26018. * Merge the array of meshes into a single mesh for performance reasons.
  26019. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26020. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26021. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26022. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26023. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26024. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  26025. * @returns a new mesh
  26026. */
  26027. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  26028. /** @hidden */
  26029. addInstance(instance: InstancedMesh): void;
  26030. /** @hidden */
  26031. removeInstance(instance: InstancedMesh): void;
  26032. }
  26033. }
  26034. declare module "babylonjs/Cameras/camera" {
  26035. import { SmartArray } from "babylonjs/Misc/smartArray";
  26036. import { Observable } from "babylonjs/Misc/observable";
  26037. import { Nullable } from "babylonjs/types";
  26038. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26039. import { Scene } from "babylonjs/scene";
  26040. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  26041. import { Node } from "babylonjs/node";
  26042. import { Mesh } from "babylonjs/Meshes/mesh";
  26043. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26044. import { ICullable } from "babylonjs/Culling/boundingInfo";
  26045. import { Viewport } from "babylonjs/Maths/math.viewport";
  26046. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26047. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26048. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26049. import { Ray } from "babylonjs/Culling/ray";
  26050. /**
  26051. * This is the base class of all the camera used in the application.
  26052. * @see http://doc.babylonjs.com/features/cameras
  26053. */
  26054. export class Camera extends Node {
  26055. /** @hidden */
  26056. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  26057. /**
  26058. * This is the default projection mode used by the cameras.
  26059. * It helps recreating a feeling of perspective and better appreciate depth.
  26060. * This is the best way to simulate real life cameras.
  26061. */
  26062. static readonly PERSPECTIVE_CAMERA: number;
  26063. /**
  26064. * This helps creating camera with an orthographic mode.
  26065. * 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.
  26066. */
  26067. static readonly ORTHOGRAPHIC_CAMERA: number;
  26068. /**
  26069. * This is the default FOV mode for perspective cameras.
  26070. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26071. */
  26072. static readonly FOVMODE_VERTICAL_FIXED: number;
  26073. /**
  26074. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26075. */
  26076. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26077. /**
  26078. * This specifies ther is no need for a camera rig.
  26079. * Basically only one eye is rendered corresponding to the camera.
  26080. */
  26081. static readonly RIG_MODE_NONE: number;
  26082. /**
  26083. * Simulates a camera Rig with one blue eye and one red eye.
  26084. * This can be use with 3d blue and red glasses.
  26085. */
  26086. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26087. /**
  26088. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26089. */
  26090. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26091. /**
  26092. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26093. */
  26094. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26095. /**
  26096. * Defines that both eyes of the camera will be rendered over under each other.
  26097. */
  26098. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26099. /**
  26100. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  26101. */
  26102. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  26103. /**
  26104. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26105. */
  26106. static readonly RIG_MODE_VR: number;
  26107. /**
  26108. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26109. */
  26110. static readonly RIG_MODE_WEBVR: number;
  26111. /**
  26112. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26113. */
  26114. static readonly RIG_MODE_CUSTOM: number;
  26115. /**
  26116. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26117. */
  26118. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26119. /**
  26120. * Define the input manager associated with the camera.
  26121. */
  26122. inputs: CameraInputsManager<Camera>;
  26123. /** @hidden */
  26124. _position: Vector3;
  26125. /**
  26126. * Define the current local position of the camera in the scene
  26127. */
  26128. get position(): Vector3;
  26129. set position(newPosition: Vector3);
  26130. /**
  26131. * The vector the camera should consider as up.
  26132. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26133. */
  26134. upVector: Vector3;
  26135. /**
  26136. * Define the current limit on the left side for an orthographic camera
  26137. * In scene unit
  26138. */
  26139. orthoLeft: Nullable<number>;
  26140. /**
  26141. * Define the current limit on the right side for an orthographic camera
  26142. * In scene unit
  26143. */
  26144. orthoRight: Nullable<number>;
  26145. /**
  26146. * Define the current limit on the bottom side for an orthographic camera
  26147. * In scene unit
  26148. */
  26149. orthoBottom: Nullable<number>;
  26150. /**
  26151. * Define the current limit on the top side for an orthographic camera
  26152. * In scene unit
  26153. */
  26154. orthoTop: Nullable<number>;
  26155. /**
  26156. * Field Of View is set in Radians. (default is 0.8)
  26157. */
  26158. fov: number;
  26159. /**
  26160. * Define the minimum distance the camera can see from.
  26161. * This is important to note that the depth buffer are not infinite and the closer it starts
  26162. * the more your scene might encounter depth fighting issue.
  26163. */
  26164. minZ: number;
  26165. /**
  26166. * Define the maximum distance the camera can see to.
  26167. * This is important to note that the depth buffer are not infinite and the further it end
  26168. * the more your scene might encounter depth fighting issue.
  26169. */
  26170. maxZ: number;
  26171. /**
  26172. * Define the default inertia of the camera.
  26173. * This helps giving a smooth feeling to the camera movement.
  26174. */
  26175. inertia: number;
  26176. /**
  26177. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26178. */
  26179. mode: number;
  26180. /**
  26181. * Define whether the camera is intermediate.
  26182. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26183. */
  26184. isIntermediate: boolean;
  26185. /**
  26186. * Define the viewport of the camera.
  26187. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26188. */
  26189. viewport: Viewport;
  26190. /**
  26191. * Restricts the camera to viewing objects with the same layerMask.
  26192. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26193. */
  26194. layerMask: number;
  26195. /**
  26196. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26197. */
  26198. fovMode: number;
  26199. /**
  26200. * Rig mode of the camera.
  26201. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26202. * This is normally controlled byt the camera themselves as internal use.
  26203. */
  26204. cameraRigMode: number;
  26205. /**
  26206. * Defines the distance between both "eyes" in case of a RIG
  26207. */
  26208. interaxialDistance: number;
  26209. /**
  26210. * Defines if stereoscopic rendering is done side by side or over under.
  26211. */
  26212. isStereoscopicSideBySide: boolean;
  26213. /**
  26214. * 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
  26215. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26216. * else in the scene. (Eg. security camera)
  26217. *
  26218. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  26219. */
  26220. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26221. /**
  26222. * When set, the camera will render to this render target instead of the default canvas
  26223. *
  26224. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26225. */
  26226. outputRenderTarget: Nullable<RenderTargetTexture>;
  26227. /**
  26228. * Observable triggered when the camera view matrix has changed.
  26229. */
  26230. onViewMatrixChangedObservable: Observable<Camera>;
  26231. /**
  26232. * Observable triggered when the camera Projection matrix has changed.
  26233. */
  26234. onProjectionMatrixChangedObservable: Observable<Camera>;
  26235. /**
  26236. * Observable triggered when the inputs have been processed.
  26237. */
  26238. onAfterCheckInputsObservable: Observable<Camera>;
  26239. /**
  26240. * Observable triggered when reset has been called and applied to the camera.
  26241. */
  26242. onRestoreStateObservable: Observable<Camera>;
  26243. /**
  26244. * Is this camera a part of a rig system?
  26245. */
  26246. isRigCamera: boolean;
  26247. /**
  26248. * If isRigCamera set to true this will be set with the parent camera.
  26249. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26250. */
  26251. rigParent?: Camera;
  26252. /** @hidden */
  26253. _cameraRigParams: any;
  26254. /** @hidden */
  26255. _rigCameras: Camera[];
  26256. /** @hidden */
  26257. _rigPostProcess: Nullable<PostProcess>;
  26258. protected _webvrViewMatrix: Matrix;
  26259. /** @hidden */
  26260. _skipRendering: boolean;
  26261. /** @hidden */
  26262. _projectionMatrix: Matrix;
  26263. /** @hidden */
  26264. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26265. /** @hidden */
  26266. _activeMeshes: SmartArray<AbstractMesh>;
  26267. protected _globalPosition: Vector3;
  26268. /** @hidden */
  26269. _computedViewMatrix: Matrix;
  26270. private _doNotComputeProjectionMatrix;
  26271. private _transformMatrix;
  26272. private _frustumPlanes;
  26273. private _refreshFrustumPlanes;
  26274. private _storedFov;
  26275. private _stateStored;
  26276. /**
  26277. * Instantiates a new camera object.
  26278. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26279. * @see http://doc.babylonjs.com/features/cameras
  26280. * @param name Defines the name of the camera in the scene
  26281. * @param position Defines the position of the camera
  26282. * @param scene Defines the scene the camera belongs too
  26283. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26284. */
  26285. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26286. /**
  26287. * Store current camera state (fov, position, etc..)
  26288. * @returns the camera
  26289. */
  26290. storeState(): Camera;
  26291. /**
  26292. * Restores the camera state values if it has been stored. You must call storeState() first
  26293. */
  26294. protected _restoreStateValues(): boolean;
  26295. /**
  26296. * Restored camera state. You must call storeState() first.
  26297. * @returns true if restored and false otherwise
  26298. */
  26299. restoreState(): boolean;
  26300. /**
  26301. * Gets the class name of the camera.
  26302. * @returns the class name
  26303. */
  26304. getClassName(): string;
  26305. /** @hidden */
  26306. readonly _isCamera: boolean;
  26307. /**
  26308. * Gets a string representation of the camera useful for debug purpose.
  26309. * @param fullDetails Defines that a more verboe level of logging is required
  26310. * @returns the string representation
  26311. */
  26312. toString(fullDetails?: boolean): string;
  26313. /**
  26314. * Gets the current world space position of the camera.
  26315. */
  26316. get globalPosition(): Vector3;
  26317. /**
  26318. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26319. * @returns the active meshe list
  26320. */
  26321. getActiveMeshes(): SmartArray<AbstractMesh>;
  26322. /**
  26323. * Check whether a mesh is part of the current active mesh list of the camera
  26324. * @param mesh Defines the mesh to check
  26325. * @returns true if active, false otherwise
  26326. */
  26327. isActiveMesh(mesh: Mesh): boolean;
  26328. /**
  26329. * Is this camera ready to be used/rendered
  26330. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26331. * @return true if the camera is ready
  26332. */
  26333. isReady(completeCheck?: boolean): boolean;
  26334. /** @hidden */
  26335. _initCache(): void;
  26336. /** @hidden */
  26337. _updateCache(ignoreParentClass?: boolean): void;
  26338. /** @hidden */
  26339. _isSynchronized(): boolean;
  26340. /** @hidden */
  26341. _isSynchronizedViewMatrix(): boolean;
  26342. /** @hidden */
  26343. _isSynchronizedProjectionMatrix(): boolean;
  26344. /**
  26345. * Attach the input controls to a specific dom element to get the input from.
  26346. * @param element Defines the element the controls should be listened from
  26347. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26348. */
  26349. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26350. /**
  26351. * Detach the current controls from the specified dom element.
  26352. * @param element Defines the element to stop listening the inputs from
  26353. */
  26354. detachControl(element: HTMLElement): void;
  26355. /**
  26356. * Update the camera state according to the different inputs gathered during the frame.
  26357. */
  26358. update(): void;
  26359. /** @hidden */
  26360. _checkInputs(): void;
  26361. /** @hidden */
  26362. get rigCameras(): Camera[];
  26363. /**
  26364. * Gets the post process used by the rig cameras
  26365. */
  26366. get rigPostProcess(): Nullable<PostProcess>;
  26367. /**
  26368. * Internal, gets the first post proces.
  26369. * @returns the first post process to be run on this camera.
  26370. */
  26371. _getFirstPostProcess(): Nullable<PostProcess>;
  26372. private _cascadePostProcessesToRigCams;
  26373. /**
  26374. * Attach a post process to the camera.
  26375. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26376. * @param postProcess The post process to attach to the camera
  26377. * @param insertAt The position of the post process in case several of them are in use in the scene
  26378. * @returns the position the post process has been inserted at
  26379. */
  26380. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26381. /**
  26382. * Detach a post process to the camera.
  26383. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26384. * @param postProcess The post process to detach from the camera
  26385. */
  26386. detachPostProcess(postProcess: PostProcess): void;
  26387. /**
  26388. * Gets the current world matrix of the camera
  26389. */
  26390. getWorldMatrix(): Matrix;
  26391. /** @hidden */
  26392. _getViewMatrix(): Matrix;
  26393. /**
  26394. * Gets the current view matrix of the camera.
  26395. * @param force forces the camera to recompute the matrix without looking at the cached state
  26396. * @returns the view matrix
  26397. */
  26398. getViewMatrix(force?: boolean): Matrix;
  26399. /**
  26400. * Freeze the projection matrix.
  26401. * It will prevent the cache check of the camera projection compute and can speed up perf
  26402. * if no parameter of the camera are meant to change
  26403. * @param projection Defines manually a projection if necessary
  26404. */
  26405. freezeProjectionMatrix(projection?: Matrix): void;
  26406. /**
  26407. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26408. */
  26409. unfreezeProjectionMatrix(): void;
  26410. /**
  26411. * Gets the current projection matrix of the camera.
  26412. * @param force forces the camera to recompute the matrix without looking at the cached state
  26413. * @returns the projection matrix
  26414. */
  26415. getProjectionMatrix(force?: boolean): Matrix;
  26416. /**
  26417. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26418. * @returns a Matrix
  26419. */
  26420. getTransformationMatrix(): Matrix;
  26421. private _updateFrustumPlanes;
  26422. /**
  26423. * Checks if a cullable object (mesh...) is in the camera frustum
  26424. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26425. * @param target The object to check
  26426. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26427. * @returns true if the object is in frustum otherwise false
  26428. */
  26429. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26430. /**
  26431. * Checks if a cullable object (mesh...) is in the camera frustum
  26432. * Unlike isInFrustum this cheks the full bounding box
  26433. * @param target The object to check
  26434. * @returns true if the object is in frustum otherwise false
  26435. */
  26436. isCompletelyInFrustum(target: ICullable): boolean;
  26437. /**
  26438. * Gets a ray in the forward direction from the camera.
  26439. * @param length Defines the length of the ray to create
  26440. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26441. * @param origin Defines the start point of the ray which defaults to the camera position
  26442. * @returns the forward ray
  26443. */
  26444. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26445. /**
  26446. * Releases resources associated with this node.
  26447. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26448. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26449. */
  26450. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26451. /** @hidden */
  26452. _isLeftCamera: boolean;
  26453. /**
  26454. * Gets the left camera of a rig setup in case of Rigged Camera
  26455. */
  26456. get isLeftCamera(): boolean;
  26457. /** @hidden */
  26458. _isRightCamera: boolean;
  26459. /**
  26460. * Gets the right camera of a rig setup in case of Rigged Camera
  26461. */
  26462. get isRightCamera(): boolean;
  26463. /**
  26464. * Gets the left camera of a rig setup in case of Rigged Camera
  26465. */
  26466. get leftCamera(): Nullable<FreeCamera>;
  26467. /**
  26468. * Gets the right camera of a rig setup in case of Rigged Camera
  26469. */
  26470. get rightCamera(): Nullable<FreeCamera>;
  26471. /**
  26472. * Gets the left camera target of a rig setup in case of Rigged Camera
  26473. * @returns the target position
  26474. */
  26475. getLeftTarget(): Nullable<Vector3>;
  26476. /**
  26477. * Gets the right camera target of a rig setup in case of Rigged Camera
  26478. * @returns the target position
  26479. */
  26480. getRightTarget(): Nullable<Vector3>;
  26481. /**
  26482. * @hidden
  26483. */
  26484. setCameraRigMode(mode: number, rigParams: any): void;
  26485. /** @hidden */
  26486. static _setStereoscopicRigMode(camera: Camera): void;
  26487. /** @hidden */
  26488. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26489. /** @hidden */
  26490. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26491. /** @hidden */
  26492. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26493. /** @hidden */
  26494. _getVRProjectionMatrix(): Matrix;
  26495. protected _updateCameraRotationMatrix(): void;
  26496. protected _updateWebVRCameraRotationMatrix(): void;
  26497. /**
  26498. * This function MUST be overwritten by the different WebVR cameras available.
  26499. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26500. * @hidden
  26501. */
  26502. _getWebVRProjectionMatrix(): Matrix;
  26503. /**
  26504. * This function MUST be overwritten by the different WebVR cameras available.
  26505. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26506. * @hidden
  26507. */
  26508. _getWebVRViewMatrix(): Matrix;
  26509. /** @hidden */
  26510. setCameraRigParameter(name: string, value: any): void;
  26511. /**
  26512. * needs to be overridden by children so sub has required properties to be copied
  26513. * @hidden
  26514. */
  26515. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26516. /**
  26517. * May need to be overridden by children
  26518. * @hidden
  26519. */
  26520. _updateRigCameras(): void;
  26521. /** @hidden */
  26522. _setupInputs(): void;
  26523. /**
  26524. * Serialiaze the camera setup to a json represention
  26525. * @returns the JSON representation
  26526. */
  26527. serialize(): any;
  26528. /**
  26529. * Clones the current camera.
  26530. * @param name The cloned camera name
  26531. * @returns the cloned camera
  26532. */
  26533. clone(name: string): Camera;
  26534. /**
  26535. * Gets the direction of the camera relative to a given local axis.
  26536. * @param localAxis Defines the reference axis to provide a relative direction.
  26537. * @return the direction
  26538. */
  26539. getDirection(localAxis: Vector3): Vector3;
  26540. /**
  26541. * Returns the current camera absolute rotation
  26542. */
  26543. get absoluteRotation(): Quaternion;
  26544. /**
  26545. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26546. * @param localAxis Defines the reference axis to provide a relative direction.
  26547. * @param result Defines the vector to store the result in
  26548. */
  26549. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26550. /**
  26551. * Gets a camera constructor for a given camera type
  26552. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26553. * @param name The name of the camera the result will be able to instantiate
  26554. * @param scene The scene the result will construct the camera in
  26555. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26556. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26557. * @returns a factory method to construc the camera
  26558. */
  26559. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26560. /**
  26561. * Compute the world matrix of the camera.
  26562. * @returns the camera world matrix
  26563. */
  26564. computeWorldMatrix(): Matrix;
  26565. /**
  26566. * Parse a JSON and creates the camera from the parsed information
  26567. * @param parsedCamera The JSON to parse
  26568. * @param scene The scene to instantiate the camera in
  26569. * @returns the newly constructed camera
  26570. */
  26571. static Parse(parsedCamera: any, scene: Scene): Camera;
  26572. }
  26573. }
  26574. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26575. import { Nullable } from "babylonjs/types";
  26576. import { Scene } from "babylonjs/scene";
  26577. import { Vector4 } from "babylonjs/Maths/math.vector";
  26578. import { Mesh } from "babylonjs/Meshes/mesh";
  26579. /**
  26580. * Class containing static functions to help procedurally build meshes
  26581. */
  26582. export class DiscBuilder {
  26583. /**
  26584. * Creates a plane polygonal mesh. By default, this is a disc
  26585. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26586. * * 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
  26587. * * 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
  26588. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26589. * * 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
  26590. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26591. * @param name defines the name of the mesh
  26592. * @param options defines the options used to create the mesh
  26593. * @param scene defines the hosting scene
  26594. * @returns the plane polygonal mesh
  26595. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26596. */
  26597. static CreateDisc(name: string, options: {
  26598. radius?: number;
  26599. tessellation?: number;
  26600. arc?: number;
  26601. updatable?: boolean;
  26602. sideOrientation?: number;
  26603. frontUVs?: Vector4;
  26604. backUVs?: Vector4;
  26605. }, scene?: Nullable<Scene>): Mesh;
  26606. }
  26607. }
  26608. declare module "babylonjs/Materials/fresnelParameters" {
  26609. import { Color3 } from "babylonjs/Maths/math.color";
  26610. /**
  26611. * This represents all the required information to add a fresnel effect on a material:
  26612. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26613. */
  26614. export class FresnelParameters {
  26615. private _isEnabled;
  26616. /**
  26617. * Define if the fresnel effect is enable or not.
  26618. */
  26619. get isEnabled(): boolean;
  26620. set isEnabled(value: boolean);
  26621. /**
  26622. * Define the color used on edges (grazing angle)
  26623. */
  26624. leftColor: Color3;
  26625. /**
  26626. * Define the color used on center
  26627. */
  26628. rightColor: Color3;
  26629. /**
  26630. * Define bias applied to computed fresnel term
  26631. */
  26632. bias: number;
  26633. /**
  26634. * Defined the power exponent applied to fresnel term
  26635. */
  26636. power: number;
  26637. /**
  26638. * Clones the current fresnel and its valuues
  26639. * @returns a clone fresnel configuration
  26640. */
  26641. clone(): FresnelParameters;
  26642. /**
  26643. * Serializes the current fresnel parameters to a JSON representation.
  26644. * @return the JSON serialization
  26645. */
  26646. serialize(): any;
  26647. /**
  26648. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26649. * @param parsedFresnelParameters Define the JSON representation
  26650. * @returns the parsed parameters
  26651. */
  26652. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26653. }
  26654. }
  26655. declare module "babylonjs/Materials/pushMaterial" {
  26656. import { Nullable } from "babylonjs/types";
  26657. import { Scene } from "babylonjs/scene";
  26658. import { Matrix } from "babylonjs/Maths/math.vector";
  26659. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26660. import { Mesh } from "babylonjs/Meshes/mesh";
  26661. import { Material } from "babylonjs/Materials/material";
  26662. import { Effect } from "babylonjs/Materials/effect";
  26663. /**
  26664. * Base class of materials working in push mode in babylon JS
  26665. * @hidden
  26666. */
  26667. export class PushMaterial extends Material {
  26668. protected _activeEffect: Effect;
  26669. protected _normalMatrix: Matrix;
  26670. /**
  26671. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26672. * This means that the material can keep using a previous shader while a new one is being compiled.
  26673. * This is mostly used when shader parallel compilation is supported (true by default)
  26674. */
  26675. allowShaderHotSwapping: boolean;
  26676. constructor(name: string, scene: Scene);
  26677. getEffect(): Effect;
  26678. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26679. /**
  26680. * Binds the given world matrix to the active effect
  26681. *
  26682. * @param world the matrix to bind
  26683. */
  26684. bindOnlyWorldMatrix(world: Matrix): void;
  26685. /**
  26686. * Binds the given normal matrix to the active effect
  26687. *
  26688. * @param normalMatrix the matrix to bind
  26689. */
  26690. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26691. bind(world: Matrix, mesh?: Mesh): void;
  26692. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26693. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26694. }
  26695. }
  26696. declare module "babylonjs/Materials/materialFlags" {
  26697. /**
  26698. * This groups all the flags used to control the materials channel.
  26699. */
  26700. export class MaterialFlags {
  26701. private static _DiffuseTextureEnabled;
  26702. /**
  26703. * Are diffuse textures enabled in the application.
  26704. */
  26705. static get DiffuseTextureEnabled(): boolean;
  26706. static set DiffuseTextureEnabled(value: boolean);
  26707. private static _AmbientTextureEnabled;
  26708. /**
  26709. * Are ambient textures enabled in the application.
  26710. */
  26711. static get AmbientTextureEnabled(): boolean;
  26712. static set AmbientTextureEnabled(value: boolean);
  26713. private static _OpacityTextureEnabled;
  26714. /**
  26715. * Are opacity textures enabled in the application.
  26716. */
  26717. static get OpacityTextureEnabled(): boolean;
  26718. static set OpacityTextureEnabled(value: boolean);
  26719. private static _ReflectionTextureEnabled;
  26720. /**
  26721. * Are reflection textures enabled in the application.
  26722. */
  26723. static get ReflectionTextureEnabled(): boolean;
  26724. static set ReflectionTextureEnabled(value: boolean);
  26725. private static _EmissiveTextureEnabled;
  26726. /**
  26727. * Are emissive textures enabled in the application.
  26728. */
  26729. static get EmissiveTextureEnabled(): boolean;
  26730. static set EmissiveTextureEnabled(value: boolean);
  26731. private static _SpecularTextureEnabled;
  26732. /**
  26733. * Are specular textures enabled in the application.
  26734. */
  26735. static get SpecularTextureEnabled(): boolean;
  26736. static set SpecularTextureEnabled(value: boolean);
  26737. private static _BumpTextureEnabled;
  26738. /**
  26739. * Are bump textures enabled in the application.
  26740. */
  26741. static get BumpTextureEnabled(): boolean;
  26742. static set BumpTextureEnabled(value: boolean);
  26743. private static _LightmapTextureEnabled;
  26744. /**
  26745. * Are lightmap textures enabled in the application.
  26746. */
  26747. static get LightmapTextureEnabled(): boolean;
  26748. static set LightmapTextureEnabled(value: boolean);
  26749. private static _RefractionTextureEnabled;
  26750. /**
  26751. * Are refraction textures enabled in the application.
  26752. */
  26753. static get RefractionTextureEnabled(): boolean;
  26754. static set RefractionTextureEnabled(value: boolean);
  26755. private static _ColorGradingTextureEnabled;
  26756. /**
  26757. * Are color grading textures enabled in the application.
  26758. */
  26759. static get ColorGradingTextureEnabled(): boolean;
  26760. static set ColorGradingTextureEnabled(value: boolean);
  26761. private static _FresnelEnabled;
  26762. /**
  26763. * Are fresnels enabled in the application.
  26764. */
  26765. static get FresnelEnabled(): boolean;
  26766. static set FresnelEnabled(value: boolean);
  26767. private static _ClearCoatTextureEnabled;
  26768. /**
  26769. * Are clear coat textures enabled in the application.
  26770. */
  26771. static get ClearCoatTextureEnabled(): boolean;
  26772. static set ClearCoatTextureEnabled(value: boolean);
  26773. private static _ClearCoatBumpTextureEnabled;
  26774. /**
  26775. * Are clear coat bump textures enabled in the application.
  26776. */
  26777. static get ClearCoatBumpTextureEnabled(): boolean;
  26778. static set ClearCoatBumpTextureEnabled(value: boolean);
  26779. private static _ClearCoatTintTextureEnabled;
  26780. /**
  26781. * Are clear coat tint textures enabled in the application.
  26782. */
  26783. static get ClearCoatTintTextureEnabled(): boolean;
  26784. static set ClearCoatTintTextureEnabled(value: boolean);
  26785. private static _SheenTextureEnabled;
  26786. /**
  26787. * Are sheen textures enabled in the application.
  26788. */
  26789. static get SheenTextureEnabled(): boolean;
  26790. static set SheenTextureEnabled(value: boolean);
  26791. private static _AnisotropicTextureEnabled;
  26792. /**
  26793. * Are anisotropic textures enabled in the application.
  26794. */
  26795. static get AnisotropicTextureEnabled(): boolean;
  26796. static set AnisotropicTextureEnabled(value: boolean);
  26797. private static _ThicknessTextureEnabled;
  26798. /**
  26799. * Are thickness textures enabled in the application.
  26800. */
  26801. static get ThicknessTextureEnabled(): boolean;
  26802. static set ThicknessTextureEnabled(value: boolean);
  26803. }
  26804. }
  26805. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26806. /** @hidden */
  26807. export var defaultFragmentDeclaration: {
  26808. name: string;
  26809. shader: string;
  26810. };
  26811. }
  26812. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26813. /** @hidden */
  26814. export var defaultUboDeclaration: {
  26815. name: string;
  26816. shader: string;
  26817. };
  26818. }
  26819. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26820. /** @hidden */
  26821. export var lightFragmentDeclaration: {
  26822. name: string;
  26823. shader: string;
  26824. };
  26825. }
  26826. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26827. /** @hidden */
  26828. export var lightUboDeclaration: {
  26829. name: string;
  26830. shader: string;
  26831. };
  26832. }
  26833. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26834. /** @hidden */
  26835. export var lightsFragmentFunctions: {
  26836. name: string;
  26837. shader: string;
  26838. };
  26839. }
  26840. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26841. /** @hidden */
  26842. export var shadowsFragmentFunctions: {
  26843. name: string;
  26844. shader: string;
  26845. };
  26846. }
  26847. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26848. /** @hidden */
  26849. export var fresnelFunction: {
  26850. name: string;
  26851. shader: string;
  26852. };
  26853. }
  26854. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26855. /** @hidden */
  26856. export var reflectionFunction: {
  26857. name: string;
  26858. shader: string;
  26859. };
  26860. }
  26861. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  26862. /** @hidden */
  26863. export var bumpFragmentFunctions: {
  26864. name: string;
  26865. shader: string;
  26866. };
  26867. }
  26868. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  26869. /** @hidden */
  26870. export var logDepthDeclaration: {
  26871. name: string;
  26872. shader: string;
  26873. };
  26874. }
  26875. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  26876. /** @hidden */
  26877. export var bumpFragment: {
  26878. name: string;
  26879. shader: string;
  26880. };
  26881. }
  26882. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  26883. /** @hidden */
  26884. export var depthPrePass: {
  26885. name: string;
  26886. shader: string;
  26887. };
  26888. }
  26889. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  26890. /** @hidden */
  26891. export var lightFragment: {
  26892. name: string;
  26893. shader: string;
  26894. };
  26895. }
  26896. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  26897. /** @hidden */
  26898. export var logDepthFragment: {
  26899. name: string;
  26900. shader: string;
  26901. };
  26902. }
  26903. declare module "babylonjs/Shaders/default.fragment" {
  26904. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  26905. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26906. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26907. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26908. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26909. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  26910. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26911. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  26912. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26913. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26914. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26915. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26916. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26917. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26918. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26919. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  26920. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  26921. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  26922. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  26923. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  26924. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  26925. /** @hidden */
  26926. export var defaultPixelShader: {
  26927. name: string;
  26928. shader: string;
  26929. };
  26930. }
  26931. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  26932. /** @hidden */
  26933. export var defaultVertexDeclaration: {
  26934. name: string;
  26935. shader: string;
  26936. };
  26937. }
  26938. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  26939. /** @hidden */
  26940. export var bumpVertexDeclaration: {
  26941. name: string;
  26942. shader: string;
  26943. };
  26944. }
  26945. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  26946. /** @hidden */
  26947. export var bumpVertex: {
  26948. name: string;
  26949. shader: string;
  26950. };
  26951. }
  26952. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  26953. /** @hidden */
  26954. export var fogVertex: {
  26955. name: string;
  26956. shader: string;
  26957. };
  26958. }
  26959. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  26960. /** @hidden */
  26961. export var shadowsVertex: {
  26962. name: string;
  26963. shader: string;
  26964. };
  26965. }
  26966. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  26967. /** @hidden */
  26968. export var pointCloudVertex: {
  26969. name: string;
  26970. shader: string;
  26971. };
  26972. }
  26973. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  26974. /** @hidden */
  26975. export var logDepthVertex: {
  26976. name: string;
  26977. shader: string;
  26978. };
  26979. }
  26980. declare module "babylonjs/Shaders/default.vertex" {
  26981. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  26982. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26983. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26984. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  26985. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  26986. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  26987. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  26988. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  26989. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26990. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26991. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  26992. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  26993. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26994. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  26995. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  26996. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  26997. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  26998. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  26999. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27000. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27001. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  27002. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27003. /** @hidden */
  27004. export var defaultVertexShader: {
  27005. name: string;
  27006. shader: string;
  27007. };
  27008. }
  27009. declare module "babylonjs/Materials/standardMaterial" {
  27010. import { SmartArray } from "babylonjs/Misc/smartArray";
  27011. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27012. import { Nullable } from "babylonjs/types";
  27013. import { Scene } from "babylonjs/scene";
  27014. import { Matrix } from "babylonjs/Maths/math.vector";
  27015. import { Color3 } from "babylonjs/Maths/math.color";
  27016. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27018. import { Mesh } from "babylonjs/Meshes/mesh";
  27019. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27020. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27021. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  27022. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27023. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27024. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27025. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27026. import "babylonjs/Shaders/default.fragment";
  27027. import "babylonjs/Shaders/default.vertex";
  27028. /** @hidden */
  27029. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  27030. MAINUV1: boolean;
  27031. MAINUV2: boolean;
  27032. DIFFUSE: boolean;
  27033. DIFFUSEDIRECTUV: number;
  27034. AMBIENT: boolean;
  27035. AMBIENTDIRECTUV: number;
  27036. OPACITY: boolean;
  27037. OPACITYDIRECTUV: number;
  27038. OPACITYRGB: boolean;
  27039. REFLECTION: boolean;
  27040. EMISSIVE: boolean;
  27041. EMISSIVEDIRECTUV: number;
  27042. SPECULAR: boolean;
  27043. SPECULARDIRECTUV: number;
  27044. BUMP: boolean;
  27045. BUMPDIRECTUV: number;
  27046. PARALLAX: boolean;
  27047. PARALLAXOCCLUSION: boolean;
  27048. SPECULAROVERALPHA: boolean;
  27049. CLIPPLANE: boolean;
  27050. CLIPPLANE2: boolean;
  27051. CLIPPLANE3: boolean;
  27052. CLIPPLANE4: boolean;
  27053. CLIPPLANE5: boolean;
  27054. CLIPPLANE6: boolean;
  27055. ALPHATEST: boolean;
  27056. DEPTHPREPASS: boolean;
  27057. ALPHAFROMDIFFUSE: boolean;
  27058. POINTSIZE: boolean;
  27059. FOG: boolean;
  27060. SPECULARTERM: boolean;
  27061. DIFFUSEFRESNEL: boolean;
  27062. OPACITYFRESNEL: boolean;
  27063. REFLECTIONFRESNEL: boolean;
  27064. REFRACTIONFRESNEL: boolean;
  27065. EMISSIVEFRESNEL: boolean;
  27066. FRESNEL: boolean;
  27067. NORMAL: boolean;
  27068. UV1: boolean;
  27069. UV2: boolean;
  27070. VERTEXCOLOR: boolean;
  27071. VERTEXALPHA: boolean;
  27072. NUM_BONE_INFLUENCERS: number;
  27073. BonesPerMesh: number;
  27074. BONETEXTURE: boolean;
  27075. INSTANCES: boolean;
  27076. GLOSSINESS: boolean;
  27077. ROUGHNESS: boolean;
  27078. EMISSIVEASILLUMINATION: boolean;
  27079. LINKEMISSIVEWITHDIFFUSE: boolean;
  27080. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27081. LIGHTMAP: boolean;
  27082. LIGHTMAPDIRECTUV: number;
  27083. OBJECTSPACE_NORMALMAP: boolean;
  27084. USELIGHTMAPASSHADOWMAP: boolean;
  27085. REFLECTIONMAP_3D: boolean;
  27086. REFLECTIONMAP_SPHERICAL: boolean;
  27087. REFLECTIONMAP_PLANAR: boolean;
  27088. REFLECTIONMAP_CUBIC: boolean;
  27089. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27090. REFLECTIONMAP_PROJECTION: boolean;
  27091. REFLECTIONMAP_SKYBOX: boolean;
  27092. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  27093. REFLECTIONMAP_EXPLICIT: boolean;
  27094. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27095. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27096. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27097. INVERTCUBICMAP: boolean;
  27098. LOGARITHMICDEPTH: boolean;
  27099. REFRACTION: boolean;
  27100. REFRACTIONMAP_3D: boolean;
  27101. REFLECTIONOVERALPHA: boolean;
  27102. TWOSIDEDLIGHTING: boolean;
  27103. SHADOWFLOAT: boolean;
  27104. MORPHTARGETS: boolean;
  27105. MORPHTARGETS_NORMAL: boolean;
  27106. MORPHTARGETS_TANGENT: boolean;
  27107. MORPHTARGETS_UV: boolean;
  27108. NUM_MORPH_INFLUENCERS: number;
  27109. NONUNIFORMSCALING: boolean;
  27110. PREMULTIPLYALPHA: boolean;
  27111. IMAGEPROCESSING: boolean;
  27112. VIGNETTE: boolean;
  27113. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27114. VIGNETTEBLENDMODEOPAQUE: boolean;
  27115. TONEMAPPING: boolean;
  27116. TONEMAPPING_ACES: boolean;
  27117. CONTRAST: boolean;
  27118. COLORCURVES: boolean;
  27119. COLORGRADING: boolean;
  27120. COLORGRADING3D: boolean;
  27121. SAMPLER3DGREENDEPTH: boolean;
  27122. SAMPLER3DBGRMAP: boolean;
  27123. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27124. MULTIVIEW: boolean;
  27125. /**
  27126. * If the reflection texture on this material is in linear color space
  27127. * @hidden
  27128. */
  27129. IS_REFLECTION_LINEAR: boolean;
  27130. /**
  27131. * If the refraction texture on this material is in linear color space
  27132. * @hidden
  27133. */
  27134. IS_REFRACTION_LINEAR: boolean;
  27135. EXPOSURE: boolean;
  27136. constructor();
  27137. setReflectionMode(modeToEnable: string): void;
  27138. }
  27139. /**
  27140. * This is the default material used in Babylon. It is the best trade off between quality
  27141. * and performances.
  27142. * @see http://doc.babylonjs.com/babylon101/materials
  27143. */
  27144. export class StandardMaterial extends PushMaterial {
  27145. private _diffuseTexture;
  27146. /**
  27147. * The basic texture of the material as viewed under a light.
  27148. */
  27149. diffuseTexture: Nullable<BaseTexture>;
  27150. private _ambientTexture;
  27151. /**
  27152. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27153. */
  27154. ambientTexture: Nullable<BaseTexture>;
  27155. private _opacityTexture;
  27156. /**
  27157. * Define the transparency of the material from a texture.
  27158. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27159. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27160. */
  27161. opacityTexture: Nullable<BaseTexture>;
  27162. private _reflectionTexture;
  27163. /**
  27164. * Define the texture used to display the reflection.
  27165. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27166. */
  27167. reflectionTexture: Nullable<BaseTexture>;
  27168. private _emissiveTexture;
  27169. /**
  27170. * Define texture of the material as if self lit.
  27171. * This will be mixed in the final result even in the absence of light.
  27172. */
  27173. emissiveTexture: Nullable<BaseTexture>;
  27174. private _specularTexture;
  27175. /**
  27176. * Define how the color and intensity of the highlight given by the light in the material.
  27177. */
  27178. specularTexture: Nullable<BaseTexture>;
  27179. private _bumpTexture;
  27180. /**
  27181. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27182. * 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.
  27183. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27184. */
  27185. bumpTexture: Nullable<BaseTexture>;
  27186. private _lightmapTexture;
  27187. /**
  27188. * Complex lighting can be computationally expensive to compute at runtime.
  27189. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27190. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27191. */
  27192. lightmapTexture: Nullable<BaseTexture>;
  27193. private _refractionTexture;
  27194. /**
  27195. * Define the texture used to display the refraction.
  27196. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27197. */
  27198. refractionTexture: Nullable<BaseTexture>;
  27199. /**
  27200. * The color of the material lit by the environmental background lighting.
  27201. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27202. */
  27203. ambientColor: Color3;
  27204. /**
  27205. * The basic color of the material as viewed under a light.
  27206. */
  27207. diffuseColor: Color3;
  27208. /**
  27209. * Define how the color and intensity of the highlight given by the light in the material.
  27210. */
  27211. specularColor: Color3;
  27212. /**
  27213. * Define the color of the material as if self lit.
  27214. * This will be mixed in the final result even in the absence of light.
  27215. */
  27216. emissiveColor: Color3;
  27217. /**
  27218. * Defines how sharp are the highlights in the material.
  27219. * The bigger the value the sharper giving a more glossy feeling to the result.
  27220. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27221. */
  27222. specularPower: number;
  27223. private _useAlphaFromDiffuseTexture;
  27224. /**
  27225. * Does the transparency come from the diffuse texture alpha channel.
  27226. */
  27227. useAlphaFromDiffuseTexture: boolean;
  27228. private _useEmissiveAsIllumination;
  27229. /**
  27230. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27231. */
  27232. useEmissiveAsIllumination: boolean;
  27233. private _linkEmissiveWithDiffuse;
  27234. /**
  27235. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27236. * the emissive level when the final color is close to one.
  27237. */
  27238. linkEmissiveWithDiffuse: boolean;
  27239. private _useSpecularOverAlpha;
  27240. /**
  27241. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27242. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27243. */
  27244. useSpecularOverAlpha: boolean;
  27245. private _useReflectionOverAlpha;
  27246. /**
  27247. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27248. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27249. */
  27250. useReflectionOverAlpha: boolean;
  27251. private _disableLighting;
  27252. /**
  27253. * Does lights from the scene impacts this material.
  27254. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27255. */
  27256. disableLighting: boolean;
  27257. private _useObjectSpaceNormalMap;
  27258. /**
  27259. * Allows using an object space normal map (instead of tangent space).
  27260. */
  27261. useObjectSpaceNormalMap: boolean;
  27262. private _useParallax;
  27263. /**
  27264. * Is parallax enabled or not.
  27265. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27266. */
  27267. useParallax: boolean;
  27268. private _useParallaxOcclusion;
  27269. /**
  27270. * Is parallax occlusion enabled or not.
  27271. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27272. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27273. */
  27274. useParallaxOcclusion: boolean;
  27275. /**
  27276. * 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.
  27277. */
  27278. parallaxScaleBias: number;
  27279. private _roughness;
  27280. /**
  27281. * Helps to define how blurry the reflections should appears in the material.
  27282. */
  27283. roughness: number;
  27284. /**
  27285. * In case of refraction, define the value of the index of refraction.
  27286. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27287. */
  27288. indexOfRefraction: number;
  27289. /**
  27290. * Invert the refraction texture alongside the y axis.
  27291. * It can be useful with procedural textures or probe for instance.
  27292. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27293. */
  27294. invertRefractionY: boolean;
  27295. /**
  27296. * Defines the alpha limits in alpha test mode.
  27297. */
  27298. alphaCutOff: number;
  27299. private _useLightmapAsShadowmap;
  27300. /**
  27301. * In case of light mapping, define whether the map contains light or shadow informations.
  27302. */
  27303. useLightmapAsShadowmap: boolean;
  27304. private _diffuseFresnelParameters;
  27305. /**
  27306. * Define the diffuse fresnel parameters of the material.
  27307. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27308. */
  27309. diffuseFresnelParameters: FresnelParameters;
  27310. private _opacityFresnelParameters;
  27311. /**
  27312. * Define the opacity fresnel parameters of the material.
  27313. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27314. */
  27315. opacityFresnelParameters: FresnelParameters;
  27316. private _reflectionFresnelParameters;
  27317. /**
  27318. * Define the reflection fresnel parameters of the material.
  27319. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27320. */
  27321. reflectionFresnelParameters: FresnelParameters;
  27322. private _refractionFresnelParameters;
  27323. /**
  27324. * Define the refraction fresnel parameters of the material.
  27325. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27326. */
  27327. refractionFresnelParameters: FresnelParameters;
  27328. private _emissiveFresnelParameters;
  27329. /**
  27330. * Define the emissive fresnel parameters of the material.
  27331. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27332. */
  27333. emissiveFresnelParameters: FresnelParameters;
  27334. private _useReflectionFresnelFromSpecular;
  27335. /**
  27336. * If true automatically deducts the fresnels values from the material specularity.
  27337. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27338. */
  27339. useReflectionFresnelFromSpecular: boolean;
  27340. private _useGlossinessFromSpecularMapAlpha;
  27341. /**
  27342. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27343. */
  27344. useGlossinessFromSpecularMapAlpha: boolean;
  27345. private _maxSimultaneousLights;
  27346. /**
  27347. * Defines the maximum number of lights that can be used in the material
  27348. */
  27349. maxSimultaneousLights: number;
  27350. private _invertNormalMapX;
  27351. /**
  27352. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27353. */
  27354. invertNormalMapX: boolean;
  27355. private _invertNormalMapY;
  27356. /**
  27357. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27358. */
  27359. invertNormalMapY: boolean;
  27360. private _twoSidedLighting;
  27361. /**
  27362. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27363. */
  27364. twoSidedLighting: boolean;
  27365. /**
  27366. * Default configuration related to image processing available in the standard Material.
  27367. */
  27368. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27369. /**
  27370. * Gets the image processing configuration used either in this material.
  27371. */
  27372. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27373. /**
  27374. * Sets the Default image processing configuration used either in the this material.
  27375. *
  27376. * If sets to null, the scene one is in use.
  27377. */
  27378. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27379. /**
  27380. * Keep track of the image processing observer to allow dispose and replace.
  27381. */
  27382. private _imageProcessingObserver;
  27383. /**
  27384. * Attaches a new image processing configuration to the Standard Material.
  27385. * @param configuration
  27386. */
  27387. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27388. /**
  27389. * Gets wether the color curves effect is enabled.
  27390. */
  27391. get cameraColorCurvesEnabled(): boolean;
  27392. /**
  27393. * Sets wether the color curves effect is enabled.
  27394. */
  27395. set cameraColorCurvesEnabled(value: boolean);
  27396. /**
  27397. * Gets wether the color grading effect is enabled.
  27398. */
  27399. get cameraColorGradingEnabled(): boolean;
  27400. /**
  27401. * Gets wether the color grading effect is enabled.
  27402. */
  27403. set cameraColorGradingEnabled(value: boolean);
  27404. /**
  27405. * Gets wether tonemapping is enabled or not.
  27406. */
  27407. get cameraToneMappingEnabled(): boolean;
  27408. /**
  27409. * Sets wether tonemapping is enabled or not
  27410. */
  27411. set cameraToneMappingEnabled(value: boolean);
  27412. /**
  27413. * The camera exposure used on this material.
  27414. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27415. * This corresponds to a photographic exposure.
  27416. */
  27417. get cameraExposure(): number;
  27418. /**
  27419. * The camera exposure used on this material.
  27420. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27421. * This corresponds to a photographic exposure.
  27422. */
  27423. set cameraExposure(value: number);
  27424. /**
  27425. * Gets The camera contrast used on this material.
  27426. */
  27427. get cameraContrast(): number;
  27428. /**
  27429. * Sets The camera contrast used on this material.
  27430. */
  27431. set cameraContrast(value: number);
  27432. /**
  27433. * Gets the Color Grading 2D Lookup Texture.
  27434. */
  27435. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27436. /**
  27437. * Sets the Color Grading 2D Lookup Texture.
  27438. */
  27439. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27440. /**
  27441. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27442. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27443. * 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;
  27444. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27445. */
  27446. get cameraColorCurves(): Nullable<ColorCurves>;
  27447. /**
  27448. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27449. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27450. * 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;
  27451. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27452. */
  27453. set cameraColorCurves(value: Nullable<ColorCurves>);
  27454. /**
  27455. * Custom callback helping to override the default shader used in the material.
  27456. */
  27457. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27458. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27459. protected _worldViewProjectionMatrix: Matrix;
  27460. protected _globalAmbientColor: Color3;
  27461. protected _useLogarithmicDepth: boolean;
  27462. protected _rebuildInParallel: boolean;
  27463. /**
  27464. * Instantiates a new standard material.
  27465. * This is the default material used in Babylon. It is the best trade off between quality
  27466. * and performances.
  27467. * @see http://doc.babylonjs.com/babylon101/materials
  27468. * @param name Define the name of the material in the scene
  27469. * @param scene Define the scene the material belong to
  27470. */
  27471. constructor(name: string, scene: Scene);
  27472. /**
  27473. * Gets a boolean indicating that current material needs to register RTT
  27474. */
  27475. get hasRenderTargetTextures(): boolean;
  27476. /**
  27477. * Gets the current class name of the material e.g. "StandardMaterial"
  27478. * Mainly use in serialization.
  27479. * @returns the class name
  27480. */
  27481. getClassName(): string;
  27482. /**
  27483. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27484. * You can try switching to logarithmic depth.
  27485. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27486. */
  27487. get useLogarithmicDepth(): boolean;
  27488. set useLogarithmicDepth(value: boolean);
  27489. /**
  27490. * Specifies if the material will require alpha blending
  27491. * @returns a boolean specifying if alpha blending is needed
  27492. */
  27493. needAlphaBlending(): boolean;
  27494. /**
  27495. * Specifies if this material should be rendered in alpha test mode
  27496. * @returns a boolean specifying if an alpha test is needed.
  27497. */
  27498. needAlphaTesting(): boolean;
  27499. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27500. /**
  27501. * Get the texture used for alpha test purpose.
  27502. * @returns the diffuse texture in case of the standard material.
  27503. */
  27504. getAlphaTestTexture(): Nullable<BaseTexture>;
  27505. /**
  27506. * Get if the submesh is ready to be used and all its information available.
  27507. * Child classes can use it to update shaders
  27508. * @param mesh defines the mesh to check
  27509. * @param subMesh defines which submesh to check
  27510. * @param useInstances specifies that instances should be used
  27511. * @returns a boolean indicating that the submesh is ready or not
  27512. */
  27513. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27514. /**
  27515. * Builds the material UBO layouts.
  27516. * Used internally during the effect preparation.
  27517. */
  27518. buildUniformLayout(): void;
  27519. /**
  27520. * Unbinds the material from the mesh
  27521. */
  27522. unbind(): void;
  27523. /**
  27524. * Binds the submesh to this material by preparing the effect and shader to draw
  27525. * @param world defines the world transformation matrix
  27526. * @param mesh defines the mesh containing the submesh
  27527. * @param subMesh defines the submesh to bind the material to
  27528. */
  27529. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27530. /**
  27531. * Get the list of animatables in the material.
  27532. * @returns the list of animatables object used in the material
  27533. */
  27534. getAnimatables(): IAnimatable[];
  27535. /**
  27536. * Gets the active textures from the material
  27537. * @returns an array of textures
  27538. */
  27539. getActiveTextures(): BaseTexture[];
  27540. /**
  27541. * Specifies if the material uses a texture
  27542. * @param texture defines the texture to check against the material
  27543. * @returns a boolean specifying if the material uses the texture
  27544. */
  27545. hasTexture(texture: BaseTexture): boolean;
  27546. /**
  27547. * Disposes the material
  27548. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27549. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27550. */
  27551. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27552. /**
  27553. * Makes a duplicate of the material, and gives it a new name
  27554. * @param name defines the new name for the duplicated material
  27555. * @returns the cloned material
  27556. */
  27557. clone(name: string): StandardMaterial;
  27558. /**
  27559. * Serializes this material in a JSON representation
  27560. * @returns the serialized material object
  27561. */
  27562. serialize(): any;
  27563. /**
  27564. * Creates a standard material from parsed material data
  27565. * @param source defines the JSON representation of the material
  27566. * @param scene defines the hosting scene
  27567. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27568. * @returns a new standard material
  27569. */
  27570. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27571. /**
  27572. * Are diffuse textures enabled in the application.
  27573. */
  27574. static get DiffuseTextureEnabled(): boolean;
  27575. static set DiffuseTextureEnabled(value: boolean);
  27576. /**
  27577. * Are ambient textures enabled in the application.
  27578. */
  27579. static get AmbientTextureEnabled(): boolean;
  27580. static set AmbientTextureEnabled(value: boolean);
  27581. /**
  27582. * Are opacity textures enabled in the application.
  27583. */
  27584. static get OpacityTextureEnabled(): boolean;
  27585. static set OpacityTextureEnabled(value: boolean);
  27586. /**
  27587. * Are reflection textures enabled in the application.
  27588. */
  27589. static get ReflectionTextureEnabled(): boolean;
  27590. static set ReflectionTextureEnabled(value: boolean);
  27591. /**
  27592. * Are emissive textures enabled in the application.
  27593. */
  27594. static get EmissiveTextureEnabled(): boolean;
  27595. static set EmissiveTextureEnabled(value: boolean);
  27596. /**
  27597. * Are specular textures enabled in the application.
  27598. */
  27599. static get SpecularTextureEnabled(): boolean;
  27600. static set SpecularTextureEnabled(value: boolean);
  27601. /**
  27602. * Are bump textures enabled in the application.
  27603. */
  27604. static get BumpTextureEnabled(): boolean;
  27605. static set BumpTextureEnabled(value: boolean);
  27606. /**
  27607. * Are lightmap textures enabled in the application.
  27608. */
  27609. static get LightmapTextureEnabled(): boolean;
  27610. static set LightmapTextureEnabled(value: boolean);
  27611. /**
  27612. * Are refraction textures enabled in the application.
  27613. */
  27614. static get RefractionTextureEnabled(): boolean;
  27615. static set RefractionTextureEnabled(value: boolean);
  27616. /**
  27617. * Are color grading textures enabled in the application.
  27618. */
  27619. static get ColorGradingTextureEnabled(): boolean;
  27620. static set ColorGradingTextureEnabled(value: boolean);
  27621. /**
  27622. * Are fresnels enabled in the application.
  27623. */
  27624. static get FresnelEnabled(): boolean;
  27625. static set FresnelEnabled(value: boolean);
  27626. }
  27627. }
  27628. declare module "babylonjs/Particles/solidParticleSystem" {
  27629. import { Nullable } from "babylonjs/types";
  27630. import { Vector3 } from "babylonjs/Maths/math.vector";
  27631. import { Mesh } from "babylonjs/Meshes/mesh";
  27632. import { Scene, IDisposable } from "babylonjs/scene";
  27633. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27634. import { Material } from "babylonjs/Materials/material";
  27635. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27636. /**
  27637. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27638. *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.
  27639. * The SPS is also a particle system. It provides some methods to manage the particles.
  27640. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27641. *
  27642. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27643. */
  27644. export class SolidParticleSystem implements IDisposable {
  27645. /**
  27646. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27647. * Example : var p = SPS.particles[i];
  27648. */
  27649. particles: SolidParticle[];
  27650. /**
  27651. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27652. */
  27653. nbParticles: number;
  27654. /**
  27655. * If the particles must ever face the camera (default false). Useful for planar particles.
  27656. */
  27657. billboard: boolean;
  27658. /**
  27659. * Recompute normals when adding a shape
  27660. */
  27661. recomputeNormals: boolean;
  27662. /**
  27663. * This a counter ofr your own usage. It's not set by any SPS functions.
  27664. */
  27665. counter: number;
  27666. /**
  27667. * The SPS name. This name is also given to the underlying mesh.
  27668. */
  27669. name: string;
  27670. /**
  27671. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27672. */
  27673. mesh: Mesh;
  27674. /**
  27675. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27676. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27677. */
  27678. vars: any;
  27679. /**
  27680. * This array is populated when the SPS is set as 'pickable'.
  27681. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27682. * Each element of this array is an object `{idx: int, faceId: int}`.
  27683. * `idx` is the picked particle index in the `SPS.particles` array
  27684. * `faceId` is the picked face index counted within this particle.
  27685. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27686. */
  27687. pickedParticles: {
  27688. idx: number;
  27689. faceId: number;
  27690. }[];
  27691. /**
  27692. * This array is populated when `enableDepthSort` is set to true.
  27693. * Each element of this array is an instance of the class DepthSortedParticle.
  27694. */
  27695. depthSortedParticles: DepthSortedParticle[];
  27696. /**
  27697. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27698. * @hidden
  27699. */
  27700. _bSphereOnly: boolean;
  27701. /**
  27702. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27703. * @hidden
  27704. */
  27705. _bSphereRadiusFactor: number;
  27706. private _scene;
  27707. private _positions;
  27708. private _indices;
  27709. private _normals;
  27710. private _colors;
  27711. private _uvs;
  27712. private _indices32;
  27713. private _positions32;
  27714. private _normals32;
  27715. private _fixedNormal32;
  27716. private _colors32;
  27717. private _uvs32;
  27718. private _index;
  27719. private _updatable;
  27720. private _pickable;
  27721. private _isVisibilityBoxLocked;
  27722. private _alwaysVisible;
  27723. private _depthSort;
  27724. private _expandable;
  27725. private _shapeCounter;
  27726. private _copy;
  27727. private _color;
  27728. private _computeParticleColor;
  27729. private _computeParticleTexture;
  27730. private _computeParticleRotation;
  27731. private _computeParticleVertex;
  27732. private _computeBoundingBox;
  27733. private _depthSortParticles;
  27734. private _camera;
  27735. private _mustUnrotateFixedNormals;
  27736. private _particlesIntersect;
  27737. private _needs32Bits;
  27738. private _isNotBuilt;
  27739. private _lastParticleId;
  27740. private _idxOfId;
  27741. private _multimaterialEnabled;
  27742. private _useModelMaterial;
  27743. private _indicesByMaterial;
  27744. private _materialIndexes;
  27745. private _depthSortFunction;
  27746. private _materialSortFunction;
  27747. private _materials;
  27748. private _multimaterial;
  27749. private _materialIndexesById;
  27750. private _defaultMaterial;
  27751. private _autoUpdateSubMeshes;
  27752. /**
  27753. * Creates a SPS (Solid Particle System) object.
  27754. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27755. * @param scene (Scene) is the scene in which the SPS is added.
  27756. * @param options defines the options of the sps e.g.
  27757. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27758. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27759. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27760. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  27761. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27762. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27763. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27764. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27765. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27766. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27767. */
  27768. constructor(name: string, scene: Scene, options?: {
  27769. updatable?: boolean;
  27770. isPickable?: boolean;
  27771. enableDepthSort?: boolean;
  27772. particleIntersection?: boolean;
  27773. boundingSphereOnly?: boolean;
  27774. bSphereRadiusFactor?: number;
  27775. expandable?: boolean;
  27776. useModelMaterial?: boolean;
  27777. enableMultiMaterial?: boolean;
  27778. });
  27779. /**
  27780. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27781. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27782. * @returns the created mesh
  27783. */
  27784. buildMesh(): Mesh;
  27785. /**
  27786. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27787. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27788. * Thus the particles generated from `digest()` have their property `position` set yet.
  27789. * @param mesh ( Mesh ) is the mesh to be digested
  27790. * @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
  27791. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27792. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27793. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27794. * @returns the current SPS
  27795. */
  27796. digest(mesh: Mesh, options?: {
  27797. facetNb?: number;
  27798. number?: number;
  27799. delta?: number;
  27800. storage?: [];
  27801. }): SolidParticleSystem;
  27802. /**
  27803. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27804. * @hidden
  27805. */
  27806. private _unrotateFixedNormals;
  27807. /**
  27808. * Resets the temporary working copy particle
  27809. * @hidden
  27810. */
  27811. private _resetCopy;
  27812. /**
  27813. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27814. * @param p the current index in the positions array to be updated
  27815. * @param ind the current index in the indices array
  27816. * @param shape a Vector3 array, the shape geometry
  27817. * @param positions the positions array to be updated
  27818. * @param meshInd the shape indices array
  27819. * @param indices the indices array to be updated
  27820. * @param meshUV the shape uv array
  27821. * @param uvs the uv array to be updated
  27822. * @param meshCol the shape color array
  27823. * @param colors the color array to be updated
  27824. * @param meshNor the shape normals array
  27825. * @param normals the normals array to be updated
  27826. * @param idx the particle index
  27827. * @param idxInShape the particle index in its shape
  27828. * @param options the addShape() method passed options
  27829. * @model the particle model
  27830. * @hidden
  27831. */
  27832. private _meshBuilder;
  27833. /**
  27834. * Returns a shape Vector3 array from positions float array
  27835. * @param positions float array
  27836. * @returns a vector3 array
  27837. * @hidden
  27838. */
  27839. private _posToShape;
  27840. /**
  27841. * Returns a shapeUV array from a float uvs (array deep copy)
  27842. * @param uvs as a float array
  27843. * @returns a shapeUV array
  27844. * @hidden
  27845. */
  27846. private _uvsToShapeUV;
  27847. /**
  27848. * Adds a new particle object in the particles array
  27849. * @param idx particle index in particles array
  27850. * @param id particle id
  27851. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27852. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27853. * @param model particle ModelShape object
  27854. * @param shapeId model shape identifier
  27855. * @param idxInShape index of the particle in the current model
  27856. * @param bInfo model bounding info object
  27857. * @param storage target storage array, if any
  27858. * @hidden
  27859. */
  27860. private _addParticle;
  27861. /**
  27862. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27863. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27864. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27865. * @param nb (positive integer) the number of particles to be created from this model
  27866. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27867. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27868. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27869. * @returns the number of shapes in the system
  27870. */
  27871. addShape(mesh: Mesh, nb: number, options?: {
  27872. positionFunction?: any;
  27873. vertexFunction?: any;
  27874. storage?: [];
  27875. }): number;
  27876. /**
  27877. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27878. * @hidden
  27879. */
  27880. private _rebuildParticle;
  27881. /**
  27882. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27883. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  27884. * @returns the SPS.
  27885. */
  27886. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27887. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27888. * Returns an array with the removed particles.
  27889. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  27890. * The SPS can't be empty so at least one particle needs to remain in place.
  27891. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27892. * @param start index of the first particle to remove
  27893. * @param end index of the last particle to remove (included)
  27894. * @returns an array populated with the removed particles
  27895. */
  27896. removeParticles(start: number, end: number): SolidParticle[];
  27897. /**
  27898. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27899. * @param solidParticleArray an array populated with Solid Particles objects
  27900. * @returns the SPS
  27901. */
  27902. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27903. /**
  27904. * Creates a new particle and modifies the SPS mesh geometry :
  27905. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27906. * - calls _addParticle() to populate the particle array
  27907. * factorized code from addShape() and insertParticlesFromArray()
  27908. * @param idx particle index in the particles array
  27909. * @param i particle index in its shape
  27910. * @param modelShape particle ModelShape object
  27911. * @param shape shape vertex array
  27912. * @param meshInd shape indices array
  27913. * @param meshUV shape uv array
  27914. * @param meshCol shape color array
  27915. * @param meshNor shape normals array
  27916. * @param bbInfo shape bounding info
  27917. * @param storage target particle storage
  27918. * @options addShape() passed options
  27919. * @hidden
  27920. */
  27921. private _insertNewParticle;
  27922. /**
  27923. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27924. * This method calls `updateParticle()` for each particle of the SPS.
  27925. * For an animated SPS, it is usually called within the render loop.
  27926. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  27927. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27928. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27929. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27930. * @returns the SPS.
  27931. */
  27932. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27933. /**
  27934. * Disposes the SPS.
  27935. */
  27936. dispose(): void;
  27937. /**
  27938. * Returns a SolidParticle object from its identifier : particle.id
  27939. * @param id (integer) the particle Id
  27940. * @returns the searched particle or null if not found in the SPS.
  27941. */
  27942. getParticleById(id: number): Nullable<SolidParticle>;
  27943. /**
  27944. * Returns a new array populated with the particles having the passed shapeId.
  27945. * @param shapeId (integer) the shape identifier
  27946. * @returns a new solid particle array
  27947. */
  27948. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27949. /**
  27950. * Populates the passed array "ref" with the particles having the passed shapeId.
  27951. * @param shapeId the shape identifier
  27952. * @returns the SPS
  27953. * @param ref
  27954. */
  27955. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27956. /**
  27957. * Computes the required SubMeshes according the materials assigned to the particles.
  27958. * @returns the solid particle system.
  27959. * Does nothing if called before the SPS mesh is built.
  27960. */
  27961. computeSubMeshes(): SolidParticleSystem;
  27962. /**
  27963. * Sorts the solid particles by material when MultiMaterial is enabled.
  27964. * Updates the indices32 array.
  27965. * Updates the indicesByMaterial array.
  27966. * Updates the mesh indices array.
  27967. * @returns the SPS
  27968. * @hidden
  27969. */
  27970. private _sortParticlesByMaterial;
  27971. /**
  27972. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27973. * @hidden
  27974. */
  27975. private _setMaterialIndexesById;
  27976. /**
  27977. * Returns an array with unique values of Materials from the passed array
  27978. * @param array the material array to be checked and filtered
  27979. * @hidden
  27980. */
  27981. private _filterUniqueMaterialId;
  27982. /**
  27983. * Sets a new Standard Material as _defaultMaterial if not already set.
  27984. * @hidden
  27985. */
  27986. private _setDefaultMaterial;
  27987. /**
  27988. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27989. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27990. * @returns the SPS.
  27991. */
  27992. refreshVisibleSize(): SolidParticleSystem;
  27993. /**
  27994. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27995. * @param size the size (float) of the visibility box
  27996. * note : this doesn't lock the SPS mesh bounding box.
  27997. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27998. */
  27999. setVisibilityBox(size: number): void;
  28000. /**
  28001. * Gets whether the SPS as always visible or not
  28002. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28003. */
  28004. get isAlwaysVisible(): boolean;
  28005. /**
  28006. * Sets the SPS as always visible or not
  28007. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28008. */
  28009. set isAlwaysVisible(val: boolean);
  28010. /**
  28011. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28012. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28013. */
  28014. set isVisibilityBoxLocked(val: boolean);
  28015. /**
  28016. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28017. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28018. */
  28019. get isVisibilityBoxLocked(): boolean;
  28020. /**
  28021. * Tells to `setParticles()` to compute the particle rotations or not.
  28022. * Default value : true. The SPS is faster when it's set to false.
  28023. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28024. */
  28025. set computeParticleRotation(val: boolean);
  28026. /**
  28027. * Tells to `setParticles()` to compute the particle colors or not.
  28028. * Default value : true. The SPS is faster when it's set to false.
  28029. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28030. */
  28031. set computeParticleColor(val: boolean);
  28032. set computeParticleTexture(val: boolean);
  28033. /**
  28034. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  28035. * Default value : false. The SPS is faster when it's set to false.
  28036. * Note : the particle custom vertex positions aren't stored values.
  28037. */
  28038. set computeParticleVertex(val: boolean);
  28039. /**
  28040. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  28041. */
  28042. set computeBoundingBox(val: boolean);
  28043. /**
  28044. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  28045. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28046. * Default : `true`
  28047. */
  28048. set depthSortParticles(val: boolean);
  28049. /**
  28050. * Gets if `setParticles()` computes the particle rotations or not.
  28051. * Default value : true. The SPS is faster when it's set to false.
  28052. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28053. */
  28054. get computeParticleRotation(): boolean;
  28055. /**
  28056. * Gets if `setParticles()` computes the particle colors or not.
  28057. * Default value : true. The SPS is faster when it's set to false.
  28058. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28059. */
  28060. get computeParticleColor(): boolean;
  28061. /**
  28062. * Gets if `setParticles()` computes the particle textures or not.
  28063. * Default value : true. The SPS is faster when it's set to false.
  28064. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28065. */
  28066. get computeParticleTexture(): boolean;
  28067. /**
  28068. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28069. * Default value : false. The SPS is faster when it's set to false.
  28070. * Note : the particle custom vertex positions aren't stored values.
  28071. */
  28072. get computeParticleVertex(): boolean;
  28073. /**
  28074. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28075. */
  28076. get computeBoundingBox(): boolean;
  28077. /**
  28078. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28079. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28080. * Default : `true`
  28081. */
  28082. get depthSortParticles(): boolean;
  28083. /**
  28084. * Gets if the SPS is created as expandable at construction time.
  28085. * Default : `false`
  28086. */
  28087. get expandable(): boolean;
  28088. /**
  28089. * Gets if the SPS supports the Multi Materials
  28090. */
  28091. get multimaterialEnabled(): boolean;
  28092. /**
  28093. * Gets if the SPS uses the model materials for its own multimaterial.
  28094. */
  28095. get useModelMaterial(): boolean;
  28096. /**
  28097. * The SPS used material array.
  28098. */
  28099. get materials(): Material[];
  28100. /**
  28101. * Sets the SPS MultiMaterial from the passed materials.
  28102. * Note : the passed array is internally copied and not used then by reference.
  28103. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28104. */
  28105. setMultiMaterial(materials: Material[]): void;
  28106. /**
  28107. * The SPS computed multimaterial object
  28108. */
  28109. get multimaterial(): MultiMaterial;
  28110. set multimaterial(mm: MultiMaterial);
  28111. /**
  28112. * If the subMeshes must be updated on the next call to setParticles()
  28113. */
  28114. get autoUpdateSubMeshes(): boolean;
  28115. set autoUpdateSubMeshes(val: boolean);
  28116. /**
  28117. * This function does nothing. It may be overwritten to set all the particle first values.
  28118. * The SPS doesn't call this function, you may have to call it by your own.
  28119. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28120. */
  28121. initParticles(): void;
  28122. /**
  28123. * This function does nothing. It may be overwritten to recycle a particle.
  28124. * The SPS doesn't call this function, you may have to call it by your own.
  28125. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28126. * @param particle The particle to recycle
  28127. * @returns the recycled particle
  28128. */
  28129. recycleParticle(particle: SolidParticle): SolidParticle;
  28130. /**
  28131. * Updates a particle : this function should be overwritten by the user.
  28132. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28133. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28134. * @example : just set a particle position or velocity and recycle conditions
  28135. * @param particle The particle to update
  28136. * @returns the updated particle
  28137. */
  28138. updateParticle(particle: SolidParticle): SolidParticle;
  28139. /**
  28140. * Updates a vertex of a particle : it can be overwritten by the user.
  28141. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28142. * @param particle the current particle
  28143. * @param vertex the current index of the current particle
  28144. * @param pt the index of the current vertex in the particle shape
  28145. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28146. * @example : just set a vertex particle position
  28147. * @returns the updated vertex
  28148. */
  28149. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  28150. /**
  28151. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28152. * This does nothing and may be overwritten by the user.
  28153. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28154. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28155. * @param update the boolean update value actually passed to setParticles()
  28156. */
  28157. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28158. /**
  28159. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28160. * This will be passed three parameters.
  28161. * This does nothing and may be overwritten by the user.
  28162. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28163. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28164. * @param update the boolean update value actually passed to setParticles()
  28165. */
  28166. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28167. }
  28168. }
  28169. declare module "babylonjs/Particles/solidParticle" {
  28170. import { Nullable } from "babylonjs/types";
  28171. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28172. import { Color4 } from "babylonjs/Maths/math.color";
  28173. import { Mesh } from "babylonjs/Meshes/mesh";
  28174. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28175. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28176. import { Plane } from "babylonjs/Maths/math.plane";
  28177. import { Material } from "babylonjs/Materials/material";
  28178. /**
  28179. * Represents one particle of a solid particle system.
  28180. */
  28181. export class SolidParticle {
  28182. /**
  28183. * particle global index
  28184. */
  28185. idx: number;
  28186. /**
  28187. * particle identifier
  28188. */
  28189. id: number;
  28190. /**
  28191. * The color of the particle
  28192. */
  28193. color: Nullable<Color4>;
  28194. /**
  28195. * The world space position of the particle.
  28196. */
  28197. position: Vector3;
  28198. /**
  28199. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28200. */
  28201. rotation: Vector3;
  28202. /**
  28203. * The world space rotation quaternion of the particle.
  28204. */
  28205. rotationQuaternion: Nullable<Quaternion>;
  28206. /**
  28207. * The scaling of the particle.
  28208. */
  28209. scaling: Vector3;
  28210. /**
  28211. * The uvs of the particle.
  28212. */
  28213. uvs: Vector4;
  28214. /**
  28215. * The current speed of the particle.
  28216. */
  28217. velocity: Vector3;
  28218. /**
  28219. * The pivot point in the particle local space.
  28220. */
  28221. pivot: Vector3;
  28222. /**
  28223. * Must the particle be translated from its pivot point in its local space ?
  28224. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28225. * Default : false
  28226. */
  28227. translateFromPivot: boolean;
  28228. /**
  28229. * Is the particle active or not ?
  28230. */
  28231. alive: boolean;
  28232. /**
  28233. * Is the particle visible or not ?
  28234. */
  28235. isVisible: boolean;
  28236. /**
  28237. * Index of this particle in the global "positions" array (Internal use)
  28238. * @hidden
  28239. */
  28240. _pos: number;
  28241. /**
  28242. * @hidden Index of this particle in the global "indices" array (Internal use)
  28243. */
  28244. _ind: number;
  28245. /**
  28246. * @hidden ModelShape of this particle (Internal use)
  28247. */
  28248. _model: ModelShape;
  28249. /**
  28250. * ModelShape id of this particle
  28251. */
  28252. shapeId: number;
  28253. /**
  28254. * Index of the particle in its shape id
  28255. */
  28256. idxInShape: number;
  28257. /**
  28258. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28259. */
  28260. _modelBoundingInfo: BoundingInfo;
  28261. /**
  28262. * @hidden Particle BoundingInfo object (Internal use)
  28263. */
  28264. _boundingInfo: BoundingInfo;
  28265. /**
  28266. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28267. */
  28268. _sps: SolidParticleSystem;
  28269. /**
  28270. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28271. */
  28272. _stillInvisible: boolean;
  28273. /**
  28274. * @hidden Last computed particle rotation matrix
  28275. */
  28276. _rotationMatrix: number[];
  28277. /**
  28278. * Parent particle Id, if any.
  28279. * Default null.
  28280. */
  28281. parentId: Nullable<number>;
  28282. /**
  28283. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28284. */
  28285. materialIndex: Nullable<number>;
  28286. /**
  28287. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28288. * The possible values are :
  28289. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28290. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28291. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28292. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28293. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28294. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28295. * */
  28296. cullingStrategy: number;
  28297. /**
  28298. * @hidden Internal global position in the SPS.
  28299. */
  28300. _globalPosition: Vector3;
  28301. /**
  28302. * Creates a Solid Particle object.
  28303. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28304. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28305. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28306. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28307. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28308. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28309. * @param shapeId (integer) is the model shape identifier in the SPS.
  28310. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28311. * @param sps defines the sps it is associated to
  28312. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28313. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28314. */
  28315. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28316. /**
  28317. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28318. * @param target the particle target
  28319. * @returns the current particle
  28320. */
  28321. copyToRef(target: SolidParticle): SolidParticle;
  28322. /**
  28323. * Legacy support, changed scale to scaling
  28324. */
  28325. get scale(): Vector3;
  28326. /**
  28327. * Legacy support, changed scale to scaling
  28328. */
  28329. set scale(scale: Vector3);
  28330. /**
  28331. * Legacy support, changed quaternion to rotationQuaternion
  28332. */
  28333. get quaternion(): Nullable<Quaternion>;
  28334. /**
  28335. * Legacy support, changed quaternion to rotationQuaternion
  28336. */
  28337. set quaternion(q: Nullable<Quaternion>);
  28338. /**
  28339. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28340. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28341. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28342. * @returns true if it intersects
  28343. */
  28344. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28345. /**
  28346. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28347. * A particle is in the frustum if its bounding box intersects the frustum
  28348. * @param frustumPlanes defines the frustum to test
  28349. * @returns true if the particle is in the frustum planes
  28350. */
  28351. isInFrustum(frustumPlanes: Plane[]): boolean;
  28352. /**
  28353. * get the rotation matrix of the particle
  28354. * @hidden
  28355. */
  28356. getRotationMatrix(m: Matrix): void;
  28357. }
  28358. /**
  28359. * Represents the shape of the model used by one particle of a solid particle system.
  28360. * SPS internal tool, don't use it manually.
  28361. */
  28362. export class ModelShape {
  28363. /**
  28364. * The shape id
  28365. * @hidden
  28366. */
  28367. shapeID: number;
  28368. /**
  28369. * flat array of model positions (internal use)
  28370. * @hidden
  28371. */
  28372. _shape: Vector3[];
  28373. /**
  28374. * flat array of model UVs (internal use)
  28375. * @hidden
  28376. */
  28377. _shapeUV: number[];
  28378. /**
  28379. * color array of the model
  28380. * @hidden
  28381. */
  28382. _shapeColors: number[];
  28383. /**
  28384. * indices array of the model
  28385. * @hidden
  28386. */
  28387. _indices: number[];
  28388. /**
  28389. * normals array of the model
  28390. * @hidden
  28391. */
  28392. _normals: number[];
  28393. /**
  28394. * length of the shape in the model indices array (internal use)
  28395. * @hidden
  28396. */
  28397. _indicesLength: number;
  28398. /**
  28399. * Custom position function (internal use)
  28400. * @hidden
  28401. */
  28402. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28403. /**
  28404. * Custom vertex function (internal use)
  28405. * @hidden
  28406. */
  28407. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28408. /**
  28409. * Model material (internal use)
  28410. * @hidden
  28411. */
  28412. _material: Nullable<Material>;
  28413. /**
  28414. * 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.
  28415. * SPS internal tool, don't use it manually.
  28416. * @hidden
  28417. */
  28418. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  28419. }
  28420. /**
  28421. * Represents a Depth Sorted Particle in the solid particle system.
  28422. * @hidden
  28423. */
  28424. export class DepthSortedParticle {
  28425. /**
  28426. * Index of the particle in the "indices" array
  28427. */
  28428. ind: number;
  28429. /**
  28430. * Length of the particle shape in the "indices" array
  28431. */
  28432. indicesLength: number;
  28433. /**
  28434. * Squared distance from the particle to the camera
  28435. */
  28436. sqDistance: number;
  28437. /**
  28438. * Material index when used with MultiMaterials
  28439. */
  28440. materialIndex: number;
  28441. /**
  28442. * Creates a new sorted particle
  28443. * @param materialIndex
  28444. */
  28445. constructor(ind: number, indLength: number, materialIndex: number);
  28446. }
  28447. }
  28448. declare module "babylonjs/Collisions/meshCollisionData" {
  28449. import { Collider } from "babylonjs/Collisions/collider";
  28450. import { Vector3 } from "babylonjs/Maths/math.vector";
  28451. import { Nullable } from "babylonjs/types";
  28452. import { Observer } from "babylonjs/Misc/observable";
  28453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28454. /**
  28455. * @hidden
  28456. */
  28457. export class _MeshCollisionData {
  28458. _checkCollisions: boolean;
  28459. _collisionMask: number;
  28460. _collisionGroup: number;
  28461. _collider: Nullable<Collider>;
  28462. _oldPositionForCollisions: Vector3;
  28463. _diffPositionForCollisions: Vector3;
  28464. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28465. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28466. }
  28467. }
  28468. declare module "babylonjs/Meshes/abstractMesh" {
  28469. import { Observable } from "babylonjs/Misc/observable";
  28470. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28471. import { Camera } from "babylonjs/Cameras/camera";
  28472. import { Scene, IDisposable } from "babylonjs/scene";
  28473. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28474. import { Node } from "babylonjs/node";
  28475. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28476. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28477. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28478. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28479. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28480. import { Material } from "babylonjs/Materials/material";
  28481. import { Light } from "babylonjs/Lights/light";
  28482. import { Skeleton } from "babylonjs/Bones/skeleton";
  28483. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28484. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28485. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28486. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28487. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28488. import { Plane } from "babylonjs/Maths/math.plane";
  28489. import { Ray } from "babylonjs/Culling/ray";
  28490. import { Collider } from "babylonjs/Collisions/collider";
  28491. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28492. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28493. /** @hidden */
  28494. class _FacetDataStorage {
  28495. facetPositions: Vector3[];
  28496. facetNormals: Vector3[];
  28497. facetPartitioning: number[][];
  28498. facetNb: number;
  28499. partitioningSubdivisions: number;
  28500. partitioningBBoxRatio: number;
  28501. facetDataEnabled: boolean;
  28502. facetParameters: any;
  28503. bbSize: Vector3;
  28504. subDiv: {
  28505. max: number;
  28506. X: number;
  28507. Y: number;
  28508. Z: number;
  28509. };
  28510. facetDepthSort: boolean;
  28511. facetDepthSortEnabled: boolean;
  28512. depthSortedIndices: IndicesArray;
  28513. depthSortedFacets: {
  28514. ind: number;
  28515. sqDistance: number;
  28516. }[];
  28517. facetDepthSortFunction: (f1: {
  28518. ind: number;
  28519. sqDistance: number;
  28520. }, f2: {
  28521. ind: number;
  28522. sqDistance: number;
  28523. }) => number;
  28524. facetDepthSortFrom: Vector3;
  28525. facetDepthSortOrigin: Vector3;
  28526. invertedMatrix: Matrix;
  28527. }
  28528. /**
  28529. * @hidden
  28530. **/
  28531. class _InternalAbstractMeshDataInfo {
  28532. _hasVertexAlpha: boolean;
  28533. _useVertexColors: boolean;
  28534. _numBoneInfluencers: number;
  28535. _applyFog: boolean;
  28536. _receiveShadows: boolean;
  28537. _facetData: _FacetDataStorage;
  28538. _visibility: number;
  28539. _skeleton: Nullable<Skeleton>;
  28540. _layerMask: number;
  28541. _computeBonesUsingShaders: boolean;
  28542. _isActive: boolean;
  28543. _onlyForInstances: boolean;
  28544. _isActiveIntermediate: boolean;
  28545. _onlyForInstancesIntermediate: boolean;
  28546. _actAsRegularMesh: boolean;
  28547. }
  28548. /**
  28549. * Class used to store all common mesh properties
  28550. */
  28551. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28552. /** No occlusion */
  28553. static OCCLUSION_TYPE_NONE: number;
  28554. /** Occlusion set to optimisitic */
  28555. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28556. /** Occlusion set to strict */
  28557. static OCCLUSION_TYPE_STRICT: number;
  28558. /** Use an accurante occlusion algorithm */
  28559. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28560. /** Use a conservative occlusion algorithm */
  28561. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28562. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28563. * Test order :
  28564. * Is the bounding sphere outside the frustum ?
  28565. * If not, are the bounding box vertices outside the frustum ?
  28566. * It not, then the cullable object is in the frustum.
  28567. */
  28568. static readonly CULLINGSTRATEGY_STANDARD: number;
  28569. /** Culling strategy : Bounding Sphere Only.
  28570. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28571. * It's also less accurate than the standard because some not visible objects can still be selected.
  28572. * Test : is the bounding sphere outside the frustum ?
  28573. * If not, then the cullable object is in the frustum.
  28574. */
  28575. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28576. /** Culling strategy : Optimistic Inclusion.
  28577. * This in an inclusion test first, then the standard exclusion test.
  28578. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28579. * 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.
  28580. * Anyway, it's as accurate as the standard strategy.
  28581. * Test :
  28582. * Is the cullable object bounding sphere center in the frustum ?
  28583. * If not, apply the default culling strategy.
  28584. */
  28585. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28586. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28587. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28588. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28589. * 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.
  28590. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28591. * Test :
  28592. * Is the cullable object bounding sphere center in the frustum ?
  28593. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28594. */
  28595. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28596. /**
  28597. * No billboard
  28598. */
  28599. static get BILLBOARDMODE_NONE(): number;
  28600. /** Billboard on X axis */
  28601. static get BILLBOARDMODE_X(): number;
  28602. /** Billboard on Y axis */
  28603. static get BILLBOARDMODE_Y(): number;
  28604. /** Billboard on Z axis */
  28605. static get BILLBOARDMODE_Z(): number;
  28606. /** Billboard on all axes */
  28607. static get BILLBOARDMODE_ALL(): number;
  28608. /** Billboard on using position instead of orientation */
  28609. static get BILLBOARDMODE_USE_POSITION(): number;
  28610. /** @hidden */
  28611. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28612. /**
  28613. * The culling strategy to use to check whether the mesh must be rendered or not.
  28614. * This value can be changed at any time and will be used on the next render mesh selection.
  28615. * The possible values are :
  28616. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28617. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28618. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28619. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28620. * Please read each static variable documentation to get details about the culling process.
  28621. * */
  28622. cullingStrategy: number;
  28623. /**
  28624. * Gets the number of facets in the mesh
  28625. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28626. */
  28627. get facetNb(): number;
  28628. /**
  28629. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28630. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28631. */
  28632. get partitioningSubdivisions(): number;
  28633. set partitioningSubdivisions(nb: number);
  28634. /**
  28635. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28636. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28637. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28638. */
  28639. get partitioningBBoxRatio(): number;
  28640. set partitioningBBoxRatio(ratio: number);
  28641. /**
  28642. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28643. * Works only for updatable meshes.
  28644. * Doesn't work with multi-materials
  28645. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28646. */
  28647. get mustDepthSortFacets(): boolean;
  28648. set mustDepthSortFacets(sort: boolean);
  28649. /**
  28650. * The location (Vector3) where the facet depth sort must be computed from.
  28651. * By default, the active camera position.
  28652. * Used only when facet depth sort is enabled
  28653. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28654. */
  28655. get facetDepthSortFrom(): Vector3;
  28656. set facetDepthSortFrom(location: Vector3);
  28657. /**
  28658. * gets a boolean indicating if facetData is enabled
  28659. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28660. */
  28661. get isFacetDataEnabled(): boolean;
  28662. /** @hidden */
  28663. _updateNonUniformScalingState(value: boolean): boolean;
  28664. /**
  28665. * An event triggered when this mesh collides with another one
  28666. */
  28667. onCollideObservable: Observable<AbstractMesh>;
  28668. /** Set a function to call when this mesh collides with another one */
  28669. set onCollide(callback: () => void);
  28670. /**
  28671. * An event triggered when the collision's position changes
  28672. */
  28673. onCollisionPositionChangeObservable: Observable<Vector3>;
  28674. /** Set a function to call when the collision's position changes */
  28675. set onCollisionPositionChange(callback: () => void);
  28676. /**
  28677. * An event triggered when material is changed
  28678. */
  28679. onMaterialChangedObservable: Observable<AbstractMesh>;
  28680. /**
  28681. * Gets or sets the orientation for POV movement & rotation
  28682. */
  28683. definedFacingForward: boolean;
  28684. /** @hidden */
  28685. _occlusionQuery: Nullable<WebGLQuery>;
  28686. /** @hidden */
  28687. _renderingGroup: Nullable<RenderingGroup>;
  28688. /**
  28689. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28690. */
  28691. get visibility(): number;
  28692. /**
  28693. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28694. */
  28695. set visibility(value: number);
  28696. /** Gets or sets the alpha index used to sort transparent meshes
  28697. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28698. */
  28699. alphaIndex: number;
  28700. /**
  28701. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28702. */
  28703. isVisible: boolean;
  28704. /**
  28705. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28706. */
  28707. isPickable: boolean;
  28708. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28709. showSubMeshesBoundingBox: boolean;
  28710. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28711. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28712. */
  28713. isBlocker: boolean;
  28714. /**
  28715. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28716. */
  28717. enablePointerMoveEvents: boolean;
  28718. /**
  28719. * Specifies the rendering group id for this mesh (0 by default)
  28720. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28721. */
  28722. renderingGroupId: number;
  28723. private _material;
  28724. /** Gets or sets current material */
  28725. get material(): Nullable<Material>;
  28726. set material(value: Nullable<Material>);
  28727. /**
  28728. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28729. * @see http://doc.babylonjs.com/babylon101/shadows
  28730. */
  28731. get receiveShadows(): boolean;
  28732. set receiveShadows(value: boolean);
  28733. /** Defines color to use when rendering outline */
  28734. outlineColor: Color3;
  28735. /** Define width to use when rendering outline */
  28736. outlineWidth: number;
  28737. /** Defines color to use when rendering overlay */
  28738. overlayColor: Color3;
  28739. /** Defines alpha to use when rendering overlay */
  28740. overlayAlpha: number;
  28741. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28742. get hasVertexAlpha(): boolean;
  28743. set hasVertexAlpha(value: boolean);
  28744. /** 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) */
  28745. get useVertexColors(): boolean;
  28746. set useVertexColors(value: boolean);
  28747. /**
  28748. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28749. */
  28750. get computeBonesUsingShaders(): boolean;
  28751. set computeBonesUsingShaders(value: boolean);
  28752. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28753. get numBoneInfluencers(): number;
  28754. set numBoneInfluencers(value: number);
  28755. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28756. get applyFog(): boolean;
  28757. set applyFog(value: boolean);
  28758. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28759. useOctreeForRenderingSelection: boolean;
  28760. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28761. useOctreeForPicking: boolean;
  28762. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28763. useOctreeForCollisions: boolean;
  28764. /**
  28765. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28766. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28767. */
  28768. get layerMask(): number;
  28769. set layerMask(value: number);
  28770. /**
  28771. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28772. */
  28773. alwaysSelectAsActiveMesh: boolean;
  28774. /**
  28775. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28776. */
  28777. doNotSyncBoundingInfo: boolean;
  28778. /**
  28779. * Gets or sets the current action manager
  28780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28781. */
  28782. actionManager: Nullable<AbstractActionManager>;
  28783. private _meshCollisionData;
  28784. /**
  28785. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28786. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28787. */
  28788. ellipsoid: Vector3;
  28789. /**
  28790. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28791. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28792. */
  28793. ellipsoidOffset: Vector3;
  28794. /**
  28795. * Gets or sets a collision mask used to mask collisions (default is -1).
  28796. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28797. */
  28798. get collisionMask(): number;
  28799. set collisionMask(mask: number);
  28800. /**
  28801. * Gets or sets the current collision group mask (-1 by default).
  28802. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28803. */
  28804. get collisionGroup(): number;
  28805. set collisionGroup(mask: number);
  28806. /**
  28807. * Defines edge width used when edgesRenderer is enabled
  28808. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28809. */
  28810. edgesWidth: number;
  28811. /**
  28812. * Defines edge color used when edgesRenderer is enabled
  28813. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28814. */
  28815. edgesColor: Color4;
  28816. /** @hidden */
  28817. _edgesRenderer: Nullable<IEdgesRenderer>;
  28818. /** @hidden */
  28819. _masterMesh: Nullable<AbstractMesh>;
  28820. /** @hidden */
  28821. _boundingInfo: Nullable<BoundingInfo>;
  28822. /** @hidden */
  28823. _renderId: number;
  28824. /**
  28825. * Gets or sets the list of subMeshes
  28826. * @see http://doc.babylonjs.com/how_to/multi_materials
  28827. */
  28828. subMeshes: SubMesh[];
  28829. /** @hidden */
  28830. _intersectionsInProgress: AbstractMesh[];
  28831. /** @hidden */
  28832. _unIndexed: boolean;
  28833. /** @hidden */
  28834. _lightSources: Light[];
  28835. /** Gets the list of lights affecting that mesh */
  28836. get lightSources(): Light[];
  28837. /** @hidden */
  28838. get _positions(): Nullable<Vector3[]>;
  28839. /** @hidden */
  28840. _waitingData: {
  28841. lods: Nullable<any>;
  28842. actions: Nullable<any>;
  28843. freezeWorldMatrix: Nullable<boolean>;
  28844. };
  28845. /** @hidden */
  28846. _bonesTransformMatrices: Nullable<Float32Array>;
  28847. /** @hidden */
  28848. _transformMatrixTexture: Nullable<RawTexture>;
  28849. /**
  28850. * Gets or sets a skeleton to apply skining transformations
  28851. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28852. */
  28853. set skeleton(value: Nullable<Skeleton>);
  28854. get skeleton(): Nullable<Skeleton>;
  28855. /**
  28856. * An event triggered when the mesh is rebuilt.
  28857. */
  28858. onRebuildObservable: Observable<AbstractMesh>;
  28859. /**
  28860. * Creates a new AbstractMesh
  28861. * @param name defines the name of the mesh
  28862. * @param scene defines the hosting scene
  28863. */
  28864. constructor(name: string, scene?: Nullable<Scene>);
  28865. /**
  28866. * Returns the string "AbstractMesh"
  28867. * @returns "AbstractMesh"
  28868. */
  28869. getClassName(): string;
  28870. /**
  28871. * Gets a string representation of the current mesh
  28872. * @param fullDetails defines a boolean indicating if full details must be included
  28873. * @returns a string representation of the current mesh
  28874. */
  28875. toString(fullDetails?: boolean): string;
  28876. /**
  28877. * @hidden
  28878. */
  28879. protected _getEffectiveParent(): Nullable<Node>;
  28880. /** @hidden */
  28881. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28882. /** @hidden */
  28883. _rebuild(): void;
  28884. /** @hidden */
  28885. _resyncLightSources(): void;
  28886. /** @hidden */
  28887. _resyncLightSource(light: Light): void;
  28888. /** @hidden */
  28889. _unBindEffect(): void;
  28890. /** @hidden */
  28891. _removeLightSource(light: Light, dispose: boolean): void;
  28892. private _markSubMeshesAsDirty;
  28893. /** @hidden */
  28894. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28895. /** @hidden */
  28896. _markSubMeshesAsAttributesDirty(): void;
  28897. /** @hidden */
  28898. _markSubMeshesAsMiscDirty(): void;
  28899. /**
  28900. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28901. */
  28902. get scaling(): Vector3;
  28903. set scaling(newScaling: Vector3);
  28904. /**
  28905. * Returns true if the mesh is blocked. Implemented by child classes
  28906. */
  28907. get isBlocked(): boolean;
  28908. /**
  28909. * Returns the mesh itself by default. Implemented by child classes
  28910. * @param camera defines the camera to use to pick the right LOD level
  28911. * @returns the currentAbstractMesh
  28912. */
  28913. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28914. /**
  28915. * Returns 0 by default. Implemented by child classes
  28916. * @returns an integer
  28917. */
  28918. getTotalVertices(): number;
  28919. /**
  28920. * Returns a positive integer : the total number of indices in this mesh geometry.
  28921. * @returns the numner of indices or zero if the mesh has no geometry.
  28922. */
  28923. getTotalIndices(): number;
  28924. /**
  28925. * Returns null by default. Implemented by child classes
  28926. * @returns null
  28927. */
  28928. getIndices(): Nullable<IndicesArray>;
  28929. /**
  28930. * Returns the array of the requested vertex data kind. Implemented by child classes
  28931. * @param kind defines the vertex data kind to use
  28932. * @returns null
  28933. */
  28934. getVerticesData(kind: string): Nullable<FloatArray>;
  28935. /**
  28936. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28937. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28938. * Note that a new underlying VertexBuffer object is created each call.
  28939. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28940. * @param kind defines vertex data kind:
  28941. * * VertexBuffer.PositionKind
  28942. * * VertexBuffer.UVKind
  28943. * * VertexBuffer.UV2Kind
  28944. * * VertexBuffer.UV3Kind
  28945. * * VertexBuffer.UV4Kind
  28946. * * VertexBuffer.UV5Kind
  28947. * * VertexBuffer.UV6Kind
  28948. * * VertexBuffer.ColorKind
  28949. * * VertexBuffer.MatricesIndicesKind
  28950. * * VertexBuffer.MatricesIndicesExtraKind
  28951. * * VertexBuffer.MatricesWeightsKind
  28952. * * VertexBuffer.MatricesWeightsExtraKind
  28953. * @param data defines the data source
  28954. * @param updatable defines if the data must be flagged as updatable (or static)
  28955. * @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
  28956. * @returns the current mesh
  28957. */
  28958. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28959. /**
  28960. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28961. * If the mesh has no geometry, it is simply returned as it is.
  28962. * @param kind defines vertex data kind:
  28963. * * VertexBuffer.PositionKind
  28964. * * VertexBuffer.UVKind
  28965. * * VertexBuffer.UV2Kind
  28966. * * VertexBuffer.UV3Kind
  28967. * * VertexBuffer.UV4Kind
  28968. * * VertexBuffer.UV5Kind
  28969. * * VertexBuffer.UV6Kind
  28970. * * VertexBuffer.ColorKind
  28971. * * VertexBuffer.MatricesIndicesKind
  28972. * * VertexBuffer.MatricesIndicesExtraKind
  28973. * * VertexBuffer.MatricesWeightsKind
  28974. * * VertexBuffer.MatricesWeightsExtraKind
  28975. * @param data defines the data source
  28976. * @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
  28977. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28978. * @returns the current mesh
  28979. */
  28980. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28981. /**
  28982. * Sets the mesh indices,
  28983. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28984. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28985. * @param totalVertices Defines the total number of vertices
  28986. * @returns the current mesh
  28987. */
  28988. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28989. /**
  28990. * Gets a boolean indicating if specific vertex data is present
  28991. * @param kind defines the vertex data kind to use
  28992. * @returns true is data kind is present
  28993. */
  28994. isVerticesDataPresent(kind: string): boolean;
  28995. /**
  28996. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28997. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28998. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28999. * @returns a BoundingInfo
  29000. */
  29001. getBoundingInfo(): BoundingInfo;
  29002. /**
  29003. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  29004. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  29005. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  29006. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  29007. * @returns the current mesh
  29008. */
  29009. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  29010. /**
  29011. * Overwrite the current bounding info
  29012. * @param boundingInfo defines the new bounding info
  29013. * @returns the current mesh
  29014. */
  29015. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  29016. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  29017. get useBones(): boolean;
  29018. /** @hidden */
  29019. _preActivate(): void;
  29020. /** @hidden */
  29021. _preActivateForIntermediateRendering(renderId: number): void;
  29022. /** @hidden */
  29023. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29024. /** @hidden */
  29025. _postActivate(): void;
  29026. /** @hidden */
  29027. _freeze(): void;
  29028. /** @hidden */
  29029. _unFreeze(): void;
  29030. /**
  29031. * Gets the current world matrix
  29032. * @returns a Matrix
  29033. */
  29034. getWorldMatrix(): Matrix;
  29035. /** @hidden */
  29036. _getWorldMatrixDeterminant(): number;
  29037. /**
  29038. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  29039. */
  29040. get isAnInstance(): boolean;
  29041. /**
  29042. * Gets a boolean indicating if this mesh has instances
  29043. */
  29044. get hasInstances(): boolean;
  29045. /**
  29046. * Perform relative position change from the point of view of behind the front of the mesh.
  29047. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29048. * Supports definition of mesh facing forward or backward
  29049. * @param amountRight defines the distance on the right axis
  29050. * @param amountUp defines the distance on the up axis
  29051. * @param amountForward defines the distance on the forward axis
  29052. * @returns the current mesh
  29053. */
  29054. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29055. /**
  29056. * Calculate relative position change from the point of view of behind the front of the mesh.
  29057. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29058. * Supports definition of mesh facing forward or backward
  29059. * @param amountRight defines the distance on the right axis
  29060. * @param amountUp defines the distance on the up axis
  29061. * @param amountForward defines the distance on the forward axis
  29062. * @returns the new displacement vector
  29063. */
  29064. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29065. /**
  29066. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29067. * Supports definition of mesh facing forward or backward
  29068. * @param flipBack defines the flip
  29069. * @param twirlClockwise defines the twirl
  29070. * @param tiltRight defines the tilt
  29071. * @returns the current mesh
  29072. */
  29073. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29074. /**
  29075. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29076. * Supports definition of mesh facing forward or backward.
  29077. * @param flipBack defines the flip
  29078. * @param twirlClockwise defines the twirl
  29079. * @param tiltRight defines the tilt
  29080. * @returns the new rotation vector
  29081. */
  29082. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29083. /**
  29084. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29085. * This means the mesh underlying bounding box and sphere are recomputed.
  29086. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29087. * @returns the current mesh
  29088. */
  29089. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29090. /** @hidden */
  29091. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29092. /** @hidden */
  29093. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29094. /** @hidden */
  29095. _updateBoundingInfo(): AbstractMesh;
  29096. /** @hidden */
  29097. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29098. /** @hidden */
  29099. protected _afterComputeWorldMatrix(): void;
  29100. /** @hidden */
  29101. get _effectiveMesh(): AbstractMesh;
  29102. /**
  29103. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29104. * A mesh is in the frustum if its bounding box intersects the frustum
  29105. * @param frustumPlanes defines the frustum to test
  29106. * @returns true if the mesh is in the frustum planes
  29107. */
  29108. isInFrustum(frustumPlanes: Plane[]): boolean;
  29109. /**
  29110. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29111. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29112. * @param frustumPlanes defines the frustum to test
  29113. * @returns true if the mesh is completely in the frustum planes
  29114. */
  29115. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29116. /**
  29117. * True if the mesh intersects another mesh or a SolidParticle object
  29118. * @param mesh defines a target mesh or SolidParticle to test
  29119. * @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)
  29120. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29121. * @returns true if there is an intersection
  29122. */
  29123. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29124. /**
  29125. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29126. * @param point defines the point to test
  29127. * @returns true if there is an intersection
  29128. */
  29129. intersectsPoint(point: Vector3): boolean;
  29130. /**
  29131. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29132. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29133. */
  29134. get checkCollisions(): boolean;
  29135. set checkCollisions(collisionEnabled: boolean);
  29136. /**
  29137. * Gets Collider object used to compute collisions (not physics)
  29138. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29139. */
  29140. get collider(): Nullable<Collider>;
  29141. /**
  29142. * Move the mesh using collision engine
  29143. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29144. * @param displacement defines the requested displacement vector
  29145. * @returns the current mesh
  29146. */
  29147. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29148. private _onCollisionPositionChange;
  29149. /** @hidden */
  29150. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29151. /** @hidden */
  29152. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29153. /** @hidden */
  29154. _checkCollision(collider: Collider): AbstractMesh;
  29155. /** @hidden */
  29156. _generatePointsArray(): boolean;
  29157. /**
  29158. * Checks if the passed Ray intersects with the mesh
  29159. * @param ray defines the ray to use
  29160. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29161. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29162. * @returns the picking info
  29163. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29164. */
  29165. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29166. /**
  29167. * Clones the current mesh
  29168. * @param name defines the mesh name
  29169. * @param newParent defines the new mesh parent
  29170. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29171. * @returns the new mesh
  29172. */
  29173. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29174. /**
  29175. * Disposes all the submeshes of the current meshnp
  29176. * @returns the current mesh
  29177. */
  29178. releaseSubMeshes(): AbstractMesh;
  29179. /**
  29180. * Releases resources associated with this abstract mesh.
  29181. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29182. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29183. */
  29184. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29185. /**
  29186. * Adds the passed mesh as a child to the current mesh
  29187. * @param mesh defines the child mesh
  29188. * @returns the current mesh
  29189. */
  29190. addChild(mesh: AbstractMesh): AbstractMesh;
  29191. /**
  29192. * Removes the passed mesh from the current mesh children list
  29193. * @param mesh defines the child mesh
  29194. * @returns the current mesh
  29195. */
  29196. removeChild(mesh: AbstractMesh): AbstractMesh;
  29197. /** @hidden */
  29198. private _initFacetData;
  29199. /**
  29200. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29201. * This method can be called within the render loop.
  29202. * 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
  29203. * @returns the current mesh
  29204. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29205. */
  29206. updateFacetData(): AbstractMesh;
  29207. /**
  29208. * Returns the facetLocalNormals array.
  29209. * The normals are expressed in the mesh local spac
  29210. * @returns an array of Vector3
  29211. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29212. */
  29213. getFacetLocalNormals(): Vector3[];
  29214. /**
  29215. * Returns the facetLocalPositions array.
  29216. * The facet positions are expressed in the mesh local space
  29217. * @returns an array of Vector3
  29218. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29219. */
  29220. getFacetLocalPositions(): Vector3[];
  29221. /**
  29222. * Returns the facetLocalPartioning array
  29223. * @returns an array of array of numbers
  29224. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29225. */
  29226. getFacetLocalPartitioning(): number[][];
  29227. /**
  29228. * Returns the i-th facet position in the world system.
  29229. * This method allocates a new Vector3 per call
  29230. * @param i defines the facet index
  29231. * @returns a new Vector3
  29232. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29233. */
  29234. getFacetPosition(i: number): Vector3;
  29235. /**
  29236. * Sets the reference Vector3 with the i-th facet position in the world system
  29237. * @param i defines the facet index
  29238. * @param ref defines the target vector
  29239. * @returns the current mesh
  29240. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29241. */
  29242. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29243. /**
  29244. * Returns the i-th facet normal in the world system.
  29245. * This method allocates a new Vector3 per call
  29246. * @param i defines the facet index
  29247. * @returns a new Vector3
  29248. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29249. */
  29250. getFacetNormal(i: number): Vector3;
  29251. /**
  29252. * Sets the reference Vector3 with the i-th facet normal in the world system
  29253. * @param i defines the facet index
  29254. * @param ref defines the target vector
  29255. * @returns the current mesh
  29256. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29257. */
  29258. getFacetNormalToRef(i: number, ref: Vector3): this;
  29259. /**
  29260. * 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)
  29261. * @param x defines x coordinate
  29262. * @param y defines y coordinate
  29263. * @param z defines z coordinate
  29264. * @returns the array of facet indexes
  29265. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29266. */
  29267. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29268. /**
  29269. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29270. * @param projected sets as the (x,y,z) world projection on the facet
  29271. * @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
  29272. * @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
  29273. * @param x defines x coordinate
  29274. * @param y defines y coordinate
  29275. * @param z defines z coordinate
  29276. * @returns the face index if found (or null instead)
  29277. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29278. */
  29279. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29280. /**
  29281. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29282. * @param projected sets as the (x,y,z) local projection on the facet
  29283. * @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
  29284. * @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
  29285. * @param x defines x coordinate
  29286. * @param y defines y coordinate
  29287. * @param z defines z coordinate
  29288. * @returns the face index if found (or null instead)
  29289. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29290. */
  29291. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29292. /**
  29293. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29294. * @returns the parameters
  29295. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29296. */
  29297. getFacetDataParameters(): any;
  29298. /**
  29299. * Disables the feature FacetData and frees the related memory
  29300. * @returns the current mesh
  29301. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29302. */
  29303. disableFacetData(): AbstractMesh;
  29304. /**
  29305. * Updates the AbstractMesh indices array
  29306. * @param indices defines the data source
  29307. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29308. * @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)
  29309. * @returns the current mesh
  29310. */
  29311. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29312. /**
  29313. * Creates new normals data for the mesh
  29314. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29315. * @returns the current mesh
  29316. */
  29317. createNormals(updatable: boolean): AbstractMesh;
  29318. /**
  29319. * Align the mesh with a normal
  29320. * @param normal defines the normal to use
  29321. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29322. * @returns the current mesh
  29323. */
  29324. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29325. /** @hidden */
  29326. _checkOcclusionQuery(): boolean;
  29327. /**
  29328. * Disables the mesh edge rendering mode
  29329. * @returns the currentAbstractMesh
  29330. */
  29331. disableEdgesRendering(): AbstractMesh;
  29332. /**
  29333. * Enables the edge rendering mode on the mesh.
  29334. * This mode makes the mesh edges visible
  29335. * @param epsilon defines the maximal distance between two angles to detect a face
  29336. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29337. * @returns the currentAbstractMesh
  29338. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29339. */
  29340. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29341. }
  29342. }
  29343. declare module "babylonjs/Actions/actionEvent" {
  29344. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29345. import { Nullable } from "babylonjs/types";
  29346. import { Sprite } from "babylonjs/Sprites/sprite";
  29347. import { Scene } from "babylonjs/scene";
  29348. import { Vector2 } from "babylonjs/Maths/math.vector";
  29349. /**
  29350. * Interface used to define ActionEvent
  29351. */
  29352. export interface IActionEvent {
  29353. /** The mesh or sprite that triggered the action */
  29354. source: any;
  29355. /** The X mouse cursor position at the time of the event */
  29356. pointerX: number;
  29357. /** The Y mouse cursor position at the time of the event */
  29358. pointerY: number;
  29359. /** The mesh that is currently pointed at (can be null) */
  29360. meshUnderPointer: Nullable<AbstractMesh>;
  29361. /** the original (browser) event that triggered the ActionEvent */
  29362. sourceEvent?: any;
  29363. /** additional data for the event */
  29364. additionalData?: any;
  29365. }
  29366. /**
  29367. * ActionEvent is the event being sent when an action is triggered.
  29368. */
  29369. export class ActionEvent implements IActionEvent {
  29370. /** The mesh or sprite that triggered the action */
  29371. source: any;
  29372. /** The X mouse cursor position at the time of the event */
  29373. pointerX: number;
  29374. /** The Y mouse cursor position at the time of the event */
  29375. pointerY: number;
  29376. /** The mesh that is currently pointed at (can be null) */
  29377. meshUnderPointer: Nullable<AbstractMesh>;
  29378. /** the original (browser) event that triggered the ActionEvent */
  29379. sourceEvent?: any;
  29380. /** additional data for the event */
  29381. additionalData?: any;
  29382. /**
  29383. * Creates a new ActionEvent
  29384. * @param source The mesh or sprite that triggered the action
  29385. * @param pointerX The X mouse cursor position at the time of the event
  29386. * @param pointerY The Y mouse cursor position at the time of the event
  29387. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29388. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29389. * @param additionalData additional data for the event
  29390. */
  29391. constructor(
  29392. /** The mesh or sprite that triggered the action */
  29393. source: any,
  29394. /** The X mouse cursor position at the time of the event */
  29395. pointerX: number,
  29396. /** The Y mouse cursor position at the time of the event */
  29397. pointerY: number,
  29398. /** The mesh that is currently pointed at (can be null) */
  29399. meshUnderPointer: Nullable<AbstractMesh>,
  29400. /** the original (browser) event that triggered the ActionEvent */
  29401. sourceEvent?: any,
  29402. /** additional data for the event */
  29403. additionalData?: any);
  29404. /**
  29405. * Helper function to auto-create an ActionEvent from a source mesh.
  29406. * @param source The source mesh that triggered the event
  29407. * @param evt The original (browser) event
  29408. * @param additionalData additional data for the event
  29409. * @returns the new ActionEvent
  29410. */
  29411. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29412. /**
  29413. * Helper function to auto-create an ActionEvent from a source sprite
  29414. * @param source The source sprite that triggered the event
  29415. * @param scene Scene associated with the sprite
  29416. * @param evt The original (browser) event
  29417. * @param additionalData additional data for the event
  29418. * @returns the new ActionEvent
  29419. */
  29420. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29421. /**
  29422. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29423. * @param scene the scene where the event occurred
  29424. * @param evt The original (browser) event
  29425. * @returns the new ActionEvent
  29426. */
  29427. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29428. /**
  29429. * Helper function to auto-create an ActionEvent from a primitive
  29430. * @param prim defines the target primitive
  29431. * @param pointerPos defines the pointer position
  29432. * @param evt The original (browser) event
  29433. * @param additionalData additional data for the event
  29434. * @returns the new ActionEvent
  29435. */
  29436. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29437. }
  29438. }
  29439. declare module "babylonjs/Actions/abstractActionManager" {
  29440. import { IDisposable } from "babylonjs/scene";
  29441. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29442. import { IAction } from "babylonjs/Actions/action";
  29443. import { Nullable } from "babylonjs/types";
  29444. /**
  29445. * Abstract class used to decouple action Manager from scene and meshes.
  29446. * Do not instantiate.
  29447. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29448. */
  29449. export abstract class AbstractActionManager implements IDisposable {
  29450. /** Gets the list of active triggers */
  29451. static Triggers: {
  29452. [key: string]: number;
  29453. };
  29454. /** Gets the cursor to use when hovering items */
  29455. hoverCursor: string;
  29456. /** Gets the list of actions */
  29457. actions: IAction[];
  29458. /**
  29459. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29460. */
  29461. isRecursive: boolean;
  29462. /**
  29463. * Releases all associated resources
  29464. */
  29465. abstract dispose(): void;
  29466. /**
  29467. * Does this action manager has pointer triggers
  29468. */
  29469. abstract get hasPointerTriggers(): boolean;
  29470. /**
  29471. * Does this action manager has pick triggers
  29472. */
  29473. abstract get hasPickTriggers(): boolean;
  29474. /**
  29475. * Process a specific trigger
  29476. * @param trigger defines the trigger to process
  29477. * @param evt defines the event details to be processed
  29478. */
  29479. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29480. /**
  29481. * Does this action manager handles actions of any of the given triggers
  29482. * @param triggers defines the triggers to be tested
  29483. * @return a boolean indicating whether one (or more) of the triggers is handled
  29484. */
  29485. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29486. /**
  29487. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29488. * speed.
  29489. * @param triggerA defines the trigger to be tested
  29490. * @param triggerB defines the trigger to be tested
  29491. * @return a boolean indicating whether one (or more) of the triggers is handled
  29492. */
  29493. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29494. /**
  29495. * Does this action manager handles actions of a given trigger
  29496. * @param trigger defines the trigger to be tested
  29497. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29498. * @return whether the trigger is handled
  29499. */
  29500. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29501. /**
  29502. * Serialize this manager to a JSON object
  29503. * @param name defines the property name to store this manager
  29504. * @returns a JSON representation of this manager
  29505. */
  29506. abstract serialize(name: string): any;
  29507. /**
  29508. * Registers an action to this action manager
  29509. * @param action defines the action to be registered
  29510. * @return the action amended (prepared) after registration
  29511. */
  29512. abstract registerAction(action: IAction): Nullable<IAction>;
  29513. /**
  29514. * Unregisters an action to this action manager
  29515. * @param action defines the action to be unregistered
  29516. * @return a boolean indicating whether the action has been unregistered
  29517. */
  29518. abstract unregisterAction(action: IAction): Boolean;
  29519. /**
  29520. * Does exist one action manager with at least one trigger
  29521. **/
  29522. static get HasTriggers(): boolean;
  29523. /**
  29524. * Does exist one action manager with at least one pick trigger
  29525. **/
  29526. static get HasPickTriggers(): boolean;
  29527. /**
  29528. * Does exist one action manager that handles actions of a given trigger
  29529. * @param trigger defines the trigger to be tested
  29530. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29531. **/
  29532. static HasSpecificTrigger(trigger: number): boolean;
  29533. }
  29534. }
  29535. declare module "babylonjs/node" {
  29536. import { Scene } from "babylonjs/scene";
  29537. import { Nullable } from "babylonjs/types";
  29538. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29539. import { Engine } from "babylonjs/Engines/engine";
  29540. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29541. import { Observable } from "babylonjs/Misc/observable";
  29542. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29543. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29544. import { Animatable } from "babylonjs/Animations/animatable";
  29545. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29546. import { Animation } from "babylonjs/Animations/animation";
  29547. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29548. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29549. /**
  29550. * Defines how a node can be built from a string name.
  29551. */
  29552. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29553. /**
  29554. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29555. */
  29556. export class Node implements IBehaviorAware<Node> {
  29557. /** @hidden */
  29558. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29559. private static _NodeConstructors;
  29560. /**
  29561. * Add a new node constructor
  29562. * @param type defines the type name of the node to construct
  29563. * @param constructorFunc defines the constructor function
  29564. */
  29565. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29566. /**
  29567. * Returns a node constructor based on type name
  29568. * @param type defines the type name
  29569. * @param name defines the new node name
  29570. * @param scene defines the hosting scene
  29571. * @param options defines optional options to transmit to constructors
  29572. * @returns the new constructor or null
  29573. */
  29574. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29575. /**
  29576. * Gets or sets the name of the node
  29577. */
  29578. name: string;
  29579. /**
  29580. * Gets or sets the id of the node
  29581. */
  29582. id: string;
  29583. /**
  29584. * Gets or sets the unique id of the node
  29585. */
  29586. uniqueId: number;
  29587. /**
  29588. * Gets or sets a string used to store user defined state for the node
  29589. */
  29590. state: string;
  29591. /**
  29592. * Gets or sets an object used to store user defined information for the node
  29593. */
  29594. metadata: any;
  29595. /**
  29596. * For internal use only. Please do not use.
  29597. */
  29598. reservedDataStore: any;
  29599. /**
  29600. * List of inspectable custom properties (used by the Inspector)
  29601. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29602. */
  29603. inspectableCustomProperties: IInspectable[];
  29604. private _doNotSerialize;
  29605. /**
  29606. * Gets or sets a boolean used to define if the node must be serialized
  29607. */
  29608. get doNotSerialize(): boolean;
  29609. set doNotSerialize(value: boolean);
  29610. /** @hidden */
  29611. _isDisposed: boolean;
  29612. /**
  29613. * Gets a list of Animations associated with the node
  29614. */
  29615. animations: import("babylonjs/Animations/animation").Animation[];
  29616. protected _ranges: {
  29617. [name: string]: Nullable<AnimationRange>;
  29618. };
  29619. /**
  29620. * Callback raised when the node is ready to be used
  29621. */
  29622. onReady: Nullable<(node: Node) => void>;
  29623. private _isEnabled;
  29624. private _isParentEnabled;
  29625. private _isReady;
  29626. /** @hidden */
  29627. _currentRenderId: number;
  29628. private _parentUpdateId;
  29629. /** @hidden */
  29630. _childUpdateId: number;
  29631. /** @hidden */
  29632. _waitingParentId: Nullable<string>;
  29633. /** @hidden */
  29634. _scene: Scene;
  29635. /** @hidden */
  29636. _cache: any;
  29637. private _parentNode;
  29638. private _children;
  29639. /** @hidden */
  29640. _worldMatrix: Matrix;
  29641. /** @hidden */
  29642. _worldMatrixDeterminant: number;
  29643. /** @hidden */
  29644. _worldMatrixDeterminantIsDirty: boolean;
  29645. /** @hidden */
  29646. private _sceneRootNodesIndex;
  29647. /**
  29648. * Gets a boolean indicating if the node has been disposed
  29649. * @returns true if the node was disposed
  29650. */
  29651. isDisposed(): boolean;
  29652. /**
  29653. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29654. * @see https://doc.babylonjs.com/how_to/parenting
  29655. */
  29656. set parent(parent: Nullable<Node>);
  29657. get parent(): Nullable<Node>;
  29658. /** @hidden */
  29659. _addToSceneRootNodes(): void;
  29660. /** @hidden */
  29661. _removeFromSceneRootNodes(): void;
  29662. private _animationPropertiesOverride;
  29663. /**
  29664. * Gets or sets the animation properties override
  29665. */
  29666. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29667. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29668. /**
  29669. * Gets a string idenfifying the name of the class
  29670. * @returns "Node" string
  29671. */
  29672. getClassName(): string;
  29673. /** @hidden */
  29674. readonly _isNode: boolean;
  29675. /**
  29676. * An event triggered when the mesh is disposed
  29677. */
  29678. onDisposeObservable: Observable<Node>;
  29679. private _onDisposeObserver;
  29680. /**
  29681. * Sets a callback that will be raised when the node will be disposed
  29682. */
  29683. set onDispose(callback: () => void);
  29684. /**
  29685. * Creates a new Node
  29686. * @param name the name and id to be given to this node
  29687. * @param scene the scene this node will be added to
  29688. */
  29689. constructor(name: string, scene?: Nullable<Scene>);
  29690. /**
  29691. * Gets the scene of the node
  29692. * @returns a scene
  29693. */
  29694. getScene(): Scene;
  29695. /**
  29696. * Gets the engine of the node
  29697. * @returns a Engine
  29698. */
  29699. getEngine(): Engine;
  29700. private _behaviors;
  29701. /**
  29702. * Attach a behavior to the node
  29703. * @see http://doc.babylonjs.com/features/behaviour
  29704. * @param behavior defines the behavior to attach
  29705. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29706. * @returns the current Node
  29707. */
  29708. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29709. /**
  29710. * Remove an attached behavior
  29711. * @see http://doc.babylonjs.com/features/behaviour
  29712. * @param behavior defines the behavior to attach
  29713. * @returns the current Node
  29714. */
  29715. removeBehavior(behavior: Behavior<Node>): Node;
  29716. /**
  29717. * Gets the list of attached behaviors
  29718. * @see http://doc.babylonjs.com/features/behaviour
  29719. */
  29720. get behaviors(): Behavior<Node>[];
  29721. /**
  29722. * Gets an attached behavior by name
  29723. * @param name defines the name of the behavior to look for
  29724. * @see http://doc.babylonjs.com/features/behaviour
  29725. * @returns null if behavior was not found else the requested behavior
  29726. */
  29727. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29728. /**
  29729. * Returns the latest update of the World matrix
  29730. * @returns a Matrix
  29731. */
  29732. getWorldMatrix(): Matrix;
  29733. /** @hidden */
  29734. _getWorldMatrixDeterminant(): number;
  29735. /**
  29736. * Returns directly the latest state of the mesh World matrix.
  29737. * A Matrix is returned.
  29738. */
  29739. get worldMatrixFromCache(): Matrix;
  29740. /** @hidden */
  29741. _initCache(): void;
  29742. /** @hidden */
  29743. updateCache(force?: boolean): void;
  29744. /** @hidden */
  29745. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29746. /** @hidden */
  29747. _updateCache(ignoreParentClass?: boolean): void;
  29748. /** @hidden */
  29749. _isSynchronized(): boolean;
  29750. /** @hidden */
  29751. _markSyncedWithParent(): void;
  29752. /** @hidden */
  29753. isSynchronizedWithParent(): boolean;
  29754. /** @hidden */
  29755. isSynchronized(): boolean;
  29756. /**
  29757. * Is this node ready to be used/rendered
  29758. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29759. * @return true if the node is ready
  29760. */
  29761. isReady(completeCheck?: boolean): boolean;
  29762. /**
  29763. * Is this node enabled?
  29764. * 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
  29765. * @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
  29766. * @return whether this node (and its parent) is enabled
  29767. */
  29768. isEnabled(checkAncestors?: boolean): boolean;
  29769. /** @hidden */
  29770. protected _syncParentEnabledState(): void;
  29771. /**
  29772. * Set the enabled state of this node
  29773. * @param value defines the new enabled state
  29774. */
  29775. setEnabled(value: boolean): void;
  29776. /**
  29777. * Is this node a descendant of the given node?
  29778. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29779. * @param ancestor defines the parent node to inspect
  29780. * @returns a boolean indicating if this node is a descendant of the given node
  29781. */
  29782. isDescendantOf(ancestor: Node): boolean;
  29783. /** @hidden */
  29784. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29785. /**
  29786. * Will return all nodes that have this node as ascendant
  29787. * @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
  29788. * @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
  29789. * @return all children nodes of all types
  29790. */
  29791. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29792. /**
  29793. * Get all child-meshes of this node
  29794. * @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)
  29795. * @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
  29796. * @returns an array of AbstractMesh
  29797. */
  29798. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29799. /**
  29800. * Get all direct children of this node
  29801. * @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
  29802. * @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)
  29803. * @returns an array of Node
  29804. */
  29805. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29806. /** @hidden */
  29807. _setReady(state: boolean): void;
  29808. /**
  29809. * Get an animation by name
  29810. * @param name defines the name of the animation to look for
  29811. * @returns null if not found else the requested animation
  29812. */
  29813. getAnimationByName(name: string): Nullable<Animation>;
  29814. /**
  29815. * Creates an animation range for this node
  29816. * @param name defines the name of the range
  29817. * @param from defines the starting key
  29818. * @param to defines the end key
  29819. */
  29820. createAnimationRange(name: string, from: number, to: number): void;
  29821. /**
  29822. * Delete a specific animation range
  29823. * @param name defines the name of the range to delete
  29824. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29825. */
  29826. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29827. /**
  29828. * Get an animation range by name
  29829. * @param name defines the name of the animation range to look for
  29830. * @returns null if not found else the requested animation range
  29831. */
  29832. getAnimationRange(name: string): Nullable<AnimationRange>;
  29833. /**
  29834. * Gets the list of all animation ranges defined on this node
  29835. * @returns an array
  29836. */
  29837. getAnimationRanges(): Nullable<AnimationRange>[];
  29838. /**
  29839. * Will start the animation sequence
  29840. * @param name defines the range frames for animation sequence
  29841. * @param loop defines if the animation should loop (false by default)
  29842. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29843. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29844. * @returns the object created for this animation. If range does not exist, it will return null
  29845. */
  29846. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29847. /**
  29848. * Serialize animation ranges into a JSON compatible object
  29849. * @returns serialization object
  29850. */
  29851. serializeAnimationRanges(): any;
  29852. /**
  29853. * Computes the world matrix of the node
  29854. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29855. * @returns the world matrix
  29856. */
  29857. computeWorldMatrix(force?: boolean): Matrix;
  29858. /**
  29859. * Releases resources associated with this node.
  29860. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29861. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29862. */
  29863. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29864. /**
  29865. * Parse animation range data from a serialization object and store them into a given node
  29866. * @param node defines where to store the animation ranges
  29867. * @param parsedNode defines the serialization object to read data from
  29868. * @param scene defines the hosting scene
  29869. */
  29870. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29871. /**
  29872. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29873. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29874. * @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
  29875. * @returns the new bounding vectors
  29876. */
  29877. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29878. min: Vector3;
  29879. max: Vector3;
  29880. };
  29881. }
  29882. }
  29883. declare module "babylonjs/Animations/animation" {
  29884. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  29885. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  29886. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29887. import { Nullable } from "babylonjs/types";
  29888. import { Scene } from "babylonjs/scene";
  29889. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  29890. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29891. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  29892. import { Node } from "babylonjs/node";
  29893. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29894. import { Size } from "babylonjs/Maths/math.size";
  29895. import { Animatable } from "babylonjs/Animations/animatable";
  29896. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  29897. /**
  29898. * @hidden
  29899. */
  29900. export class _IAnimationState {
  29901. key: number;
  29902. repeatCount: number;
  29903. workValue?: any;
  29904. loopMode?: number;
  29905. offsetValue?: any;
  29906. highLimitValue?: any;
  29907. }
  29908. /**
  29909. * Class used to store any kind of animation
  29910. */
  29911. export class Animation {
  29912. /**Name of the animation */
  29913. name: string;
  29914. /**Property to animate */
  29915. targetProperty: string;
  29916. /**The frames per second of the animation */
  29917. framePerSecond: number;
  29918. /**The data type of the animation */
  29919. dataType: number;
  29920. /**The loop mode of the animation */
  29921. loopMode?: number | undefined;
  29922. /**Specifies if blending should be enabled */
  29923. enableBlending?: boolean | undefined;
  29924. /**
  29925. * Use matrix interpolation instead of using direct key value when animating matrices
  29926. */
  29927. static AllowMatricesInterpolation: boolean;
  29928. /**
  29929. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29930. */
  29931. static AllowMatrixDecomposeForInterpolation: boolean;
  29932. /**
  29933. * Stores the key frames of the animation
  29934. */
  29935. private _keys;
  29936. /**
  29937. * Stores the easing function of the animation
  29938. */
  29939. private _easingFunction;
  29940. /**
  29941. * @hidden Internal use only
  29942. */
  29943. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  29944. /**
  29945. * The set of event that will be linked to this animation
  29946. */
  29947. private _events;
  29948. /**
  29949. * Stores an array of target property paths
  29950. */
  29951. targetPropertyPath: string[];
  29952. /**
  29953. * Stores the blending speed of the animation
  29954. */
  29955. blendingSpeed: number;
  29956. /**
  29957. * Stores the animation ranges for the animation
  29958. */
  29959. private _ranges;
  29960. /**
  29961. * @hidden Internal use
  29962. */
  29963. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29964. /**
  29965. * Sets up an animation
  29966. * @param property The property to animate
  29967. * @param animationType The animation type to apply
  29968. * @param framePerSecond The frames per second of the animation
  29969. * @param easingFunction The easing function used in the animation
  29970. * @returns The created animation
  29971. */
  29972. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29973. /**
  29974. * Create and start an animation on a node
  29975. * @param name defines the name of the global animation that will be run on all nodes
  29976. * @param node defines the root node where the animation will take place
  29977. * @param targetProperty defines property to animate
  29978. * @param framePerSecond defines the number of frame per second yo use
  29979. * @param totalFrame defines the number of frames in total
  29980. * @param from defines the initial value
  29981. * @param to defines the final value
  29982. * @param loopMode defines which loop mode you want to use (off by default)
  29983. * @param easingFunction defines the easing function to use (linear by default)
  29984. * @param onAnimationEnd defines the callback to call when animation end
  29985. * @returns the animatable created for this animation
  29986. */
  29987. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29988. /**
  29989. * Create and start an animation on a node and its descendants
  29990. * @param name defines the name of the global animation that will be run on all nodes
  29991. * @param node defines the root node where the animation will take place
  29992. * @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
  29993. * @param targetProperty defines property to animate
  29994. * @param framePerSecond defines the number of frame per second to use
  29995. * @param totalFrame defines the number of frames in total
  29996. * @param from defines the initial value
  29997. * @param to defines the final value
  29998. * @param loopMode defines which loop mode you want to use (off by default)
  29999. * @param easingFunction defines the easing function to use (linear by default)
  30000. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  30001. * @returns the list of animatables created for all nodes
  30002. * @example https://www.babylonjs-playground.com/#MH0VLI
  30003. */
  30004. 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[]>;
  30005. /**
  30006. * Creates a new animation, merges it with the existing animations and starts it
  30007. * @param name Name of the animation
  30008. * @param node Node which contains the scene that begins the animations
  30009. * @param targetProperty Specifies which property to animate
  30010. * @param framePerSecond The frames per second of the animation
  30011. * @param totalFrame The total number of frames
  30012. * @param from The frame at the beginning of the animation
  30013. * @param to The frame at the end of the animation
  30014. * @param loopMode Specifies the loop mode of the animation
  30015. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  30016. * @param onAnimationEnd Callback to run once the animation is complete
  30017. * @returns Nullable animation
  30018. */
  30019. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30020. /**
  30021. * Transition property of an host to the target Value
  30022. * @param property The property to transition
  30023. * @param targetValue The target Value of the property
  30024. * @param host The object where the property to animate belongs
  30025. * @param scene Scene used to run the animation
  30026. * @param frameRate Framerate (in frame/s) to use
  30027. * @param transition The transition type we want to use
  30028. * @param duration The duration of the animation, in milliseconds
  30029. * @param onAnimationEnd Callback trigger at the end of the animation
  30030. * @returns Nullable animation
  30031. */
  30032. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  30033. /**
  30034. * Return the array of runtime animations currently using this animation
  30035. */
  30036. get runtimeAnimations(): RuntimeAnimation[];
  30037. /**
  30038. * Specifies if any of the runtime animations are currently running
  30039. */
  30040. get hasRunningRuntimeAnimations(): boolean;
  30041. /**
  30042. * Initializes the animation
  30043. * @param name Name of the animation
  30044. * @param targetProperty Property to animate
  30045. * @param framePerSecond The frames per second of the animation
  30046. * @param dataType The data type of the animation
  30047. * @param loopMode The loop mode of the animation
  30048. * @param enableBlending Specifies if blending should be enabled
  30049. */
  30050. constructor(
  30051. /**Name of the animation */
  30052. name: string,
  30053. /**Property to animate */
  30054. targetProperty: string,
  30055. /**The frames per second of the animation */
  30056. framePerSecond: number,
  30057. /**The data type of the animation */
  30058. dataType: number,
  30059. /**The loop mode of the animation */
  30060. loopMode?: number | undefined,
  30061. /**Specifies if blending should be enabled */
  30062. enableBlending?: boolean | undefined);
  30063. /**
  30064. * Converts the animation to a string
  30065. * @param fullDetails support for multiple levels of logging within scene loading
  30066. * @returns String form of the animation
  30067. */
  30068. toString(fullDetails?: boolean): string;
  30069. /**
  30070. * Add an event to this animation
  30071. * @param event Event to add
  30072. */
  30073. addEvent(event: AnimationEvent): void;
  30074. /**
  30075. * Remove all events found at the given frame
  30076. * @param frame The frame to remove events from
  30077. */
  30078. removeEvents(frame: number): void;
  30079. /**
  30080. * Retrieves all the events from the animation
  30081. * @returns Events from the animation
  30082. */
  30083. getEvents(): AnimationEvent[];
  30084. /**
  30085. * Creates an animation range
  30086. * @param name Name of the animation range
  30087. * @param from Starting frame of the animation range
  30088. * @param to Ending frame of the animation
  30089. */
  30090. createRange(name: string, from: number, to: number): void;
  30091. /**
  30092. * Deletes an animation range by name
  30093. * @param name Name of the animation range to delete
  30094. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30095. */
  30096. deleteRange(name: string, deleteFrames?: boolean): void;
  30097. /**
  30098. * Gets the animation range by name, or null if not defined
  30099. * @param name Name of the animation range
  30100. * @returns Nullable animation range
  30101. */
  30102. getRange(name: string): Nullable<AnimationRange>;
  30103. /**
  30104. * Gets the key frames from the animation
  30105. * @returns The key frames of the animation
  30106. */
  30107. getKeys(): Array<IAnimationKey>;
  30108. /**
  30109. * Gets the highest frame rate of the animation
  30110. * @returns Highest frame rate of the animation
  30111. */
  30112. getHighestFrame(): number;
  30113. /**
  30114. * Gets the easing function of the animation
  30115. * @returns Easing function of the animation
  30116. */
  30117. getEasingFunction(): IEasingFunction;
  30118. /**
  30119. * Sets the easing function of the animation
  30120. * @param easingFunction A custom mathematical formula for animation
  30121. */
  30122. setEasingFunction(easingFunction: EasingFunction): void;
  30123. /**
  30124. * Interpolates a scalar linearly
  30125. * @param startValue Start value of the animation curve
  30126. * @param endValue End value of the animation curve
  30127. * @param gradient Scalar amount to interpolate
  30128. * @returns Interpolated scalar value
  30129. */
  30130. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30131. /**
  30132. * Interpolates a scalar cubically
  30133. * @param startValue Start value of the animation curve
  30134. * @param outTangent End tangent of the animation
  30135. * @param endValue End value of the animation curve
  30136. * @param inTangent Start tangent of the animation curve
  30137. * @param gradient Scalar amount to interpolate
  30138. * @returns Interpolated scalar value
  30139. */
  30140. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30141. /**
  30142. * Interpolates a quaternion using a spherical linear interpolation
  30143. * @param startValue Start value of the animation curve
  30144. * @param endValue End value of the animation curve
  30145. * @param gradient Scalar amount to interpolate
  30146. * @returns Interpolated quaternion value
  30147. */
  30148. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30149. /**
  30150. * Interpolates a quaternion cubically
  30151. * @param startValue Start value of the animation curve
  30152. * @param outTangent End tangent of the animation curve
  30153. * @param endValue End value of the animation curve
  30154. * @param inTangent Start tangent of the animation curve
  30155. * @param gradient Scalar amount to interpolate
  30156. * @returns Interpolated quaternion value
  30157. */
  30158. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30159. /**
  30160. * Interpolates a Vector3 linearl
  30161. * @param startValue Start value of the animation curve
  30162. * @param endValue End value of the animation curve
  30163. * @param gradient Scalar amount to interpolate
  30164. * @returns Interpolated scalar value
  30165. */
  30166. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30167. /**
  30168. * Interpolates a Vector3 cubically
  30169. * @param startValue Start value of the animation curve
  30170. * @param outTangent End tangent of the animation
  30171. * @param endValue End value of the animation curve
  30172. * @param inTangent Start tangent of the animation curve
  30173. * @param gradient Scalar amount to interpolate
  30174. * @returns InterpolatedVector3 value
  30175. */
  30176. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30177. /**
  30178. * Interpolates a Vector2 linearly
  30179. * @param startValue Start value of the animation curve
  30180. * @param endValue End value of the animation curve
  30181. * @param gradient Scalar amount to interpolate
  30182. * @returns Interpolated Vector2 value
  30183. */
  30184. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30185. /**
  30186. * Interpolates a Vector2 cubically
  30187. * @param startValue Start value of the animation curve
  30188. * @param outTangent End tangent of the animation
  30189. * @param endValue End value of the animation curve
  30190. * @param inTangent Start tangent of the animation curve
  30191. * @param gradient Scalar amount to interpolate
  30192. * @returns Interpolated Vector2 value
  30193. */
  30194. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30195. /**
  30196. * Interpolates a size linearly
  30197. * @param startValue Start value of the animation curve
  30198. * @param endValue End value of the animation curve
  30199. * @param gradient Scalar amount to interpolate
  30200. * @returns Interpolated Size value
  30201. */
  30202. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30203. /**
  30204. * Interpolates a Color3 linearly
  30205. * @param startValue Start value of the animation curve
  30206. * @param endValue End value of the animation curve
  30207. * @param gradient Scalar amount to interpolate
  30208. * @returns Interpolated Color3 value
  30209. */
  30210. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30211. /**
  30212. * Interpolates a Color4 linearly
  30213. * @param startValue Start value of the animation curve
  30214. * @param endValue End value of the animation curve
  30215. * @param gradient Scalar amount to interpolate
  30216. * @returns Interpolated Color3 value
  30217. */
  30218. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30219. /**
  30220. * @hidden Internal use only
  30221. */
  30222. _getKeyValue(value: any): any;
  30223. /**
  30224. * @hidden Internal use only
  30225. */
  30226. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30227. /**
  30228. * Defines the function to use to interpolate matrices
  30229. * @param startValue defines the start matrix
  30230. * @param endValue defines the end matrix
  30231. * @param gradient defines the gradient between both matrices
  30232. * @param result defines an optional target matrix where to store the interpolation
  30233. * @returns the interpolated matrix
  30234. */
  30235. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30236. /**
  30237. * Makes a copy of the animation
  30238. * @returns Cloned animation
  30239. */
  30240. clone(): Animation;
  30241. /**
  30242. * Sets the key frames of the animation
  30243. * @param values The animation key frames to set
  30244. */
  30245. setKeys(values: Array<IAnimationKey>): void;
  30246. /**
  30247. * Serializes the animation to an object
  30248. * @returns Serialized object
  30249. */
  30250. serialize(): any;
  30251. /**
  30252. * Float animation type
  30253. */
  30254. static readonly ANIMATIONTYPE_FLOAT: number;
  30255. /**
  30256. * Vector3 animation type
  30257. */
  30258. static readonly ANIMATIONTYPE_VECTOR3: number;
  30259. /**
  30260. * Quaternion animation type
  30261. */
  30262. static readonly ANIMATIONTYPE_QUATERNION: number;
  30263. /**
  30264. * Matrix animation type
  30265. */
  30266. static readonly ANIMATIONTYPE_MATRIX: number;
  30267. /**
  30268. * Color3 animation type
  30269. */
  30270. static readonly ANIMATIONTYPE_COLOR3: number;
  30271. /**
  30272. * Color3 animation type
  30273. */
  30274. static readonly ANIMATIONTYPE_COLOR4: number;
  30275. /**
  30276. * Vector2 animation type
  30277. */
  30278. static readonly ANIMATIONTYPE_VECTOR2: number;
  30279. /**
  30280. * Size animation type
  30281. */
  30282. static readonly ANIMATIONTYPE_SIZE: number;
  30283. /**
  30284. * Relative Loop Mode
  30285. */
  30286. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30287. /**
  30288. * Cycle Loop Mode
  30289. */
  30290. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30291. /**
  30292. * Constant Loop Mode
  30293. */
  30294. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30295. /** @hidden */
  30296. static _UniversalLerp(left: any, right: any, amount: number): any;
  30297. /**
  30298. * Parses an animation object and creates an animation
  30299. * @param parsedAnimation Parsed animation object
  30300. * @returns Animation object
  30301. */
  30302. static Parse(parsedAnimation: any): Animation;
  30303. /**
  30304. * Appends the serialized animations from the source animations
  30305. * @param source Source containing the animations
  30306. * @param destination Target to store the animations
  30307. */
  30308. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30309. }
  30310. }
  30311. declare module "babylonjs/Animations/animatable.interface" {
  30312. import { Nullable } from "babylonjs/types";
  30313. import { Animation } from "babylonjs/Animations/animation";
  30314. /**
  30315. * Interface containing an array of animations
  30316. */
  30317. export interface IAnimatable {
  30318. /**
  30319. * Array of animations
  30320. */
  30321. animations: Nullable<Array<Animation>>;
  30322. }
  30323. }
  30324. declare module "babylonjs/Misc/decorators" {
  30325. import { Nullable } from "babylonjs/types";
  30326. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30327. import { Scene } from "babylonjs/scene";
  30328. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30329. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30330. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30331. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30332. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30333. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30334. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30335. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30336. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30337. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30338. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30339. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30340. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30341. /**
  30342. * Decorator used to define property that can be serialized as reference to a camera
  30343. * @param sourceName defines the name of the property to decorate
  30344. */
  30345. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30346. /**
  30347. * Class used to help serialization objects
  30348. */
  30349. export class SerializationHelper {
  30350. /** @hidden */
  30351. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30352. /** @hidden */
  30353. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30354. /** @hidden */
  30355. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30356. /** @hidden */
  30357. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30358. /**
  30359. * Appends the serialized animations from the source animations
  30360. * @param source Source containing the animations
  30361. * @param destination Target to store the animations
  30362. */
  30363. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30364. /**
  30365. * Static function used to serialized a specific entity
  30366. * @param entity defines the entity to serialize
  30367. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30368. * @returns a JSON compatible object representing the serialization of the entity
  30369. */
  30370. static Serialize<T>(entity: T, serializationObject?: any): any;
  30371. /**
  30372. * Creates a new entity from a serialization data object
  30373. * @param creationFunction defines a function used to instanciated the new entity
  30374. * @param source defines the source serialization data
  30375. * @param scene defines the hosting scene
  30376. * @param rootUrl defines the root url for resources
  30377. * @returns a new entity
  30378. */
  30379. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30380. /**
  30381. * Clones an object
  30382. * @param creationFunction defines the function used to instanciate the new object
  30383. * @param source defines the source object
  30384. * @returns the cloned object
  30385. */
  30386. static Clone<T>(creationFunction: () => T, source: T): T;
  30387. /**
  30388. * Instanciates a new object based on a source one (some data will be shared between both object)
  30389. * @param creationFunction defines the function used to instanciate the new object
  30390. * @param source defines the source object
  30391. * @returns the new object
  30392. */
  30393. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30394. }
  30395. }
  30396. declare module "babylonjs/Misc/guid" {
  30397. /**
  30398. * Class used to manipulate GUIDs
  30399. */
  30400. export class GUID {
  30401. /**
  30402. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30403. * Be aware Math.random() could cause collisions, but:
  30404. * "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"
  30405. * @returns a pseudo random id
  30406. */
  30407. static RandomId(): string;
  30408. }
  30409. }
  30410. declare module "babylonjs/Materials/Textures/baseTexture" {
  30411. import { Observable } from "babylonjs/Misc/observable";
  30412. import { Nullable } from "babylonjs/types";
  30413. import { Scene } from "babylonjs/scene";
  30414. import { Matrix } from "babylonjs/Maths/math.vector";
  30415. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30416. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30417. import { ISize } from "babylonjs/Maths/math.size";
  30418. import "babylonjs/Misc/fileTools";
  30419. /**
  30420. * Base class of all the textures in babylon.
  30421. * It groups all the common properties the materials, post process, lights... might need
  30422. * in order to make a correct use of the texture.
  30423. */
  30424. export class BaseTexture implements IAnimatable {
  30425. /**
  30426. * Default anisotropic filtering level for the application.
  30427. * It is set to 4 as a good tradeoff between perf and quality.
  30428. */
  30429. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30430. /**
  30431. * Gets or sets the unique id of the texture
  30432. */
  30433. uniqueId: number;
  30434. /**
  30435. * Define the name of the texture.
  30436. */
  30437. name: string;
  30438. /**
  30439. * Gets or sets an object used to store user defined information.
  30440. */
  30441. metadata: any;
  30442. /**
  30443. * For internal use only. Please do not use.
  30444. */
  30445. reservedDataStore: any;
  30446. private _hasAlpha;
  30447. /**
  30448. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30449. */
  30450. set hasAlpha(value: boolean);
  30451. get hasAlpha(): boolean;
  30452. /**
  30453. * Defines if the alpha value should be determined via the rgb values.
  30454. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30455. */
  30456. getAlphaFromRGB: boolean;
  30457. /**
  30458. * Intensity or strength of the texture.
  30459. * It is commonly used by materials to fine tune the intensity of the texture
  30460. */
  30461. level: number;
  30462. /**
  30463. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30464. * This is part of the texture as textures usually maps to one uv set.
  30465. */
  30466. coordinatesIndex: number;
  30467. private _coordinatesMode;
  30468. /**
  30469. * How a texture is mapped.
  30470. *
  30471. * | Value | Type | Description |
  30472. * | ----- | ----------------------------------- | ----------- |
  30473. * | 0 | EXPLICIT_MODE | |
  30474. * | 1 | SPHERICAL_MODE | |
  30475. * | 2 | PLANAR_MODE | |
  30476. * | 3 | CUBIC_MODE | |
  30477. * | 4 | PROJECTION_MODE | |
  30478. * | 5 | SKYBOX_MODE | |
  30479. * | 6 | INVCUBIC_MODE | |
  30480. * | 7 | EQUIRECTANGULAR_MODE | |
  30481. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30482. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30483. */
  30484. set coordinatesMode(value: number);
  30485. get coordinatesMode(): number;
  30486. /**
  30487. * | Value | Type | Description |
  30488. * | ----- | ------------------ | ----------- |
  30489. * | 0 | CLAMP_ADDRESSMODE | |
  30490. * | 1 | WRAP_ADDRESSMODE | |
  30491. * | 2 | MIRROR_ADDRESSMODE | |
  30492. */
  30493. wrapU: number;
  30494. /**
  30495. * | Value | Type | Description |
  30496. * | ----- | ------------------ | ----------- |
  30497. * | 0 | CLAMP_ADDRESSMODE | |
  30498. * | 1 | WRAP_ADDRESSMODE | |
  30499. * | 2 | MIRROR_ADDRESSMODE | |
  30500. */
  30501. wrapV: number;
  30502. /**
  30503. * | Value | Type | Description |
  30504. * | ----- | ------------------ | ----------- |
  30505. * | 0 | CLAMP_ADDRESSMODE | |
  30506. * | 1 | WRAP_ADDRESSMODE | |
  30507. * | 2 | MIRROR_ADDRESSMODE | |
  30508. */
  30509. wrapR: number;
  30510. /**
  30511. * With compliant hardware and browser (supporting anisotropic filtering)
  30512. * this defines the level of anisotropic filtering in the texture.
  30513. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30514. */
  30515. anisotropicFilteringLevel: number;
  30516. /**
  30517. * Define if the texture is a cube texture or if false a 2d texture.
  30518. */
  30519. get isCube(): boolean;
  30520. set isCube(value: boolean);
  30521. /**
  30522. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30523. */
  30524. get is3D(): boolean;
  30525. set is3D(value: boolean);
  30526. /**
  30527. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30528. */
  30529. get is2DArray(): boolean;
  30530. set is2DArray(value: boolean);
  30531. /**
  30532. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30533. * HDR texture are usually stored in linear space.
  30534. * This only impacts the PBR and Background materials
  30535. */
  30536. gammaSpace: boolean;
  30537. /**
  30538. * Gets or sets whether or not the texture contains RGBD data.
  30539. */
  30540. get isRGBD(): boolean;
  30541. set isRGBD(value: boolean);
  30542. /**
  30543. * Is Z inverted in the texture (useful in a cube texture).
  30544. */
  30545. invertZ: boolean;
  30546. /**
  30547. * Are mip maps generated for this texture or not.
  30548. */
  30549. get noMipmap(): boolean;
  30550. /**
  30551. * @hidden
  30552. */
  30553. lodLevelInAlpha: boolean;
  30554. /**
  30555. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30556. */
  30557. get lodGenerationOffset(): number;
  30558. set lodGenerationOffset(value: number);
  30559. /**
  30560. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30561. */
  30562. get lodGenerationScale(): number;
  30563. set lodGenerationScale(value: number);
  30564. /**
  30565. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30566. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30567. * average roughness values.
  30568. */
  30569. get linearSpecularLOD(): boolean;
  30570. set linearSpecularLOD(value: boolean);
  30571. /**
  30572. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30573. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30574. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30575. */
  30576. get irradianceTexture(): Nullable<BaseTexture>;
  30577. set irradianceTexture(value: Nullable<BaseTexture>);
  30578. /**
  30579. * Define if the texture is a render target.
  30580. */
  30581. isRenderTarget: boolean;
  30582. /**
  30583. * Define the unique id of the texture in the scene.
  30584. */
  30585. get uid(): string;
  30586. /**
  30587. * Return a string representation of the texture.
  30588. * @returns the texture as a string
  30589. */
  30590. toString(): string;
  30591. /**
  30592. * Get the class name of the texture.
  30593. * @returns "BaseTexture"
  30594. */
  30595. getClassName(): string;
  30596. /**
  30597. * Define the list of animation attached to the texture.
  30598. */
  30599. animations: import("babylonjs/Animations/animation").Animation[];
  30600. /**
  30601. * An event triggered when the texture is disposed.
  30602. */
  30603. onDisposeObservable: Observable<BaseTexture>;
  30604. private _onDisposeObserver;
  30605. /**
  30606. * Callback triggered when the texture has been disposed.
  30607. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30608. */
  30609. set onDispose(callback: () => void);
  30610. /**
  30611. * Define the current state of the loading sequence when in delayed load mode.
  30612. */
  30613. delayLoadState: number;
  30614. private _scene;
  30615. /** @hidden */
  30616. _texture: Nullable<InternalTexture>;
  30617. private _uid;
  30618. /**
  30619. * Define if the texture is preventinga material to render or not.
  30620. * If not and the texture is not ready, the engine will use a default black texture instead.
  30621. */
  30622. get isBlocking(): boolean;
  30623. /**
  30624. * Instantiates a new BaseTexture.
  30625. * Base class of all the textures in babylon.
  30626. * It groups all the common properties the materials, post process, lights... might need
  30627. * in order to make a correct use of the texture.
  30628. * @param scene Define the scene the texture blongs to
  30629. */
  30630. constructor(scene: Nullable<Scene>);
  30631. /**
  30632. * Get the scene the texture belongs to.
  30633. * @returns the scene or null if undefined
  30634. */
  30635. getScene(): Nullable<Scene>;
  30636. /**
  30637. * Get the texture transform matrix used to offset tile the texture for istance.
  30638. * @returns the transformation matrix
  30639. */
  30640. getTextureMatrix(): Matrix;
  30641. /**
  30642. * Get the texture reflection matrix used to rotate/transform the reflection.
  30643. * @returns the reflection matrix
  30644. */
  30645. getReflectionTextureMatrix(): Matrix;
  30646. /**
  30647. * Get the underlying lower level texture from Babylon.
  30648. * @returns the insternal texture
  30649. */
  30650. getInternalTexture(): Nullable<InternalTexture>;
  30651. /**
  30652. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30653. * @returns true if ready or not blocking
  30654. */
  30655. isReadyOrNotBlocking(): boolean;
  30656. /**
  30657. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30658. * @returns true if fully ready
  30659. */
  30660. isReady(): boolean;
  30661. private _cachedSize;
  30662. /**
  30663. * Get the size of the texture.
  30664. * @returns the texture size.
  30665. */
  30666. getSize(): ISize;
  30667. /**
  30668. * Get the base size of the texture.
  30669. * It can be different from the size if the texture has been resized for POT for instance
  30670. * @returns the base size
  30671. */
  30672. getBaseSize(): ISize;
  30673. /**
  30674. * Update the sampling mode of the texture.
  30675. * Default is Trilinear mode.
  30676. *
  30677. * | Value | Type | Description |
  30678. * | ----- | ------------------ | ----------- |
  30679. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30680. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30681. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30682. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30683. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30684. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30685. * | 7 | NEAREST_LINEAR | |
  30686. * | 8 | NEAREST_NEAREST | |
  30687. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30688. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30689. * | 11 | LINEAR_LINEAR | |
  30690. * | 12 | LINEAR_NEAREST | |
  30691. *
  30692. * > _mag_: magnification filter (close to the viewer)
  30693. * > _min_: minification filter (far from the viewer)
  30694. * > _mip_: filter used between mip map levels
  30695. *@param samplingMode Define the new sampling mode of the texture
  30696. */
  30697. updateSamplingMode(samplingMode: number): void;
  30698. /**
  30699. * Scales the texture if is `canRescale()`
  30700. * @param ratio the resize factor we want to use to rescale
  30701. */
  30702. scale(ratio: number): void;
  30703. /**
  30704. * Get if the texture can rescale.
  30705. */
  30706. get canRescale(): boolean;
  30707. /** @hidden */
  30708. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30709. /** @hidden */
  30710. _rebuild(): void;
  30711. /**
  30712. * Triggers the load sequence in delayed load mode.
  30713. */
  30714. delayLoad(): void;
  30715. /**
  30716. * Clones the texture.
  30717. * @returns the cloned texture
  30718. */
  30719. clone(): Nullable<BaseTexture>;
  30720. /**
  30721. * Get the texture underlying type (INT, FLOAT...)
  30722. */
  30723. get textureType(): number;
  30724. /**
  30725. * Get the texture underlying format (RGB, RGBA...)
  30726. */
  30727. get textureFormat(): number;
  30728. /**
  30729. * Indicates that textures need to be re-calculated for all materials
  30730. */
  30731. protected _markAllSubMeshesAsTexturesDirty(): void;
  30732. /**
  30733. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30734. * This will returns an RGBA array buffer containing either in values (0-255) or
  30735. * float values (0-1) depending of the underlying buffer type.
  30736. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30737. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30738. * @param buffer defines a user defined buffer to fill with data (can be null)
  30739. * @returns The Array buffer containing the pixels data.
  30740. */
  30741. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30742. /**
  30743. * Release and destroy the underlying lower level texture aka internalTexture.
  30744. */
  30745. releaseInternalTexture(): void;
  30746. /** @hidden */
  30747. get _lodTextureHigh(): Nullable<BaseTexture>;
  30748. /** @hidden */
  30749. get _lodTextureMid(): Nullable<BaseTexture>;
  30750. /** @hidden */
  30751. get _lodTextureLow(): Nullable<BaseTexture>;
  30752. /**
  30753. * Dispose the texture and release its associated resources.
  30754. */
  30755. dispose(): void;
  30756. /**
  30757. * Serialize the texture into a JSON representation that can be parsed later on.
  30758. * @returns the JSON representation of the texture
  30759. */
  30760. serialize(): any;
  30761. /**
  30762. * Helper function to be called back once a list of texture contains only ready textures.
  30763. * @param textures Define the list of textures to wait for
  30764. * @param callback Define the callback triggered once the entire list will be ready
  30765. */
  30766. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30767. }
  30768. }
  30769. declare module "babylonjs/Materials/effect" {
  30770. import { Observable } from "babylonjs/Misc/observable";
  30771. import { Nullable } from "babylonjs/types";
  30772. import { IDisposable } from "babylonjs/scene";
  30773. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30774. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30775. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30776. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30777. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30778. import { Engine } from "babylonjs/Engines/engine";
  30779. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30780. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30781. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30782. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30783. /**
  30784. * Options to be used when creating an effect.
  30785. */
  30786. export interface IEffectCreationOptions {
  30787. /**
  30788. * Atrributes that will be used in the shader.
  30789. */
  30790. attributes: string[];
  30791. /**
  30792. * Uniform varible names that will be set in the shader.
  30793. */
  30794. uniformsNames: string[];
  30795. /**
  30796. * Uniform buffer variable names that will be set in the shader.
  30797. */
  30798. uniformBuffersNames: string[];
  30799. /**
  30800. * Sampler texture variable names that will be set in the shader.
  30801. */
  30802. samplers: string[];
  30803. /**
  30804. * Define statements that will be set in the shader.
  30805. */
  30806. defines: any;
  30807. /**
  30808. * Possible fallbacks for this effect to improve performance when needed.
  30809. */
  30810. fallbacks: Nullable<IEffectFallbacks>;
  30811. /**
  30812. * Callback that will be called when the shader is compiled.
  30813. */
  30814. onCompiled: Nullable<(effect: Effect) => void>;
  30815. /**
  30816. * Callback that will be called if an error occurs during shader compilation.
  30817. */
  30818. onError: Nullable<(effect: Effect, errors: string) => void>;
  30819. /**
  30820. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30821. */
  30822. indexParameters?: any;
  30823. /**
  30824. * Max number of lights that can be used in the shader.
  30825. */
  30826. maxSimultaneousLights?: number;
  30827. /**
  30828. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30829. */
  30830. transformFeedbackVaryings?: Nullable<string[]>;
  30831. }
  30832. /**
  30833. * Effect containing vertex and fragment shader that can be executed on an object.
  30834. */
  30835. export class Effect implements IDisposable {
  30836. /**
  30837. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30838. */
  30839. static ShadersRepository: string;
  30840. /**
  30841. * Name of the effect.
  30842. */
  30843. name: any;
  30844. /**
  30845. * String container all the define statements that should be set on the shader.
  30846. */
  30847. defines: string;
  30848. /**
  30849. * Callback that will be called when the shader is compiled.
  30850. */
  30851. onCompiled: Nullable<(effect: Effect) => void>;
  30852. /**
  30853. * Callback that will be called if an error occurs during shader compilation.
  30854. */
  30855. onError: Nullable<(effect: Effect, errors: string) => void>;
  30856. /**
  30857. * Callback that will be called when effect is bound.
  30858. */
  30859. onBind: Nullable<(effect: Effect) => void>;
  30860. /**
  30861. * Unique ID of the effect.
  30862. */
  30863. uniqueId: number;
  30864. /**
  30865. * Observable that will be called when the shader is compiled.
  30866. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30867. */
  30868. onCompileObservable: Observable<Effect>;
  30869. /**
  30870. * Observable that will be called if an error occurs during shader compilation.
  30871. */
  30872. onErrorObservable: Observable<Effect>;
  30873. /** @hidden */
  30874. _onBindObservable: Nullable<Observable<Effect>>;
  30875. /**
  30876. * @hidden
  30877. * Specifies if the effect was previously ready
  30878. */
  30879. _wasPreviouslyReady: boolean;
  30880. /**
  30881. * Observable that will be called when effect is bound.
  30882. */
  30883. get onBindObservable(): Observable<Effect>;
  30884. /** @hidden */
  30885. _bonesComputationForcedToCPU: boolean;
  30886. private static _uniqueIdSeed;
  30887. private _engine;
  30888. private _uniformBuffersNames;
  30889. private _uniformsNames;
  30890. private _samplerList;
  30891. private _samplers;
  30892. private _isReady;
  30893. private _compilationError;
  30894. private _allFallbacksProcessed;
  30895. private _attributesNames;
  30896. private _attributes;
  30897. private _attributeLocationByName;
  30898. private _uniforms;
  30899. /**
  30900. * Key for the effect.
  30901. * @hidden
  30902. */
  30903. _key: string;
  30904. private _indexParameters;
  30905. private _fallbacks;
  30906. private _vertexSourceCode;
  30907. private _fragmentSourceCode;
  30908. private _vertexSourceCodeOverride;
  30909. private _fragmentSourceCodeOverride;
  30910. private _transformFeedbackVaryings;
  30911. /**
  30912. * Compiled shader to webGL program.
  30913. * @hidden
  30914. */
  30915. _pipelineContext: Nullable<IPipelineContext>;
  30916. private _valueCache;
  30917. private static _baseCache;
  30918. /**
  30919. * Instantiates an effect.
  30920. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30921. * @param baseName Name of the effect.
  30922. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30923. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30924. * @param samplers List of sampler variables that will be passed to the shader.
  30925. * @param engine Engine to be used to render the effect
  30926. * @param defines Define statements to be added to the shader.
  30927. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30928. * @param onCompiled Callback that will be called when the shader is compiled.
  30929. * @param onError Callback that will be called if an error occurs during shader compilation.
  30930. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30931. */
  30932. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  30933. private _useFinalCode;
  30934. /**
  30935. * Unique key for this effect
  30936. */
  30937. get key(): string;
  30938. /**
  30939. * If the effect has been compiled and prepared.
  30940. * @returns if the effect is compiled and prepared.
  30941. */
  30942. isReady(): boolean;
  30943. private _isReadyInternal;
  30944. /**
  30945. * The engine the effect was initialized with.
  30946. * @returns the engine.
  30947. */
  30948. getEngine(): Engine;
  30949. /**
  30950. * The pipeline context for this effect
  30951. * @returns the associated pipeline context
  30952. */
  30953. getPipelineContext(): Nullable<IPipelineContext>;
  30954. /**
  30955. * The set of names of attribute variables for the shader.
  30956. * @returns An array of attribute names.
  30957. */
  30958. getAttributesNames(): string[];
  30959. /**
  30960. * Returns the attribute at the given index.
  30961. * @param index The index of the attribute.
  30962. * @returns The location of the attribute.
  30963. */
  30964. getAttributeLocation(index: number): number;
  30965. /**
  30966. * Returns the attribute based on the name of the variable.
  30967. * @param name of the attribute to look up.
  30968. * @returns the attribute location.
  30969. */
  30970. getAttributeLocationByName(name: string): number;
  30971. /**
  30972. * The number of attributes.
  30973. * @returns the numnber of attributes.
  30974. */
  30975. getAttributesCount(): number;
  30976. /**
  30977. * Gets the index of a uniform variable.
  30978. * @param uniformName of the uniform to look up.
  30979. * @returns the index.
  30980. */
  30981. getUniformIndex(uniformName: string): number;
  30982. /**
  30983. * Returns the attribute based on the name of the variable.
  30984. * @param uniformName of the uniform to look up.
  30985. * @returns the location of the uniform.
  30986. */
  30987. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30988. /**
  30989. * Returns an array of sampler variable names
  30990. * @returns The array of sampler variable neames.
  30991. */
  30992. getSamplers(): string[];
  30993. /**
  30994. * The error from the last compilation.
  30995. * @returns the error string.
  30996. */
  30997. getCompilationError(): string;
  30998. /**
  30999. * Gets a boolean indicating that all fallbacks were used during compilation
  31000. * @returns true if all fallbacks were used
  31001. */
  31002. allFallbacksProcessed(): boolean;
  31003. /**
  31004. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  31005. * @param func The callback to be used.
  31006. */
  31007. executeWhenCompiled(func: (effect: Effect) => void): void;
  31008. private _checkIsReady;
  31009. private _loadShader;
  31010. /**
  31011. * Recompiles the webGL program
  31012. * @param vertexSourceCode The source code for the vertex shader.
  31013. * @param fragmentSourceCode The source code for the fragment shader.
  31014. * @param onCompiled Callback called when completed.
  31015. * @param onError Callback called on error.
  31016. * @hidden
  31017. */
  31018. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  31019. /**
  31020. * Prepares the effect
  31021. * @hidden
  31022. */
  31023. _prepareEffect(): void;
  31024. private _processCompilationErrors;
  31025. /**
  31026. * Checks if the effect is supported. (Must be called after compilation)
  31027. */
  31028. get isSupported(): boolean;
  31029. /**
  31030. * Binds a texture to the engine to be used as output of the shader.
  31031. * @param channel Name of the output variable.
  31032. * @param texture Texture to bind.
  31033. * @hidden
  31034. */
  31035. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  31036. /**
  31037. * Sets a texture on the engine to be used in the shader.
  31038. * @param channel Name of the sampler variable.
  31039. * @param texture Texture to set.
  31040. */
  31041. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31042. /**
  31043. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31044. * @param channel Name of the sampler variable.
  31045. * @param texture Texture to set.
  31046. */
  31047. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31048. /**
  31049. * Sets an array of textures on the engine to be used in the shader.
  31050. * @param channel Name of the variable.
  31051. * @param textures Textures to set.
  31052. */
  31053. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31054. /**
  31055. * 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)
  31056. * @param channel Name of the sampler variable.
  31057. * @param postProcess Post process to get the input texture from.
  31058. */
  31059. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31060. /**
  31061. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31062. * 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)
  31063. * @param channel Name of the sampler variable.
  31064. * @param postProcess Post process to get the output texture from.
  31065. */
  31066. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31067. /** @hidden */
  31068. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31069. /** @hidden */
  31070. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31071. /** @hidden */
  31072. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31073. /** @hidden */
  31074. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31075. /**
  31076. * Binds a buffer to a uniform.
  31077. * @param buffer Buffer to bind.
  31078. * @param name Name of the uniform variable to bind to.
  31079. */
  31080. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31081. /**
  31082. * Binds block to a uniform.
  31083. * @param blockName Name of the block to bind.
  31084. * @param index Index to bind.
  31085. */
  31086. bindUniformBlock(blockName: string, index: number): void;
  31087. /**
  31088. * Sets an interger value on a uniform variable.
  31089. * @param uniformName Name of the variable.
  31090. * @param value Value to be set.
  31091. * @returns this effect.
  31092. */
  31093. setInt(uniformName: string, value: number): Effect;
  31094. /**
  31095. * Sets an int array on a uniform variable.
  31096. * @param uniformName Name of the variable.
  31097. * @param array array to be set.
  31098. * @returns this effect.
  31099. */
  31100. setIntArray(uniformName: string, array: Int32Array): Effect;
  31101. /**
  31102. * 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)
  31103. * @param uniformName Name of the variable.
  31104. * @param array array to be set.
  31105. * @returns this effect.
  31106. */
  31107. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31108. /**
  31109. * 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)
  31110. * @param uniformName Name of the variable.
  31111. * @param array array to be set.
  31112. * @returns this effect.
  31113. */
  31114. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31115. /**
  31116. * 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)
  31117. * @param uniformName Name of the variable.
  31118. * @param array array to be set.
  31119. * @returns this effect.
  31120. */
  31121. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31122. /**
  31123. * Sets an float array on a uniform variable.
  31124. * @param uniformName Name of the variable.
  31125. * @param array array to be set.
  31126. * @returns this effect.
  31127. */
  31128. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31129. /**
  31130. * 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)
  31131. * @param uniformName Name of the variable.
  31132. * @param array array to be set.
  31133. * @returns this effect.
  31134. */
  31135. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31136. /**
  31137. * 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)
  31138. * @param uniformName Name of the variable.
  31139. * @param array array to be set.
  31140. * @returns this effect.
  31141. */
  31142. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31143. /**
  31144. * 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)
  31145. * @param uniformName Name of the variable.
  31146. * @param array array to be set.
  31147. * @returns this effect.
  31148. */
  31149. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31150. /**
  31151. * Sets an array on a uniform variable.
  31152. * @param uniformName Name of the variable.
  31153. * @param array array to be set.
  31154. * @returns this effect.
  31155. */
  31156. setArray(uniformName: string, array: number[]): Effect;
  31157. /**
  31158. * 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)
  31159. * @param uniformName Name of the variable.
  31160. * @param array array to be set.
  31161. * @returns this effect.
  31162. */
  31163. setArray2(uniformName: string, array: number[]): Effect;
  31164. /**
  31165. * 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)
  31166. * @param uniformName Name of the variable.
  31167. * @param array array to be set.
  31168. * @returns this effect.
  31169. */
  31170. setArray3(uniformName: string, array: number[]): Effect;
  31171. /**
  31172. * 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)
  31173. * @param uniformName Name of the variable.
  31174. * @param array array to be set.
  31175. * @returns this effect.
  31176. */
  31177. setArray4(uniformName: string, array: number[]): Effect;
  31178. /**
  31179. * Sets matrices on a uniform variable.
  31180. * @param uniformName Name of the variable.
  31181. * @param matrices matrices to be set.
  31182. * @returns this effect.
  31183. */
  31184. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31185. /**
  31186. * Sets matrix on a uniform variable.
  31187. * @param uniformName Name of the variable.
  31188. * @param matrix matrix to be set.
  31189. * @returns this effect.
  31190. */
  31191. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31192. /**
  31193. * 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)
  31194. * @param uniformName Name of the variable.
  31195. * @param matrix matrix to be set.
  31196. * @returns this effect.
  31197. */
  31198. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31199. /**
  31200. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31201. * @param uniformName Name of the variable.
  31202. * @param matrix matrix to be set.
  31203. * @returns this effect.
  31204. */
  31205. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31206. /**
  31207. * Sets a float on a uniform variable.
  31208. * @param uniformName Name of the variable.
  31209. * @param value value to be set.
  31210. * @returns this effect.
  31211. */
  31212. setFloat(uniformName: string, value: number): Effect;
  31213. /**
  31214. * Sets a boolean on a uniform variable.
  31215. * @param uniformName Name of the variable.
  31216. * @param bool value to be set.
  31217. * @returns this effect.
  31218. */
  31219. setBool(uniformName: string, bool: boolean): Effect;
  31220. /**
  31221. * Sets a Vector2 on a uniform variable.
  31222. * @param uniformName Name of the variable.
  31223. * @param vector2 vector2 to be set.
  31224. * @returns this effect.
  31225. */
  31226. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31227. /**
  31228. * Sets a float2 on a uniform variable.
  31229. * @param uniformName Name of the variable.
  31230. * @param x First float in float2.
  31231. * @param y Second float in float2.
  31232. * @returns this effect.
  31233. */
  31234. setFloat2(uniformName: string, x: number, y: number): Effect;
  31235. /**
  31236. * Sets a Vector3 on a uniform variable.
  31237. * @param uniformName Name of the variable.
  31238. * @param vector3 Value to be set.
  31239. * @returns this effect.
  31240. */
  31241. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31242. /**
  31243. * Sets a float3 on a uniform variable.
  31244. * @param uniformName Name of the variable.
  31245. * @param x First float in float3.
  31246. * @param y Second float in float3.
  31247. * @param z Third float in float3.
  31248. * @returns this effect.
  31249. */
  31250. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31251. /**
  31252. * Sets a Vector4 on a uniform variable.
  31253. * @param uniformName Name of the variable.
  31254. * @param vector4 Value to be set.
  31255. * @returns this effect.
  31256. */
  31257. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31258. /**
  31259. * Sets a float4 on a uniform variable.
  31260. * @param uniformName Name of the variable.
  31261. * @param x First float in float4.
  31262. * @param y Second float in float4.
  31263. * @param z Third float in float4.
  31264. * @param w Fourth float in float4.
  31265. * @returns this effect.
  31266. */
  31267. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31268. /**
  31269. * Sets a Color3 on a uniform variable.
  31270. * @param uniformName Name of the variable.
  31271. * @param color3 Value to be set.
  31272. * @returns this effect.
  31273. */
  31274. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31275. /**
  31276. * Sets a Color4 on a uniform variable.
  31277. * @param uniformName Name of the variable.
  31278. * @param color3 Value to be set.
  31279. * @param alpha Alpha value to be set.
  31280. * @returns this effect.
  31281. */
  31282. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31283. /**
  31284. * Sets a Color4 on a uniform variable
  31285. * @param uniformName defines the name of the variable
  31286. * @param color4 defines the value to be set
  31287. * @returns this effect.
  31288. */
  31289. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31290. /** Release all associated resources */
  31291. dispose(): void;
  31292. /**
  31293. * This function will add a new shader to the shader store
  31294. * @param name the name of the shader
  31295. * @param pixelShader optional pixel shader content
  31296. * @param vertexShader optional vertex shader content
  31297. */
  31298. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31299. /**
  31300. * Store of each shader (The can be looked up using effect.key)
  31301. */
  31302. static ShadersStore: {
  31303. [key: string]: string;
  31304. };
  31305. /**
  31306. * Store of each included file for a shader (The can be looked up using effect.key)
  31307. */
  31308. static IncludesShadersStore: {
  31309. [key: string]: string;
  31310. };
  31311. /**
  31312. * Resets the cache of effects.
  31313. */
  31314. static ResetCache(): void;
  31315. }
  31316. }
  31317. declare module "babylonjs/Engines/engineCapabilities" {
  31318. /**
  31319. * Interface used to describe the capabilities of the engine relatively to the current browser
  31320. */
  31321. export interface EngineCapabilities {
  31322. /** Maximum textures units per fragment shader */
  31323. maxTexturesImageUnits: number;
  31324. /** Maximum texture units per vertex shader */
  31325. maxVertexTextureImageUnits: number;
  31326. /** Maximum textures units in the entire pipeline */
  31327. maxCombinedTexturesImageUnits: number;
  31328. /** Maximum texture size */
  31329. maxTextureSize: number;
  31330. /** Maximum texture samples */
  31331. maxSamples?: number;
  31332. /** Maximum cube texture size */
  31333. maxCubemapTextureSize: number;
  31334. /** Maximum render texture size */
  31335. maxRenderTextureSize: number;
  31336. /** Maximum number of vertex attributes */
  31337. maxVertexAttribs: number;
  31338. /** Maximum number of varyings */
  31339. maxVaryingVectors: number;
  31340. /** Maximum number of uniforms per vertex shader */
  31341. maxVertexUniformVectors: number;
  31342. /** Maximum number of uniforms per fragment shader */
  31343. maxFragmentUniformVectors: number;
  31344. /** Defines if standard derivates (dx/dy) are supported */
  31345. standardDerivatives: boolean;
  31346. /** Defines if s3tc texture compression is supported */
  31347. s3tc?: WEBGL_compressed_texture_s3tc;
  31348. /** Defines if pvrtc texture compression is supported */
  31349. pvrtc: any;
  31350. /** Defines if etc1 texture compression is supported */
  31351. etc1: any;
  31352. /** Defines if etc2 texture compression is supported */
  31353. etc2: any;
  31354. /** Defines if astc texture compression is supported */
  31355. astc: any;
  31356. /** Defines if float textures are supported */
  31357. textureFloat: boolean;
  31358. /** Defines if vertex array objects are supported */
  31359. vertexArrayObject: boolean;
  31360. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31361. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31362. /** Gets the maximum level of anisotropy supported */
  31363. maxAnisotropy: number;
  31364. /** Defines if instancing is supported */
  31365. instancedArrays: boolean;
  31366. /** Defines if 32 bits indices are supported */
  31367. uintIndices: boolean;
  31368. /** Defines if high precision shaders are supported */
  31369. highPrecisionShaderSupported: boolean;
  31370. /** Defines if depth reading in the fragment shader is supported */
  31371. fragmentDepthSupported: boolean;
  31372. /** Defines if float texture linear filtering is supported*/
  31373. textureFloatLinearFiltering: boolean;
  31374. /** Defines if rendering to float textures is supported */
  31375. textureFloatRender: boolean;
  31376. /** Defines if half float textures are supported*/
  31377. textureHalfFloat: boolean;
  31378. /** Defines if half float texture linear filtering is supported*/
  31379. textureHalfFloatLinearFiltering: boolean;
  31380. /** Defines if rendering to half float textures is supported */
  31381. textureHalfFloatRender: boolean;
  31382. /** Defines if textureLOD shader command is supported */
  31383. textureLOD: boolean;
  31384. /** Defines if draw buffers extension is supported */
  31385. drawBuffersExtension: boolean;
  31386. /** Defines if depth textures are supported */
  31387. depthTextureExtension: boolean;
  31388. /** Defines if float color buffer are supported */
  31389. colorBufferFloat: boolean;
  31390. /** Gets disjoint timer query extension (null if not supported) */
  31391. timerQuery?: EXT_disjoint_timer_query;
  31392. /** Defines if timestamp can be used with timer query */
  31393. canUseTimestampForTimerQuery: boolean;
  31394. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31395. multiview?: any;
  31396. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31397. oculusMultiview?: any;
  31398. /** Function used to let the system compiles shaders in background */
  31399. parallelShaderCompile?: {
  31400. COMPLETION_STATUS_KHR: number;
  31401. };
  31402. /** Max number of texture samples for MSAA */
  31403. maxMSAASamples: number;
  31404. /** Defines if the blend min max extension is supported */
  31405. blendMinMax: boolean;
  31406. }
  31407. }
  31408. declare module "babylonjs/States/depthCullingState" {
  31409. import { Nullable } from "babylonjs/types";
  31410. /**
  31411. * @hidden
  31412. **/
  31413. export class DepthCullingState {
  31414. private _isDepthTestDirty;
  31415. private _isDepthMaskDirty;
  31416. private _isDepthFuncDirty;
  31417. private _isCullFaceDirty;
  31418. private _isCullDirty;
  31419. private _isZOffsetDirty;
  31420. private _isFrontFaceDirty;
  31421. private _depthTest;
  31422. private _depthMask;
  31423. private _depthFunc;
  31424. private _cull;
  31425. private _cullFace;
  31426. private _zOffset;
  31427. private _frontFace;
  31428. /**
  31429. * Initializes the state.
  31430. */
  31431. constructor();
  31432. get isDirty(): boolean;
  31433. get zOffset(): number;
  31434. set zOffset(value: number);
  31435. get cullFace(): Nullable<number>;
  31436. set cullFace(value: Nullable<number>);
  31437. get cull(): Nullable<boolean>;
  31438. set cull(value: Nullable<boolean>);
  31439. get depthFunc(): Nullable<number>;
  31440. set depthFunc(value: Nullable<number>);
  31441. get depthMask(): boolean;
  31442. set depthMask(value: boolean);
  31443. get depthTest(): boolean;
  31444. set depthTest(value: boolean);
  31445. get frontFace(): Nullable<number>;
  31446. set frontFace(value: Nullable<number>);
  31447. reset(): void;
  31448. apply(gl: WebGLRenderingContext): void;
  31449. }
  31450. }
  31451. declare module "babylonjs/States/stencilState" {
  31452. /**
  31453. * @hidden
  31454. **/
  31455. export class StencilState {
  31456. /** 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 */
  31457. static readonly ALWAYS: number;
  31458. /** Passed to stencilOperation to specify that stencil value must be kept */
  31459. static readonly KEEP: number;
  31460. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31461. static readonly REPLACE: number;
  31462. private _isStencilTestDirty;
  31463. private _isStencilMaskDirty;
  31464. private _isStencilFuncDirty;
  31465. private _isStencilOpDirty;
  31466. private _stencilTest;
  31467. private _stencilMask;
  31468. private _stencilFunc;
  31469. private _stencilFuncRef;
  31470. private _stencilFuncMask;
  31471. private _stencilOpStencilFail;
  31472. private _stencilOpDepthFail;
  31473. private _stencilOpStencilDepthPass;
  31474. get isDirty(): boolean;
  31475. get stencilFunc(): number;
  31476. set stencilFunc(value: number);
  31477. get stencilFuncRef(): number;
  31478. set stencilFuncRef(value: number);
  31479. get stencilFuncMask(): number;
  31480. set stencilFuncMask(value: number);
  31481. get stencilOpStencilFail(): number;
  31482. set stencilOpStencilFail(value: number);
  31483. get stencilOpDepthFail(): number;
  31484. set stencilOpDepthFail(value: number);
  31485. get stencilOpStencilDepthPass(): number;
  31486. set stencilOpStencilDepthPass(value: number);
  31487. get stencilMask(): number;
  31488. set stencilMask(value: number);
  31489. get stencilTest(): boolean;
  31490. set stencilTest(value: boolean);
  31491. constructor();
  31492. reset(): void;
  31493. apply(gl: WebGLRenderingContext): void;
  31494. }
  31495. }
  31496. declare module "babylonjs/States/alphaCullingState" {
  31497. /**
  31498. * @hidden
  31499. **/
  31500. export class AlphaState {
  31501. private _isAlphaBlendDirty;
  31502. private _isBlendFunctionParametersDirty;
  31503. private _isBlendEquationParametersDirty;
  31504. private _isBlendConstantsDirty;
  31505. private _alphaBlend;
  31506. private _blendFunctionParameters;
  31507. private _blendEquationParameters;
  31508. private _blendConstants;
  31509. /**
  31510. * Initializes the state.
  31511. */
  31512. constructor();
  31513. get isDirty(): boolean;
  31514. get alphaBlend(): boolean;
  31515. set alphaBlend(value: boolean);
  31516. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31517. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31518. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31519. reset(): void;
  31520. apply(gl: WebGLRenderingContext): void;
  31521. }
  31522. }
  31523. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31524. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31525. /** @hidden */
  31526. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31527. attributeProcessor(attribute: string): string;
  31528. varyingProcessor(varying: string, isFragment: boolean): string;
  31529. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31530. }
  31531. }
  31532. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31533. /**
  31534. * Interface for attribute information associated with buffer instanciation
  31535. */
  31536. export interface InstancingAttributeInfo {
  31537. /**
  31538. * Name of the GLSL attribute
  31539. * if attribute index is not specified, this is used to retrieve the index from the effect
  31540. */
  31541. attributeName: string;
  31542. /**
  31543. * Index/offset of the attribute in the vertex shader
  31544. * if not specified, this will be computes from the name.
  31545. */
  31546. index?: number;
  31547. /**
  31548. * size of the attribute, 1, 2, 3 or 4
  31549. */
  31550. attributeSize: number;
  31551. /**
  31552. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31553. */
  31554. offset: number;
  31555. /**
  31556. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31557. * default to 1
  31558. */
  31559. divisor?: number;
  31560. /**
  31561. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31562. * default is FLOAT
  31563. */
  31564. attributeType?: number;
  31565. /**
  31566. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31567. */
  31568. normalized?: boolean;
  31569. }
  31570. }
  31571. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31572. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31573. import { Nullable } from "babylonjs/types";
  31574. module "babylonjs/Engines/thinEngine" {
  31575. interface ThinEngine {
  31576. /**
  31577. * Update a video texture
  31578. * @param texture defines the texture to update
  31579. * @param video defines the video element to use
  31580. * @param invertY defines if data must be stored with Y axis inverted
  31581. */
  31582. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31583. }
  31584. }
  31585. }
  31586. declare module "babylonjs/Materials/Textures/videoTexture" {
  31587. import { Observable } from "babylonjs/Misc/observable";
  31588. import { Nullable } from "babylonjs/types";
  31589. import { Scene } from "babylonjs/scene";
  31590. import { Texture } from "babylonjs/Materials/Textures/texture";
  31591. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31592. /**
  31593. * Settings for finer control over video usage
  31594. */
  31595. export interface VideoTextureSettings {
  31596. /**
  31597. * Applies `autoplay` to video, if specified
  31598. */
  31599. autoPlay?: boolean;
  31600. /**
  31601. * Applies `loop` to video, if specified
  31602. */
  31603. loop?: boolean;
  31604. /**
  31605. * Automatically updates internal texture from video at every frame in the render loop
  31606. */
  31607. autoUpdateTexture: boolean;
  31608. /**
  31609. * Image src displayed during the video loading or until the user interacts with the video.
  31610. */
  31611. poster?: string;
  31612. }
  31613. /**
  31614. * If you want to display a video in your scene, this is the special texture for that.
  31615. * This special texture works similar to other textures, with the exception of a few parameters.
  31616. * @see https://doc.babylonjs.com/how_to/video_texture
  31617. */
  31618. export class VideoTexture extends Texture {
  31619. /**
  31620. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31621. */
  31622. readonly autoUpdateTexture: boolean;
  31623. /**
  31624. * The video instance used by the texture internally
  31625. */
  31626. readonly video: HTMLVideoElement;
  31627. private _onUserActionRequestedObservable;
  31628. /**
  31629. * Event triggerd when a dom action is required by the user to play the video.
  31630. * This happens due to recent changes in browser policies preventing video to auto start.
  31631. */
  31632. get onUserActionRequestedObservable(): Observable<Texture>;
  31633. private _generateMipMaps;
  31634. private _engine;
  31635. private _stillImageCaptured;
  31636. private _displayingPosterTexture;
  31637. private _settings;
  31638. private _createInternalTextureOnEvent;
  31639. private _frameId;
  31640. private _currentSrc;
  31641. /**
  31642. * Creates a video texture.
  31643. * If you want to display a video in your scene, this is the special texture for that.
  31644. * This special texture works similar to other textures, with the exception of a few parameters.
  31645. * @see https://doc.babylonjs.com/how_to/video_texture
  31646. * @param name optional name, will detect from video source, if not defined
  31647. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31648. * @param scene is obviously the current scene.
  31649. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31650. * @param invertY is false by default but can be used to invert video on Y axis
  31651. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31652. * @param settings allows finer control over video usage
  31653. */
  31654. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31655. private _getName;
  31656. private _getVideo;
  31657. private _createInternalTexture;
  31658. private reset;
  31659. /**
  31660. * @hidden Internal method to initiate `update`.
  31661. */
  31662. _rebuild(): void;
  31663. /**
  31664. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31665. */
  31666. update(): void;
  31667. /**
  31668. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31669. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31670. */
  31671. updateTexture(isVisible: boolean): void;
  31672. protected _updateInternalTexture: () => void;
  31673. /**
  31674. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31675. * @param url New url.
  31676. */
  31677. updateURL(url: string): void;
  31678. /**
  31679. * Clones the texture.
  31680. * @returns the cloned texture
  31681. */
  31682. clone(): VideoTexture;
  31683. /**
  31684. * Dispose the texture and release its associated resources.
  31685. */
  31686. dispose(): void;
  31687. /**
  31688. * Creates a video texture straight from a stream.
  31689. * @param scene Define the scene the texture should be created in
  31690. * @param stream Define the stream the texture should be created from
  31691. * @returns The created video texture as a promise
  31692. */
  31693. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31694. /**
  31695. * Creates a video texture straight from your WebCam video feed.
  31696. * @param scene Define the scene the texture should be created in
  31697. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31698. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31699. * @returns The created video texture as a promise
  31700. */
  31701. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31702. minWidth: number;
  31703. maxWidth: number;
  31704. minHeight: number;
  31705. maxHeight: number;
  31706. deviceId: string;
  31707. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31708. /**
  31709. * Creates a video texture straight from your WebCam video feed.
  31710. * @param scene Define the scene the texture should be created in
  31711. * @param onReady Define a callback to triggered once the texture will be ready
  31712. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31713. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31714. */
  31715. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31716. minWidth: number;
  31717. maxWidth: number;
  31718. minHeight: number;
  31719. maxHeight: number;
  31720. deviceId: string;
  31721. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31722. }
  31723. }
  31724. declare module "babylonjs/Engines/thinEngine" {
  31725. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31726. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31727. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31728. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31729. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31730. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31731. import { Observable } from "babylonjs/Misc/observable";
  31732. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31733. import { StencilState } from "babylonjs/States/stencilState";
  31734. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31735. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31736. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31737. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31738. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31739. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31740. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31741. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31742. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31743. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31744. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31745. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31746. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31747. import { WebRequest } from "babylonjs/Misc/webRequest";
  31748. import { LoadFileError } from "babylonjs/Misc/fileTools";
  31749. /**
  31750. * Defines the interface used by objects working like Scene
  31751. * @hidden
  31752. */
  31753. interface ISceneLike {
  31754. _addPendingData(data: any): void;
  31755. _removePendingData(data: any): void;
  31756. offlineProvider: IOfflineProvider;
  31757. }
  31758. /** Interface defining initialization parameters for Engine class */
  31759. export interface EngineOptions extends WebGLContextAttributes {
  31760. /**
  31761. * Defines if the engine should no exceed a specified device ratio
  31762. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31763. */
  31764. limitDeviceRatio?: number;
  31765. /**
  31766. * Defines if webvr should be enabled automatically
  31767. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31768. */
  31769. autoEnableWebVR?: boolean;
  31770. /**
  31771. * Defines if webgl2 should be turned off even if supported
  31772. * @see http://doc.babylonjs.com/features/webgl2
  31773. */
  31774. disableWebGL2Support?: boolean;
  31775. /**
  31776. * Defines if webaudio should be initialized as well
  31777. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31778. */
  31779. audioEngine?: boolean;
  31780. /**
  31781. * Defines if animations should run using a deterministic lock step
  31782. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31783. */
  31784. deterministicLockstep?: boolean;
  31785. /** Defines the maximum steps to use with deterministic lock step mode */
  31786. lockstepMaxSteps?: number;
  31787. /** Defines the seconds between each deterministic lock step */
  31788. timeStep?: number;
  31789. /**
  31790. * Defines that engine should ignore context lost events
  31791. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31792. */
  31793. doNotHandleContextLost?: boolean;
  31794. /**
  31795. * Defines that engine should ignore modifying touch action attribute and style
  31796. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31797. */
  31798. doNotHandleTouchAction?: boolean;
  31799. /**
  31800. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31801. */
  31802. useHighPrecisionFloats?: boolean;
  31803. }
  31804. /**
  31805. * The base engine class (root of all engines)
  31806. */
  31807. export class ThinEngine {
  31808. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31809. static ExceptionList: ({
  31810. key: string;
  31811. capture: string;
  31812. captureConstraint: number;
  31813. targets: string[];
  31814. } | {
  31815. key: string;
  31816. capture: null;
  31817. captureConstraint: null;
  31818. targets: string[];
  31819. })[];
  31820. /** @hidden */
  31821. static _TextureLoaders: IInternalTextureLoader[];
  31822. /**
  31823. * Returns the current npm package of the sdk
  31824. */
  31825. static get NpmPackage(): string;
  31826. /**
  31827. * Returns the current version of the framework
  31828. */
  31829. static get Version(): string;
  31830. /**
  31831. * Returns a string describing the current engine
  31832. */
  31833. get description(): string;
  31834. /**
  31835. * Gets or sets the epsilon value used by collision engine
  31836. */
  31837. static CollisionsEpsilon: number;
  31838. /**
  31839. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31840. */
  31841. static get ShadersRepository(): string;
  31842. static set ShadersRepository(value: string);
  31843. /**
  31844. * Gets or sets the textures that the engine should not attempt to load as compressed
  31845. */
  31846. protected _excludedCompressedTextures: string[];
  31847. /**
  31848. * Filters the compressed texture formats to only include
  31849. * files that are not included in the skippable list
  31850. *
  31851. * @param url the current extension
  31852. * @param textureFormatInUse the current compressed texture format
  31853. * @returns "format" string
  31854. */
  31855. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  31856. /** @hidden */
  31857. _shaderProcessor: IShaderProcessor;
  31858. /**
  31859. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31860. */
  31861. forcePOTTextures: boolean;
  31862. /**
  31863. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31864. */
  31865. isFullscreen: boolean;
  31866. /**
  31867. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31868. */
  31869. cullBackFaces: boolean;
  31870. /**
  31871. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31872. */
  31873. renderEvenInBackground: boolean;
  31874. /**
  31875. * Gets or sets a boolean indicating that cache can be kept between frames
  31876. */
  31877. preventCacheWipeBetweenFrames: boolean;
  31878. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31879. validateShaderPrograms: boolean;
  31880. /**
  31881. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31882. * This can provide greater z depth for distant objects.
  31883. */
  31884. useReverseDepthBuffer: boolean;
  31885. /**
  31886. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31887. */
  31888. disableUniformBuffers: boolean;
  31889. /** @hidden */
  31890. _uniformBuffers: UniformBuffer[];
  31891. /**
  31892. * Gets a boolean indicating that the engine supports uniform buffers
  31893. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31894. */
  31895. get supportsUniformBuffers(): boolean;
  31896. /** @hidden */
  31897. _gl: WebGLRenderingContext;
  31898. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31899. protected _windowIsBackground: boolean;
  31900. protected _webGLVersion: number;
  31901. protected _creationOptions: EngineOptions;
  31902. protected _highPrecisionShadersAllowed: boolean;
  31903. /** @hidden */
  31904. get _shouldUseHighPrecisionShader(): boolean;
  31905. /**
  31906. * Gets a boolean indicating that only power of 2 textures are supported
  31907. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31908. */
  31909. get needPOTTextures(): boolean;
  31910. /** @hidden */
  31911. _badOS: boolean;
  31912. /** @hidden */
  31913. _badDesktopOS: boolean;
  31914. private _hardwareScalingLevel;
  31915. /** @hidden */
  31916. _caps: EngineCapabilities;
  31917. private _isStencilEnable;
  31918. private _glVersion;
  31919. private _glRenderer;
  31920. private _glVendor;
  31921. /** @hidden */
  31922. _videoTextureSupported: boolean;
  31923. protected _renderingQueueLaunched: boolean;
  31924. protected _activeRenderLoops: (() => void)[];
  31925. /**
  31926. * Observable signaled when a context lost event is raised
  31927. */
  31928. onContextLostObservable: Observable<ThinEngine>;
  31929. /**
  31930. * Observable signaled when a context restored event is raised
  31931. */
  31932. onContextRestoredObservable: Observable<ThinEngine>;
  31933. private _onContextLost;
  31934. private _onContextRestored;
  31935. protected _contextWasLost: boolean;
  31936. /** @hidden */
  31937. _doNotHandleContextLost: boolean;
  31938. /**
  31939. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31940. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31941. */
  31942. get doNotHandleContextLost(): boolean;
  31943. set doNotHandleContextLost(value: boolean);
  31944. /**
  31945. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31946. */
  31947. disableVertexArrayObjects: boolean;
  31948. /** @hidden */
  31949. protected _colorWrite: boolean;
  31950. /** @hidden */
  31951. protected _colorWriteChanged: boolean;
  31952. /** @hidden */
  31953. protected _depthCullingState: DepthCullingState;
  31954. /** @hidden */
  31955. protected _stencilState: StencilState;
  31956. /** @hidden */
  31957. _alphaState: AlphaState;
  31958. /** @hidden */
  31959. _alphaMode: number;
  31960. /** @hidden */
  31961. _alphaEquation: number;
  31962. /** @hidden */
  31963. _internalTexturesCache: InternalTexture[];
  31964. /** @hidden */
  31965. protected _activeChannel: number;
  31966. private _currentTextureChannel;
  31967. /** @hidden */
  31968. protected _boundTexturesCache: {
  31969. [key: string]: Nullable<InternalTexture>;
  31970. };
  31971. /** @hidden */
  31972. protected _currentEffect: Nullable<Effect>;
  31973. /** @hidden */
  31974. protected _currentProgram: Nullable<WebGLProgram>;
  31975. private _compiledEffects;
  31976. private _vertexAttribArraysEnabled;
  31977. /** @hidden */
  31978. protected _cachedViewport: Nullable<IViewportLike>;
  31979. private _cachedVertexArrayObject;
  31980. /** @hidden */
  31981. protected _cachedVertexBuffers: any;
  31982. /** @hidden */
  31983. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31984. /** @hidden */
  31985. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31986. /** @hidden */
  31987. _currentRenderTarget: Nullable<InternalTexture>;
  31988. private _uintIndicesCurrentlySet;
  31989. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31990. /** @hidden */
  31991. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31992. private _currentBufferPointers;
  31993. private _currentInstanceLocations;
  31994. private _currentInstanceBuffers;
  31995. private _textureUnits;
  31996. /** @hidden */
  31997. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31998. /** @hidden */
  31999. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32000. /** @hidden */
  32001. _boundRenderFunction: any;
  32002. private _vaoRecordInProgress;
  32003. private _mustWipeVertexAttributes;
  32004. private _emptyTexture;
  32005. private _emptyCubeTexture;
  32006. private _emptyTexture3D;
  32007. private _emptyTexture2DArray;
  32008. /** @hidden */
  32009. _frameHandler: number;
  32010. private _nextFreeTextureSlots;
  32011. private _maxSimultaneousTextures;
  32012. private _activeRequests;
  32013. protected _texturesSupported: string[];
  32014. /** @hidden */
  32015. _textureFormatInUse: Nullable<string>;
  32016. protected get _supportsHardwareTextureRescaling(): boolean;
  32017. /**
  32018. * Gets the list of texture formats supported
  32019. */
  32020. get texturesSupported(): Array<string>;
  32021. /**
  32022. * Gets the list of texture formats in use
  32023. */
  32024. get textureFormatInUse(): Nullable<string>;
  32025. /**
  32026. * Gets the current viewport
  32027. */
  32028. get currentViewport(): Nullable<IViewportLike>;
  32029. /**
  32030. * Gets the default empty texture
  32031. */
  32032. get emptyTexture(): InternalTexture;
  32033. /**
  32034. * Gets the default empty 3D texture
  32035. */
  32036. get emptyTexture3D(): InternalTexture;
  32037. /**
  32038. * Gets the default empty 2D array texture
  32039. */
  32040. get emptyTexture2DArray(): InternalTexture;
  32041. /**
  32042. * Gets the default empty cube texture
  32043. */
  32044. get emptyCubeTexture(): InternalTexture;
  32045. /**
  32046. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32047. */
  32048. readonly premultipliedAlpha: boolean;
  32049. /**
  32050. * Observable event triggered before each texture is initialized
  32051. */
  32052. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32053. /**
  32054. * Creates a new engine
  32055. * @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
  32056. * @param antialias defines enable antialiasing (default: false)
  32057. * @param options defines further options to be sent to the getContext() function
  32058. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32059. */
  32060. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32061. private _rebuildInternalTextures;
  32062. private _rebuildEffects;
  32063. /**
  32064. * Gets a boolean indicating if all created effects are ready
  32065. * @returns true if all effects are ready
  32066. */
  32067. areAllEffectsReady(): boolean;
  32068. protected _rebuildBuffers(): void;
  32069. private _initGLContext;
  32070. /**
  32071. * Gets version of the current webGL context
  32072. */
  32073. get webGLVersion(): number;
  32074. /**
  32075. * Gets a string idenfifying the name of the class
  32076. * @returns "Engine" string
  32077. */
  32078. getClassName(): string;
  32079. /**
  32080. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32081. */
  32082. get isStencilEnable(): boolean;
  32083. /** @hidden */
  32084. _prepareWorkingCanvas(): void;
  32085. /**
  32086. * Reset the texture cache to empty state
  32087. */
  32088. resetTextureCache(): void;
  32089. /**
  32090. * Gets an object containing information about the current webGL context
  32091. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32092. */
  32093. getGlInfo(): {
  32094. vendor: string;
  32095. renderer: string;
  32096. version: string;
  32097. };
  32098. /**
  32099. * Defines the hardware scaling level.
  32100. * By default the hardware scaling level is computed from the window device ratio.
  32101. * 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.
  32102. * @param level defines the level to use
  32103. */
  32104. setHardwareScalingLevel(level: number): void;
  32105. /**
  32106. * Gets the current hardware scaling level.
  32107. * By default the hardware scaling level is computed from the window device ratio.
  32108. * 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.
  32109. * @returns a number indicating the current hardware scaling level
  32110. */
  32111. getHardwareScalingLevel(): number;
  32112. /**
  32113. * Gets the list of loaded textures
  32114. * @returns an array containing all loaded textures
  32115. */
  32116. getLoadedTexturesCache(): InternalTexture[];
  32117. /**
  32118. * Gets the object containing all engine capabilities
  32119. * @returns the EngineCapabilities object
  32120. */
  32121. getCaps(): EngineCapabilities;
  32122. /**
  32123. * stop executing a render loop function and remove it from the execution array
  32124. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32125. */
  32126. stopRenderLoop(renderFunction?: () => void): void;
  32127. /** @hidden */
  32128. _renderLoop(): void;
  32129. /**
  32130. * Gets the HTML canvas attached with the current webGL context
  32131. * @returns a HTML canvas
  32132. */
  32133. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32134. /**
  32135. * Gets host window
  32136. * @returns the host window object
  32137. */
  32138. getHostWindow(): Nullable<Window>;
  32139. /**
  32140. * Gets the current render width
  32141. * @param useScreen defines if screen size must be used (or the current render target if any)
  32142. * @returns a number defining the current render width
  32143. */
  32144. getRenderWidth(useScreen?: boolean): number;
  32145. /**
  32146. * Gets the current render height
  32147. * @param useScreen defines if screen size must be used (or the current render target if any)
  32148. * @returns a number defining the current render height
  32149. */
  32150. getRenderHeight(useScreen?: boolean): number;
  32151. /**
  32152. * Can be used to override the current requestAnimationFrame requester.
  32153. * @hidden
  32154. */
  32155. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32156. /**
  32157. * Register and execute a render loop. The engine can have more than one render function
  32158. * @param renderFunction defines the function to continuously execute
  32159. */
  32160. runRenderLoop(renderFunction: () => void): void;
  32161. /**
  32162. * Clear the current render buffer or the current render target (if any is set up)
  32163. * @param color defines the color to use
  32164. * @param backBuffer defines if the back buffer must be cleared
  32165. * @param depth defines if the depth buffer must be cleared
  32166. * @param stencil defines if the stencil buffer must be cleared
  32167. */
  32168. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32169. private _viewportCached;
  32170. /** @hidden */
  32171. _viewport(x: number, y: number, width: number, height: number): void;
  32172. /**
  32173. * Set the WebGL's viewport
  32174. * @param viewport defines the viewport element to be used
  32175. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32176. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32177. */
  32178. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32179. /**
  32180. * Begin a new frame
  32181. */
  32182. beginFrame(): void;
  32183. /**
  32184. * Enf the current frame
  32185. */
  32186. endFrame(): void;
  32187. /**
  32188. * Resize the view according to the canvas' size
  32189. */
  32190. resize(): void;
  32191. /**
  32192. * Force a specific size of the canvas
  32193. * @param width defines the new canvas' width
  32194. * @param height defines the new canvas' height
  32195. */
  32196. setSize(width: number, height: number): void;
  32197. /**
  32198. * Binds the frame buffer to the specified texture.
  32199. * @param texture The texture to render to or null for the default canvas
  32200. * @param faceIndex The face of the texture to render to in case of cube texture
  32201. * @param requiredWidth The width of the target to render to
  32202. * @param requiredHeight The height of the target to render to
  32203. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32204. * @param lodLevel defines the lod level to bind to the frame buffer
  32205. * @param layer defines the 2d array index to bind to frame buffer to
  32206. */
  32207. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32208. /** @hidden */
  32209. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32210. /**
  32211. * Unbind the current render target texture from the webGL context
  32212. * @param texture defines the render target texture to unbind
  32213. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32214. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32215. */
  32216. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32217. /**
  32218. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32219. */
  32220. flushFramebuffer(): void;
  32221. /**
  32222. * Unbind the current render target and bind the default framebuffer
  32223. */
  32224. restoreDefaultFramebuffer(): void;
  32225. /** @hidden */
  32226. protected _resetVertexBufferBinding(): void;
  32227. /**
  32228. * Creates a vertex buffer
  32229. * @param data the data for the vertex buffer
  32230. * @returns the new WebGL static buffer
  32231. */
  32232. createVertexBuffer(data: DataArray): DataBuffer;
  32233. private _createVertexBuffer;
  32234. /**
  32235. * Creates a dynamic vertex buffer
  32236. * @param data the data for the dynamic vertex buffer
  32237. * @returns the new WebGL dynamic buffer
  32238. */
  32239. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32240. protected _resetIndexBufferBinding(): void;
  32241. /**
  32242. * Creates a new index buffer
  32243. * @param indices defines the content of the index buffer
  32244. * @param updatable defines if the index buffer must be updatable
  32245. * @returns a new webGL buffer
  32246. */
  32247. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32248. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32249. /**
  32250. * Bind a webGL buffer to the webGL context
  32251. * @param buffer defines the buffer to bind
  32252. */
  32253. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32254. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32255. private bindBuffer;
  32256. /**
  32257. * update the bound buffer with the given data
  32258. * @param data defines the data to update
  32259. */
  32260. updateArrayBuffer(data: Float32Array): void;
  32261. private _vertexAttribPointer;
  32262. /** @hidden */
  32263. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32264. private _bindVertexBuffersAttributes;
  32265. /**
  32266. * Records a vertex array object
  32267. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32268. * @param vertexBuffers defines the list of vertex buffers to store
  32269. * @param indexBuffer defines the index buffer to store
  32270. * @param effect defines the effect to store
  32271. * @returns the new vertex array object
  32272. */
  32273. recordVertexArrayObject(vertexBuffers: {
  32274. [key: string]: VertexBuffer;
  32275. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32276. /**
  32277. * Bind a specific vertex array object
  32278. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32279. * @param vertexArrayObject defines the vertex array object to bind
  32280. * @param indexBuffer defines the index buffer to bind
  32281. */
  32282. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32283. /**
  32284. * Bind webGl buffers directly to the webGL context
  32285. * @param vertexBuffer defines the vertex buffer to bind
  32286. * @param indexBuffer defines the index buffer to bind
  32287. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32288. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32289. * @param effect defines the effect associated with the vertex buffer
  32290. */
  32291. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32292. private _unbindVertexArrayObject;
  32293. /**
  32294. * Bind a list of vertex buffers to the webGL context
  32295. * @param vertexBuffers defines the list of vertex buffers to bind
  32296. * @param indexBuffer defines the index buffer to bind
  32297. * @param effect defines the effect associated with the vertex buffers
  32298. */
  32299. bindBuffers(vertexBuffers: {
  32300. [key: string]: Nullable<VertexBuffer>;
  32301. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32302. /**
  32303. * Unbind all instance attributes
  32304. */
  32305. unbindInstanceAttributes(): void;
  32306. /**
  32307. * Release and free the memory of a vertex array object
  32308. * @param vao defines the vertex array object to delete
  32309. */
  32310. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32311. /** @hidden */
  32312. _releaseBuffer(buffer: DataBuffer): boolean;
  32313. protected _deleteBuffer(buffer: DataBuffer): void;
  32314. /**
  32315. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32316. * @param instancesBuffer defines the webGL buffer to update and bind
  32317. * @param data defines the data to store in the buffer
  32318. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32319. */
  32320. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32321. /**
  32322. * Bind the content of a webGL buffer used with instantiation
  32323. * @param instancesBuffer defines the webGL buffer to bind
  32324. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32325. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  32326. */
  32327. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32328. /**
  32329. * Disable the instance attribute corresponding to the name in parameter
  32330. * @param name defines the name of the attribute to disable
  32331. */
  32332. disableInstanceAttributeByName(name: string): void;
  32333. /**
  32334. * Disable the instance attribute corresponding to the location in parameter
  32335. * @param attributeLocation defines the attribute location of the attribute to disable
  32336. */
  32337. disableInstanceAttribute(attributeLocation: number): void;
  32338. /**
  32339. * Disable the attribute corresponding to the location in parameter
  32340. * @param attributeLocation defines the attribute location of the attribute to disable
  32341. */
  32342. disableAttributeByIndex(attributeLocation: number): void;
  32343. /**
  32344. * Send a draw order
  32345. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32346. * @param indexStart defines the starting index
  32347. * @param indexCount defines the number of index to draw
  32348. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32349. */
  32350. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32351. /**
  32352. * Draw a list of points
  32353. * @param verticesStart defines the index of first vertex to draw
  32354. * @param verticesCount defines the count of vertices to draw
  32355. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32356. */
  32357. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32358. /**
  32359. * Draw a list of unindexed primitives
  32360. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32361. * @param verticesStart defines the index of first vertex to draw
  32362. * @param verticesCount defines the count of vertices to draw
  32363. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32364. */
  32365. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32366. /**
  32367. * Draw a list of indexed primitives
  32368. * @param fillMode defines the primitive to use
  32369. * @param indexStart defines the starting index
  32370. * @param indexCount defines the number of index to draw
  32371. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32372. */
  32373. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32374. /**
  32375. * Draw a list of unindexed primitives
  32376. * @param fillMode defines the primitive to use
  32377. * @param verticesStart defines the index of first vertex to draw
  32378. * @param verticesCount defines the count of vertices to draw
  32379. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32380. */
  32381. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32382. private _drawMode;
  32383. /** @hidden */
  32384. protected _reportDrawCall(): void;
  32385. /** @hidden */
  32386. _releaseEffect(effect: Effect): void;
  32387. /** @hidden */
  32388. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32389. /**
  32390. * Create a new effect (used to store vertex/fragment shaders)
  32391. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32392. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32393. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32394. * @param samplers defines an array of string used to represent textures
  32395. * @param defines defines the string containing the defines to use to compile the shaders
  32396. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32397. * @param onCompiled defines a function to call when the effect creation is successful
  32398. * @param onError defines a function to call when the effect creation has failed
  32399. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32400. * @returns the new Effect
  32401. */
  32402. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  32403. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32404. private _compileShader;
  32405. private _compileRawShader;
  32406. /**
  32407. * Directly creates a webGL program
  32408. * @param pipelineContext defines the pipeline context to attach to
  32409. * @param vertexCode defines the vertex shader code to use
  32410. * @param fragmentCode defines the fragment shader code to use
  32411. * @param context defines the webGL context to use (if not set, the current one will be used)
  32412. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32413. * @returns the new webGL program
  32414. */
  32415. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32416. /**
  32417. * Creates a webGL program
  32418. * @param pipelineContext defines the pipeline context to attach to
  32419. * @param vertexCode defines the vertex shader code to use
  32420. * @param fragmentCode defines the fragment shader code to use
  32421. * @param defines defines the string containing the defines to use to compile the shaders
  32422. * @param context defines the webGL context to use (if not set, the current one will be used)
  32423. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32424. * @returns the new webGL program
  32425. */
  32426. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32427. /**
  32428. * Creates a new pipeline context
  32429. * @returns the new pipeline
  32430. */
  32431. createPipelineContext(): IPipelineContext;
  32432. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32433. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32434. /** @hidden */
  32435. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32436. /** @hidden */
  32437. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32438. /** @hidden */
  32439. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32440. /**
  32441. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32442. * @param pipelineContext defines the pipeline context to use
  32443. * @param uniformsNames defines the list of uniform names
  32444. * @returns an array of webGL uniform locations
  32445. */
  32446. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32447. /**
  32448. * Gets the lsit of active attributes for a given webGL program
  32449. * @param pipelineContext defines the pipeline context to use
  32450. * @param attributesNames defines the list of attribute names to get
  32451. * @returns an array of indices indicating the offset of each attribute
  32452. */
  32453. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32454. /**
  32455. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32456. * @param effect defines the effect to activate
  32457. */
  32458. enableEffect(effect: Nullable<Effect>): void;
  32459. /**
  32460. * Set the value of an uniform to a number (int)
  32461. * @param uniform defines the webGL uniform location where to store the value
  32462. * @param value defines the int number to store
  32463. */
  32464. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32465. /**
  32466. * Set the value of an uniform to an array of int32
  32467. * @param uniform defines the webGL uniform location where to store the value
  32468. * @param array defines the array of int32 to store
  32469. */
  32470. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32471. /**
  32472. * Set the value of an uniform to an array of int32 (stored as vec2)
  32473. * @param uniform defines the webGL uniform location where to store the value
  32474. * @param array defines the array of int32 to store
  32475. */
  32476. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32477. /**
  32478. * Set the value of an uniform to an array of int32 (stored as vec3)
  32479. * @param uniform defines the webGL uniform location where to store the value
  32480. * @param array defines the array of int32 to store
  32481. */
  32482. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32483. /**
  32484. * Set the value of an uniform to an array of int32 (stored as vec4)
  32485. * @param uniform defines the webGL uniform location where to store the value
  32486. * @param array defines the array of int32 to store
  32487. */
  32488. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32489. /**
  32490. * Set the value of an uniform to an array of number
  32491. * @param uniform defines the webGL uniform location where to store the value
  32492. * @param array defines the array of number to store
  32493. */
  32494. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32495. /**
  32496. * Set the value of an uniform to an array of number (stored as vec2)
  32497. * @param uniform defines the webGL uniform location where to store the value
  32498. * @param array defines the array of number to store
  32499. */
  32500. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32501. /**
  32502. * Set the value of an uniform to an array of number (stored as vec3)
  32503. * @param uniform defines the webGL uniform location where to store the value
  32504. * @param array defines the array of number to store
  32505. */
  32506. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32507. /**
  32508. * Set the value of an uniform to an array of number (stored as vec4)
  32509. * @param uniform defines the webGL uniform location where to store the value
  32510. * @param array defines the array of number to store
  32511. */
  32512. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32513. /**
  32514. * Set the value of an uniform to an array of float32 (stored as matrices)
  32515. * @param uniform defines the webGL uniform location where to store the value
  32516. * @param matrices defines the array of float32 to store
  32517. */
  32518. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32519. /**
  32520. * Set the value of an uniform to a matrix (3x3)
  32521. * @param uniform defines the webGL uniform location where to store the value
  32522. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32523. */
  32524. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32525. /**
  32526. * Set the value of an uniform to a matrix (2x2)
  32527. * @param uniform defines the webGL uniform location where to store the value
  32528. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32529. */
  32530. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32531. /**
  32532. * Set the value of an uniform to a number (float)
  32533. * @param uniform defines the webGL uniform location where to store the value
  32534. * @param value defines the float number to store
  32535. */
  32536. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32537. /**
  32538. * Set the value of an uniform to a vec2
  32539. * @param uniform defines the webGL uniform location where to store the value
  32540. * @param x defines the 1st component of the value
  32541. * @param y defines the 2nd component of the value
  32542. */
  32543. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32544. /**
  32545. * Set the value of an uniform to a vec3
  32546. * @param uniform defines the webGL uniform location where to store the value
  32547. * @param x defines the 1st component of the value
  32548. * @param y defines the 2nd component of the value
  32549. * @param z defines the 3rd component of the value
  32550. */
  32551. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32552. /**
  32553. * Set the value of an uniform to a vec4
  32554. * @param uniform defines the webGL uniform location where to store the value
  32555. * @param x defines the 1st component of the value
  32556. * @param y defines the 2nd component of the value
  32557. * @param z defines the 3rd component of the value
  32558. * @param w defines the 4th component of the value
  32559. */
  32560. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32561. /**
  32562. * Apply all cached states (depth, culling, stencil and alpha)
  32563. */
  32564. applyStates(): void;
  32565. /**
  32566. * Enable or disable color writing
  32567. * @param enable defines the state to set
  32568. */
  32569. setColorWrite(enable: boolean): void;
  32570. /**
  32571. * Gets a boolean indicating if color writing is enabled
  32572. * @returns the current color writing state
  32573. */
  32574. getColorWrite(): boolean;
  32575. /**
  32576. * Gets the depth culling state manager
  32577. */
  32578. get depthCullingState(): DepthCullingState;
  32579. /**
  32580. * Gets the alpha state manager
  32581. */
  32582. get alphaState(): AlphaState;
  32583. /**
  32584. * Gets the stencil state manager
  32585. */
  32586. get stencilState(): StencilState;
  32587. /**
  32588. * Clears the list of texture accessible through engine.
  32589. * This can help preventing texture load conflict due to name collision.
  32590. */
  32591. clearInternalTexturesCache(): void;
  32592. /**
  32593. * Force the entire cache to be cleared
  32594. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32595. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32596. */
  32597. wipeCaches(bruteForce?: boolean): void;
  32598. /** @hidden */
  32599. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32600. min: number;
  32601. mag: number;
  32602. };
  32603. /** @hidden */
  32604. _createTexture(): WebGLTexture;
  32605. /**
  32606. * Usually called from Texture.ts.
  32607. * Passed information to create a WebGLTexture
  32608. * @param urlArg defines a value which contains one of the following:
  32609. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32610. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32611. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32612. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32613. * @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)
  32614. * @param scene needed for loading to the correct scene
  32615. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32616. * @param onLoad optional callback to be called upon successful completion
  32617. * @param onError optional callback to be called upon failure
  32618. * @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
  32619. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32620. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32621. * @param forcedExtension defines the extension to use to pick the right loader
  32622. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32623. * @param mimeType defines an optional mime type
  32624. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32625. */
  32626. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  32627. /**
  32628. * Loads an image as an HTMLImageElement.
  32629. * @param input url string, ArrayBuffer, or Blob to load
  32630. * @param onLoad callback called when the image successfully loads
  32631. * @param onError callback called when the image fails to load
  32632. * @param offlineProvider offline provider for caching
  32633. * @param mimeType optional mime type
  32634. * @returns the HTMLImageElement of the loaded image
  32635. * @hidden
  32636. */
  32637. static _FileToolsLoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  32638. /**
  32639. * @hidden
  32640. */
  32641. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32642. /**
  32643. * Creates a raw texture
  32644. * @param data defines the data to store in the texture
  32645. * @param width defines the width of the texture
  32646. * @param height defines the height of the texture
  32647. * @param format defines the format of the data
  32648. * @param generateMipMaps defines if the engine should generate the mip levels
  32649. * @param invertY defines if data must be stored with Y axis inverted
  32650. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32651. * @param compression defines the compression used (null by default)
  32652. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32653. * @returns the raw texture inside an InternalTexture
  32654. */
  32655. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32656. /**
  32657. * Creates a new raw cube texture
  32658. * @param data defines the array of data to use to create each face
  32659. * @param size defines the size of the textures
  32660. * @param format defines the format of the data
  32661. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32662. * @param generateMipMaps defines if the engine should generate the mip levels
  32663. * @param invertY defines if data must be stored with Y axis inverted
  32664. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32665. * @param compression defines the compression used (null by default)
  32666. * @returns the cube texture as an InternalTexture
  32667. */
  32668. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32669. /**
  32670. * Creates a new raw 3D texture
  32671. * @param data defines the data used to create the texture
  32672. * @param width defines the width of the texture
  32673. * @param height defines the height of the texture
  32674. * @param depth defines the depth of the texture
  32675. * @param format defines the format of the texture
  32676. * @param generateMipMaps defines if the engine must generate mip levels
  32677. * @param invertY defines if data must be stored with Y axis inverted
  32678. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32679. * @param compression defines the compressed used (can be null)
  32680. * @param textureType defines the compressed used (can be null)
  32681. * @returns a new raw 3D texture (stored in an InternalTexture)
  32682. */
  32683. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32684. /**
  32685. * Creates a new raw 2D array texture
  32686. * @param data defines the data used to create the texture
  32687. * @param width defines the width of the texture
  32688. * @param height defines the height of the texture
  32689. * @param depth defines the number of layers of the texture
  32690. * @param format defines the format of the texture
  32691. * @param generateMipMaps defines if the engine must generate mip levels
  32692. * @param invertY defines if data must be stored with Y axis inverted
  32693. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32694. * @param compression defines the compressed used (can be null)
  32695. * @param textureType defines the compressed used (can be null)
  32696. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32697. */
  32698. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32699. private _unpackFlipYCached;
  32700. /**
  32701. * In case you are sharing the context with other applications, it might
  32702. * be interested to not cache the unpack flip y state to ensure a consistent
  32703. * value would be set.
  32704. */
  32705. enableUnpackFlipYCached: boolean;
  32706. /** @hidden */
  32707. _unpackFlipY(value: boolean): void;
  32708. /** @hidden */
  32709. _getUnpackAlignement(): number;
  32710. private _getTextureTarget;
  32711. /**
  32712. * Update the sampling mode of a given texture
  32713. * @param samplingMode defines the required sampling mode
  32714. * @param texture defines the texture to update
  32715. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32716. */
  32717. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32718. /**
  32719. * Update the sampling mode of a given texture
  32720. * @param texture defines the texture to update
  32721. * @param wrapU defines the texture wrap mode of the u coordinates
  32722. * @param wrapV defines the texture wrap mode of the v coordinates
  32723. * @param wrapR defines the texture wrap mode of the r coordinates
  32724. */
  32725. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32726. /** @hidden */
  32727. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32728. width: number;
  32729. height: number;
  32730. layers?: number;
  32731. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32732. /** @hidden */
  32733. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32734. /** @hidden */
  32735. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32736. /**
  32737. * Update a portion of an internal texture
  32738. * @param texture defines the texture to update
  32739. * @param imageData defines the data to store into the texture
  32740. * @param xOffset defines the x coordinates of the update rectangle
  32741. * @param yOffset defines the y coordinates of the update rectangle
  32742. * @param width defines the width of the update rectangle
  32743. * @param height defines the height of the update rectangle
  32744. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32745. * @param lod defines the lod level to update (0 by default)
  32746. */
  32747. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32748. /** @hidden */
  32749. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32750. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32751. private _prepareWebGLTexture;
  32752. /** @hidden */
  32753. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32754. private _getDepthStencilBuffer;
  32755. /** @hidden */
  32756. _releaseFramebufferObjects(texture: InternalTexture): void;
  32757. /** @hidden */
  32758. _releaseTexture(texture: InternalTexture): void;
  32759. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32760. protected _setProgram(program: WebGLProgram): void;
  32761. protected _boundUniforms: {
  32762. [key: number]: WebGLUniformLocation;
  32763. };
  32764. /**
  32765. * Binds an effect to the webGL context
  32766. * @param effect defines the effect to bind
  32767. */
  32768. bindSamplers(effect: Effect): void;
  32769. private _activateCurrentTexture;
  32770. /** @hidden */
  32771. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32772. /** @hidden */
  32773. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32774. /**
  32775. * Unbind all textures from the webGL context
  32776. */
  32777. unbindAllTextures(): void;
  32778. /**
  32779. * Sets a texture to the according uniform.
  32780. * @param channel The texture channel
  32781. * @param uniform The uniform to set
  32782. * @param texture The texture to apply
  32783. */
  32784. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32785. private _bindSamplerUniformToChannel;
  32786. private _getTextureWrapMode;
  32787. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32788. /**
  32789. * Sets an array of texture to the webGL context
  32790. * @param channel defines the channel where the texture array must be set
  32791. * @param uniform defines the associated uniform location
  32792. * @param textures defines the array of textures to bind
  32793. */
  32794. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32795. /** @hidden */
  32796. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32797. private _setTextureParameterFloat;
  32798. private _setTextureParameterInteger;
  32799. /**
  32800. * Unbind all vertex attributes from the webGL context
  32801. */
  32802. unbindAllAttributes(): void;
  32803. /**
  32804. * 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
  32805. */
  32806. releaseEffects(): void;
  32807. /**
  32808. * Dispose and release all associated resources
  32809. */
  32810. dispose(): void;
  32811. /**
  32812. * Attach a new callback raised when context lost event is fired
  32813. * @param callback defines the callback to call
  32814. */
  32815. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32816. /**
  32817. * Attach a new callback raised when context restored event is fired
  32818. * @param callback defines the callback to call
  32819. */
  32820. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32821. /**
  32822. * Get the current error code of the webGL context
  32823. * @returns the error code
  32824. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32825. */
  32826. getError(): number;
  32827. private _canRenderToFloatFramebuffer;
  32828. private _canRenderToHalfFloatFramebuffer;
  32829. private _canRenderToFramebuffer;
  32830. /** @hidden */
  32831. _getWebGLTextureType(type: number): number;
  32832. /** @hidden */
  32833. _getInternalFormat(format: number): number;
  32834. /** @hidden */
  32835. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32836. /** @hidden */
  32837. _getRGBAMultiSampleBufferFormat(type: number): number;
  32838. /** @hidden */
  32839. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  32840. /**
  32841. * Loads a file from a url
  32842. * @param url url to load
  32843. * @param onSuccess callback called when the file successfully loads
  32844. * @param onProgress callback called while file is loading (if the server supports this mode)
  32845. * @param offlineProvider defines the offline provider for caching
  32846. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32847. * @param onError callback called when the file fails to load
  32848. * @returns a file request object
  32849. * @hidden
  32850. */
  32851. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  32852. /**
  32853. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32854. * @param x defines the x coordinate of the rectangle where pixels must be read
  32855. * @param y defines the y coordinate of the rectangle where pixels must be read
  32856. * @param width defines the width of the rectangle where pixels must be read
  32857. * @param height defines the height of the rectangle where pixels must be read
  32858. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32859. * @returns a Uint8Array containing RGBA colors
  32860. */
  32861. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32862. private static _isSupported;
  32863. /**
  32864. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32865. * @returns true if the engine can be created
  32866. * @ignorenaming
  32867. */
  32868. static isSupported(): boolean;
  32869. /**
  32870. * Find the next highest power of two.
  32871. * @param x Number to start search from.
  32872. * @return Next highest power of two.
  32873. */
  32874. static CeilingPOT(x: number): number;
  32875. /**
  32876. * Find the next lowest power of two.
  32877. * @param x Number to start search from.
  32878. * @return Next lowest power of two.
  32879. */
  32880. static FloorPOT(x: number): number;
  32881. /**
  32882. * Find the nearest power of two.
  32883. * @param x Number to start search from.
  32884. * @return Next nearest power of two.
  32885. */
  32886. static NearestPOT(x: number): number;
  32887. /**
  32888. * Get the closest exponent of two
  32889. * @param value defines the value to approximate
  32890. * @param max defines the maximum value to return
  32891. * @param mode defines how to define the closest value
  32892. * @returns closest exponent of two of the given value
  32893. */
  32894. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32895. /**
  32896. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32897. * @param func - the function to be called
  32898. * @param requester - the object that will request the next frame. Falls back to window.
  32899. * @returns frame number
  32900. */
  32901. static QueueNewFrame(func: () => void, requester?: any): number;
  32902. /**
  32903. * Gets host document
  32904. * @returns the host document object
  32905. */
  32906. getHostDocument(): Nullable<Document>;
  32907. }
  32908. }
  32909. declare module "babylonjs/Maths/sphericalPolynomial" {
  32910. import { Vector3 } from "babylonjs/Maths/math.vector";
  32911. import { Color3 } from "babylonjs/Maths/math.color";
  32912. /**
  32913. * Class representing spherical harmonics coefficients to the 3rd degree
  32914. */
  32915. export class SphericalHarmonics {
  32916. /**
  32917. * Defines whether or not the harmonics have been prescaled for rendering.
  32918. */
  32919. preScaled: boolean;
  32920. /**
  32921. * The l0,0 coefficients of the spherical harmonics
  32922. */
  32923. l00: Vector3;
  32924. /**
  32925. * The l1,-1 coefficients of the spherical harmonics
  32926. */
  32927. l1_1: Vector3;
  32928. /**
  32929. * The l1,0 coefficients of the spherical harmonics
  32930. */
  32931. l10: Vector3;
  32932. /**
  32933. * The l1,1 coefficients of the spherical harmonics
  32934. */
  32935. l11: Vector3;
  32936. /**
  32937. * The l2,-2 coefficients of the spherical harmonics
  32938. */
  32939. l2_2: Vector3;
  32940. /**
  32941. * The l2,-1 coefficients of the spherical harmonics
  32942. */
  32943. l2_1: Vector3;
  32944. /**
  32945. * The l2,0 coefficients of the spherical harmonics
  32946. */
  32947. l20: Vector3;
  32948. /**
  32949. * The l2,1 coefficients of the spherical harmonics
  32950. */
  32951. l21: Vector3;
  32952. /**
  32953. * The l2,2 coefficients of the spherical harmonics
  32954. */
  32955. l22: Vector3;
  32956. /**
  32957. * Adds a light to the spherical harmonics
  32958. * @param direction the direction of the light
  32959. * @param color the color of the light
  32960. * @param deltaSolidAngle the delta solid angle of the light
  32961. */
  32962. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32963. /**
  32964. * Scales the spherical harmonics by the given amount
  32965. * @param scale the amount to scale
  32966. */
  32967. scaleInPlace(scale: number): void;
  32968. /**
  32969. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32970. *
  32971. * ```
  32972. * E_lm = A_l * L_lm
  32973. * ```
  32974. *
  32975. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32976. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32977. * the scaling factors are given in equation 9.
  32978. */
  32979. convertIncidentRadianceToIrradiance(): void;
  32980. /**
  32981. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32982. *
  32983. * ```
  32984. * L = (1/pi) * E * rho
  32985. * ```
  32986. *
  32987. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32988. */
  32989. convertIrradianceToLambertianRadiance(): void;
  32990. /**
  32991. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32992. * required operations at run time.
  32993. *
  32994. * This is simply done by scaling back the SH with Ylm constants parameter.
  32995. * The trigonometric part being applied by the shader at run time.
  32996. */
  32997. preScaleForRendering(): void;
  32998. /**
  32999. * Constructs a spherical harmonics from an array.
  33000. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33001. * @returns the spherical harmonics
  33002. */
  33003. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33004. /**
  33005. * Gets the spherical harmonics from polynomial
  33006. * @param polynomial the spherical polynomial
  33007. * @returns the spherical harmonics
  33008. */
  33009. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33010. }
  33011. /**
  33012. * Class representing spherical polynomial coefficients to the 3rd degree
  33013. */
  33014. export class SphericalPolynomial {
  33015. private _harmonics;
  33016. /**
  33017. * The spherical harmonics used to create the polynomials.
  33018. */
  33019. get preScaledHarmonics(): SphericalHarmonics;
  33020. /**
  33021. * The x coefficients of the spherical polynomial
  33022. */
  33023. x: Vector3;
  33024. /**
  33025. * The y coefficients of the spherical polynomial
  33026. */
  33027. y: Vector3;
  33028. /**
  33029. * The z coefficients of the spherical polynomial
  33030. */
  33031. z: Vector3;
  33032. /**
  33033. * The xx coefficients of the spherical polynomial
  33034. */
  33035. xx: Vector3;
  33036. /**
  33037. * The yy coefficients of the spherical polynomial
  33038. */
  33039. yy: Vector3;
  33040. /**
  33041. * The zz coefficients of the spherical polynomial
  33042. */
  33043. zz: Vector3;
  33044. /**
  33045. * The xy coefficients of the spherical polynomial
  33046. */
  33047. xy: Vector3;
  33048. /**
  33049. * The yz coefficients of the spherical polynomial
  33050. */
  33051. yz: Vector3;
  33052. /**
  33053. * The zx coefficients of the spherical polynomial
  33054. */
  33055. zx: Vector3;
  33056. /**
  33057. * Adds an ambient color to the spherical polynomial
  33058. * @param color the color to add
  33059. */
  33060. addAmbient(color: Color3): void;
  33061. /**
  33062. * Scales the spherical polynomial by the given amount
  33063. * @param scale the amount to scale
  33064. */
  33065. scaleInPlace(scale: number): void;
  33066. /**
  33067. * Gets the spherical polynomial from harmonics
  33068. * @param harmonics the spherical harmonics
  33069. * @returns the spherical polynomial
  33070. */
  33071. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33072. /**
  33073. * Constructs a spherical polynomial from an array.
  33074. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33075. * @returns the spherical polynomial
  33076. */
  33077. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33078. }
  33079. }
  33080. declare module "babylonjs/Materials/Textures/internalTexture" {
  33081. import { Observable } from "babylonjs/Misc/observable";
  33082. import { Nullable, int } from "babylonjs/types";
  33083. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33084. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33085. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33086. /**
  33087. * Defines the source of the internal texture
  33088. */
  33089. export enum InternalTextureSource {
  33090. /**
  33091. * The source of the texture data is unknown
  33092. */
  33093. Unknown = 0,
  33094. /**
  33095. * Texture data comes from an URL
  33096. */
  33097. Url = 1,
  33098. /**
  33099. * Texture data is only used for temporary storage
  33100. */
  33101. Temp = 2,
  33102. /**
  33103. * Texture data comes from raw data (ArrayBuffer)
  33104. */
  33105. Raw = 3,
  33106. /**
  33107. * Texture content is dynamic (video or dynamic texture)
  33108. */
  33109. Dynamic = 4,
  33110. /**
  33111. * Texture content is generated by rendering to it
  33112. */
  33113. RenderTarget = 5,
  33114. /**
  33115. * Texture content is part of a multi render target process
  33116. */
  33117. MultiRenderTarget = 6,
  33118. /**
  33119. * Texture data comes from a cube data file
  33120. */
  33121. Cube = 7,
  33122. /**
  33123. * Texture data comes from a raw cube data
  33124. */
  33125. CubeRaw = 8,
  33126. /**
  33127. * Texture data come from a prefiltered cube data file
  33128. */
  33129. CubePrefiltered = 9,
  33130. /**
  33131. * Texture content is raw 3D data
  33132. */
  33133. Raw3D = 10,
  33134. /**
  33135. * Texture content is raw 2D array data
  33136. */
  33137. Raw2DArray = 11,
  33138. /**
  33139. * Texture content is a depth texture
  33140. */
  33141. Depth = 12,
  33142. /**
  33143. * Texture data comes from a raw cube data encoded with RGBD
  33144. */
  33145. CubeRawRGBD = 13
  33146. }
  33147. /**
  33148. * Class used to store data associated with WebGL texture data for the engine
  33149. * This class should not be used directly
  33150. */
  33151. export class InternalTexture {
  33152. /** @hidden */
  33153. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33154. /**
  33155. * Defines if the texture is ready
  33156. */
  33157. isReady: boolean;
  33158. /**
  33159. * Defines if the texture is a cube texture
  33160. */
  33161. isCube: boolean;
  33162. /**
  33163. * Defines if the texture contains 3D data
  33164. */
  33165. is3D: boolean;
  33166. /**
  33167. * Defines if the texture contains 2D array data
  33168. */
  33169. is2DArray: boolean;
  33170. /**
  33171. * Defines if the texture contains multiview data
  33172. */
  33173. isMultiview: boolean;
  33174. /**
  33175. * Gets the URL used to load this texture
  33176. */
  33177. url: string;
  33178. /**
  33179. * Gets the sampling mode of the texture
  33180. */
  33181. samplingMode: number;
  33182. /**
  33183. * Gets a boolean indicating if the texture needs mipmaps generation
  33184. */
  33185. generateMipMaps: boolean;
  33186. /**
  33187. * Gets the number of samples used by the texture (WebGL2+ only)
  33188. */
  33189. samples: number;
  33190. /**
  33191. * Gets the type of the texture (int, float...)
  33192. */
  33193. type: number;
  33194. /**
  33195. * Gets the format of the texture (RGB, RGBA...)
  33196. */
  33197. format: number;
  33198. /**
  33199. * Observable called when the texture is loaded
  33200. */
  33201. onLoadedObservable: Observable<InternalTexture>;
  33202. /**
  33203. * Gets the width of the texture
  33204. */
  33205. width: number;
  33206. /**
  33207. * Gets the height of the texture
  33208. */
  33209. height: number;
  33210. /**
  33211. * Gets the depth of the texture
  33212. */
  33213. depth: number;
  33214. /**
  33215. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33216. */
  33217. baseWidth: number;
  33218. /**
  33219. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33220. */
  33221. baseHeight: number;
  33222. /**
  33223. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33224. */
  33225. baseDepth: number;
  33226. /**
  33227. * Gets a boolean indicating if the texture is inverted on Y axis
  33228. */
  33229. invertY: boolean;
  33230. /** @hidden */
  33231. _invertVScale: boolean;
  33232. /** @hidden */
  33233. _associatedChannel: number;
  33234. /** @hidden */
  33235. _source: InternalTextureSource;
  33236. /** @hidden */
  33237. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33238. /** @hidden */
  33239. _bufferView: Nullable<ArrayBufferView>;
  33240. /** @hidden */
  33241. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33242. /** @hidden */
  33243. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33244. /** @hidden */
  33245. _size: number;
  33246. /** @hidden */
  33247. _extension: string;
  33248. /** @hidden */
  33249. _files: Nullable<string[]>;
  33250. /** @hidden */
  33251. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33252. /** @hidden */
  33253. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33254. /** @hidden */
  33255. _framebuffer: Nullable<WebGLFramebuffer>;
  33256. /** @hidden */
  33257. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33258. /** @hidden */
  33259. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33260. /** @hidden */
  33261. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33262. /** @hidden */
  33263. _attachments: Nullable<number[]>;
  33264. /** @hidden */
  33265. _cachedCoordinatesMode: Nullable<number>;
  33266. /** @hidden */
  33267. _cachedWrapU: Nullable<number>;
  33268. /** @hidden */
  33269. _cachedWrapV: Nullable<number>;
  33270. /** @hidden */
  33271. _cachedWrapR: Nullable<number>;
  33272. /** @hidden */
  33273. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33274. /** @hidden */
  33275. _isDisabled: boolean;
  33276. /** @hidden */
  33277. _compression: Nullable<string>;
  33278. /** @hidden */
  33279. _generateStencilBuffer: boolean;
  33280. /** @hidden */
  33281. _generateDepthBuffer: boolean;
  33282. /** @hidden */
  33283. _comparisonFunction: number;
  33284. /** @hidden */
  33285. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33286. /** @hidden */
  33287. _lodGenerationScale: number;
  33288. /** @hidden */
  33289. _lodGenerationOffset: number;
  33290. /** @hidden */
  33291. _depthStencilTexture: Nullable<InternalTexture>;
  33292. /** @hidden */
  33293. _colorTextureArray: Nullable<WebGLTexture>;
  33294. /** @hidden */
  33295. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33296. /** @hidden */
  33297. _lodTextureHigh: Nullable<BaseTexture>;
  33298. /** @hidden */
  33299. _lodTextureMid: Nullable<BaseTexture>;
  33300. /** @hidden */
  33301. _lodTextureLow: Nullable<BaseTexture>;
  33302. /** @hidden */
  33303. _isRGBD: boolean;
  33304. /** @hidden */
  33305. _linearSpecularLOD: boolean;
  33306. /** @hidden */
  33307. _irradianceTexture: Nullable<BaseTexture>;
  33308. /** @hidden */
  33309. _webGLTexture: Nullable<WebGLTexture>;
  33310. /** @hidden */
  33311. _references: number;
  33312. private _engine;
  33313. /**
  33314. * Gets the Engine the texture belongs to.
  33315. * @returns The babylon engine
  33316. */
  33317. getEngine(): ThinEngine;
  33318. /**
  33319. * Gets the data source type of the texture
  33320. */
  33321. get source(): InternalTextureSource;
  33322. /**
  33323. * Creates a new InternalTexture
  33324. * @param engine defines the engine to use
  33325. * @param source defines the type of data that will be used
  33326. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33327. */
  33328. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33329. /**
  33330. * Increments the number of references (ie. the number of Texture that point to it)
  33331. */
  33332. incrementReferences(): void;
  33333. /**
  33334. * Change the size of the texture (not the size of the content)
  33335. * @param width defines the new width
  33336. * @param height defines the new height
  33337. * @param depth defines the new depth (1 by default)
  33338. */
  33339. updateSize(width: int, height: int, depth?: int): void;
  33340. /** @hidden */
  33341. _rebuild(): void;
  33342. /** @hidden */
  33343. _swapAndDie(target: InternalTexture): void;
  33344. /**
  33345. * Dispose the current allocated resources
  33346. */
  33347. dispose(): void;
  33348. }
  33349. }
  33350. declare module "babylonjs/Audio/analyser" {
  33351. import { Scene } from "babylonjs/scene";
  33352. /**
  33353. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33354. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33355. */
  33356. export class Analyser {
  33357. /**
  33358. * Gets or sets the smoothing
  33359. * @ignorenaming
  33360. */
  33361. SMOOTHING: number;
  33362. /**
  33363. * Gets or sets the FFT table size
  33364. * @ignorenaming
  33365. */
  33366. FFT_SIZE: number;
  33367. /**
  33368. * Gets or sets the bar graph amplitude
  33369. * @ignorenaming
  33370. */
  33371. BARGRAPHAMPLITUDE: number;
  33372. /**
  33373. * Gets or sets the position of the debug canvas
  33374. * @ignorenaming
  33375. */
  33376. DEBUGCANVASPOS: {
  33377. x: number;
  33378. y: number;
  33379. };
  33380. /**
  33381. * Gets or sets the debug canvas size
  33382. * @ignorenaming
  33383. */
  33384. DEBUGCANVASSIZE: {
  33385. width: number;
  33386. height: number;
  33387. };
  33388. private _byteFreqs;
  33389. private _byteTime;
  33390. private _floatFreqs;
  33391. private _webAudioAnalyser;
  33392. private _debugCanvas;
  33393. private _debugCanvasContext;
  33394. private _scene;
  33395. private _registerFunc;
  33396. private _audioEngine;
  33397. /**
  33398. * Creates a new analyser
  33399. * @param scene defines hosting scene
  33400. */
  33401. constructor(scene: Scene);
  33402. /**
  33403. * Get the number of data values you will have to play with for the visualization
  33404. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33405. * @returns a number
  33406. */
  33407. getFrequencyBinCount(): number;
  33408. /**
  33409. * Gets the current frequency data as a byte array
  33410. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33411. * @returns a Uint8Array
  33412. */
  33413. getByteFrequencyData(): Uint8Array;
  33414. /**
  33415. * Gets the current waveform as a byte array
  33416. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33417. * @returns a Uint8Array
  33418. */
  33419. getByteTimeDomainData(): Uint8Array;
  33420. /**
  33421. * Gets the current frequency data as a float array
  33422. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33423. * @returns a Float32Array
  33424. */
  33425. getFloatFrequencyData(): Float32Array;
  33426. /**
  33427. * Renders the debug canvas
  33428. */
  33429. drawDebugCanvas(): void;
  33430. /**
  33431. * Stops rendering the debug canvas and removes it
  33432. */
  33433. stopDebugCanvas(): void;
  33434. /**
  33435. * Connects two audio nodes
  33436. * @param inputAudioNode defines first node to connect
  33437. * @param outputAudioNode defines second node to connect
  33438. */
  33439. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33440. /**
  33441. * Releases all associated resources
  33442. */
  33443. dispose(): void;
  33444. }
  33445. }
  33446. declare module "babylonjs/Audio/audioEngine" {
  33447. import { IDisposable } from "babylonjs/scene";
  33448. import { Analyser } from "babylonjs/Audio/analyser";
  33449. import { Nullable } from "babylonjs/types";
  33450. import { Observable } from "babylonjs/Misc/observable";
  33451. /**
  33452. * This represents an audio engine and it is responsible
  33453. * to play, synchronize and analyse sounds throughout the application.
  33454. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33455. */
  33456. export interface IAudioEngine extends IDisposable {
  33457. /**
  33458. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33459. */
  33460. readonly canUseWebAudio: boolean;
  33461. /**
  33462. * Gets the current AudioContext if available.
  33463. */
  33464. readonly audioContext: Nullable<AudioContext>;
  33465. /**
  33466. * The master gain node defines the global audio volume of your audio engine.
  33467. */
  33468. readonly masterGain: GainNode;
  33469. /**
  33470. * Gets whether or not mp3 are supported by your browser.
  33471. */
  33472. readonly isMP3supported: boolean;
  33473. /**
  33474. * Gets whether or not ogg are supported by your browser.
  33475. */
  33476. readonly isOGGsupported: boolean;
  33477. /**
  33478. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33479. * @ignoreNaming
  33480. */
  33481. WarnedWebAudioUnsupported: boolean;
  33482. /**
  33483. * Defines if the audio engine relies on a custom unlocked button.
  33484. * In this case, the embedded button will not be displayed.
  33485. */
  33486. useCustomUnlockedButton: boolean;
  33487. /**
  33488. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33489. */
  33490. readonly unlocked: boolean;
  33491. /**
  33492. * Event raised when audio has been unlocked on the browser.
  33493. */
  33494. onAudioUnlockedObservable: Observable<AudioEngine>;
  33495. /**
  33496. * Event raised when audio has been locked on the browser.
  33497. */
  33498. onAudioLockedObservable: Observable<AudioEngine>;
  33499. /**
  33500. * Flags the audio engine in Locked state.
  33501. * This happens due to new browser policies preventing audio to autoplay.
  33502. */
  33503. lock(): void;
  33504. /**
  33505. * Unlocks the audio engine once a user action has been done on the dom.
  33506. * This is helpful to resume play once browser policies have been satisfied.
  33507. */
  33508. unlock(): void;
  33509. }
  33510. /**
  33511. * This represents the default audio engine used in babylon.
  33512. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33513. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33514. */
  33515. export class AudioEngine implements IAudioEngine {
  33516. private _audioContext;
  33517. private _audioContextInitialized;
  33518. private _muteButton;
  33519. private _hostElement;
  33520. /**
  33521. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33522. */
  33523. canUseWebAudio: boolean;
  33524. /**
  33525. * The master gain node defines the global audio volume of your audio engine.
  33526. */
  33527. masterGain: GainNode;
  33528. /**
  33529. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33530. * @ignoreNaming
  33531. */
  33532. WarnedWebAudioUnsupported: boolean;
  33533. /**
  33534. * Gets whether or not mp3 are supported by your browser.
  33535. */
  33536. isMP3supported: boolean;
  33537. /**
  33538. * Gets whether or not ogg are supported by your browser.
  33539. */
  33540. isOGGsupported: boolean;
  33541. /**
  33542. * Gets whether audio has been unlocked on the device.
  33543. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33544. * a user interaction has happened.
  33545. */
  33546. unlocked: boolean;
  33547. /**
  33548. * Defines if the audio engine relies on a custom unlocked button.
  33549. * In this case, the embedded button will not be displayed.
  33550. */
  33551. useCustomUnlockedButton: boolean;
  33552. /**
  33553. * Event raised when audio has been unlocked on the browser.
  33554. */
  33555. onAudioUnlockedObservable: Observable<AudioEngine>;
  33556. /**
  33557. * Event raised when audio has been locked on the browser.
  33558. */
  33559. onAudioLockedObservable: Observable<AudioEngine>;
  33560. /**
  33561. * Gets the current AudioContext if available.
  33562. */
  33563. get audioContext(): Nullable<AudioContext>;
  33564. private _connectedAnalyser;
  33565. /**
  33566. * Instantiates a new audio engine.
  33567. *
  33568. * There should be only one per page as some browsers restrict the number
  33569. * of audio contexts you can create.
  33570. * @param hostElement defines the host element where to display the mute icon if necessary
  33571. */
  33572. constructor(hostElement?: Nullable<HTMLElement>);
  33573. /**
  33574. * Flags the audio engine in Locked state.
  33575. * This happens due to new browser policies preventing audio to autoplay.
  33576. */
  33577. lock(): void;
  33578. /**
  33579. * Unlocks the audio engine once a user action has been done on the dom.
  33580. * This is helpful to resume play once browser policies have been satisfied.
  33581. */
  33582. unlock(): void;
  33583. private _resumeAudioContext;
  33584. private _initializeAudioContext;
  33585. private _tryToRun;
  33586. private _triggerRunningState;
  33587. private _triggerSuspendedState;
  33588. private _displayMuteButton;
  33589. private _moveButtonToTopLeft;
  33590. private _onResize;
  33591. private _hideMuteButton;
  33592. /**
  33593. * Destroy and release the resources associated with the audio ccontext.
  33594. */
  33595. dispose(): void;
  33596. /**
  33597. * Gets the global volume sets on the master gain.
  33598. * @returns the global volume if set or -1 otherwise
  33599. */
  33600. getGlobalVolume(): number;
  33601. /**
  33602. * Sets the global volume of your experience (sets on the master gain).
  33603. * @param newVolume Defines the new global volume of the application
  33604. */
  33605. setGlobalVolume(newVolume: number): void;
  33606. /**
  33607. * Connect the audio engine to an audio analyser allowing some amazing
  33608. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33609. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33610. * @param analyser The analyser to connect to the engine
  33611. */
  33612. connectToAnalyser(analyser: Analyser): void;
  33613. }
  33614. }
  33615. declare module "babylonjs/Loading/loadingScreen" {
  33616. /**
  33617. * Interface used to present a loading screen while loading a scene
  33618. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33619. */
  33620. export interface ILoadingScreen {
  33621. /**
  33622. * Function called to display the loading screen
  33623. */
  33624. displayLoadingUI: () => void;
  33625. /**
  33626. * Function called to hide the loading screen
  33627. */
  33628. hideLoadingUI: () => void;
  33629. /**
  33630. * Gets or sets the color to use for the background
  33631. */
  33632. loadingUIBackgroundColor: string;
  33633. /**
  33634. * Gets or sets the text to display while loading
  33635. */
  33636. loadingUIText: string;
  33637. }
  33638. /**
  33639. * Class used for the default loading screen
  33640. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33641. */
  33642. export class DefaultLoadingScreen implements ILoadingScreen {
  33643. private _renderingCanvas;
  33644. private _loadingText;
  33645. private _loadingDivBackgroundColor;
  33646. private _loadingDiv;
  33647. private _loadingTextDiv;
  33648. /** Gets or sets the logo url to use for the default loading screen */
  33649. static DefaultLogoUrl: string;
  33650. /** Gets or sets the spinner url to use for the default loading screen */
  33651. static DefaultSpinnerUrl: string;
  33652. /**
  33653. * Creates a new default loading screen
  33654. * @param _renderingCanvas defines the canvas used to render the scene
  33655. * @param _loadingText defines the default text to display
  33656. * @param _loadingDivBackgroundColor defines the default background color
  33657. */
  33658. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33659. /**
  33660. * Function called to display the loading screen
  33661. */
  33662. displayLoadingUI(): void;
  33663. /**
  33664. * Function called to hide the loading screen
  33665. */
  33666. hideLoadingUI(): void;
  33667. /**
  33668. * Gets or sets the text to display while loading
  33669. */
  33670. set loadingUIText(text: string);
  33671. get loadingUIText(): string;
  33672. /**
  33673. * Gets or sets the color to use for the background
  33674. */
  33675. get loadingUIBackgroundColor(): string;
  33676. set loadingUIBackgroundColor(color: string);
  33677. private _resizeLoadingUI;
  33678. }
  33679. }
  33680. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33681. /**
  33682. * Interface for any object that can request an animation frame
  33683. */
  33684. export interface ICustomAnimationFrameRequester {
  33685. /**
  33686. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33687. */
  33688. renderFunction?: Function;
  33689. /**
  33690. * Called to request the next frame to render to
  33691. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33692. */
  33693. requestAnimationFrame: Function;
  33694. /**
  33695. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33696. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33697. */
  33698. requestID?: number;
  33699. }
  33700. }
  33701. declare module "babylonjs/Misc/performanceMonitor" {
  33702. /**
  33703. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33704. */
  33705. export class PerformanceMonitor {
  33706. private _enabled;
  33707. private _rollingFrameTime;
  33708. private _lastFrameTimeMs;
  33709. /**
  33710. * constructor
  33711. * @param frameSampleSize The number of samples required to saturate the sliding window
  33712. */
  33713. constructor(frameSampleSize?: number);
  33714. /**
  33715. * Samples current frame
  33716. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33717. */
  33718. sampleFrame(timeMs?: number): void;
  33719. /**
  33720. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33721. */
  33722. get averageFrameTime(): number;
  33723. /**
  33724. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33725. */
  33726. get averageFrameTimeVariance(): number;
  33727. /**
  33728. * Returns the frame time of the most recent frame
  33729. */
  33730. get instantaneousFrameTime(): number;
  33731. /**
  33732. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33733. */
  33734. get averageFPS(): number;
  33735. /**
  33736. * Returns the average framerate in frames per second using the most recent frame time
  33737. */
  33738. get instantaneousFPS(): number;
  33739. /**
  33740. * Returns true if enough samples have been taken to completely fill the sliding window
  33741. */
  33742. get isSaturated(): boolean;
  33743. /**
  33744. * Enables contributions to the sliding window sample set
  33745. */
  33746. enable(): void;
  33747. /**
  33748. * Disables contributions to the sliding window sample set
  33749. * Samples will not be interpolated over the disabled period
  33750. */
  33751. disable(): void;
  33752. /**
  33753. * Returns true if sampling is enabled
  33754. */
  33755. get isEnabled(): boolean;
  33756. /**
  33757. * Resets performance monitor
  33758. */
  33759. reset(): void;
  33760. }
  33761. /**
  33762. * RollingAverage
  33763. *
  33764. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33765. */
  33766. export class RollingAverage {
  33767. /**
  33768. * Current average
  33769. */
  33770. average: number;
  33771. /**
  33772. * Current variance
  33773. */
  33774. variance: number;
  33775. protected _samples: Array<number>;
  33776. protected _sampleCount: number;
  33777. protected _pos: number;
  33778. protected _m2: number;
  33779. /**
  33780. * constructor
  33781. * @param length The number of samples required to saturate the sliding window
  33782. */
  33783. constructor(length: number);
  33784. /**
  33785. * Adds a sample to the sample set
  33786. * @param v The sample value
  33787. */
  33788. add(v: number): void;
  33789. /**
  33790. * Returns previously added values or null if outside of history or outside the sliding window domain
  33791. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33792. * @return Value previously recorded with add() or null if outside of range
  33793. */
  33794. history(i: number): number;
  33795. /**
  33796. * Returns true if enough samples have been taken to completely fill the sliding window
  33797. * @return true if sample-set saturated
  33798. */
  33799. isSaturated(): boolean;
  33800. /**
  33801. * Resets the rolling average (equivalent to 0 samples taken so far)
  33802. */
  33803. reset(): void;
  33804. /**
  33805. * Wraps a value around the sample range boundaries
  33806. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33807. * @return Wrapped position in sample range
  33808. */
  33809. protected _wrapPosition(i: number): number;
  33810. }
  33811. }
  33812. declare module "babylonjs/Misc/perfCounter" {
  33813. /**
  33814. * This class is used to track a performance counter which is number based.
  33815. * The user has access to many properties which give statistics of different nature.
  33816. *
  33817. * The implementer can track two kinds of Performance Counter: time and count.
  33818. * 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.
  33819. * 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.
  33820. */
  33821. export class PerfCounter {
  33822. /**
  33823. * Gets or sets a global boolean to turn on and off all the counters
  33824. */
  33825. static Enabled: boolean;
  33826. /**
  33827. * Returns the smallest value ever
  33828. */
  33829. get min(): number;
  33830. /**
  33831. * Returns the biggest value ever
  33832. */
  33833. get max(): number;
  33834. /**
  33835. * Returns the average value since the performance counter is running
  33836. */
  33837. get average(): number;
  33838. /**
  33839. * Returns the average value of the last second the counter was monitored
  33840. */
  33841. get lastSecAverage(): number;
  33842. /**
  33843. * Returns the current value
  33844. */
  33845. get current(): number;
  33846. /**
  33847. * Gets the accumulated total
  33848. */
  33849. get total(): number;
  33850. /**
  33851. * Gets the total value count
  33852. */
  33853. get count(): number;
  33854. /**
  33855. * Creates a new counter
  33856. */
  33857. constructor();
  33858. /**
  33859. * Call this method to start monitoring a new frame.
  33860. * 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.
  33861. */
  33862. fetchNewFrame(): void;
  33863. /**
  33864. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33865. * @param newCount the count value to add to the monitored count
  33866. * @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.
  33867. */
  33868. addCount(newCount: number, fetchResult: boolean): void;
  33869. /**
  33870. * Start monitoring this performance counter
  33871. */
  33872. beginMonitoring(): void;
  33873. /**
  33874. * Compute the time lapsed since the previous beginMonitoring() call.
  33875. * @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
  33876. */
  33877. endMonitoring(newFrame?: boolean): void;
  33878. private _fetchResult;
  33879. private _startMonitoringTime;
  33880. private _min;
  33881. private _max;
  33882. private _average;
  33883. private _current;
  33884. private _totalValueCount;
  33885. private _totalAccumulated;
  33886. private _lastSecAverage;
  33887. private _lastSecAccumulated;
  33888. private _lastSecTime;
  33889. private _lastSecValueCount;
  33890. }
  33891. }
  33892. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  33893. module "babylonjs/Engines/thinEngine" {
  33894. interface ThinEngine {
  33895. /**
  33896. * Sets alpha constants used by some alpha blending modes
  33897. * @param r defines the red component
  33898. * @param g defines the green component
  33899. * @param b defines the blue component
  33900. * @param a defines the alpha component
  33901. */
  33902. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33903. /**
  33904. * Sets the current alpha mode
  33905. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33906. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33907. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33908. */
  33909. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33910. /**
  33911. * Gets the current alpha mode
  33912. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33913. * @returns the current alpha mode
  33914. */
  33915. getAlphaMode(): number;
  33916. /**
  33917. * Sets the current alpha equation
  33918. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33919. */
  33920. setAlphaEquation(equation: number): void;
  33921. /**
  33922. * Gets the current alpha equation.
  33923. * @returns the current alpha equation
  33924. */
  33925. getAlphaEquation(): number;
  33926. }
  33927. }
  33928. }
  33929. declare module "babylonjs/Engines/engine" {
  33930. import { Observable } from "babylonjs/Misc/observable";
  33931. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  33932. import { Scene } from "babylonjs/scene";
  33933. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33934. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  33935. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33936. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  33937. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  33938. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  33939. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  33940. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  33941. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  33942. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33943. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  33944. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  33945. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33946. import "babylonjs/Engines/Extensions/engine.alpha";
  33947. import { Material } from "babylonjs/Materials/material";
  33948. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33949. /**
  33950. * Defines the interface used by display changed events
  33951. */
  33952. export interface IDisplayChangedEventArgs {
  33953. /** Gets the vrDisplay object (if any) */
  33954. vrDisplay: Nullable<any>;
  33955. /** Gets a boolean indicating if webVR is supported */
  33956. vrSupported: boolean;
  33957. }
  33958. /**
  33959. * Defines the interface used by objects containing a viewport (like a camera)
  33960. */
  33961. interface IViewportOwnerLike {
  33962. /**
  33963. * Gets or sets the viewport
  33964. */
  33965. viewport: IViewportLike;
  33966. }
  33967. /**
  33968. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33969. */
  33970. export class Engine extends ThinEngine {
  33971. /** Defines that alpha blending is disabled */
  33972. static readonly ALPHA_DISABLE: number;
  33973. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33974. static readonly ALPHA_ADD: number;
  33975. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33976. static readonly ALPHA_COMBINE: number;
  33977. /** Defines that alpha blending to DEST - SRC * DEST */
  33978. static readonly ALPHA_SUBTRACT: number;
  33979. /** Defines that alpha blending to SRC * DEST */
  33980. static readonly ALPHA_MULTIPLY: number;
  33981. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33982. static readonly ALPHA_MAXIMIZED: number;
  33983. /** Defines that alpha blending to SRC + DEST */
  33984. static readonly ALPHA_ONEONE: number;
  33985. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33986. static readonly ALPHA_PREMULTIPLIED: number;
  33987. /**
  33988. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33989. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33990. */
  33991. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33992. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33993. static readonly ALPHA_INTERPOLATE: number;
  33994. /**
  33995. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33996. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33997. */
  33998. static readonly ALPHA_SCREENMODE: number;
  33999. /** Defines that the ressource is not delayed*/
  34000. static readonly DELAYLOADSTATE_NONE: number;
  34001. /** Defines that the ressource was successfully delay loaded */
  34002. static readonly DELAYLOADSTATE_LOADED: number;
  34003. /** Defines that the ressource is currently delay loading */
  34004. static readonly DELAYLOADSTATE_LOADING: number;
  34005. /** Defines that the ressource is delayed and has not started loading */
  34006. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34007. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34008. static readonly NEVER: number;
  34009. /** 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 */
  34010. static readonly ALWAYS: number;
  34011. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34012. static readonly LESS: number;
  34013. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34014. static readonly EQUAL: number;
  34015. /** 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 */
  34016. static readonly LEQUAL: number;
  34017. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34018. static readonly GREATER: number;
  34019. /** 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 */
  34020. static readonly GEQUAL: number;
  34021. /** 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 */
  34022. static readonly NOTEQUAL: number;
  34023. /** Passed to stencilOperation to specify that stencil value must be kept */
  34024. static readonly KEEP: number;
  34025. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34026. static readonly REPLACE: number;
  34027. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34028. static readonly INCR: number;
  34029. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34030. static readonly DECR: number;
  34031. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34032. static readonly INVERT: number;
  34033. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34034. static readonly INCR_WRAP: number;
  34035. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34036. static readonly DECR_WRAP: number;
  34037. /** Texture is not repeating outside of 0..1 UVs */
  34038. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34039. /** Texture is repeating outside of 0..1 UVs */
  34040. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34041. /** Texture is repeating and mirrored */
  34042. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34043. /** ALPHA */
  34044. static readonly TEXTUREFORMAT_ALPHA: number;
  34045. /** LUMINANCE */
  34046. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34047. /** LUMINANCE_ALPHA */
  34048. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34049. /** RGB */
  34050. static readonly TEXTUREFORMAT_RGB: number;
  34051. /** RGBA */
  34052. static readonly TEXTUREFORMAT_RGBA: number;
  34053. /** RED */
  34054. static readonly TEXTUREFORMAT_RED: number;
  34055. /** RED (2nd reference) */
  34056. static readonly TEXTUREFORMAT_R: number;
  34057. /** RG */
  34058. static readonly TEXTUREFORMAT_RG: number;
  34059. /** RED_INTEGER */
  34060. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34061. /** RED_INTEGER (2nd reference) */
  34062. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34063. /** RG_INTEGER */
  34064. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34065. /** RGB_INTEGER */
  34066. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34067. /** RGBA_INTEGER */
  34068. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34069. /** UNSIGNED_BYTE */
  34070. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34071. /** UNSIGNED_BYTE (2nd reference) */
  34072. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34073. /** FLOAT */
  34074. static readonly TEXTURETYPE_FLOAT: number;
  34075. /** HALF_FLOAT */
  34076. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34077. /** BYTE */
  34078. static readonly TEXTURETYPE_BYTE: number;
  34079. /** SHORT */
  34080. static readonly TEXTURETYPE_SHORT: number;
  34081. /** UNSIGNED_SHORT */
  34082. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34083. /** INT */
  34084. static readonly TEXTURETYPE_INT: number;
  34085. /** UNSIGNED_INT */
  34086. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34087. /** UNSIGNED_SHORT_4_4_4_4 */
  34088. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34089. /** UNSIGNED_SHORT_5_5_5_1 */
  34090. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34091. /** UNSIGNED_SHORT_5_6_5 */
  34092. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34093. /** UNSIGNED_INT_2_10_10_10_REV */
  34094. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34095. /** UNSIGNED_INT_24_8 */
  34096. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34097. /** UNSIGNED_INT_10F_11F_11F_REV */
  34098. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34099. /** UNSIGNED_INT_5_9_9_9_REV */
  34100. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34101. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34102. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34103. /** nearest is mag = nearest and min = nearest and mip = linear */
  34104. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34105. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34106. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34107. /** Trilinear is mag = linear and min = linear and mip = linear */
  34108. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34109. /** nearest is mag = nearest and min = nearest and mip = linear */
  34110. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34111. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34112. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34113. /** Trilinear is mag = linear and min = linear and mip = linear */
  34114. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34115. /** mag = nearest and min = nearest and mip = nearest */
  34116. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34117. /** mag = nearest and min = linear and mip = nearest */
  34118. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34119. /** mag = nearest and min = linear and mip = linear */
  34120. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34121. /** mag = nearest and min = linear and mip = none */
  34122. static readonly TEXTURE_NEAREST_LINEAR: number;
  34123. /** mag = nearest and min = nearest and mip = none */
  34124. static readonly TEXTURE_NEAREST_NEAREST: number;
  34125. /** mag = linear and min = nearest and mip = nearest */
  34126. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34127. /** mag = linear and min = nearest and mip = linear */
  34128. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34129. /** mag = linear and min = linear and mip = none */
  34130. static readonly TEXTURE_LINEAR_LINEAR: number;
  34131. /** mag = linear and min = nearest and mip = none */
  34132. static readonly TEXTURE_LINEAR_NEAREST: number;
  34133. /** Explicit coordinates mode */
  34134. static readonly TEXTURE_EXPLICIT_MODE: number;
  34135. /** Spherical coordinates mode */
  34136. static readonly TEXTURE_SPHERICAL_MODE: number;
  34137. /** Planar coordinates mode */
  34138. static readonly TEXTURE_PLANAR_MODE: number;
  34139. /** Cubic coordinates mode */
  34140. static readonly TEXTURE_CUBIC_MODE: number;
  34141. /** Projection coordinates mode */
  34142. static readonly TEXTURE_PROJECTION_MODE: number;
  34143. /** Skybox coordinates mode */
  34144. static readonly TEXTURE_SKYBOX_MODE: number;
  34145. /** Inverse Cubic coordinates mode */
  34146. static readonly TEXTURE_INVCUBIC_MODE: number;
  34147. /** Equirectangular coordinates mode */
  34148. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34149. /** Equirectangular Fixed coordinates mode */
  34150. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34151. /** Equirectangular Fixed Mirrored coordinates mode */
  34152. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34153. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34154. static readonly SCALEMODE_FLOOR: number;
  34155. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34156. static readonly SCALEMODE_NEAREST: number;
  34157. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34158. static readonly SCALEMODE_CEILING: number;
  34159. /**
  34160. * Returns the current npm package of the sdk
  34161. */
  34162. static get NpmPackage(): string;
  34163. /**
  34164. * Returns the current version of the framework
  34165. */
  34166. static get Version(): string;
  34167. /** Gets the list of created engines */
  34168. static get Instances(): Engine[];
  34169. /**
  34170. * Gets the latest created engine
  34171. */
  34172. static get LastCreatedEngine(): Nullable<Engine>;
  34173. /**
  34174. * Gets the latest created scene
  34175. */
  34176. static get LastCreatedScene(): Nullable<Scene>;
  34177. /**
  34178. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34179. * @param flag defines which part of the materials must be marked as dirty
  34180. * @param predicate defines a predicate used to filter which materials should be affected
  34181. */
  34182. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34183. /**
  34184. * Method called to create the default loading screen.
  34185. * This can be overriden in your own app.
  34186. * @param canvas The rendering canvas element
  34187. * @returns The loading screen
  34188. */
  34189. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34190. /**
  34191. * Method called to create the default rescale post process on each engine.
  34192. */
  34193. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34194. /**
  34195. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34196. **/
  34197. enableOfflineSupport: boolean;
  34198. /**
  34199. * 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)
  34200. **/
  34201. disableManifestCheck: boolean;
  34202. /**
  34203. * Gets the list of created scenes
  34204. */
  34205. scenes: Scene[];
  34206. /**
  34207. * Event raised when a new scene is created
  34208. */
  34209. onNewSceneAddedObservable: Observable<Scene>;
  34210. /**
  34211. * Gets the list of created postprocesses
  34212. */
  34213. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34214. /**
  34215. * Gets a boolean indicating if the pointer is currently locked
  34216. */
  34217. isPointerLock: boolean;
  34218. /**
  34219. * Observable event triggered each time the rendering canvas is resized
  34220. */
  34221. onResizeObservable: Observable<Engine>;
  34222. /**
  34223. * Observable event triggered each time the canvas loses focus
  34224. */
  34225. onCanvasBlurObservable: Observable<Engine>;
  34226. /**
  34227. * Observable event triggered each time the canvas gains focus
  34228. */
  34229. onCanvasFocusObservable: Observable<Engine>;
  34230. /**
  34231. * Observable event triggered each time the canvas receives pointerout event
  34232. */
  34233. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34234. /**
  34235. * Observable raised when the engine begins a new frame
  34236. */
  34237. onBeginFrameObservable: Observable<Engine>;
  34238. /**
  34239. * If set, will be used to request the next animation frame for the render loop
  34240. */
  34241. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34242. /**
  34243. * Observable raised when the engine ends the current frame
  34244. */
  34245. onEndFrameObservable: Observable<Engine>;
  34246. /**
  34247. * Observable raised when the engine is about to compile a shader
  34248. */
  34249. onBeforeShaderCompilationObservable: Observable<Engine>;
  34250. /**
  34251. * Observable raised when the engine has jsut compiled a shader
  34252. */
  34253. onAfterShaderCompilationObservable: Observable<Engine>;
  34254. /**
  34255. * Gets the audio engine
  34256. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34257. * @ignorenaming
  34258. */
  34259. static audioEngine: IAudioEngine;
  34260. /**
  34261. * Default AudioEngine factory responsible of creating the Audio Engine.
  34262. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34263. */
  34264. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34265. /**
  34266. * Default offline support factory responsible of creating a tool used to store data locally.
  34267. * By default, this will create a Database object if the workload has been embedded.
  34268. */
  34269. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34270. private _loadingScreen;
  34271. private _pointerLockRequested;
  34272. private _dummyFramebuffer;
  34273. private _rescalePostProcess;
  34274. private _deterministicLockstep;
  34275. private _lockstepMaxSteps;
  34276. private _timeStep;
  34277. protected get _supportsHardwareTextureRescaling(): boolean;
  34278. private _fps;
  34279. private _deltaTime;
  34280. /** @hidden */
  34281. _drawCalls: PerfCounter;
  34282. /** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */
  34283. canvasTabIndex: number;
  34284. /**
  34285. * Turn this value on if you want to pause FPS computation when in background
  34286. */
  34287. disablePerformanceMonitorInBackground: boolean;
  34288. private _performanceMonitor;
  34289. /**
  34290. * Gets the performance monitor attached to this engine
  34291. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34292. */
  34293. get performanceMonitor(): PerformanceMonitor;
  34294. private _onFocus;
  34295. private _onBlur;
  34296. private _onCanvasPointerOut;
  34297. private _onCanvasBlur;
  34298. private _onCanvasFocus;
  34299. private _onFullscreenChange;
  34300. private _onPointerLockChange;
  34301. /**
  34302. * Gets the HTML element used to attach event listeners
  34303. * @returns a HTML element
  34304. */
  34305. getInputElement(): Nullable<HTMLElement>;
  34306. /**
  34307. * Creates a new engine
  34308. * @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
  34309. * @param antialias defines enable antialiasing (default: false)
  34310. * @param options defines further options to be sent to the getContext() function
  34311. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34312. */
  34313. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34314. /**
  34315. * Gets current aspect ratio
  34316. * @param viewportOwner defines the camera to use to get the aspect ratio
  34317. * @param useScreen defines if screen size must be used (or the current render target if any)
  34318. * @returns a number defining the aspect ratio
  34319. */
  34320. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34321. /**
  34322. * Gets current screen aspect ratio
  34323. * @returns a number defining the aspect ratio
  34324. */
  34325. getScreenAspectRatio(): number;
  34326. /**
  34327. * Gets the client rect of the HTML canvas attached with the current webGL context
  34328. * @returns a client rectanglee
  34329. */
  34330. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34331. /**
  34332. * Gets the client rect of the HTML element used for events
  34333. * @returns a client rectanglee
  34334. */
  34335. getInputElementClientRect(): Nullable<ClientRect>;
  34336. /**
  34337. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34338. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34339. * @returns true if engine is in deterministic lock step mode
  34340. */
  34341. isDeterministicLockStep(): boolean;
  34342. /**
  34343. * Gets the max steps when engine is running in deterministic lock step
  34344. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34345. * @returns the max steps
  34346. */
  34347. getLockstepMaxSteps(): number;
  34348. /**
  34349. * Returns the time in ms between steps when using deterministic lock step.
  34350. * @returns time step in (ms)
  34351. */
  34352. getTimeStep(): number;
  34353. /**
  34354. * Force the mipmap generation for the given render target texture
  34355. * @param texture defines the render target texture to use
  34356. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34357. */
  34358. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34359. /** States */
  34360. /**
  34361. * Set various states to the webGL context
  34362. * @param culling defines backface culling state
  34363. * @param zOffset defines the value to apply to zOffset (0 by default)
  34364. * @param force defines if states must be applied even if cache is up to date
  34365. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34366. */
  34367. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34368. /**
  34369. * Set the z offset to apply to current rendering
  34370. * @param value defines the offset to apply
  34371. */
  34372. setZOffset(value: number): void;
  34373. /**
  34374. * Gets the current value of the zOffset
  34375. * @returns the current zOffset state
  34376. */
  34377. getZOffset(): number;
  34378. /**
  34379. * Enable or disable depth buffering
  34380. * @param enable defines the state to set
  34381. */
  34382. setDepthBuffer(enable: boolean): void;
  34383. /**
  34384. * Gets a boolean indicating if depth writing is enabled
  34385. * @returns the current depth writing state
  34386. */
  34387. getDepthWrite(): boolean;
  34388. /**
  34389. * Enable or disable depth writing
  34390. * @param enable defines the state to set
  34391. */
  34392. setDepthWrite(enable: boolean): void;
  34393. /**
  34394. * Gets a boolean indicating if stencil buffer is enabled
  34395. * @returns the current stencil buffer state
  34396. */
  34397. getStencilBuffer(): boolean;
  34398. /**
  34399. * Enable or disable the stencil buffer
  34400. * @param enable defines if the stencil buffer must be enabled or disabled
  34401. */
  34402. setStencilBuffer(enable: boolean): void;
  34403. /**
  34404. * Gets the current stencil mask
  34405. * @returns a number defining the new stencil mask to use
  34406. */
  34407. getStencilMask(): number;
  34408. /**
  34409. * Sets the current stencil mask
  34410. * @param mask defines the new stencil mask to use
  34411. */
  34412. setStencilMask(mask: number): void;
  34413. /**
  34414. * Gets the current stencil function
  34415. * @returns a number defining the stencil function to use
  34416. */
  34417. getStencilFunction(): number;
  34418. /**
  34419. * Gets the current stencil reference value
  34420. * @returns a number defining the stencil reference value to use
  34421. */
  34422. getStencilFunctionReference(): number;
  34423. /**
  34424. * Gets the current stencil mask
  34425. * @returns a number defining the stencil mask to use
  34426. */
  34427. getStencilFunctionMask(): number;
  34428. /**
  34429. * Sets the current stencil function
  34430. * @param stencilFunc defines the new stencil function to use
  34431. */
  34432. setStencilFunction(stencilFunc: number): void;
  34433. /**
  34434. * Sets the current stencil reference
  34435. * @param reference defines the new stencil reference to use
  34436. */
  34437. setStencilFunctionReference(reference: number): void;
  34438. /**
  34439. * Sets the current stencil mask
  34440. * @param mask defines the new stencil mask to use
  34441. */
  34442. setStencilFunctionMask(mask: number): void;
  34443. /**
  34444. * Gets the current stencil operation when stencil fails
  34445. * @returns a number defining stencil operation to use when stencil fails
  34446. */
  34447. getStencilOperationFail(): number;
  34448. /**
  34449. * Gets the current stencil operation when depth fails
  34450. * @returns a number defining stencil operation to use when depth fails
  34451. */
  34452. getStencilOperationDepthFail(): number;
  34453. /**
  34454. * Gets the current stencil operation when stencil passes
  34455. * @returns a number defining stencil operation to use when stencil passes
  34456. */
  34457. getStencilOperationPass(): number;
  34458. /**
  34459. * Sets the stencil operation to use when stencil fails
  34460. * @param operation defines the stencil operation to use when stencil fails
  34461. */
  34462. setStencilOperationFail(operation: number): void;
  34463. /**
  34464. * Sets the stencil operation to use when depth fails
  34465. * @param operation defines the stencil operation to use when depth fails
  34466. */
  34467. setStencilOperationDepthFail(operation: number): void;
  34468. /**
  34469. * Sets the stencil operation to use when stencil passes
  34470. * @param operation defines the stencil operation to use when stencil passes
  34471. */
  34472. setStencilOperationPass(operation: number): void;
  34473. /**
  34474. * Sets a boolean indicating if the dithering state is enabled or disabled
  34475. * @param value defines the dithering state
  34476. */
  34477. setDitheringState(value: boolean): void;
  34478. /**
  34479. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34480. * @param value defines the rasterizer state
  34481. */
  34482. setRasterizerState(value: boolean): void;
  34483. /**
  34484. * Gets the current depth function
  34485. * @returns a number defining the depth function
  34486. */
  34487. getDepthFunction(): Nullable<number>;
  34488. /**
  34489. * Sets the current depth function
  34490. * @param depthFunc defines the function to use
  34491. */
  34492. setDepthFunction(depthFunc: number): void;
  34493. /**
  34494. * Sets the current depth function to GREATER
  34495. */
  34496. setDepthFunctionToGreater(): void;
  34497. /**
  34498. * Sets the current depth function to GEQUAL
  34499. */
  34500. setDepthFunctionToGreaterOrEqual(): void;
  34501. /**
  34502. * Sets the current depth function to LESS
  34503. */
  34504. setDepthFunctionToLess(): void;
  34505. /**
  34506. * Sets the current depth function to LEQUAL
  34507. */
  34508. setDepthFunctionToLessOrEqual(): void;
  34509. private _cachedStencilBuffer;
  34510. private _cachedStencilFunction;
  34511. private _cachedStencilMask;
  34512. private _cachedStencilOperationPass;
  34513. private _cachedStencilOperationFail;
  34514. private _cachedStencilOperationDepthFail;
  34515. private _cachedStencilReference;
  34516. /**
  34517. * Caches the the state of the stencil buffer
  34518. */
  34519. cacheStencilState(): void;
  34520. /**
  34521. * Restores the state of the stencil buffer
  34522. */
  34523. restoreStencilState(): void;
  34524. /**
  34525. * Directly set the WebGL Viewport
  34526. * @param x defines the x coordinate of the viewport (in screen space)
  34527. * @param y defines the y coordinate of the viewport (in screen space)
  34528. * @param width defines the width of the viewport (in screen space)
  34529. * @param height defines the height of the viewport (in screen space)
  34530. * @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
  34531. */
  34532. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34533. /**
  34534. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34535. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34536. * @param y defines the y-coordinate of the corner of the clear rectangle
  34537. * @param width defines the width of the clear rectangle
  34538. * @param height defines the height of the clear rectangle
  34539. * @param clearColor defines the clear color
  34540. */
  34541. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34542. /**
  34543. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34544. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34545. * @param y defines the y-coordinate of the corner of the clear rectangle
  34546. * @param width defines the width of the clear rectangle
  34547. * @param height defines the height of the clear rectangle
  34548. */
  34549. enableScissor(x: number, y: number, width: number, height: number): void;
  34550. /**
  34551. * Disable previously set scissor test rectangle
  34552. */
  34553. disableScissor(): void;
  34554. protected _reportDrawCall(): void;
  34555. /**
  34556. * Initializes a webVR display and starts listening to display change events
  34557. * The onVRDisplayChangedObservable will be notified upon these changes
  34558. * @returns The onVRDisplayChangedObservable
  34559. */
  34560. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34561. /** @hidden */
  34562. _prepareVRComponent(): void;
  34563. /** @hidden */
  34564. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34565. /** @hidden */
  34566. _submitVRFrame(): void;
  34567. /**
  34568. * Call this function to leave webVR mode
  34569. * Will do nothing if webVR is not supported or if there is no webVR device
  34570. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34571. */
  34572. disableVR(): void;
  34573. /**
  34574. * Gets a boolean indicating that the system is in VR mode and is presenting
  34575. * @returns true if VR mode is engaged
  34576. */
  34577. isVRPresenting(): boolean;
  34578. /** @hidden */
  34579. _requestVRFrame(): void;
  34580. /** @hidden */
  34581. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34582. /**
  34583. * Gets the source code of the vertex shader associated with a specific webGL program
  34584. * @param program defines the program to use
  34585. * @returns a string containing the source code of the vertex shader associated with the program
  34586. */
  34587. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34588. /**
  34589. * Gets the source code of the fragment shader associated with a specific webGL program
  34590. * @param program defines the program to use
  34591. * @returns a string containing the source code of the fragment shader associated with the program
  34592. */
  34593. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34594. /**
  34595. * Sets a depth stencil texture from a render target to the according uniform.
  34596. * @param channel The texture channel
  34597. * @param uniform The uniform to set
  34598. * @param texture The render target texture containing the depth stencil texture to apply
  34599. */
  34600. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34601. /**
  34602. * Sets a texture to the webGL context from a postprocess
  34603. * @param channel defines the channel to use
  34604. * @param postProcess defines the source postprocess
  34605. */
  34606. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34607. /**
  34608. * Binds the output of the passed in post process to the texture channel specified
  34609. * @param channel The channel the texture should be bound to
  34610. * @param postProcess The post process which's output should be bound
  34611. */
  34612. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34613. /** @hidden */
  34614. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34615. protected _rebuildBuffers(): void;
  34616. /** @hidden */
  34617. _renderFrame(): void;
  34618. _renderLoop(): void;
  34619. /** @hidden */
  34620. _renderViews(): boolean;
  34621. /**
  34622. * Toggle full screen mode
  34623. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34624. */
  34625. switchFullscreen(requestPointerLock: boolean): void;
  34626. /**
  34627. * Enters full screen mode
  34628. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34629. */
  34630. enterFullscreen(requestPointerLock: boolean): void;
  34631. /**
  34632. * Exits full screen mode
  34633. */
  34634. exitFullscreen(): void;
  34635. /**
  34636. * Enters Pointerlock mode
  34637. */
  34638. enterPointerlock(): void;
  34639. /**
  34640. * Exits Pointerlock mode
  34641. */
  34642. exitPointerlock(): void;
  34643. /**
  34644. * Begin a new frame
  34645. */
  34646. beginFrame(): void;
  34647. /**
  34648. * Enf the current frame
  34649. */
  34650. endFrame(): void;
  34651. resize(): void;
  34652. /**
  34653. * Set the compressed texture format to use, based on the formats you have, and the formats
  34654. * supported by the hardware / browser.
  34655. *
  34656. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  34657. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  34658. * to API arguments needed to compressed textures. This puts the burden on the container
  34659. * generator to house the arcane code for determining these for current & future formats.
  34660. *
  34661. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  34662. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  34663. *
  34664. * Note: The result of this call is not taken into account when a texture is base64.
  34665. *
  34666. * @param formatsAvailable defines the list of those format families you have created
  34667. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  34668. *
  34669. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  34670. * @returns The extension selected.
  34671. */
  34672. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  34673. /**
  34674. * Set the compressed texture extensions or file names to skip.
  34675. *
  34676. * @param skippedFiles defines the list of those texture files you want to skip
  34677. * Example: [".dds", ".env", "myfile.png"]
  34678. */
  34679. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  34680. /**
  34681. * Force a specific size of the canvas
  34682. * @param width defines the new canvas' width
  34683. * @param height defines the new canvas' height
  34684. */
  34685. setSize(width: number, height: number): void;
  34686. /**
  34687. * Updates a dynamic vertex buffer.
  34688. * @param vertexBuffer the vertex buffer to update
  34689. * @param data the data used to update the vertex buffer
  34690. * @param byteOffset the byte offset of the data
  34691. * @param byteLength the byte length of the data
  34692. */
  34693. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34694. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34695. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34696. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34697. _releaseTexture(texture: InternalTexture): void;
  34698. /**
  34699. * @hidden
  34700. * Rescales a texture
  34701. * @param source input texutre
  34702. * @param destination destination texture
  34703. * @param scene scene to use to render the resize
  34704. * @param internalFormat format to use when resizing
  34705. * @param onComplete callback to be called when resize has completed
  34706. */
  34707. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34708. /**
  34709. * Gets the current framerate
  34710. * @returns a number representing the framerate
  34711. */
  34712. getFps(): number;
  34713. /**
  34714. * Gets the time spent between current and previous frame
  34715. * @returns a number representing the delta time in ms
  34716. */
  34717. getDeltaTime(): number;
  34718. private _measureFps;
  34719. /** @hidden */
  34720. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34721. /**
  34722. * Update a dynamic index buffer
  34723. * @param indexBuffer defines the target index buffer
  34724. * @param indices defines the data to update
  34725. * @param offset defines the offset in the target index buffer where update should start
  34726. */
  34727. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34728. /**
  34729. * Updates the sample count of a render target texture
  34730. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34731. * @param texture defines the texture to update
  34732. * @param samples defines the sample count to set
  34733. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34734. */
  34735. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34736. /**
  34737. * Updates a depth texture Comparison Mode and Function.
  34738. * If the comparison Function is equal to 0, the mode will be set to none.
  34739. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34740. * @param texture The texture to set the comparison function for
  34741. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34742. */
  34743. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34744. /**
  34745. * Creates a webGL buffer to use with instanciation
  34746. * @param capacity defines the size of the buffer
  34747. * @returns the webGL buffer
  34748. */
  34749. createInstancesBuffer(capacity: number): DataBuffer;
  34750. /**
  34751. * Delete a webGL buffer used with instanciation
  34752. * @param buffer defines the webGL buffer to delete
  34753. */
  34754. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34755. /** @hidden */
  34756. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34757. dispose(): void;
  34758. private _disableTouchAction;
  34759. /**
  34760. * Display the loading screen
  34761. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34762. */
  34763. displayLoadingUI(): void;
  34764. /**
  34765. * Hide the loading screen
  34766. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34767. */
  34768. hideLoadingUI(): void;
  34769. /**
  34770. * Gets the current loading screen object
  34771. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34772. */
  34773. get loadingScreen(): ILoadingScreen;
  34774. /**
  34775. * Sets the current loading screen object
  34776. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34777. */
  34778. set loadingScreen(loadingScreen: ILoadingScreen);
  34779. /**
  34780. * Sets the current loading screen text
  34781. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34782. */
  34783. set loadingUIText(text: string);
  34784. /**
  34785. * Sets the current loading screen background color
  34786. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34787. */
  34788. set loadingUIBackgroundColor(color: string);
  34789. /** Pointerlock and fullscreen */
  34790. /**
  34791. * Ask the browser to promote the current element to pointerlock mode
  34792. * @param element defines the DOM element to promote
  34793. */
  34794. static _RequestPointerlock(element: HTMLElement): void;
  34795. /**
  34796. * Asks the browser to exit pointerlock mode
  34797. */
  34798. static _ExitPointerlock(): void;
  34799. /**
  34800. * Ask the browser to promote the current element to fullscreen rendering mode
  34801. * @param element defines the DOM element to promote
  34802. */
  34803. static _RequestFullscreen(element: HTMLElement): void;
  34804. /**
  34805. * Asks the browser to exit fullscreen mode
  34806. */
  34807. static _ExitFullscreen(): void;
  34808. }
  34809. }
  34810. declare module "babylonjs/Engines/engineStore" {
  34811. import { Nullable } from "babylonjs/types";
  34812. import { Engine } from "babylonjs/Engines/engine";
  34813. import { Scene } from "babylonjs/scene";
  34814. /**
  34815. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34816. * during the life time of the application.
  34817. */
  34818. export class EngineStore {
  34819. /** Gets the list of created engines */
  34820. static Instances: import("babylonjs/Engines/engine").Engine[];
  34821. /** @hidden */
  34822. static _LastCreatedScene: Nullable<Scene>;
  34823. /**
  34824. * Gets the latest created engine
  34825. */
  34826. static get LastCreatedEngine(): Nullable<Engine>;
  34827. /**
  34828. * Gets the latest created scene
  34829. */
  34830. static get LastCreatedScene(): Nullable<Scene>;
  34831. /**
  34832. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34833. * @ignorenaming
  34834. */
  34835. static UseFallbackTexture: boolean;
  34836. /**
  34837. * Texture content used if a texture cannot loaded
  34838. * @ignorenaming
  34839. */
  34840. static FallbackTexture: string;
  34841. }
  34842. }
  34843. declare module "babylonjs/Misc/promise" {
  34844. /**
  34845. * Helper class that provides a small promise polyfill
  34846. */
  34847. export class PromisePolyfill {
  34848. /**
  34849. * Static function used to check if the polyfill is required
  34850. * If this is the case then the function will inject the polyfill to window.Promise
  34851. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34852. */
  34853. static Apply(force?: boolean): void;
  34854. }
  34855. }
  34856. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34857. /**
  34858. * Interface for screenshot methods with describe argument called `size` as object with options
  34859. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34860. */
  34861. export interface IScreenshotSize {
  34862. /**
  34863. * number in pixels for canvas height
  34864. */
  34865. height?: number;
  34866. /**
  34867. * multiplier allowing render at a higher or lower resolution
  34868. * If value is defined then height and width will be ignored and taken from camera
  34869. */
  34870. precision?: number;
  34871. /**
  34872. * number in pixels for canvas width
  34873. */
  34874. width?: number;
  34875. }
  34876. }
  34877. declare module "babylonjs/Misc/tools" {
  34878. import { Nullable, float } from "babylonjs/types";
  34879. import { DomManagement } from "babylonjs/Misc/domManagement";
  34880. import { WebRequest } from "babylonjs/Misc/webRequest";
  34881. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34882. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34883. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34884. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34885. import { Camera } from "babylonjs/Cameras/camera";
  34886. import { Engine } from "babylonjs/Engines/engine";
  34887. interface IColor4Like {
  34888. r: float;
  34889. g: float;
  34890. b: float;
  34891. a: float;
  34892. }
  34893. /**
  34894. * Class containing a set of static utilities functions
  34895. */
  34896. export class Tools {
  34897. /**
  34898. * Gets or sets the base URL to use to load assets
  34899. */
  34900. static get BaseUrl(): string;
  34901. static set BaseUrl(value: string);
  34902. /**
  34903. * Enable/Disable Custom HTTP Request Headers globally.
  34904. * default = false
  34905. * @see CustomRequestHeaders
  34906. */
  34907. static UseCustomRequestHeaders: boolean;
  34908. /**
  34909. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34910. * i.e. when loading files, where the server/service expects an Authorization header
  34911. */
  34912. static CustomRequestHeaders: {
  34913. [key: string]: string;
  34914. };
  34915. /**
  34916. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34917. */
  34918. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34919. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34920. /**
  34921. * Default behaviour for cors in the application.
  34922. * It can be a string if the expected behavior is identical in the entire app.
  34923. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34924. */
  34925. static CorsBehavior: string | ((url: string | string[]) => string);
  34926. /**
  34927. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34928. * @ignorenaming
  34929. */
  34930. static get UseFallbackTexture(): boolean;
  34931. static set UseFallbackTexture(value: boolean);
  34932. /**
  34933. * Use this object to register external classes like custom textures or material
  34934. * to allow the laoders to instantiate them
  34935. */
  34936. static get RegisteredExternalClasses(): {
  34937. [key: string]: Object;
  34938. };
  34939. static set RegisteredExternalClasses(classes: {
  34940. [key: string]: Object;
  34941. });
  34942. /**
  34943. * Texture content used if a texture cannot loaded
  34944. * @ignorenaming
  34945. */
  34946. static get fallbackTexture(): string;
  34947. static set fallbackTexture(value: string);
  34948. /**
  34949. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34950. * @param u defines the coordinate on X axis
  34951. * @param v defines the coordinate on Y axis
  34952. * @param width defines the width of the source data
  34953. * @param height defines the height of the source data
  34954. * @param pixels defines the source byte array
  34955. * @param color defines the output color
  34956. */
  34957. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34958. /**
  34959. * Interpolates between a and b via alpha
  34960. * @param a The lower value (returned when alpha = 0)
  34961. * @param b The upper value (returned when alpha = 1)
  34962. * @param alpha The interpolation-factor
  34963. * @return The mixed value
  34964. */
  34965. static Mix(a: number, b: number, alpha: number): number;
  34966. /**
  34967. * Tries to instantiate a new object from a given class name
  34968. * @param className defines the class name to instantiate
  34969. * @returns the new object or null if the system was not able to do the instantiation
  34970. */
  34971. static Instantiate(className: string): any;
  34972. /**
  34973. * Provides a slice function that will work even on IE
  34974. * @param data defines the array to slice
  34975. * @param start defines the start of the data (optional)
  34976. * @param end defines the end of the data (optional)
  34977. * @returns the new sliced array
  34978. */
  34979. static Slice<T>(data: T, start?: number, end?: number): T;
  34980. /**
  34981. * Polyfill for setImmediate
  34982. * @param action defines the action to execute after the current execution block
  34983. */
  34984. static SetImmediate(action: () => void): void;
  34985. /**
  34986. * Function indicating if a number is an exponent of 2
  34987. * @param value defines the value to test
  34988. * @returns true if the value is an exponent of 2
  34989. */
  34990. static IsExponentOfTwo(value: number): boolean;
  34991. private static _tmpFloatArray;
  34992. /**
  34993. * Returns the nearest 32-bit single precision float representation of a Number
  34994. * @param value A Number. If the parameter is of a different type, it will get converted
  34995. * to a number or to NaN if it cannot be converted
  34996. * @returns number
  34997. */
  34998. static FloatRound(value: number): number;
  34999. /**
  35000. * Extracts the filename from a path
  35001. * @param path defines the path to use
  35002. * @returns the filename
  35003. */
  35004. static GetFilename(path: string): string;
  35005. /**
  35006. * Extracts the "folder" part of a path (everything before the filename).
  35007. * @param uri The URI to extract the info from
  35008. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35009. * @returns The "folder" part of the path
  35010. */
  35011. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35012. /**
  35013. * Extracts text content from a DOM element hierarchy
  35014. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35015. */
  35016. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35017. /**
  35018. * Convert an angle in radians to degrees
  35019. * @param angle defines the angle to convert
  35020. * @returns the angle in degrees
  35021. */
  35022. static ToDegrees(angle: number): number;
  35023. /**
  35024. * Convert an angle in degrees to radians
  35025. * @param angle defines the angle to convert
  35026. * @returns the angle in radians
  35027. */
  35028. static ToRadians(angle: number): number;
  35029. /**
  35030. * Returns an array if obj is not an array
  35031. * @param obj defines the object to evaluate as an array
  35032. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35033. * @returns either obj directly if obj is an array or a new array containing obj
  35034. */
  35035. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35036. /**
  35037. * Gets the pointer prefix to use
  35038. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35039. */
  35040. static GetPointerPrefix(): string;
  35041. /**
  35042. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35043. * @param url define the url we are trying
  35044. * @param element define the dom element where to configure the cors policy
  35045. */
  35046. static SetCorsBehavior(url: string | string[], element: {
  35047. crossOrigin: string | null;
  35048. }): void;
  35049. /**
  35050. * Removes unwanted characters from an url
  35051. * @param url defines the url to clean
  35052. * @returns the cleaned url
  35053. */
  35054. static CleanUrl(url: string): string;
  35055. /**
  35056. * Gets or sets a function used to pre-process url before using them to load assets
  35057. */
  35058. static get PreprocessUrl(): (url: string) => string;
  35059. static set PreprocessUrl(processor: (url: string) => string);
  35060. /**
  35061. * Loads an image as an HTMLImageElement.
  35062. * @param input url string, ArrayBuffer, or Blob to load
  35063. * @param onLoad callback called when the image successfully loads
  35064. * @param onError callback called when the image fails to load
  35065. * @param offlineProvider offline provider for caching
  35066. * @param mimeType optional mime type
  35067. * @returns the HTMLImageElement of the loaded image
  35068. */
  35069. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35070. /**
  35071. * Loads a file from a url
  35072. * @param url url string, ArrayBuffer, or Blob to load
  35073. * @param onSuccess callback called when the file successfully loads
  35074. * @param onProgress callback called while file is loading (if the server supports this mode)
  35075. * @param offlineProvider defines the offline provider for caching
  35076. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35077. * @param onError callback called when the file fails to load
  35078. * @returns a file request object
  35079. */
  35080. 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;
  35081. /**
  35082. * Loads a file from a url
  35083. * @param url the file url to load
  35084. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35085. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35086. */
  35087. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35088. /**
  35089. * Load a script (identified by an url). When the url returns, the
  35090. * content of this file is added into a new script element, attached to the DOM (body element)
  35091. * @param scriptUrl defines the url of the script to laod
  35092. * @param onSuccess defines the callback called when the script is loaded
  35093. * @param onError defines the callback to call if an error occurs
  35094. * @param scriptId defines the id of the script element
  35095. */
  35096. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35097. /**
  35098. * Load an asynchronous script (identified by an url). When the url returns, the
  35099. * content of this file is added into a new script element, attached to the DOM (body element)
  35100. * @param scriptUrl defines the url of the script to laod
  35101. * @param scriptId defines the id of the script element
  35102. * @returns a promise request object
  35103. */
  35104. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35105. /**
  35106. * Loads a file from a blob
  35107. * @param fileToLoad defines the blob to use
  35108. * @param callback defines the callback to call when data is loaded
  35109. * @param progressCallback defines the callback to call during loading process
  35110. * @returns a file request object
  35111. */
  35112. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35113. /**
  35114. * Reads a file from a File object
  35115. * @param file defines the file to load
  35116. * @param onSuccess defines the callback to call when data is loaded
  35117. * @param onProgress defines the callback to call during loading process
  35118. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35119. * @param onError defines the callback to call when an error occurs
  35120. * @returns a file request object
  35121. */
  35122. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35123. /**
  35124. * Creates a data url from a given string content
  35125. * @param content defines the content to convert
  35126. * @returns the new data url link
  35127. */
  35128. static FileAsURL(content: string): string;
  35129. /**
  35130. * Format the given number to a specific decimal format
  35131. * @param value defines the number to format
  35132. * @param decimals defines the number of decimals to use
  35133. * @returns the formatted string
  35134. */
  35135. static Format(value: number, decimals?: number): string;
  35136. /**
  35137. * Tries to copy an object by duplicating every property
  35138. * @param source defines the source object
  35139. * @param destination defines the target object
  35140. * @param doNotCopyList defines a list of properties to avoid
  35141. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35142. */
  35143. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35144. /**
  35145. * Gets a boolean indicating if the given object has no own property
  35146. * @param obj defines the object to test
  35147. * @returns true if object has no own property
  35148. */
  35149. static IsEmpty(obj: any): boolean;
  35150. /**
  35151. * Function used to register events at window level
  35152. * @param windowElement defines the Window object to use
  35153. * @param events defines the events to register
  35154. */
  35155. static RegisterTopRootEvents(windowElement: Window, events: {
  35156. name: string;
  35157. handler: Nullable<(e: FocusEvent) => any>;
  35158. }[]): void;
  35159. /**
  35160. * Function used to unregister events from window level
  35161. * @param windowElement defines the Window object to use
  35162. * @param events defines the events to unregister
  35163. */
  35164. static UnregisterTopRootEvents(windowElement: Window, events: {
  35165. name: string;
  35166. handler: Nullable<(e: FocusEvent) => any>;
  35167. }[]): void;
  35168. /**
  35169. * @ignore
  35170. */
  35171. static _ScreenshotCanvas: HTMLCanvasElement;
  35172. /**
  35173. * Dumps the current bound framebuffer
  35174. * @param width defines the rendering width
  35175. * @param height defines the rendering height
  35176. * @param engine defines the hosting engine
  35177. * @param successCallback defines the callback triggered once the data are available
  35178. * @param mimeType defines the mime type of the result
  35179. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35180. */
  35181. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35182. /**
  35183. * Converts the canvas data to blob.
  35184. * This acts as a polyfill for browsers not supporting the to blob function.
  35185. * @param canvas Defines the canvas to extract the data from
  35186. * @param successCallback Defines the callback triggered once the data are available
  35187. * @param mimeType Defines the mime type of the result
  35188. */
  35189. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35190. /**
  35191. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35192. * @param successCallback defines the callback triggered once the data are available
  35193. * @param mimeType defines the mime type of the result
  35194. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35195. */
  35196. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35197. /**
  35198. * Downloads a blob in the browser
  35199. * @param blob defines the blob to download
  35200. * @param fileName defines the name of the downloaded file
  35201. */
  35202. static Download(blob: Blob, fileName: string): void;
  35203. /**
  35204. * Captures a screenshot of the current rendering
  35205. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35206. * @param engine defines the rendering engine
  35207. * @param camera defines the source camera
  35208. * @param size This parameter can be set to a single number or to an object with the
  35209. * following (optional) properties: precision, width, height. If a single number is passed,
  35210. * it will be used for both width and height. If an object is passed, the screenshot size
  35211. * will be derived from the parameters. The precision property is a multiplier allowing
  35212. * rendering at a higher or lower resolution
  35213. * @param successCallback defines the callback receives a single parameter which contains the
  35214. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35215. * src parameter of an <img> to display it
  35216. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35217. * Check your browser for supported MIME types
  35218. */
  35219. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35220. /**
  35221. * Captures a screenshot of the current rendering
  35222. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35223. * @param engine defines the rendering engine
  35224. * @param camera defines the source camera
  35225. * @param size This parameter can be set to a single number or to an object with the
  35226. * following (optional) properties: precision, width, height. If a single number is passed,
  35227. * it will be used for both width and height. If an object is passed, the screenshot size
  35228. * will be derived from the parameters. The precision property is a multiplier allowing
  35229. * rendering at a higher or lower resolution
  35230. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35231. * Check your browser for supported MIME types
  35232. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35233. * to the src parameter of an <img> to display it
  35234. */
  35235. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35236. /**
  35237. * Generates an image screenshot from the specified camera.
  35238. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35239. * @param engine The engine to use for rendering
  35240. * @param camera The camera to use for rendering
  35241. * @param size This parameter can be set to a single number or to an object with the
  35242. * following (optional) properties: precision, width, height. If a single number is passed,
  35243. * it will be used for both width and height. If an object is passed, the screenshot size
  35244. * will be derived from the parameters. The precision property is a multiplier allowing
  35245. * rendering at a higher or lower resolution
  35246. * @param successCallback The callback receives a single parameter which contains the
  35247. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35248. * src parameter of an <img> to display it
  35249. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35250. * Check your browser for supported MIME types
  35251. * @param samples Texture samples (default: 1)
  35252. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35253. * @param fileName A name for for the downloaded file.
  35254. */
  35255. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35256. /**
  35257. * Generates an image screenshot from the specified camera.
  35258. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35259. * @param engine The engine to use for rendering
  35260. * @param camera The camera to use for rendering
  35261. * @param size This parameter can be set to a single number or to an object with the
  35262. * following (optional) properties: precision, width, height. If a single number is passed,
  35263. * it will be used for both width and height. If an object is passed, the screenshot size
  35264. * will be derived from the parameters. The precision property is a multiplier allowing
  35265. * rendering at a higher or lower resolution
  35266. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35267. * Check your browser for supported MIME types
  35268. * @param samples Texture samples (default: 1)
  35269. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35270. * @param fileName A name for for the downloaded file.
  35271. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35272. * to the src parameter of an <img> to display it
  35273. */
  35274. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35275. /**
  35276. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35277. * Be aware Math.random() could cause collisions, but:
  35278. * "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"
  35279. * @returns a pseudo random id
  35280. */
  35281. static RandomId(): string;
  35282. /**
  35283. * Test if the given uri is a base64 string
  35284. * @param uri The uri to test
  35285. * @return True if the uri is a base64 string or false otherwise
  35286. */
  35287. static IsBase64(uri: string): boolean;
  35288. /**
  35289. * Decode the given base64 uri.
  35290. * @param uri The uri to decode
  35291. * @return The decoded base64 data.
  35292. */
  35293. static DecodeBase64(uri: string): ArrayBuffer;
  35294. /**
  35295. * Gets the absolute url.
  35296. * @param url the input url
  35297. * @return the absolute url
  35298. */
  35299. static GetAbsoluteUrl(url: string): string;
  35300. /**
  35301. * No log
  35302. */
  35303. static readonly NoneLogLevel: number;
  35304. /**
  35305. * Only message logs
  35306. */
  35307. static readonly MessageLogLevel: number;
  35308. /**
  35309. * Only warning logs
  35310. */
  35311. static readonly WarningLogLevel: number;
  35312. /**
  35313. * Only error logs
  35314. */
  35315. static readonly ErrorLogLevel: number;
  35316. /**
  35317. * All logs
  35318. */
  35319. static readonly AllLogLevel: number;
  35320. /**
  35321. * Gets a value indicating the number of loading errors
  35322. * @ignorenaming
  35323. */
  35324. static get errorsCount(): number;
  35325. /**
  35326. * Callback called when a new log is added
  35327. */
  35328. static OnNewCacheEntry: (entry: string) => void;
  35329. /**
  35330. * Log a message to the console
  35331. * @param message defines the message to log
  35332. */
  35333. static Log(message: string): void;
  35334. /**
  35335. * Write a warning message to the console
  35336. * @param message defines the message to log
  35337. */
  35338. static Warn(message: string): void;
  35339. /**
  35340. * Write an error message to the console
  35341. * @param message defines the message to log
  35342. */
  35343. static Error(message: string): void;
  35344. /**
  35345. * Gets current log cache (list of logs)
  35346. */
  35347. static get LogCache(): string;
  35348. /**
  35349. * Clears the log cache
  35350. */
  35351. static ClearLogCache(): void;
  35352. /**
  35353. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35354. */
  35355. static set LogLevels(level: number);
  35356. /**
  35357. * Checks if the window object exists
  35358. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35359. */
  35360. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35361. /**
  35362. * No performance log
  35363. */
  35364. static readonly PerformanceNoneLogLevel: number;
  35365. /**
  35366. * Use user marks to log performance
  35367. */
  35368. static readonly PerformanceUserMarkLogLevel: number;
  35369. /**
  35370. * Log performance to the console
  35371. */
  35372. static readonly PerformanceConsoleLogLevel: number;
  35373. private static _performance;
  35374. /**
  35375. * Sets the current performance log level
  35376. */
  35377. static set PerformanceLogLevel(level: number);
  35378. private static _StartPerformanceCounterDisabled;
  35379. private static _EndPerformanceCounterDisabled;
  35380. private static _StartUserMark;
  35381. private static _EndUserMark;
  35382. private static _StartPerformanceConsole;
  35383. private static _EndPerformanceConsole;
  35384. /**
  35385. * Starts a performance counter
  35386. */
  35387. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35388. /**
  35389. * Ends a specific performance coutner
  35390. */
  35391. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35392. /**
  35393. * Gets either window.performance.now() if supported or Date.now() else
  35394. */
  35395. static get Now(): number;
  35396. /**
  35397. * This method will return the name of the class used to create the instance of the given object.
  35398. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35399. * @param object the object to get the class name from
  35400. * @param isType defines if the object is actually a type
  35401. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35402. */
  35403. static GetClassName(object: any, isType?: boolean): string;
  35404. /**
  35405. * Gets the first element of an array satisfying a given predicate
  35406. * @param array defines the array to browse
  35407. * @param predicate defines the predicate to use
  35408. * @returns null if not found or the element
  35409. */
  35410. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35411. /**
  35412. * This method will return the name of the full name of the class, including its owning module (if any).
  35413. * 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).
  35414. * @param object the object to get the class name from
  35415. * @param isType defines if the object is actually a type
  35416. * @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.
  35417. * @ignorenaming
  35418. */
  35419. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35420. /**
  35421. * Returns a promise that resolves after the given amount of time.
  35422. * @param delay Number of milliseconds to delay
  35423. * @returns Promise that resolves after the given amount of time
  35424. */
  35425. static DelayAsync(delay: number): Promise<void>;
  35426. /**
  35427. * Utility function to detect if the current user agent is Safari
  35428. * @returns whether or not the current user agent is safari
  35429. */
  35430. static IsSafari(): boolean;
  35431. }
  35432. /**
  35433. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35434. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35435. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35436. * @param name The name of the class, case should be preserved
  35437. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35438. */
  35439. export function className(name: string, module?: string): (target: Object) => void;
  35440. /**
  35441. * An implementation of a loop for asynchronous functions.
  35442. */
  35443. export class AsyncLoop {
  35444. /**
  35445. * Defines the number of iterations for the loop
  35446. */
  35447. iterations: number;
  35448. /**
  35449. * Defines the current index of the loop.
  35450. */
  35451. index: number;
  35452. private _done;
  35453. private _fn;
  35454. private _successCallback;
  35455. /**
  35456. * Constructor.
  35457. * @param iterations the number of iterations.
  35458. * @param func the function to run each iteration
  35459. * @param successCallback the callback that will be called upon succesful execution
  35460. * @param offset starting offset.
  35461. */
  35462. constructor(
  35463. /**
  35464. * Defines the number of iterations for the loop
  35465. */
  35466. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35467. /**
  35468. * Execute the next iteration. Must be called after the last iteration was finished.
  35469. */
  35470. executeNext(): void;
  35471. /**
  35472. * Break the loop and run the success callback.
  35473. */
  35474. breakLoop(): void;
  35475. /**
  35476. * Create and run an async loop.
  35477. * @param iterations the number of iterations.
  35478. * @param fn the function to run each iteration
  35479. * @param successCallback the callback that will be called upon succesful execution
  35480. * @param offset starting offset.
  35481. * @returns the created async loop object
  35482. */
  35483. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35484. /**
  35485. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35486. * @param iterations total number of iterations
  35487. * @param syncedIterations number of synchronous iterations in each async iteration.
  35488. * @param fn the function to call each iteration.
  35489. * @param callback a success call back that will be called when iterating stops.
  35490. * @param breakFunction a break condition (optional)
  35491. * @param timeout timeout settings for the setTimeout function. default - 0.
  35492. * @returns the created async loop object
  35493. */
  35494. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35495. }
  35496. }
  35497. declare module "babylonjs/Misc/stringDictionary" {
  35498. import { Nullable } from "babylonjs/types";
  35499. /**
  35500. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35501. * The underlying implementation relies on an associative array to ensure the best performances.
  35502. * The value can be anything including 'null' but except 'undefined'
  35503. */
  35504. export class StringDictionary<T> {
  35505. /**
  35506. * This will clear this dictionary and copy the content from the 'source' one.
  35507. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35508. * @param source the dictionary to take the content from and copy to this dictionary
  35509. */
  35510. copyFrom(source: StringDictionary<T>): void;
  35511. /**
  35512. * Get a value based from its key
  35513. * @param key the given key to get the matching value from
  35514. * @return the value if found, otherwise undefined is returned
  35515. */
  35516. get(key: string): T | undefined;
  35517. /**
  35518. * Get a value from its key or add it if it doesn't exist.
  35519. * This method will ensure you that a given key/data will be present in the dictionary.
  35520. * @param key the given key to get the matching value from
  35521. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35522. * The factory will only be invoked if there's no data for the given key.
  35523. * @return the value corresponding to the key.
  35524. */
  35525. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35526. /**
  35527. * Get a value from its key if present in the dictionary otherwise add it
  35528. * @param key the key to get the value from
  35529. * @param val if there's no such key/value pair in the dictionary add it with this value
  35530. * @return the value corresponding to the key
  35531. */
  35532. getOrAdd(key: string, val: T): T;
  35533. /**
  35534. * Check if there's a given key in the dictionary
  35535. * @param key the key to check for
  35536. * @return true if the key is present, false otherwise
  35537. */
  35538. contains(key: string): boolean;
  35539. /**
  35540. * Add a new key and its corresponding value
  35541. * @param key the key to add
  35542. * @param value the value corresponding to the key
  35543. * @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
  35544. */
  35545. add(key: string, value: T): boolean;
  35546. /**
  35547. * Update a specific value associated to a key
  35548. * @param key defines the key to use
  35549. * @param value defines the value to store
  35550. * @returns true if the value was updated (or false if the key was not found)
  35551. */
  35552. set(key: string, value: T): boolean;
  35553. /**
  35554. * Get the element of the given key and remove it from the dictionary
  35555. * @param key defines the key to search
  35556. * @returns the value associated with the key or null if not found
  35557. */
  35558. getAndRemove(key: string): Nullable<T>;
  35559. /**
  35560. * Remove a key/value from the dictionary.
  35561. * @param key the key to remove
  35562. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35563. */
  35564. remove(key: string): boolean;
  35565. /**
  35566. * Clear the whole content of the dictionary
  35567. */
  35568. clear(): void;
  35569. /**
  35570. * Gets the current count
  35571. */
  35572. get count(): number;
  35573. /**
  35574. * Execute a callback on each key/val of the dictionary.
  35575. * Note that you can remove any element in this dictionary in the callback implementation
  35576. * @param callback the callback to execute on a given key/value pair
  35577. */
  35578. forEach(callback: (key: string, val: T) => void): void;
  35579. /**
  35580. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35581. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35582. * Note that you can remove any element in this dictionary in the callback implementation
  35583. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35584. * @returns the first item
  35585. */
  35586. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35587. private _count;
  35588. private _data;
  35589. }
  35590. }
  35591. declare module "babylonjs/Collisions/collisionCoordinator" {
  35592. import { Nullable } from "babylonjs/types";
  35593. import { Scene } from "babylonjs/scene";
  35594. import { Vector3 } from "babylonjs/Maths/math.vector";
  35595. import { Collider } from "babylonjs/Collisions/collider";
  35596. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35597. /** @hidden */
  35598. export interface ICollisionCoordinator {
  35599. createCollider(): Collider;
  35600. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35601. init(scene: Scene): void;
  35602. }
  35603. /** @hidden */
  35604. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35605. private _scene;
  35606. private _scaledPosition;
  35607. private _scaledVelocity;
  35608. private _finalPosition;
  35609. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35610. createCollider(): Collider;
  35611. init(scene: Scene): void;
  35612. private _collideWithWorld;
  35613. }
  35614. }
  35615. declare module "babylonjs/Inputs/scene.inputManager" {
  35616. import { Nullable } from "babylonjs/types";
  35617. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35618. import { Vector2 } from "babylonjs/Maths/math.vector";
  35619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35620. import { Scene } from "babylonjs/scene";
  35621. /**
  35622. * Class used to manage all inputs for the scene.
  35623. */
  35624. export class InputManager {
  35625. /** The distance in pixel that you have to move to prevent some events */
  35626. static DragMovementThreshold: number;
  35627. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35628. static LongPressDelay: number;
  35629. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35630. static DoubleClickDelay: number;
  35631. /** If you need to check double click without raising a single click at first click, enable this flag */
  35632. static ExclusiveDoubleClickMode: boolean;
  35633. private _wheelEventName;
  35634. private _onPointerMove;
  35635. private _onPointerDown;
  35636. private _onPointerUp;
  35637. private _initClickEvent;
  35638. private _initActionManager;
  35639. private _delayedSimpleClick;
  35640. private _delayedSimpleClickTimeout;
  35641. private _previousDelayedSimpleClickTimeout;
  35642. private _meshPickProceed;
  35643. private _previousButtonPressed;
  35644. private _currentPickResult;
  35645. private _previousPickResult;
  35646. private _totalPointersPressed;
  35647. private _doubleClickOccured;
  35648. private _pointerOverMesh;
  35649. private _pickedDownMesh;
  35650. private _pickedUpMesh;
  35651. private _pointerX;
  35652. private _pointerY;
  35653. private _unTranslatedPointerX;
  35654. private _unTranslatedPointerY;
  35655. private _startingPointerPosition;
  35656. private _previousStartingPointerPosition;
  35657. private _startingPointerTime;
  35658. private _previousStartingPointerTime;
  35659. private _pointerCaptures;
  35660. private _onKeyDown;
  35661. private _onKeyUp;
  35662. private _onCanvasFocusObserver;
  35663. private _onCanvasBlurObserver;
  35664. private _scene;
  35665. /**
  35666. * Creates a new InputManager
  35667. * @param scene defines the hosting scene
  35668. */
  35669. constructor(scene: Scene);
  35670. /**
  35671. * Gets the mesh that is currently under the pointer
  35672. */
  35673. get meshUnderPointer(): Nullable<AbstractMesh>;
  35674. /**
  35675. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35676. */
  35677. get unTranslatedPointer(): Vector2;
  35678. /**
  35679. * Gets or sets the current on-screen X position of the pointer
  35680. */
  35681. get pointerX(): number;
  35682. set pointerX(value: number);
  35683. /**
  35684. * Gets or sets the current on-screen Y position of the pointer
  35685. */
  35686. get pointerY(): number;
  35687. set pointerY(value: number);
  35688. private _updatePointerPosition;
  35689. private _processPointerMove;
  35690. private _setRayOnPointerInfo;
  35691. private _checkPrePointerObservable;
  35692. /**
  35693. * Use this method to simulate a pointer move on a mesh
  35694. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35695. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35696. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35697. */
  35698. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35699. /**
  35700. * Use this method to simulate a pointer down on a mesh
  35701. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35702. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35703. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35704. */
  35705. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35706. private _processPointerDown;
  35707. /** @hidden */
  35708. _isPointerSwiping(): boolean;
  35709. /**
  35710. * Use this method to simulate a pointer up on a mesh
  35711. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35712. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35713. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35714. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35715. */
  35716. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35717. private _processPointerUp;
  35718. /**
  35719. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35720. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35721. * @returns true if the pointer was captured
  35722. */
  35723. isPointerCaptured(pointerId?: number): boolean;
  35724. /**
  35725. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35726. * @param attachUp defines if you want to attach events to pointerup
  35727. * @param attachDown defines if you want to attach events to pointerdown
  35728. * @param attachMove defines if you want to attach events to pointermove
  35729. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35730. */
  35731. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35732. /**
  35733. * Detaches all event handlers
  35734. */
  35735. detachControl(): void;
  35736. /**
  35737. * Force the value of meshUnderPointer
  35738. * @param mesh defines the mesh to use
  35739. */
  35740. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35741. /**
  35742. * Gets the mesh under the pointer
  35743. * @returns a Mesh or null if no mesh is under the pointer
  35744. */
  35745. getPointerOverMesh(): Nullable<AbstractMesh>;
  35746. }
  35747. }
  35748. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35749. /**
  35750. * Helper class used to generate session unique ID
  35751. */
  35752. export class UniqueIdGenerator {
  35753. private static _UniqueIdCounter;
  35754. /**
  35755. * Gets an unique (relatively to the current scene) Id
  35756. */
  35757. static get UniqueId(): number;
  35758. }
  35759. }
  35760. declare module "babylonjs/Animations/animationGroup" {
  35761. import { Animatable } from "babylonjs/Animations/animatable";
  35762. import { Animation } from "babylonjs/Animations/animation";
  35763. import { Scene, IDisposable } from "babylonjs/scene";
  35764. import { Observable } from "babylonjs/Misc/observable";
  35765. import { Nullable } from "babylonjs/types";
  35766. import "babylonjs/Animations/animatable";
  35767. /**
  35768. * This class defines the direct association between an animation and a target
  35769. */
  35770. export class TargetedAnimation {
  35771. /**
  35772. * Animation to perform
  35773. */
  35774. animation: Animation;
  35775. /**
  35776. * Target to animate
  35777. */
  35778. target: any;
  35779. /**
  35780. * Serialize the object
  35781. * @returns the JSON object representing the current entity
  35782. */
  35783. serialize(): any;
  35784. }
  35785. /**
  35786. * Use this class to create coordinated animations on multiple targets
  35787. */
  35788. export class AnimationGroup implements IDisposable {
  35789. /** The name of the animation group */
  35790. name: string;
  35791. private _scene;
  35792. private _targetedAnimations;
  35793. private _animatables;
  35794. private _from;
  35795. private _to;
  35796. private _isStarted;
  35797. private _isPaused;
  35798. private _speedRatio;
  35799. private _loopAnimation;
  35800. /**
  35801. * Gets or sets the unique id of the node
  35802. */
  35803. uniqueId: number;
  35804. /**
  35805. * This observable will notify when one animation have ended
  35806. */
  35807. onAnimationEndObservable: Observable<TargetedAnimation>;
  35808. /**
  35809. * Observer raised when one animation loops
  35810. */
  35811. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35812. /**
  35813. * Observer raised when all animations have looped
  35814. */
  35815. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35816. /**
  35817. * This observable will notify when all animations have ended.
  35818. */
  35819. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35820. /**
  35821. * This observable will notify when all animations have paused.
  35822. */
  35823. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35824. /**
  35825. * This observable will notify when all animations are playing.
  35826. */
  35827. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35828. /**
  35829. * Gets the first frame
  35830. */
  35831. get from(): number;
  35832. /**
  35833. * Gets the last frame
  35834. */
  35835. get to(): number;
  35836. /**
  35837. * Define if the animations are started
  35838. */
  35839. get isStarted(): boolean;
  35840. /**
  35841. * Gets a value indicating that the current group is playing
  35842. */
  35843. get isPlaying(): boolean;
  35844. /**
  35845. * Gets or sets the speed ratio to use for all animations
  35846. */
  35847. get speedRatio(): number;
  35848. /**
  35849. * Gets or sets the speed ratio to use for all animations
  35850. */
  35851. set speedRatio(value: number);
  35852. /**
  35853. * Gets or sets if all animations should loop or not
  35854. */
  35855. get loopAnimation(): boolean;
  35856. set loopAnimation(value: boolean);
  35857. /**
  35858. * Gets the targeted animations for this animation group
  35859. */
  35860. get targetedAnimations(): Array<TargetedAnimation>;
  35861. /**
  35862. * returning the list of animatables controlled by this animation group.
  35863. */
  35864. get animatables(): Array<Animatable>;
  35865. /**
  35866. * Instantiates a new Animation Group.
  35867. * This helps managing several animations at once.
  35868. * @see http://doc.babylonjs.com/how_to/group
  35869. * @param name Defines the name of the group
  35870. * @param scene Defines the scene the group belongs to
  35871. */
  35872. constructor(
  35873. /** The name of the animation group */
  35874. name: string, scene?: Nullable<Scene>);
  35875. /**
  35876. * Add an animation (with its target) in the group
  35877. * @param animation defines the animation we want to add
  35878. * @param target defines the target of the animation
  35879. * @returns the TargetedAnimation object
  35880. */
  35881. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35882. /**
  35883. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35884. * It can add constant keys at begin or end
  35885. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35886. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35887. * @returns the animation group
  35888. */
  35889. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35890. private _animationLoopCount;
  35891. private _animationLoopFlags;
  35892. private _processLoop;
  35893. /**
  35894. * Start all animations on given targets
  35895. * @param loop defines if animations must loop
  35896. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35897. * @param from defines the from key (optional)
  35898. * @param to defines the to key (optional)
  35899. * @returns the current animation group
  35900. */
  35901. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35902. /**
  35903. * Pause all animations
  35904. * @returns the animation group
  35905. */
  35906. pause(): AnimationGroup;
  35907. /**
  35908. * Play all animations to initial state
  35909. * This function will start() the animations if they were not started or will restart() them if they were paused
  35910. * @param loop defines if animations must loop
  35911. * @returns the animation group
  35912. */
  35913. play(loop?: boolean): AnimationGroup;
  35914. /**
  35915. * Reset all animations to initial state
  35916. * @returns the animation group
  35917. */
  35918. reset(): AnimationGroup;
  35919. /**
  35920. * Restart animations from key 0
  35921. * @returns the animation group
  35922. */
  35923. restart(): AnimationGroup;
  35924. /**
  35925. * Stop all animations
  35926. * @returns the animation group
  35927. */
  35928. stop(): AnimationGroup;
  35929. /**
  35930. * Set animation weight for all animatables
  35931. * @param weight defines the weight to use
  35932. * @return the animationGroup
  35933. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35934. */
  35935. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35936. /**
  35937. * Synchronize and normalize all animatables with a source animatable
  35938. * @param root defines the root animatable to synchronize with
  35939. * @return the animationGroup
  35940. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35941. */
  35942. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35943. /**
  35944. * Goes to a specific frame in this animation group
  35945. * @param frame the frame number to go to
  35946. * @return the animationGroup
  35947. */
  35948. goToFrame(frame: number): AnimationGroup;
  35949. /**
  35950. * Dispose all associated resources
  35951. */
  35952. dispose(): void;
  35953. private _checkAnimationGroupEnded;
  35954. /**
  35955. * Clone the current animation group and returns a copy
  35956. * @param newName defines the name of the new group
  35957. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35958. * @returns the new aniamtion group
  35959. */
  35960. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35961. /**
  35962. * Serializes the animationGroup to an object
  35963. * @returns Serialized object
  35964. */
  35965. serialize(): any;
  35966. /**
  35967. * Returns a new AnimationGroup object parsed from the source provided.
  35968. * @param parsedAnimationGroup defines the source
  35969. * @param scene defines the scene that will receive the animationGroup
  35970. * @returns a new AnimationGroup
  35971. */
  35972. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35973. /**
  35974. * Returns the string "AnimationGroup"
  35975. * @returns "AnimationGroup"
  35976. */
  35977. getClassName(): string;
  35978. /**
  35979. * Creates a detailled string about the object
  35980. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35981. * @returns a string representing the object
  35982. */
  35983. toString(fullDetails?: boolean): string;
  35984. }
  35985. }
  35986. declare module "babylonjs/scene" {
  35987. import { Nullable } from "babylonjs/types";
  35988. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35989. import { Observable } from "babylonjs/Misc/observable";
  35990. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  35991. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  35992. import { Geometry } from "babylonjs/Meshes/geometry";
  35993. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35994. import { SubMesh } from "babylonjs/Meshes/subMesh";
  35995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35996. import { Mesh } from "babylonjs/Meshes/mesh";
  35997. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35998. import { Bone } from "babylonjs/Bones/bone";
  35999. import { Skeleton } from "babylonjs/Bones/skeleton";
  36000. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36001. import { Camera } from "babylonjs/Cameras/camera";
  36002. import { AbstractScene } from "babylonjs/abstractScene";
  36003. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36004. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36005. import { Material } from "babylonjs/Materials/material";
  36006. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36007. import { Effect } from "babylonjs/Materials/effect";
  36008. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36009. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36010. import { Light } from "babylonjs/Lights/light";
  36011. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36012. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36013. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36014. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36015. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36016. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36017. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36018. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36019. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36020. import { Engine } from "babylonjs/Engines/engine";
  36021. import { Node } from "babylonjs/node";
  36022. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36023. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36024. import { WebRequest } from "babylonjs/Misc/webRequest";
  36025. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36026. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36027. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36028. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36029. import { Plane } from "babylonjs/Maths/math.plane";
  36030. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36031. import { Ray } from "babylonjs/Culling/ray";
  36032. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36033. import { Animation } from "babylonjs/Animations/animation";
  36034. import { Animatable } from "babylonjs/Animations/animatable";
  36035. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36036. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36037. import { Collider } from "babylonjs/Collisions/collider";
  36038. /**
  36039. * Define an interface for all classes that will hold resources
  36040. */
  36041. export interface IDisposable {
  36042. /**
  36043. * Releases all held resources
  36044. */
  36045. dispose(): void;
  36046. }
  36047. /** Interface defining initialization parameters for Scene class */
  36048. export interface SceneOptions {
  36049. /**
  36050. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36051. * It will improve performance when the number of geometries becomes important.
  36052. */
  36053. useGeometryUniqueIdsMap?: boolean;
  36054. /**
  36055. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36056. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36057. */
  36058. useMaterialMeshMap?: boolean;
  36059. /**
  36060. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36061. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36062. */
  36063. useClonedMeshMap?: boolean;
  36064. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36065. virtual?: boolean;
  36066. }
  36067. /**
  36068. * Represents a scene to be rendered by the engine.
  36069. * @see http://doc.babylonjs.com/features/scene
  36070. */
  36071. export class Scene extends AbstractScene implements IAnimatable {
  36072. /** The fog is deactivated */
  36073. static readonly FOGMODE_NONE: number;
  36074. /** The fog density is following an exponential function */
  36075. static readonly FOGMODE_EXP: number;
  36076. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36077. static readonly FOGMODE_EXP2: number;
  36078. /** The fog density is following a linear function. */
  36079. static readonly FOGMODE_LINEAR: number;
  36080. /**
  36081. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36082. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36083. */
  36084. static MinDeltaTime: number;
  36085. /**
  36086. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36087. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36088. */
  36089. static MaxDeltaTime: number;
  36090. /**
  36091. * Factory used to create the default material.
  36092. * @param name The name of the material to create
  36093. * @param scene The scene to create the material for
  36094. * @returns The default material
  36095. */
  36096. static DefaultMaterialFactory(scene: Scene): Material;
  36097. /**
  36098. * Factory used to create the a collision coordinator.
  36099. * @returns The collision coordinator
  36100. */
  36101. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36102. /** @hidden */
  36103. _inputManager: InputManager;
  36104. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36105. cameraToUseForPointers: Nullable<Camera>;
  36106. /** @hidden */
  36107. readonly _isScene: boolean;
  36108. /**
  36109. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36110. */
  36111. autoClear: boolean;
  36112. /**
  36113. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36114. */
  36115. autoClearDepthAndStencil: boolean;
  36116. /**
  36117. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36118. */
  36119. clearColor: Color4;
  36120. /**
  36121. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36122. */
  36123. ambientColor: Color3;
  36124. /**
  36125. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36126. * It should only be one of the following (if not the default embedded one):
  36127. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36128. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36129. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36130. * The material properties need to be setup according to the type of texture in use.
  36131. */
  36132. environmentBRDFTexture: BaseTexture;
  36133. /** @hidden */
  36134. protected _environmentTexture: Nullable<BaseTexture>;
  36135. /**
  36136. * Texture used in all pbr material as the reflection texture.
  36137. * As in the majority of the scene they are the same (exception for multi room and so on),
  36138. * this is easier to reference from here than from all the materials.
  36139. */
  36140. get environmentTexture(): Nullable<BaseTexture>;
  36141. /**
  36142. * Texture used in all pbr material as the reflection texture.
  36143. * As in the majority of the scene they are the same (exception for multi room and so on),
  36144. * this is easier to set here than in all the materials.
  36145. */
  36146. set environmentTexture(value: Nullable<BaseTexture>);
  36147. /** @hidden */
  36148. protected _environmentIntensity: number;
  36149. /**
  36150. * Intensity of the environment in all pbr material.
  36151. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36152. * As in the majority of the scene they are the same (exception for multi room and so on),
  36153. * this is easier to reference from here than from all the materials.
  36154. */
  36155. get environmentIntensity(): number;
  36156. /**
  36157. * Intensity of the environment in all pbr material.
  36158. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36159. * As in the majority of the scene they are the same (exception for multi room and so on),
  36160. * this is easier to set here than in all the materials.
  36161. */
  36162. set environmentIntensity(value: number);
  36163. /** @hidden */
  36164. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36165. /**
  36166. * Default image processing configuration used either in the rendering
  36167. * Forward main pass or through the imageProcessingPostProcess if present.
  36168. * As in the majority of the scene they are the same (exception for multi camera),
  36169. * this is easier to reference from here than from all the materials and post process.
  36170. *
  36171. * No setter as we it is a shared configuration, you can set the values instead.
  36172. */
  36173. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36174. private _forceWireframe;
  36175. /**
  36176. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36177. */
  36178. set forceWireframe(value: boolean);
  36179. get forceWireframe(): boolean;
  36180. private _skipFrustumClipping;
  36181. /**
  36182. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36183. */
  36184. set skipFrustumClipping(value: boolean);
  36185. get skipFrustumClipping(): boolean;
  36186. private _forcePointsCloud;
  36187. /**
  36188. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36189. */
  36190. set forcePointsCloud(value: boolean);
  36191. get forcePointsCloud(): boolean;
  36192. /**
  36193. * Gets or sets the active clipplane 1
  36194. */
  36195. clipPlane: Nullable<Plane>;
  36196. /**
  36197. * Gets or sets the active clipplane 2
  36198. */
  36199. clipPlane2: Nullable<Plane>;
  36200. /**
  36201. * Gets or sets the active clipplane 3
  36202. */
  36203. clipPlane3: Nullable<Plane>;
  36204. /**
  36205. * Gets or sets the active clipplane 4
  36206. */
  36207. clipPlane4: Nullable<Plane>;
  36208. /**
  36209. * Gets or sets the active clipplane 5
  36210. */
  36211. clipPlane5: Nullable<Plane>;
  36212. /**
  36213. * Gets or sets the active clipplane 6
  36214. */
  36215. clipPlane6: Nullable<Plane>;
  36216. /**
  36217. * Gets or sets a boolean indicating if animations are enabled
  36218. */
  36219. animationsEnabled: boolean;
  36220. private _animationPropertiesOverride;
  36221. /**
  36222. * Gets or sets the animation properties override
  36223. */
  36224. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36225. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36226. /**
  36227. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36228. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36229. */
  36230. useConstantAnimationDeltaTime: boolean;
  36231. /**
  36232. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36233. * Please note that it requires to run a ray cast through the scene on every frame
  36234. */
  36235. constantlyUpdateMeshUnderPointer: boolean;
  36236. /**
  36237. * Defines the HTML cursor to use when hovering over interactive elements
  36238. */
  36239. hoverCursor: string;
  36240. /**
  36241. * Defines the HTML default cursor to use (empty by default)
  36242. */
  36243. defaultCursor: string;
  36244. /**
  36245. * Defines whether cursors are handled by the scene.
  36246. */
  36247. doNotHandleCursors: boolean;
  36248. /**
  36249. * This is used to call preventDefault() on pointer down
  36250. * in order to block unwanted artifacts like system double clicks
  36251. */
  36252. preventDefaultOnPointerDown: boolean;
  36253. /**
  36254. * This is used to call preventDefault() on pointer up
  36255. * in order to block unwanted artifacts like system double clicks
  36256. */
  36257. preventDefaultOnPointerUp: boolean;
  36258. /**
  36259. * Gets or sets user defined metadata
  36260. */
  36261. metadata: any;
  36262. /**
  36263. * For internal use only. Please do not use.
  36264. */
  36265. reservedDataStore: any;
  36266. /**
  36267. * Gets the name of the plugin used to load this scene (null by default)
  36268. */
  36269. loadingPluginName: string;
  36270. /**
  36271. * Use this array to add regular expressions used to disable offline support for specific urls
  36272. */
  36273. disableOfflineSupportExceptionRules: RegExp[];
  36274. /**
  36275. * An event triggered when the scene is disposed.
  36276. */
  36277. onDisposeObservable: Observable<Scene>;
  36278. private _onDisposeObserver;
  36279. /** Sets a function to be executed when this scene is disposed. */
  36280. set onDispose(callback: () => void);
  36281. /**
  36282. * An event triggered before rendering the scene (right after animations and physics)
  36283. */
  36284. onBeforeRenderObservable: Observable<Scene>;
  36285. private _onBeforeRenderObserver;
  36286. /** Sets a function to be executed before rendering this scene */
  36287. set beforeRender(callback: Nullable<() => void>);
  36288. /**
  36289. * An event triggered after rendering the scene
  36290. */
  36291. onAfterRenderObservable: Observable<Scene>;
  36292. /**
  36293. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36294. */
  36295. onAfterRenderCameraObservable: Observable<Camera>;
  36296. private _onAfterRenderObserver;
  36297. /** Sets a function to be executed after rendering this scene */
  36298. set afterRender(callback: Nullable<() => void>);
  36299. /**
  36300. * An event triggered before animating the scene
  36301. */
  36302. onBeforeAnimationsObservable: Observable<Scene>;
  36303. /**
  36304. * An event triggered after animations processing
  36305. */
  36306. onAfterAnimationsObservable: Observable<Scene>;
  36307. /**
  36308. * An event triggered before draw calls are ready to be sent
  36309. */
  36310. onBeforeDrawPhaseObservable: Observable<Scene>;
  36311. /**
  36312. * An event triggered after draw calls have been sent
  36313. */
  36314. onAfterDrawPhaseObservable: Observable<Scene>;
  36315. /**
  36316. * An event triggered when the scene is ready
  36317. */
  36318. onReadyObservable: Observable<Scene>;
  36319. /**
  36320. * An event triggered before rendering a camera
  36321. */
  36322. onBeforeCameraRenderObservable: Observable<Camera>;
  36323. private _onBeforeCameraRenderObserver;
  36324. /** Sets a function to be executed before rendering a camera*/
  36325. set beforeCameraRender(callback: () => void);
  36326. /**
  36327. * An event triggered after rendering a camera
  36328. */
  36329. onAfterCameraRenderObservable: Observable<Camera>;
  36330. private _onAfterCameraRenderObserver;
  36331. /** Sets a function to be executed after rendering a camera*/
  36332. set afterCameraRender(callback: () => void);
  36333. /**
  36334. * An event triggered when active meshes evaluation is about to start
  36335. */
  36336. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36337. /**
  36338. * An event triggered when active meshes evaluation is done
  36339. */
  36340. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36341. /**
  36342. * An event triggered when particles rendering is about to start
  36343. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36344. */
  36345. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36346. /**
  36347. * An event triggered when particles rendering is done
  36348. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36349. */
  36350. onAfterParticlesRenderingObservable: Observable<Scene>;
  36351. /**
  36352. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36353. */
  36354. onDataLoadedObservable: Observable<Scene>;
  36355. /**
  36356. * An event triggered when a camera is created
  36357. */
  36358. onNewCameraAddedObservable: Observable<Camera>;
  36359. /**
  36360. * An event triggered when a camera is removed
  36361. */
  36362. onCameraRemovedObservable: Observable<Camera>;
  36363. /**
  36364. * An event triggered when a light is created
  36365. */
  36366. onNewLightAddedObservable: Observable<Light>;
  36367. /**
  36368. * An event triggered when a light is removed
  36369. */
  36370. onLightRemovedObservable: Observable<Light>;
  36371. /**
  36372. * An event triggered when a geometry is created
  36373. */
  36374. onNewGeometryAddedObservable: Observable<Geometry>;
  36375. /**
  36376. * An event triggered when a geometry is removed
  36377. */
  36378. onGeometryRemovedObservable: Observable<Geometry>;
  36379. /**
  36380. * An event triggered when a transform node is created
  36381. */
  36382. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36383. /**
  36384. * An event triggered when a transform node is removed
  36385. */
  36386. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36387. /**
  36388. * An event triggered when a mesh is created
  36389. */
  36390. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36391. /**
  36392. * An event triggered when a mesh is removed
  36393. */
  36394. onMeshRemovedObservable: Observable<AbstractMesh>;
  36395. /**
  36396. * An event triggered when a skeleton is created
  36397. */
  36398. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36399. /**
  36400. * An event triggered when a skeleton is removed
  36401. */
  36402. onSkeletonRemovedObservable: Observable<Skeleton>;
  36403. /**
  36404. * An event triggered when a material is created
  36405. */
  36406. onNewMaterialAddedObservable: Observable<Material>;
  36407. /**
  36408. * An event triggered when a material is removed
  36409. */
  36410. onMaterialRemovedObservable: Observable<Material>;
  36411. /**
  36412. * An event triggered when a texture is created
  36413. */
  36414. onNewTextureAddedObservable: Observable<BaseTexture>;
  36415. /**
  36416. * An event triggered when a texture is removed
  36417. */
  36418. onTextureRemovedObservable: Observable<BaseTexture>;
  36419. /**
  36420. * An event triggered when render targets are about to be rendered
  36421. * Can happen multiple times per frame.
  36422. */
  36423. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36424. /**
  36425. * An event triggered when render targets were rendered.
  36426. * Can happen multiple times per frame.
  36427. */
  36428. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36429. /**
  36430. * An event triggered before calculating deterministic simulation step
  36431. */
  36432. onBeforeStepObservable: Observable<Scene>;
  36433. /**
  36434. * An event triggered after calculating deterministic simulation step
  36435. */
  36436. onAfterStepObservable: Observable<Scene>;
  36437. /**
  36438. * An event triggered when the activeCamera property is updated
  36439. */
  36440. onActiveCameraChanged: Observable<Scene>;
  36441. /**
  36442. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36443. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36444. * 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)
  36445. */
  36446. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36447. /**
  36448. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36449. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36450. * 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)
  36451. */
  36452. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36453. /**
  36454. * This Observable will when a mesh has been imported into the scene.
  36455. */
  36456. onMeshImportedObservable: Observable<AbstractMesh>;
  36457. /**
  36458. * This Observable will when an animation file has been imported into the scene.
  36459. */
  36460. onAnimationFileImportedObservable: Observable<Scene>;
  36461. /**
  36462. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36463. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36464. */
  36465. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36466. /** @hidden */
  36467. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36468. /**
  36469. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36470. */
  36471. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36472. /**
  36473. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36474. */
  36475. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36476. /**
  36477. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36478. */
  36479. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36480. /** Callback called when a pointer move is detected */
  36481. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36482. /** Callback called when a pointer down is detected */
  36483. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36484. /** Callback called when a pointer up is detected */
  36485. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36486. /** Callback called when a pointer pick is detected */
  36487. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36488. /**
  36489. * 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).
  36490. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36491. */
  36492. onPrePointerObservable: Observable<PointerInfoPre>;
  36493. /**
  36494. * Observable event triggered each time an input event is received from the rendering canvas
  36495. */
  36496. onPointerObservable: Observable<PointerInfo>;
  36497. /**
  36498. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36499. */
  36500. get unTranslatedPointer(): Vector2;
  36501. /**
  36502. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36503. */
  36504. static get DragMovementThreshold(): number;
  36505. static set DragMovementThreshold(value: number);
  36506. /**
  36507. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36508. */
  36509. static get LongPressDelay(): number;
  36510. static set LongPressDelay(value: number);
  36511. /**
  36512. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36513. */
  36514. static get DoubleClickDelay(): number;
  36515. static set DoubleClickDelay(value: number);
  36516. /** If you need to check double click without raising a single click at first click, enable this flag */
  36517. static get ExclusiveDoubleClickMode(): boolean;
  36518. static set ExclusiveDoubleClickMode(value: boolean);
  36519. /** @hidden */
  36520. _mirroredCameraPosition: Nullable<Vector3>;
  36521. /**
  36522. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36523. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36524. */
  36525. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36526. /**
  36527. * Observable event triggered each time an keyboard event is received from the hosting window
  36528. */
  36529. onKeyboardObservable: Observable<KeyboardInfo>;
  36530. private _useRightHandedSystem;
  36531. /**
  36532. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36533. */
  36534. set useRightHandedSystem(value: boolean);
  36535. get useRightHandedSystem(): boolean;
  36536. private _timeAccumulator;
  36537. private _currentStepId;
  36538. private _currentInternalStep;
  36539. /**
  36540. * Sets the step Id used by deterministic lock step
  36541. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36542. * @param newStepId defines the step Id
  36543. */
  36544. setStepId(newStepId: number): void;
  36545. /**
  36546. * Gets the step Id used by deterministic lock step
  36547. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36548. * @returns the step Id
  36549. */
  36550. getStepId(): number;
  36551. /**
  36552. * Gets the internal step used by deterministic lock step
  36553. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36554. * @returns the internal step
  36555. */
  36556. getInternalStep(): number;
  36557. private _fogEnabled;
  36558. /**
  36559. * Gets or sets a boolean indicating if fog is enabled on this scene
  36560. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36561. * (Default is true)
  36562. */
  36563. set fogEnabled(value: boolean);
  36564. get fogEnabled(): boolean;
  36565. private _fogMode;
  36566. /**
  36567. * Gets or sets the fog mode to use
  36568. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36569. * | mode | value |
  36570. * | --- | --- |
  36571. * | FOGMODE_NONE | 0 |
  36572. * | FOGMODE_EXP | 1 |
  36573. * | FOGMODE_EXP2 | 2 |
  36574. * | FOGMODE_LINEAR | 3 |
  36575. */
  36576. set fogMode(value: number);
  36577. get fogMode(): number;
  36578. /**
  36579. * Gets or sets the fog color to use
  36580. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36581. * (Default is Color3(0.2, 0.2, 0.3))
  36582. */
  36583. fogColor: Color3;
  36584. /**
  36585. * Gets or sets the fog density to use
  36586. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36587. * (Default is 0.1)
  36588. */
  36589. fogDensity: number;
  36590. /**
  36591. * Gets or sets the fog start distance to use
  36592. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36593. * (Default is 0)
  36594. */
  36595. fogStart: number;
  36596. /**
  36597. * Gets or sets the fog end distance to use
  36598. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36599. * (Default is 1000)
  36600. */
  36601. fogEnd: number;
  36602. private _shadowsEnabled;
  36603. /**
  36604. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36605. */
  36606. set shadowsEnabled(value: boolean);
  36607. get shadowsEnabled(): boolean;
  36608. private _lightsEnabled;
  36609. /**
  36610. * Gets or sets a boolean indicating if lights are enabled on this scene
  36611. */
  36612. set lightsEnabled(value: boolean);
  36613. get lightsEnabled(): boolean;
  36614. /** All of the active cameras added to this scene. */
  36615. activeCameras: Camera[];
  36616. /** @hidden */
  36617. _activeCamera: Nullable<Camera>;
  36618. /** Gets or sets the current active camera */
  36619. get activeCamera(): Nullable<Camera>;
  36620. set activeCamera(value: Nullable<Camera>);
  36621. private _defaultMaterial;
  36622. /** The default material used on meshes when no material is affected */
  36623. get defaultMaterial(): Material;
  36624. /** The default material used on meshes when no material is affected */
  36625. set defaultMaterial(value: Material);
  36626. private _texturesEnabled;
  36627. /**
  36628. * Gets or sets a boolean indicating if textures are enabled on this scene
  36629. */
  36630. set texturesEnabled(value: boolean);
  36631. get texturesEnabled(): boolean;
  36632. /**
  36633. * Gets or sets a boolean indicating if particles are enabled on this scene
  36634. */
  36635. particlesEnabled: boolean;
  36636. /**
  36637. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36638. */
  36639. spritesEnabled: boolean;
  36640. private _skeletonsEnabled;
  36641. /**
  36642. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36643. */
  36644. set skeletonsEnabled(value: boolean);
  36645. get skeletonsEnabled(): boolean;
  36646. /**
  36647. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36648. */
  36649. lensFlaresEnabled: boolean;
  36650. /**
  36651. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36652. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36653. */
  36654. collisionsEnabled: boolean;
  36655. private _collisionCoordinator;
  36656. /** @hidden */
  36657. get collisionCoordinator(): ICollisionCoordinator;
  36658. /**
  36659. * Defines the gravity applied to this scene (used only for collisions)
  36660. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36661. */
  36662. gravity: Vector3;
  36663. /**
  36664. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36665. */
  36666. postProcessesEnabled: boolean;
  36667. /**
  36668. * The list of postprocesses added to the scene
  36669. */
  36670. postProcesses: PostProcess[];
  36671. /**
  36672. * Gets the current postprocess manager
  36673. */
  36674. postProcessManager: PostProcessManager;
  36675. /**
  36676. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36677. */
  36678. renderTargetsEnabled: boolean;
  36679. /**
  36680. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36681. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36682. */
  36683. dumpNextRenderTargets: boolean;
  36684. /**
  36685. * The list of user defined render targets added to the scene
  36686. */
  36687. customRenderTargets: RenderTargetTexture[];
  36688. /**
  36689. * Defines if texture loading must be delayed
  36690. * If true, textures will only be loaded when they need to be rendered
  36691. */
  36692. useDelayedTextureLoading: boolean;
  36693. /**
  36694. * Gets the list of meshes imported to the scene through SceneLoader
  36695. */
  36696. importedMeshesFiles: String[];
  36697. /**
  36698. * Gets or sets a boolean indicating if probes are enabled on this scene
  36699. */
  36700. probesEnabled: boolean;
  36701. /**
  36702. * Gets or sets the current offline provider to use to store scene data
  36703. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36704. */
  36705. offlineProvider: IOfflineProvider;
  36706. /**
  36707. * Gets or sets the action manager associated with the scene
  36708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36709. */
  36710. actionManager: AbstractActionManager;
  36711. private _meshesForIntersections;
  36712. /**
  36713. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36714. */
  36715. proceduralTexturesEnabled: boolean;
  36716. private _engine;
  36717. private _totalVertices;
  36718. /** @hidden */
  36719. _activeIndices: PerfCounter;
  36720. /** @hidden */
  36721. _activeParticles: PerfCounter;
  36722. /** @hidden */
  36723. _activeBones: PerfCounter;
  36724. private _animationRatio;
  36725. /** @hidden */
  36726. _animationTimeLast: number;
  36727. /** @hidden */
  36728. _animationTime: number;
  36729. /**
  36730. * Gets or sets a general scale for animation speed
  36731. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36732. */
  36733. animationTimeScale: number;
  36734. /** @hidden */
  36735. _cachedMaterial: Nullable<Material>;
  36736. /** @hidden */
  36737. _cachedEffect: Nullable<Effect>;
  36738. /** @hidden */
  36739. _cachedVisibility: Nullable<number>;
  36740. private _renderId;
  36741. private _frameId;
  36742. private _executeWhenReadyTimeoutId;
  36743. private _intermediateRendering;
  36744. private _viewUpdateFlag;
  36745. private _projectionUpdateFlag;
  36746. /** @hidden */
  36747. _toBeDisposed: Nullable<IDisposable>[];
  36748. private _activeRequests;
  36749. /** @hidden */
  36750. _pendingData: any[];
  36751. private _isDisposed;
  36752. /**
  36753. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36754. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36755. */
  36756. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36757. private _activeMeshes;
  36758. private _processedMaterials;
  36759. private _renderTargets;
  36760. /** @hidden */
  36761. _activeParticleSystems: SmartArray<IParticleSystem>;
  36762. private _activeSkeletons;
  36763. private _softwareSkinnedMeshes;
  36764. private _renderingManager;
  36765. /** @hidden */
  36766. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36767. private _transformMatrix;
  36768. private _sceneUbo;
  36769. /** @hidden */
  36770. _viewMatrix: Matrix;
  36771. private _projectionMatrix;
  36772. /** @hidden */
  36773. _forcedViewPosition: Nullable<Vector3>;
  36774. /** @hidden */
  36775. _frustumPlanes: Plane[];
  36776. /**
  36777. * Gets the list of frustum planes (built from the active camera)
  36778. */
  36779. get frustumPlanes(): Plane[];
  36780. /**
  36781. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36782. * This is useful if there are more lights that the maximum simulteanous authorized
  36783. */
  36784. requireLightSorting: boolean;
  36785. /** @hidden */
  36786. readonly useMaterialMeshMap: boolean;
  36787. /** @hidden */
  36788. readonly useClonedMeshMap: boolean;
  36789. private _externalData;
  36790. private _uid;
  36791. /**
  36792. * @hidden
  36793. * Backing store of defined scene components.
  36794. */
  36795. _components: ISceneComponent[];
  36796. /**
  36797. * @hidden
  36798. * Backing store of defined scene components.
  36799. */
  36800. _serializableComponents: ISceneSerializableComponent[];
  36801. /**
  36802. * List of components to register on the next registration step.
  36803. */
  36804. private _transientComponents;
  36805. /**
  36806. * Registers the transient components if needed.
  36807. */
  36808. private _registerTransientComponents;
  36809. /**
  36810. * @hidden
  36811. * Add a component to the scene.
  36812. * Note that the ccomponent could be registered on th next frame if this is called after
  36813. * the register component stage.
  36814. * @param component Defines the component to add to the scene
  36815. */
  36816. _addComponent(component: ISceneComponent): void;
  36817. /**
  36818. * @hidden
  36819. * Gets a component from the scene.
  36820. * @param name defines the name of the component to retrieve
  36821. * @returns the component or null if not present
  36822. */
  36823. _getComponent(name: string): Nullable<ISceneComponent>;
  36824. /**
  36825. * @hidden
  36826. * Defines the actions happening before camera updates.
  36827. */
  36828. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36829. /**
  36830. * @hidden
  36831. * Defines the actions happening before clear the canvas.
  36832. */
  36833. _beforeClearStage: Stage<SimpleStageAction>;
  36834. /**
  36835. * @hidden
  36836. * Defines the actions when collecting render targets for the frame.
  36837. */
  36838. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36839. /**
  36840. * @hidden
  36841. * Defines the actions happening for one camera in the frame.
  36842. */
  36843. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36844. /**
  36845. * @hidden
  36846. * Defines the actions happening during the per mesh ready checks.
  36847. */
  36848. _isReadyForMeshStage: Stage<MeshStageAction>;
  36849. /**
  36850. * @hidden
  36851. * Defines the actions happening before evaluate active mesh checks.
  36852. */
  36853. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36854. /**
  36855. * @hidden
  36856. * Defines the actions happening during the evaluate sub mesh checks.
  36857. */
  36858. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36859. /**
  36860. * @hidden
  36861. * Defines the actions happening during the active mesh stage.
  36862. */
  36863. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36864. /**
  36865. * @hidden
  36866. * Defines the actions happening during the per camera render target step.
  36867. */
  36868. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36869. /**
  36870. * @hidden
  36871. * Defines the actions happening just before the active camera is drawing.
  36872. */
  36873. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36874. /**
  36875. * @hidden
  36876. * Defines the actions happening just before a render target is drawing.
  36877. */
  36878. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36879. /**
  36880. * @hidden
  36881. * Defines the actions happening just before a rendering group is drawing.
  36882. */
  36883. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36884. /**
  36885. * @hidden
  36886. * Defines the actions happening just before a mesh is drawing.
  36887. */
  36888. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36889. /**
  36890. * @hidden
  36891. * Defines the actions happening just after a mesh has been drawn.
  36892. */
  36893. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36894. /**
  36895. * @hidden
  36896. * Defines the actions happening just after a rendering group has been drawn.
  36897. */
  36898. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36899. /**
  36900. * @hidden
  36901. * Defines the actions happening just after the active camera has been drawn.
  36902. */
  36903. _afterCameraDrawStage: Stage<CameraStageAction>;
  36904. /**
  36905. * @hidden
  36906. * Defines the actions happening just after a render target has been drawn.
  36907. */
  36908. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36909. /**
  36910. * @hidden
  36911. * Defines the actions happening just after rendering all cameras and computing intersections.
  36912. */
  36913. _afterRenderStage: Stage<SimpleStageAction>;
  36914. /**
  36915. * @hidden
  36916. * Defines the actions happening when a pointer move event happens.
  36917. */
  36918. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36919. /**
  36920. * @hidden
  36921. * Defines the actions happening when a pointer down event happens.
  36922. */
  36923. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36924. /**
  36925. * @hidden
  36926. * Defines the actions happening when a pointer up event happens.
  36927. */
  36928. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36929. /**
  36930. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36931. */
  36932. private geometriesByUniqueId;
  36933. /**
  36934. * Creates a new Scene
  36935. * @param engine defines the engine to use to render this scene
  36936. * @param options defines the scene options
  36937. */
  36938. constructor(engine: Engine, options?: SceneOptions);
  36939. /**
  36940. * Gets a string idenfifying the name of the class
  36941. * @returns "Scene" string
  36942. */
  36943. getClassName(): string;
  36944. private _defaultMeshCandidates;
  36945. /**
  36946. * @hidden
  36947. */
  36948. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36949. private _defaultSubMeshCandidates;
  36950. /**
  36951. * @hidden
  36952. */
  36953. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36954. /**
  36955. * Sets the default candidate providers for the scene.
  36956. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36957. * and getCollidingSubMeshCandidates to their default function
  36958. */
  36959. setDefaultCandidateProviders(): void;
  36960. /**
  36961. * Gets the mesh that is currently under the pointer
  36962. */
  36963. get meshUnderPointer(): Nullable<AbstractMesh>;
  36964. /**
  36965. * Gets or sets the current on-screen X position of the pointer
  36966. */
  36967. get pointerX(): number;
  36968. set pointerX(value: number);
  36969. /**
  36970. * Gets or sets the current on-screen Y position of the pointer
  36971. */
  36972. get pointerY(): number;
  36973. set pointerY(value: number);
  36974. /**
  36975. * Gets the cached material (ie. the latest rendered one)
  36976. * @returns the cached material
  36977. */
  36978. getCachedMaterial(): Nullable<Material>;
  36979. /**
  36980. * Gets the cached effect (ie. the latest rendered one)
  36981. * @returns the cached effect
  36982. */
  36983. getCachedEffect(): Nullable<Effect>;
  36984. /**
  36985. * Gets the cached visibility state (ie. the latest rendered one)
  36986. * @returns the cached visibility state
  36987. */
  36988. getCachedVisibility(): Nullable<number>;
  36989. /**
  36990. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36991. * @param material defines the current material
  36992. * @param effect defines the current effect
  36993. * @param visibility defines the current visibility state
  36994. * @returns true if one parameter is not cached
  36995. */
  36996. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36997. /**
  36998. * Gets the engine associated with the scene
  36999. * @returns an Engine
  37000. */
  37001. getEngine(): Engine;
  37002. /**
  37003. * Gets the total number of vertices rendered per frame
  37004. * @returns the total number of vertices rendered per frame
  37005. */
  37006. getTotalVertices(): number;
  37007. /**
  37008. * Gets the performance counter for total vertices
  37009. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37010. */
  37011. get totalVerticesPerfCounter(): PerfCounter;
  37012. /**
  37013. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37014. * @returns the total number of active indices rendered per frame
  37015. */
  37016. getActiveIndices(): number;
  37017. /**
  37018. * Gets the performance counter for active indices
  37019. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37020. */
  37021. get totalActiveIndicesPerfCounter(): PerfCounter;
  37022. /**
  37023. * Gets the total number of active particles rendered per frame
  37024. * @returns the total number of active particles rendered per frame
  37025. */
  37026. getActiveParticles(): number;
  37027. /**
  37028. * Gets the performance counter for active particles
  37029. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37030. */
  37031. get activeParticlesPerfCounter(): PerfCounter;
  37032. /**
  37033. * Gets the total number of active bones rendered per frame
  37034. * @returns the total number of active bones rendered per frame
  37035. */
  37036. getActiveBones(): number;
  37037. /**
  37038. * Gets the performance counter for active bones
  37039. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37040. */
  37041. get activeBonesPerfCounter(): PerfCounter;
  37042. /**
  37043. * Gets the array of active meshes
  37044. * @returns an array of AbstractMesh
  37045. */
  37046. getActiveMeshes(): SmartArray<AbstractMesh>;
  37047. /**
  37048. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37049. * @returns a number
  37050. */
  37051. getAnimationRatio(): number;
  37052. /**
  37053. * Gets an unique Id for the current render phase
  37054. * @returns a number
  37055. */
  37056. getRenderId(): number;
  37057. /**
  37058. * Gets an unique Id for the current frame
  37059. * @returns a number
  37060. */
  37061. getFrameId(): number;
  37062. /** Call this function if you want to manually increment the render Id*/
  37063. incrementRenderId(): void;
  37064. private _createUbo;
  37065. /**
  37066. * Use this method to simulate a pointer move on a mesh
  37067. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37068. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37069. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37070. * @returns the current scene
  37071. */
  37072. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37073. /**
  37074. * Use this method to simulate a pointer down on a mesh
  37075. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37076. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37077. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37078. * @returns the current scene
  37079. */
  37080. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37081. /**
  37082. * Use this method to simulate a pointer up on a mesh
  37083. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37084. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37085. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37086. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37087. * @returns the current scene
  37088. */
  37089. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37090. /**
  37091. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37092. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37093. * @returns true if the pointer was captured
  37094. */
  37095. isPointerCaptured(pointerId?: number): boolean;
  37096. /**
  37097. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37098. * @param attachUp defines if you want to attach events to pointerup
  37099. * @param attachDown defines if you want to attach events to pointerdown
  37100. * @param attachMove defines if you want to attach events to pointermove
  37101. */
  37102. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37103. /** Detaches all event handlers*/
  37104. detachControl(): void;
  37105. /**
  37106. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37107. * Delay loaded resources are not taking in account
  37108. * @return true if all required resources are ready
  37109. */
  37110. isReady(): boolean;
  37111. /** Resets all cached information relative to material (including effect and visibility) */
  37112. resetCachedMaterial(): void;
  37113. /**
  37114. * Registers a function to be called before every frame render
  37115. * @param func defines the function to register
  37116. */
  37117. registerBeforeRender(func: () => void): void;
  37118. /**
  37119. * Unregisters a function called before every frame render
  37120. * @param func defines the function to unregister
  37121. */
  37122. unregisterBeforeRender(func: () => void): void;
  37123. /**
  37124. * Registers a function to be called after every frame render
  37125. * @param func defines the function to register
  37126. */
  37127. registerAfterRender(func: () => void): void;
  37128. /**
  37129. * Unregisters a function called after every frame render
  37130. * @param func defines the function to unregister
  37131. */
  37132. unregisterAfterRender(func: () => void): void;
  37133. private _executeOnceBeforeRender;
  37134. /**
  37135. * The provided function will run before render once and will be disposed afterwards.
  37136. * A timeout delay can be provided so that the function will be executed in N ms.
  37137. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37138. * @param func The function to be executed.
  37139. * @param timeout optional delay in ms
  37140. */
  37141. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37142. /** @hidden */
  37143. _addPendingData(data: any): void;
  37144. /** @hidden */
  37145. _removePendingData(data: any): void;
  37146. /**
  37147. * Returns the number of items waiting to be loaded
  37148. * @returns the number of items waiting to be loaded
  37149. */
  37150. getWaitingItemsCount(): number;
  37151. /**
  37152. * Returns a boolean indicating if the scene is still loading data
  37153. */
  37154. get isLoading(): boolean;
  37155. /**
  37156. * Registers a function to be executed when the scene is ready
  37157. * @param {Function} func - the function to be executed
  37158. */
  37159. executeWhenReady(func: () => void): void;
  37160. /**
  37161. * Returns a promise that resolves when the scene is ready
  37162. * @returns A promise that resolves when the scene is ready
  37163. */
  37164. whenReadyAsync(): Promise<void>;
  37165. /** @hidden */
  37166. _checkIsReady(): void;
  37167. /**
  37168. * Gets all animatable attached to the scene
  37169. */
  37170. get animatables(): Animatable[];
  37171. /**
  37172. * Resets the last animation time frame.
  37173. * Useful to override when animations start running when loading a scene for the first time.
  37174. */
  37175. resetLastAnimationTimeFrame(): void;
  37176. /**
  37177. * Gets the current view matrix
  37178. * @returns a Matrix
  37179. */
  37180. getViewMatrix(): Matrix;
  37181. /**
  37182. * Gets the current projection matrix
  37183. * @returns a Matrix
  37184. */
  37185. getProjectionMatrix(): Matrix;
  37186. /**
  37187. * Gets the current transform matrix
  37188. * @returns a Matrix made of View * Projection
  37189. */
  37190. getTransformMatrix(): Matrix;
  37191. /**
  37192. * Sets the current transform matrix
  37193. * @param viewL defines the View matrix to use
  37194. * @param projectionL defines the Projection matrix to use
  37195. * @param viewR defines the right View matrix to use (if provided)
  37196. * @param projectionR defines the right Projection matrix to use (if provided)
  37197. */
  37198. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37199. /**
  37200. * Gets the uniform buffer used to store scene data
  37201. * @returns a UniformBuffer
  37202. */
  37203. getSceneUniformBuffer(): UniformBuffer;
  37204. /**
  37205. * Gets an unique (relatively to the current scene) Id
  37206. * @returns an unique number for the scene
  37207. */
  37208. getUniqueId(): number;
  37209. /**
  37210. * Add a mesh to the list of scene's meshes
  37211. * @param newMesh defines the mesh to add
  37212. * @param recursive if all child meshes should also be added to the scene
  37213. */
  37214. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37215. /**
  37216. * Remove a mesh for the list of scene's meshes
  37217. * @param toRemove defines the mesh to remove
  37218. * @param recursive if all child meshes should also be removed from the scene
  37219. * @returns the index where the mesh was in the mesh list
  37220. */
  37221. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37222. /**
  37223. * Add a transform node to the list of scene's transform nodes
  37224. * @param newTransformNode defines the transform node to add
  37225. */
  37226. addTransformNode(newTransformNode: TransformNode): void;
  37227. /**
  37228. * Remove a transform node for the list of scene's transform nodes
  37229. * @param toRemove defines the transform node to remove
  37230. * @returns the index where the transform node was in the transform node list
  37231. */
  37232. removeTransformNode(toRemove: TransformNode): number;
  37233. /**
  37234. * Remove a skeleton for the list of scene's skeletons
  37235. * @param toRemove defines the skeleton to remove
  37236. * @returns the index where the skeleton was in the skeleton list
  37237. */
  37238. removeSkeleton(toRemove: Skeleton): number;
  37239. /**
  37240. * Remove a morph target for the list of scene's morph targets
  37241. * @param toRemove defines the morph target to remove
  37242. * @returns the index where the morph target was in the morph target list
  37243. */
  37244. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37245. /**
  37246. * Remove a light for the list of scene's lights
  37247. * @param toRemove defines the light to remove
  37248. * @returns the index where the light was in the light list
  37249. */
  37250. removeLight(toRemove: Light): number;
  37251. /**
  37252. * Remove a camera for the list of scene's cameras
  37253. * @param toRemove defines the camera to remove
  37254. * @returns the index where the camera was in the camera list
  37255. */
  37256. removeCamera(toRemove: Camera): number;
  37257. /**
  37258. * Remove a particle system for the list of scene's particle systems
  37259. * @param toRemove defines the particle system to remove
  37260. * @returns the index where the particle system was in the particle system list
  37261. */
  37262. removeParticleSystem(toRemove: IParticleSystem): number;
  37263. /**
  37264. * Remove a animation for the list of scene's animations
  37265. * @param toRemove defines the animation to remove
  37266. * @returns the index where the animation was in the animation list
  37267. */
  37268. removeAnimation(toRemove: Animation): number;
  37269. /**
  37270. * Will stop the animation of the given target
  37271. * @param target - the target
  37272. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37273. * @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)
  37274. */
  37275. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37276. /**
  37277. * Removes the given animation group from this scene.
  37278. * @param toRemove The animation group to remove
  37279. * @returns The index of the removed animation group
  37280. */
  37281. removeAnimationGroup(toRemove: AnimationGroup): number;
  37282. /**
  37283. * Removes the given multi-material from this scene.
  37284. * @param toRemove The multi-material to remove
  37285. * @returns The index of the removed multi-material
  37286. */
  37287. removeMultiMaterial(toRemove: MultiMaterial): number;
  37288. /**
  37289. * Removes the given material from this scene.
  37290. * @param toRemove The material to remove
  37291. * @returns The index of the removed material
  37292. */
  37293. removeMaterial(toRemove: Material): number;
  37294. /**
  37295. * Removes the given action manager from this scene.
  37296. * @param toRemove The action manager to remove
  37297. * @returns The index of the removed action manager
  37298. */
  37299. removeActionManager(toRemove: AbstractActionManager): number;
  37300. /**
  37301. * Removes the given texture from this scene.
  37302. * @param toRemove The texture to remove
  37303. * @returns The index of the removed texture
  37304. */
  37305. removeTexture(toRemove: BaseTexture): number;
  37306. /**
  37307. * Adds the given light to this scene
  37308. * @param newLight The light to add
  37309. */
  37310. addLight(newLight: Light): void;
  37311. /**
  37312. * Sorts the list list based on light priorities
  37313. */
  37314. sortLightsByPriority(): void;
  37315. /**
  37316. * Adds the given camera to this scene
  37317. * @param newCamera The camera to add
  37318. */
  37319. addCamera(newCamera: Camera): void;
  37320. /**
  37321. * Adds the given skeleton to this scene
  37322. * @param newSkeleton The skeleton to add
  37323. */
  37324. addSkeleton(newSkeleton: Skeleton): void;
  37325. /**
  37326. * Adds the given particle system to this scene
  37327. * @param newParticleSystem The particle system to add
  37328. */
  37329. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37330. /**
  37331. * Adds the given animation to this scene
  37332. * @param newAnimation The animation to add
  37333. */
  37334. addAnimation(newAnimation: Animation): void;
  37335. /**
  37336. * Adds the given animation group to this scene.
  37337. * @param newAnimationGroup The animation group to add
  37338. */
  37339. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37340. /**
  37341. * Adds the given multi-material to this scene
  37342. * @param newMultiMaterial The multi-material to add
  37343. */
  37344. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37345. /**
  37346. * Adds the given material to this scene
  37347. * @param newMaterial The material to add
  37348. */
  37349. addMaterial(newMaterial: Material): void;
  37350. /**
  37351. * Adds the given morph target to this scene
  37352. * @param newMorphTargetManager The morph target to add
  37353. */
  37354. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37355. /**
  37356. * Adds the given geometry to this scene
  37357. * @param newGeometry The geometry to add
  37358. */
  37359. addGeometry(newGeometry: Geometry): void;
  37360. /**
  37361. * Adds the given action manager to this scene
  37362. * @param newActionManager The action manager to add
  37363. */
  37364. addActionManager(newActionManager: AbstractActionManager): void;
  37365. /**
  37366. * Adds the given texture to this scene.
  37367. * @param newTexture The texture to add
  37368. */
  37369. addTexture(newTexture: BaseTexture): void;
  37370. /**
  37371. * Switch active camera
  37372. * @param newCamera defines the new active camera
  37373. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37374. */
  37375. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37376. /**
  37377. * sets the active camera of the scene using its ID
  37378. * @param id defines the camera's ID
  37379. * @return the new active camera or null if none found.
  37380. */
  37381. setActiveCameraByID(id: string): Nullable<Camera>;
  37382. /**
  37383. * sets the active camera of the scene using its name
  37384. * @param name defines the camera's name
  37385. * @returns the new active camera or null if none found.
  37386. */
  37387. setActiveCameraByName(name: string): Nullable<Camera>;
  37388. /**
  37389. * get an animation group using its name
  37390. * @param name defines the material's name
  37391. * @return the animation group or null if none found.
  37392. */
  37393. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37394. /**
  37395. * Get a material using its unique id
  37396. * @param uniqueId defines the material's unique id
  37397. * @return the material or null if none found.
  37398. */
  37399. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37400. /**
  37401. * get a material using its id
  37402. * @param id defines the material's ID
  37403. * @return the material or null if none found.
  37404. */
  37405. getMaterialByID(id: string): Nullable<Material>;
  37406. /**
  37407. * Gets a the last added material using a given id
  37408. * @param id defines the material's ID
  37409. * @return the last material with the given id or null if none found.
  37410. */
  37411. getLastMaterialByID(id: string): Nullable<Material>;
  37412. /**
  37413. * Gets a material using its name
  37414. * @param name defines the material's name
  37415. * @return the material or null if none found.
  37416. */
  37417. getMaterialByName(name: string): Nullable<Material>;
  37418. /**
  37419. * Get a texture using its unique id
  37420. * @param uniqueId defines the texture's unique id
  37421. * @return the texture or null if none found.
  37422. */
  37423. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37424. /**
  37425. * Gets a camera using its id
  37426. * @param id defines the id to look for
  37427. * @returns the camera or null if not found
  37428. */
  37429. getCameraByID(id: string): Nullable<Camera>;
  37430. /**
  37431. * Gets a camera using its unique id
  37432. * @param uniqueId defines the unique id to look for
  37433. * @returns the camera or null if not found
  37434. */
  37435. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37436. /**
  37437. * Gets a camera using its name
  37438. * @param name defines the camera's name
  37439. * @return the camera or null if none found.
  37440. */
  37441. getCameraByName(name: string): Nullable<Camera>;
  37442. /**
  37443. * Gets a bone using its id
  37444. * @param id defines the bone's id
  37445. * @return the bone or null if not found
  37446. */
  37447. getBoneByID(id: string): Nullable<Bone>;
  37448. /**
  37449. * Gets a bone using its id
  37450. * @param name defines the bone's name
  37451. * @return the bone or null if not found
  37452. */
  37453. getBoneByName(name: string): Nullable<Bone>;
  37454. /**
  37455. * Gets a light node using its name
  37456. * @param name defines the the light's name
  37457. * @return the light or null if none found.
  37458. */
  37459. getLightByName(name: string): Nullable<Light>;
  37460. /**
  37461. * Gets a light node using its id
  37462. * @param id defines the light's id
  37463. * @return the light or null if none found.
  37464. */
  37465. getLightByID(id: string): Nullable<Light>;
  37466. /**
  37467. * Gets a light node using its scene-generated unique ID
  37468. * @param uniqueId defines the light's unique id
  37469. * @return the light or null if none found.
  37470. */
  37471. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37472. /**
  37473. * Gets a particle system by id
  37474. * @param id defines the particle system id
  37475. * @return the corresponding system or null if none found
  37476. */
  37477. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37478. /**
  37479. * Gets a geometry using its ID
  37480. * @param id defines the geometry's id
  37481. * @return the geometry or null if none found.
  37482. */
  37483. getGeometryByID(id: string): Nullable<Geometry>;
  37484. private _getGeometryByUniqueID;
  37485. /**
  37486. * Add a new geometry to this scene
  37487. * @param geometry defines the geometry to be added to the scene.
  37488. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37489. * @return a boolean defining if the geometry was added or not
  37490. */
  37491. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37492. /**
  37493. * Removes an existing geometry
  37494. * @param geometry defines the geometry to be removed from the scene
  37495. * @return a boolean defining if the geometry was removed or not
  37496. */
  37497. removeGeometry(geometry: Geometry): boolean;
  37498. /**
  37499. * Gets the list of geometries attached to the scene
  37500. * @returns an array of Geometry
  37501. */
  37502. getGeometries(): Geometry[];
  37503. /**
  37504. * Gets the first added mesh found of a given ID
  37505. * @param id defines the id to search for
  37506. * @return the mesh found or null if not found at all
  37507. */
  37508. getMeshByID(id: string): Nullable<AbstractMesh>;
  37509. /**
  37510. * Gets a list of meshes using their id
  37511. * @param id defines the id to search for
  37512. * @returns a list of meshes
  37513. */
  37514. getMeshesByID(id: string): Array<AbstractMesh>;
  37515. /**
  37516. * Gets the first added transform node found of a given ID
  37517. * @param id defines the id to search for
  37518. * @return the found transform node or null if not found at all.
  37519. */
  37520. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37521. /**
  37522. * Gets a transform node with its auto-generated unique id
  37523. * @param uniqueId efines the unique id to search for
  37524. * @return the found transform node or null if not found at all.
  37525. */
  37526. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37527. /**
  37528. * Gets a list of transform nodes using their id
  37529. * @param id defines the id to search for
  37530. * @returns a list of transform nodes
  37531. */
  37532. getTransformNodesByID(id: string): Array<TransformNode>;
  37533. /**
  37534. * Gets a mesh with its auto-generated unique id
  37535. * @param uniqueId defines the unique id to search for
  37536. * @return the found mesh or null if not found at all.
  37537. */
  37538. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37539. /**
  37540. * Gets a the last added mesh using a given id
  37541. * @param id defines the id to search for
  37542. * @return the found mesh or null if not found at all.
  37543. */
  37544. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37545. /**
  37546. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37547. * @param id defines the id to search for
  37548. * @return the found node or null if not found at all
  37549. */
  37550. getLastEntryByID(id: string): Nullable<Node>;
  37551. /**
  37552. * Gets a node (Mesh, Camera, Light) using a given id
  37553. * @param id defines the id to search for
  37554. * @return the found node or null if not found at all
  37555. */
  37556. getNodeByID(id: string): Nullable<Node>;
  37557. /**
  37558. * Gets a node (Mesh, Camera, Light) using a given name
  37559. * @param name defines the name to search for
  37560. * @return the found node or null if not found at all.
  37561. */
  37562. getNodeByName(name: string): Nullable<Node>;
  37563. /**
  37564. * Gets a mesh using a given name
  37565. * @param name defines the name to search for
  37566. * @return the found mesh or null if not found at all.
  37567. */
  37568. getMeshByName(name: string): Nullable<AbstractMesh>;
  37569. /**
  37570. * Gets a transform node using a given name
  37571. * @param name defines the name to search for
  37572. * @return the found transform node or null if not found at all.
  37573. */
  37574. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37575. /**
  37576. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37577. * @param id defines the id to search for
  37578. * @return the found skeleton or null if not found at all.
  37579. */
  37580. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37581. /**
  37582. * Gets a skeleton using a given auto generated unique id
  37583. * @param uniqueId defines the unique id to search for
  37584. * @return the found skeleton or null if not found at all.
  37585. */
  37586. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37587. /**
  37588. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37589. * @param id defines the id to search for
  37590. * @return the found skeleton or null if not found at all.
  37591. */
  37592. getSkeletonById(id: string): Nullable<Skeleton>;
  37593. /**
  37594. * Gets a skeleton using a given name
  37595. * @param name defines the name to search for
  37596. * @return the found skeleton or null if not found at all.
  37597. */
  37598. getSkeletonByName(name: string): Nullable<Skeleton>;
  37599. /**
  37600. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37601. * @param id defines the id to search for
  37602. * @return the found morph target manager or null if not found at all.
  37603. */
  37604. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37605. /**
  37606. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37607. * @param id defines the id to search for
  37608. * @return the found morph target or null if not found at all.
  37609. */
  37610. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37611. /**
  37612. * Gets a boolean indicating if the given mesh is active
  37613. * @param mesh defines the mesh to look for
  37614. * @returns true if the mesh is in the active list
  37615. */
  37616. isActiveMesh(mesh: AbstractMesh): boolean;
  37617. /**
  37618. * Return a unique id as a string which can serve as an identifier for the scene
  37619. */
  37620. get uid(): string;
  37621. /**
  37622. * Add an externaly attached data from its key.
  37623. * This method call will fail and return false, if such key already exists.
  37624. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37625. * @param key the unique key that identifies the data
  37626. * @param data the data object to associate to the key for this Engine instance
  37627. * @return true if no such key were already present and the data was added successfully, false otherwise
  37628. */
  37629. addExternalData<T>(key: string, data: T): boolean;
  37630. /**
  37631. * Get an externaly attached data from its key
  37632. * @param key the unique key that identifies the data
  37633. * @return the associated data, if present (can be null), or undefined if not present
  37634. */
  37635. getExternalData<T>(key: string): Nullable<T>;
  37636. /**
  37637. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37638. * @param key the unique key that identifies the data
  37639. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37640. * @return the associated data, can be null if the factory returned null.
  37641. */
  37642. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37643. /**
  37644. * Remove an externaly attached data from the Engine instance
  37645. * @param key the unique key that identifies the data
  37646. * @return true if the data was successfully removed, false if it doesn't exist
  37647. */
  37648. removeExternalData(key: string): boolean;
  37649. private _evaluateSubMesh;
  37650. /**
  37651. * Clear the processed materials smart array preventing retention point in material dispose.
  37652. */
  37653. freeProcessedMaterials(): void;
  37654. private _preventFreeActiveMeshesAndRenderingGroups;
  37655. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37656. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37657. * when disposing several meshes in a row or a hierarchy of meshes.
  37658. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37659. */
  37660. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37661. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37662. /**
  37663. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37664. */
  37665. freeActiveMeshes(): void;
  37666. /**
  37667. * Clear the info related to rendering groups preventing retention points during dispose.
  37668. */
  37669. freeRenderingGroups(): void;
  37670. /** @hidden */
  37671. _isInIntermediateRendering(): boolean;
  37672. /**
  37673. * Lambda returning the list of potentially active meshes.
  37674. */
  37675. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37676. /**
  37677. * Lambda returning the list of potentially active sub meshes.
  37678. */
  37679. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37680. /**
  37681. * Lambda returning the list of potentially intersecting sub meshes.
  37682. */
  37683. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37684. /**
  37685. * Lambda returning the list of potentially colliding sub meshes.
  37686. */
  37687. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37688. private _activeMeshesFrozen;
  37689. private _skipEvaluateActiveMeshesCompletely;
  37690. /**
  37691. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37692. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37693. * @returns the current scene
  37694. */
  37695. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37696. /**
  37697. * Use this function to restart evaluating active meshes on every frame
  37698. * @returns the current scene
  37699. */
  37700. unfreezeActiveMeshes(): Scene;
  37701. private _evaluateActiveMeshes;
  37702. private _activeMesh;
  37703. /**
  37704. * Update the transform matrix to update from the current active camera
  37705. * @param force defines a boolean used to force the update even if cache is up to date
  37706. */
  37707. updateTransformMatrix(force?: boolean): void;
  37708. private _bindFrameBuffer;
  37709. /** @hidden */
  37710. _allowPostProcessClearColor: boolean;
  37711. /** @hidden */
  37712. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37713. private _processSubCameras;
  37714. private _checkIntersections;
  37715. /** @hidden */
  37716. _advancePhysicsEngineStep(step: number): void;
  37717. /**
  37718. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37719. */
  37720. getDeterministicFrameTime: () => number;
  37721. /** @hidden */
  37722. _animate(): void;
  37723. /** Execute all animations (for a frame) */
  37724. animate(): void;
  37725. /**
  37726. * Render the scene
  37727. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37728. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37729. */
  37730. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37731. /**
  37732. * Freeze all materials
  37733. * A frozen material will not be updatable but should be faster to render
  37734. */
  37735. freezeMaterials(): void;
  37736. /**
  37737. * Unfreeze all materials
  37738. * A frozen material will not be updatable but should be faster to render
  37739. */
  37740. unfreezeMaterials(): void;
  37741. /**
  37742. * Releases all held ressources
  37743. */
  37744. dispose(): void;
  37745. /**
  37746. * Gets if the scene is already disposed
  37747. */
  37748. get isDisposed(): boolean;
  37749. /**
  37750. * Call this function to reduce memory footprint of the scene.
  37751. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37752. */
  37753. clearCachedVertexData(): void;
  37754. /**
  37755. * This function will remove the local cached buffer data from texture.
  37756. * It will save memory but will prevent the texture from being rebuilt
  37757. */
  37758. cleanCachedTextureBuffer(): void;
  37759. /**
  37760. * Get the world extend vectors with an optional filter
  37761. *
  37762. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37763. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37764. */
  37765. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37766. min: Vector3;
  37767. max: Vector3;
  37768. };
  37769. /**
  37770. * Creates a ray that can be used to pick in the scene
  37771. * @param x defines the x coordinate of the origin (on-screen)
  37772. * @param y defines the y coordinate of the origin (on-screen)
  37773. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37774. * @param camera defines the camera to use for the picking
  37775. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37776. * @returns a Ray
  37777. */
  37778. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37779. /**
  37780. * Creates a ray that can be used to pick in the scene
  37781. * @param x defines the x coordinate of the origin (on-screen)
  37782. * @param y defines the y coordinate of the origin (on-screen)
  37783. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37784. * @param result defines the ray where to store the picking ray
  37785. * @param camera defines the camera to use for the picking
  37786. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37787. * @returns the current scene
  37788. */
  37789. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37790. /**
  37791. * Creates a ray that can be used to pick in the scene
  37792. * @param x defines the x coordinate of the origin (on-screen)
  37793. * @param y defines the y coordinate of the origin (on-screen)
  37794. * @param camera defines the camera to use for the picking
  37795. * @returns a Ray
  37796. */
  37797. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37798. /**
  37799. * Creates a ray that can be used to pick in the scene
  37800. * @param x defines the x coordinate of the origin (on-screen)
  37801. * @param y defines the y coordinate of the origin (on-screen)
  37802. * @param result defines the ray where to store the picking ray
  37803. * @param camera defines the camera to use for the picking
  37804. * @returns the current scene
  37805. */
  37806. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37807. /** Launch a ray to try to pick a mesh in the scene
  37808. * @param x position on screen
  37809. * @param y position on screen
  37810. * @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
  37811. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37812. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37813. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37814. * @returns a PickingInfo
  37815. */
  37816. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37817. /** Use the given ray to pick a mesh in the scene
  37818. * @param ray The ray to use to pick meshes
  37819. * @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
  37820. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37821. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37822. * @returns a PickingInfo
  37823. */
  37824. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37825. /**
  37826. * Launch a ray to try to pick a mesh in the scene
  37827. * @param x X position on screen
  37828. * @param y Y position on screen
  37829. * @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
  37830. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37831. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37832. * @returns an array of PickingInfo
  37833. */
  37834. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37835. /**
  37836. * Launch a ray to try to pick a mesh in the scene
  37837. * @param ray Ray to use
  37838. * @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
  37839. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37840. * @returns an array of PickingInfo
  37841. */
  37842. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37843. /**
  37844. * Force the value of meshUnderPointer
  37845. * @param mesh defines the mesh to use
  37846. */
  37847. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37848. /**
  37849. * Gets the mesh under the pointer
  37850. * @returns a Mesh or null if no mesh is under the pointer
  37851. */
  37852. getPointerOverMesh(): Nullable<AbstractMesh>;
  37853. /** @hidden */
  37854. _rebuildGeometries(): void;
  37855. /** @hidden */
  37856. _rebuildTextures(): void;
  37857. private _getByTags;
  37858. /**
  37859. * Get a list of meshes by tags
  37860. * @param tagsQuery defines the tags query to use
  37861. * @param forEach defines a predicate used to filter results
  37862. * @returns an array of Mesh
  37863. */
  37864. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37865. /**
  37866. * Get a list of cameras by tags
  37867. * @param tagsQuery defines the tags query to use
  37868. * @param forEach defines a predicate used to filter results
  37869. * @returns an array of Camera
  37870. */
  37871. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37872. /**
  37873. * Get a list of lights by tags
  37874. * @param tagsQuery defines the tags query to use
  37875. * @param forEach defines a predicate used to filter results
  37876. * @returns an array of Light
  37877. */
  37878. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37879. /**
  37880. * Get a list of materials by tags
  37881. * @param tagsQuery defines the tags query to use
  37882. * @param forEach defines a predicate used to filter results
  37883. * @returns an array of Material
  37884. */
  37885. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37886. /**
  37887. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37888. * This allowed control for front to back rendering or reversly depending of the special needs.
  37889. *
  37890. * @param renderingGroupId The rendering group id corresponding to its index
  37891. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37892. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37893. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37894. */
  37895. 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;
  37896. /**
  37897. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37898. *
  37899. * @param renderingGroupId The rendering group id corresponding to its index
  37900. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37901. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37902. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37903. */
  37904. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37905. /**
  37906. * Gets the current auto clear configuration for one rendering group of the rendering
  37907. * manager.
  37908. * @param index the rendering group index to get the information for
  37909. * @returns The auto clear setup for the requested rendering group
  37910. */
  37911. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37912. private _blockMaterialDirtyMechanism;
  37913. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37914. get blockMaterialDirtyMechanism(): boolean;
  37915. set blockMaterialDirtyMechanism(value: boolean);
  37916. /**
  37917. * Will flag all materials as dirty to trigger new shader compilation
  37918. * @param flag defines the flag used to specify which material part must be marked as dirty
  37919. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37920. */
  37921. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37922. /** @hidden */
  37923. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  37924. /** @hidden */
  37925. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37926. /** @hidden */
  37927. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  37928. /** @hidden */
  37929. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37930. /** @hidden */
  37931. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37932. /** @hidden */
  37933. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37934. }
  37935. }
  37936. declare module "babylonjs/assetContainer" {
  37937. import { AbstractScene } from "babylonjs/abstractScene";
  37938. import { Scene } from "babylonjs/scene";
  37939. import { Mesh } from "babylonjs/Meshes/mesh";
  37940. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37941. import { Skeleton } from "babylonjs/Bones/skeleton";
  37942. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37943. import { Animatable } from "babylonjs/Animations/animatable";
  37944. import { Nullable } from "babylonjs/types";
  37945. import { Node } from "babylonjs/node";
  37946. /**
  37947. * Set of assets to keep when moving a scene into an asset container.
  37948. */
  37949. export class KeepAssets extends AbstractScene {
  37950. }
  37951. /**
  37952. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37953. */
  37954. export class InstantiatedEntries {
  37955. /**
  37956. * List of new root nodes (eg. nodes with no parent)
  37957. */
  37958. rootNodes: TransformNode[];
  37959. /**
  37960. * List of new skeletons
  37961. */
  37962. skeletons: Skeleton[];
  37963. /**
  37964. * List of new animation groups
  37965. */
  37966. animationGroups: AnimationGroup[];
  37967. }
  37968. /**
  37969. * Container with a set of assets that can be added or removed from a scene.
  37970. */
  37971. export class AssetContainer extends AbstractScene {
  37972. /**
  37973. * The scene the AssetContainer belongs to.
  37974. */
  37975. scene: Scene;
  37976. /**
  37977. * Instantiates an AssetContainer.
  37978. * @param scene The scene the AssetContainer belongs to.
  37979. */
  37980. constructor(scene: Scene);
  37981. /**
  37982. * Instantiate or clone all meshes and add the new ones to the scene.
  37983. * Skeletons and animation groups will all be cloned
  37984. * @param nameFunction defines an optional function used to get new names for clones
  37985. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37986. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37987. */
  37988. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37989. /**
  37990. * Adds all the assets from the container to the scene.
  37991. */
  37992. addAllToScene(): void;
  37993. /**
  37994. * Removes all the assets in the container from the scene
  37995. */
  37996. removeAllFromScene(): void;
  37997. /**
  37998. * Disposes all the assets in the container
  37999. */
  38000. dispose(): void;
  38001. private _moveAssets;
  38002. /**
  38003. * Removes all the assets contained in the scene and adds them to the container.
  38004. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38005. */
  38006. moveAllFromScene(keepAssets?: KeepAssets): void;
  38007. /**
  38008. * 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.
  38009. * @returns the root mesh
  38010. */
  38011. createRootMesh(): Mesh;
  38012. /**
  38013. * Merge animations from this asset container into a scene
  38014. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38015. * @param animatables set of animatables to retarget to a node from the scene
  38016. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38017. */
  38018. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  38019. }
  38020. }
  38021. declare module "babylonjs/abstractScene" {
  38022. import { Scene } from "babylonjs/scene";
  38023. import { Nullable } from "babylonjs/types";
  38024. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38025. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38026. import { Geometry } from "babylonjs/Meshes/geometry";
  38027. import { Skeleton } from "babylonjs/Bones/skeleton";
  38028. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38029. import { AssetContainer } from "babylonjs/assetContainer";
  38030. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38031. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38032. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38033. import { Material } from "babylonjs/Materials/material";
  38034. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38035. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38036. import { Camera } from "babylonjs/Cameras/camera";
  38037. import { Light } from "babylonjs/Lights/light";
  38038. import { Node } from "babylonjs/node";
  38039. import { Animation } from "babylonjs/Animations/animation";
  38040. /**
  38041. * Defines how the parser contract is defined.
  38042. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38043. */
  38044. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38045. /**
  38046. * Defines how the individual parser contract is defined.
  38047. * These parser can parse an individual asset
  38048. */
  38049. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38050. /**
  38051. * Base class of the scene acting as a container for the different elements composing a scene.
  38052. * This class is dynamically extended by the different components of the scene increasing
  38053. * flexibility and reducing coupling
  38054. */
  38055. export abstract class AbstractScene {
  38056. /**
  38057. * Stores the list of available parsers in the application.
  38058. */
  38059. private static _BabylonFileParsers;
  38060. /**
  38061. * Stores the list of available individual parsers in the application.
  38062. */
  38063. private static _IndividualBabylonFileParsers;
  38064. /**
  38065. * Adds a parser in the list of available ones
  38066. * @param name Defines the name of the parser
  38067. * @param parser Defines the parser to add
  38068. */
  38069. static AddParser(name: string, parser: BabylonFileParser): void;
  38070. /**
  38071. * Gets a general parser from the list of avaialble ones
  38072. * @param name Defines the name of the parser
  38073. * @returns the requested parser or null
  38074. */
  38075. static GetParser(name: string): Nullable<BabylonFileParser>;
  38076. /**
  38077. * Adds n individual parser in the list of available ones
  38078. * @param name Defines the name of the parser
  38079. * @param parser Defines the parser to add
  38080. */
  38081. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38082. /**
  38083. * Gets an individual parser from the list of avaialble ones
  38084. * @param name Defines the name of the parser
  38085. * @returns the requested parser or null
  38086. */
  38087. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38088. /**
  38089. * Parser json data and populate both a scene and its associated container object
  38090. * @param jsonData Defines the data to parse
  38091. * @param scene Defines the scene to parse the data for
  38092. * @param container Defines the container attached to the parsing sequence
  38093. * @param rootUrl Defines the root url of the data
  38094. */
  38095. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38096. /**
  38097. * Gets the list of root nodes (ie. nodes with no parent)
  38098. */
  38099. rootNodes: Node[];
  38100. /** All of the cameras added to this scene
  38101. * @see http://doc.babylonjs.com/babylon101/cameras
  38102. */
  38103. cameras: Camera[];
  38104. /**
  38105. * All of the lights added to this scene
  38106. * @see http://doc.babylonjs.com/babylon101/lights
  38107. */
  38108. lights: Light[];
  38109. /**
  38110. * All of the (abstract) meshes added to this scene
  38111. */
  38112. meshes: AbstractMesh[];
  38113. /**
  38114. * The list of skeletons added to the scene
  38115. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38116. */
  38117. skeletons: Skeleton[];
  38118. /**
  38119. * All of the particle systems added to this scene
  38120. * @see http://doc.babylonjs.com/babylon101/particles
  38121. */
  38122. particleSystems: IParticleSystem[];
  38123. /**
  38124. * Gets a list of Animations associated with the scene
  38125. */
  38126. animations: Animation[];
  38127. /**
  38128. * All of the animation groups added to this scene
  38129. * @see http://doc.babylonjs.com/how_to/group
  38130. */
  38131. animationGroups: AnimationGroup[];
  38132. /**
  38133. * All of the multi-materials added to this scene
  38134. * @see http://doc.babylonjs.com/how_to/multi_materials
  38135. */
  38136. multiMaterials: MultiMaterial[];
  38137. /**
  38138. * All of the materials added to this scene
  38139. * In the context of a Scene, it is not supposed to be modified manually.
  38140. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38141. * Note also that the order of the Material within the array is not significant and might change.
  38142. * @see http://doc.babylonjs.com/babylon101/materials
  38143. */
  38144. materials: Material[];
  38145. /**
  38146. * The list of morph target managers added to the scene
  38147. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38148. */
  38149. morphTargetManagers: MorphTargetManager[];
  38150. /**
  38151. * The list of geometries used in the scene.
  38152. */
  38153. geometries: Geometry[];
  38154. /**
  38155. * All of the tranform nodes added to this scene
  38156. * In the context of a Scene, it is not supposed to be modified manually.
  38157. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38158. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38159. * @see http://doc.babylonjs.com/how_to/transformnode
  38160. */
  38161. transformNodes: TransformNode[];
  38162. /**
  38163. * ActionManagers available on the scene.
  38164. */
  38165. actionManagers: AbstractActionManager[];
  38166. /**
  38167. * Textures to keep.
  38168. */
  38169. textures: BaseTexture[];
  38170. /**
  38171. * Environment texture for the scene
  38172. */
  38173. environmentTexture: Nullable<BaseTexture>;
  38174. /**
  38175. * @returns all meshes, lights, cameras, transformNodes and bones
  38176. */
  38177. getNodes(): Array<Node>;
  38178. }
  38179. }
  38180. declare module "babylonjs/Audio/sound" {
  38181. import { Observable } from "babylonjs/Misc/observable";
  38182. import { Vector3 } from "babylonjs/Maths/math.vector";
  38183. import { Nullable } from "babylonjs/types";
  38184. import { Scene } from "babylonjs/scene";
  38185. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38186. /**
  38187. * Interface used to define options for Sound class
  38188. */
  38189. export interface ISoundOptions {
  38190. /**
  38191. * Does the sound autoplay once loaded.
  38192. */
  38193. autoplay?: boolean;
  38194. /**
  38195. * Does the sound loop after it finishes playing once.
  38196. */
  38197. loop?: boolean;
  38198. /**
  38199. * Sound's volume
  38200. */
  38201. volume?: number;
  38202. /**
  38203. * Is it a spatial sound?
  38204. */
  38205. spatialSound?: boolean;
  38206. /**
  38207. * Maximum distance to hear that sound
  38208. */
  38209. maxDistance?: number;
  38210. /**
  38211. * Uses user defined attenuation function
  38212. */
  38213. useCustomAttenuation?: boolean;
  38214. /**
  38215. * Define the roll off factor of spatial sounds.
  38216. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38217. */
  38218. rolloffFactor?: number;
  38219. /**
  38220. * Define the reference distance the sound should be heard perfectly.
  38221. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38222. */
  38223. refDistance?: number;
  38224. /**
  38225. * Define the distance attenuation model the sound will follow.
  38226. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38227. */
  38228. distanceModel?: string;
  38229. /**
  38230. * Defines the playback speed (1 by default)
  38231. */
  38232. playbackRate?: number;
  38233. /**
  38234. * Defines if the sound is from a streaming source
  38235. */
  38236. streaming?: boolean;
  38237. /**
  38238. * Defines an optional length (in seconds) inside the sound file
  38239. */
  38240. length?: number;
  38241. /**
  38242. * Defines an optional offset (in seconds) inside the sound file
  38243. */
  38244. offset?: number;
  38245. /**
  38246. * If true, URLs will not be required to state the audio file codec to use.
  38247. */
  38248. skipCodecCheck?: boolean;
  38249. }
  38250. /**
  38251. * Defines a sound that can be played in the application.
  38252. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38253. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38254. */
  38255. export class Sound {
  38256. /**
  38257. * The name of the sound in the scene.
  38258. */
  38259. name: string;
  38260. /**
  38261. * Does the sound autoplay once loaded.
  38262. */
  38263. autoplay: boolean;
  38264. /**
  38265. * Does the sound loop after it finishes playing once.
  38266. */
  38267. loop: boolean;
  38268. /**
  38269. * Does the sound use a custom attenuation curve to simulate the falloff
  38270. * happening when the source gets further away from the camera.
  38271. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38272. */
  38273. useCustomAttenuation: boolean;
  38274. /**
  38275. * The sound track id this sound belongs to.
  38276. */
  38277. soundTrackId: number;
  38278. /**
  38279. * Is this sound currently played.
  38280. */
  38281. isPlaying: boolean;
  38282. /**
  38283. * Is this sound currently paused.
  38284. */
  38285. isPaused: boolean;
  38286. /**
  38287. * Does this sound enables spatial sound.
  38288. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38289. */
  38290. spatialSound: boolean;
  38291. /**
  38292. * Define the reference distance the sound should be heard perfectly.
  38293. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38294. */
  38295. refDistance: number;
  38296. /**
  38297. * Define the roll off factor of spatial sounds.
  38298. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38299. */
  38300. rolloffFactor: number;
  38301. /**
  38302. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38303. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38304. */
  38305. maxDistance: number;
  38306. /**
  38307. * Define the distance attenuation model the sound will follow.
  38308. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38309. */
  38310. distanceModel: string;
  38311. /**
  38312. * @hidden
  38313. * Back Compat
  38314. **/
  38315. onended: () => any;
  38316. /**
  38317. * Observable event when the current playing sound finishes.
  38318. */
  38319. onEndedObservable: Observable<Sound>;
  38320. private _panningModel;
  38321. private _playbackRate;
  38322. private _streaming;
  38323. private _startTime;
  38324. private _startOffset;
  38325. private _position;
  38326. /** @hidden */
  38327. _positionInEmitterSpace: boolean;
  38328. private _localDirection;
  38329. private _volume;
  38330. private _isReadyToPlay;
  38331. private _isDirectional;
  38332. private _readyToPlayCallback;
  38333. private _audioBuffer;
  38334. private _soundSource;
  38335. private _streamingSource;
  38336. private _soundPanner;
  38337. private _soundGain;
  38338. private _inputAudioNode;
  38339. private _outputAudioNode;
  38340. private _coneInnerAngle;
  38341. private _coneOuterAngle;
  38342. private _coneOuterGain;
  38343. private _scene;
  38344. private _connectedTransformNode;
  38345. private _customAttenuationFunction;
  38346. private _registerFunc;
  38347. private _isOutputConnected;
  38348. private _htmlAudioElement;
  38349. private _urlType;
  38350. private _length?;
  38351. private _offset?;
  38352. /** @hidden */
  38353. static _SceneComponentInitialization: (scene: Scene) => void;
  38354. /**
  38355. * Create a sound and attach it to a scene
  38356. * @param name Name of your sound
  38357. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38358. * @param scene defines the scene the sound belongs to
  38359. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38360. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38361. */
  38362. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38363. /**
  38364. * Release the sound and its associated resources
  38365. */
  38366. dispose(): void;
  38367. /**
  38368. * Gets if the sounds is ready to be played or not.
  38369. * @returns true if ready, otherwise false
  38370. */
  38371. isReady(): boolean;
  38372. private _soundLoaded;
  38373. /**
  38374. * Sets the data of the sound from an audiobuffer
  38375. * @param audioBuffer The audioBuffer containing the data
  38376. */
  38377. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38378. /**
  38379. * Updates the current sounds options such as maxdistance, loop...
  38380. * @param options A JSON object containing values named as the object properties
  38381. */
  38382. updateOptions(options: ISoundOptions): void;
  38383. private _createSpatialParameters;
  38384. private _updateSpatialParameters;
  38385. /**
  38386. * Switch the panning model to HRTF:
  38387. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38388. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38389. */
  38390. switchPanningModelToHRTF(): void;
  38391. /**
  38392. * Switch the panning model to Equal Power:
  38393. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38394. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38395. */
  38396. switchPanningModelToEqualPower(): void;
  38397. private _switchPanningModel;
  38398. /**
  38399. * Connect this sound to a sound track audio node like gain...
  38400. * @param soundTrackAudioNode the sound track audio node to connect to
  38401. */
  38402. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38403. /**
  38404. * Transform this sound into a directional source
  38405. * @param coneInnerAngle Size of the inner cone in degree
  38406. * @param coneOuterAngle Size of the outer cone in degree
  38407. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38408. */
  38409. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38410. /**
  38411. * Gets or sets the inner angle for the directional cone.
  38412. */
  38413. get directionalConeInnerAngle(): number;
  38414. /**
  38415. * Gets or sets the inner angle for the directional cone.
  38416. */
  38417. set directionalConeInnerAngle(value: number);
  38418. /**
  38419. * Gets or sets the outer angle for the directional cone.
  38420. */
  38421. get directionalConeOuterAngle(): number;
  38422. /**
  38423. * Gets or sets the outer angle for the directional cone.
  38424. */
  38425. set directionalConeOuterAngle(value: number);
  38426. /**
  38427. * Sets the position of the emitter if spatial sound is enabled
  38428. * @param newPosition Defines the new posisiton
  38429. */
  38430. setPosition(newPosition: Vector3): void;
  38431. /**
  38432. * Sets the local direction of the emitter if spatial sound is enabled
  38433. * @param newLocalDirection Defines the new local direction
  38434. */
  38435. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38436. private _updateDirection;
  38437. /** @hidden */
  38438. updateDistanceFromListener(): void;
  38439. /**
  38440. * Sets a new custom attenuation function for the sound.
  38441. * @param callback Defines the function used for the attenuation
  38442. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38443. */
  38444. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38445. /**
  38446. * Play the sound
  38447. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38448. * @param offset (optional) Start the sound at a specific time in seconds
  38449. * @param length (optional) Sound duration (in seconds)
  38450. */
  38451. play(time?: number, offset?: number, length?: number): void;
  38452. private _onended;
  38453. /**
  38454. * Stop the sound
  38455. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38456. */
  38457. stop(time?: number): void;
  38458. /**
  38459. * Put the sound in pause
  38460. */
  38461. pause(): void;
  38462. /**
  38463. * Sets a dedicated volume for this sounds
  38464. * @param newVolume Define the new volume of the sound
  38465. * @param time Define time for gradual change to new volume
  38466. */
  38467. setVolume(newVolume: number, time?: number): void;
  38468. /**
  38469. * Set the sound play back rate
  38470. * @param newPlaybackRate Define the playback rate the sound should be played at
  38471. */
  38472. setPlaybackRate(newPlaybackRate: number): void;
  38473. /**
  38474. * Gets the volume of the sound.
  38475. * @returns the volume of the sound
  38476. */
  38477. getVolume(): number;
  38478. /**
  38479. * Attach the sound to a dedicated mesh
  38480. * @param transformNode The transform node to connect the sound with
  38481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38482. */
  38483. attachToMesh(transformNode: TransformNode): void;
  38484. /**
  38485. * Detach the sound from the previously attached mesh
  38486. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38487. */
  38488. detachFromMesh(): void;
  38489. private _onRegisterAfterWorldMatrixUpdate;
  38490. /**
  38491. * Clone the current sound in the scene.
  38492. * @returns the new sound clone
  38493. */
  38494. clone(): Nullable<Sound>;
  38495. /**
  38496. * Gets the current underlying audio buffer containing the data
  38497. * @returns the audio buffer
  38498. */
  38499. getAudioBuffer(): Nullable<AudioBuffer>;
  38500. /**
  38501. * Serializes the Sound in a JSON representation
  38502. * @returns the JSON representation of the sound
  38503. */
  38504. serialize(): any;
  38505. /**
  38506. * Parse a JSON representation of a sound to innstantiate in a given scene
  38507. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38508. * @param scene Define the scene the new parsed sound should be created in
  38509. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38510. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38511. * @returns the newly parsed sound
  38512. */
  38513. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38514. }
  38515. }
  38516. declare module "babylonjs/Actions/directAudioActions" {
  38517. import { Action } from "babylonjs/Actions/action";
  38518. import { Condition } from "babylonjs/Actions/condition";
  38519. import { Sound } from "babylonjs/Audio/sound";
  38520. /**
  38521. * This defines an action helpful to play a defined sound on a triggered action.
  38522. */
  38523. export class PlaySoundAction extends Action {
  38524. private _sound;
  38525. /**
  38526. * Instantiate the action
  38527. * @param triggerOptions defines the trigger options
  38528. * @param sound defines the sound to play
  38529. * @param condition defines the trigger related conditions
  38530. */
  38531. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38532. /** @hidden */
  38533. _prepare(): void;
  38534. /**
  38535. * Execute the action and play the sound.
  38536. */
  38537. execute(): void;
  38538. /**
  38539. * Serializes the actions and its related information.
  38540. * @param parent defines the object to serialize in
  38541. * @returns the serialized object
  38542. */
  38543. serialize(parent: any): any;
  38544. }
  38545. /**
  38546. * This defines an action helpful to stop a defined sound on a triggered action.
  38547. */
  38548. export class StopSoundAction extends Action {
  38549. private _sound;
  38550. /**
  38551. * Instantiate the action
  38552. * @param triggerOptions defines the trigger options
  38553. * @param sound defines the sound to stop
  38554. * @param condition defines the trigger related conditions
  38555. */
  38556. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38557. /** @hidden */
  38558. _prepare(): void;
  38559. /**
  38560. * Execute the action and stop the sound.
  38561. */
  38562. execute(): void;
  38563. /**
  38564. * Serializes the actions and its related information.
  38565. * @param parent defines the object to serialize in
  38566. * @returns the serialized object
  38567. */
  38568. serialize(parent: any): any;
  38569. }
  38570. }
  38571. declare module "babylonjs/Actions/interpolateValueAction" {
  38572. import { Action } from "babylonjs/Actions/action";
  38573. import { Condition } from "babylonjs/Actions/condition";
  38574. import { Observable } from "babylonjs/Misc/observable";
  38575. /**
  38576. * This defines an action responsible to change the value of a property
  38577. * by interpolating between its current value and the newly set one once triggered.
  38578. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38579. */
  38580. export class InterpolateValueAction extends Action {
  38581. /**
  38582. * Defines the path of the property where the value should be interpolated
  38583. */
  38584. propertyPath: string;
  38585. /**
  38586. * Defines the target value at the end of the interpolation.
  38587. */
  38588. value: any;
  38589. /**
  38590. * Defines the time it will take for the property to interpolate to the value.
  38591. */
  38592. duration: number;
  38593. /**
  38594. * Defines if the other scene animations should be stopped when the action has been triggered
  38595. */
  38596. stopOtherAnimations?: boolean;
  38597. /**
  38598. * Defines a callback raised once the interpolation animation has been done.
  38599. */
  38600. onInterpolationDone?: () => void;
  38601. /**
  38602. * Observable triggered once the interpolation animation has been done.
  38603. */
  38604. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38605. private _target;
  38606. private _effectiveTarget;
  38607. private _property;
  38608. /**
  38609. * Instantiate the action
  38610. * @param triggerOptions defines the trigger options
  38611. * @param target defines the object containing the value to interpolate
  38612. * @param propertyPath defines the path to the property in the target object
  38613. * @param value defines the target value at the end of the interpolation
  38614. * @param duration deines the time it will take for the property to interpolate to the value.
  38615. * @param condition defines the trigger related conditions
  38616. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38617. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38618. */
  38619. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38620. /** @hidden */
  38621. _prepare(): void;
  38622. /**
  38623. * Execute the action starts the value interpolation.
  38624. */
  38625. execute(): void;
  38626. /**
  38627. * Serializes the actions and its related information.
  38628. * @param parent defines the object to serialize in
  38629. * @returns the serialized object
  38630. */
  38631. serialize(parent: any): any;
  38632. }
  38633. }
  38634. declare module "babylonjs/Actions/index" {
  38635. export * from "babylonjs/Actions/abstractActionManager";
  38636. export * from "babylonjs/Actions/action";
  38637. export * from "babylonjs/Actions/actionEvent";
  38638. export * from "babylonjs/Actions/actionManager";
  38639. export * from "babylonjs/Actions/condition";
  38640. export * from "babylonjs/Actions/directActions";
  38641. export * from "babylonjs/Actions/directAudioActions";
  38642. export * from "babylonjs/Actions/interpolateValueAction";
  38643. }
  38644. declare module "babylonjs/Animations/index" {
  38645. export * from "babylonjs/Animations/animatable";
  38646. export * from "babylonjs/Animations/animation";
  38647. export * from "babylonjs/Animations/animationGroup";
  38648. export * from "babylonjs/Animations/animationPropertiesOverride";
  38649. export * from "babylonjs/Animations/easing";
  38650. export * from "babylonjs/Animations/runtimeAnimation";
  38651. export * from "babylonjs/Animations/animationEvent";
  38652. export * from "babylonjs/Animations/animationGroup";
  38653. export * from "babylonjs/Animations/animationKey";
  38654. export * from "babylonjs/Animations/animationRange";
  38655. export * from "babylonjs/Animations/animatable.interface";
  38656. }
  38657. declare module "babylonjs/Audio/soundTrack" {
  38658. import { Sound } from "babylonjs/Audio/sound";
  38659. import { Analyser } from "babylonjs/Audio/analyser";
  38660. import { Scene } from "babylonjs/scene";
  38661. /**
  38662. * Options allowed during the creation of a sound track.
  38663. */
  38664. export interface ISoundTrackOptions {
  38665. /**
  38666. * The volume the sound track should take during creation
  38667. */
  38668. volume?: number;
  38669. /**
  38670. * Define if the sound track is the main sound track of the scene
  38671. */
  38672. mainTrack?: boolean;
  38673. }
  38674. /**
  38675. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38676. * It will be also used in a future release to apply effects on a specific track.
  38677. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38678. */
  38679. export class SoundTrack {
  38680. /**
  38681. * The unique identifier of the sound track in the scene.
  38682. */
  38683. id: number;
  38684. /**
  38685. * The list of sounds included in the sound track.
  38686. */
  38687. soundCollection: Array<Sound>;
  38688. private _outputAudioNode;
  38689. private _scene;
  38690. private _connectedAnalyser;
  38691. private _options;
  38692. private _isInitialized;
  38693. /**
  38694. * Creates a new sound track.
  38695. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38696. * @param scene Define the scene the sound track belongs to
  38697. * @param options
  38698. */
  38699. constructor(scene: Scene, options?: ISoundTrackOptions);
  38700. private _initializeSoundTrackAudioGraph;
  38701. /**
  38702. * Release the sound track and its associated resources
  38703. */
  38704. dispose(): void;
  38705. /**
  38706. * Adds a sound to this sound track
  38707. * @param sound define the cound to add
  38708. * @ignoreNaming
  38709. */
  38710. AddSound(sound: Sound): void;
  38711. /**
  38712. * Removes a sound to this sound track
  38713. * @param sound define the cound to remove
  38714. * @ignoreNaming
  38715. */
  38716. RemoveSound(sound: Sound): void;
  38717. /**
  38718. * Set a global volume for the full sound track.
  38719. * @param newVolume Define the new volume of the sound track
  38720. */
  38721. setVolume(newVolume: number): void;
  38722. /**
  38723. * Switch the panning model to HRTF:
  38724. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38725. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38726. */
  38727. switchPanningModelToHRTF(): void;
  38728. /**
  38729. * Switch the panning model to Equal Power:
  38730. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38731. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38732. */
  38733. switchPanningModelToEqualPower(): void;
  38734. /**
  38735. * Connect the sound track to an audio analyser allowing some amazing
  38736. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38737. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38738. * @param analyser The analyser to connect to the engine
  38739. */
  38740. connectToAnalyser(analyser: Analyser): void;
  38741. }
  38742. }
  38743. declare module "babylonjs/Audio/audioSceneComponent" {
  38744. import { Sound } from "babylonjs/Audio/sound";
  38745. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38746. import { Nullable } from "babylonjs/types";
  38747. import { Vector3 } from "babylonjs/Maths/math.vector";
  38748. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38749. import { Scene } from "babylonjs/scene";
  38750. import { AbstractScene } from "babylonjs/abstractScene";
  38751. import "babylonjs/Audio/audioEngine";
  38752. module "babylonjs/abstractScene" {
  38753. interface AbstractScene {
  38754. /**
  38755. * The list of sounds used in the scene.
  38756. */
  38757. sounds: Nullable<Array<Sound>>;
  38758. }
  38759. }
  38760. module "babylonjs/scene" {
  38761. interface Scene {
  38762. /**
  38763. * @hidden
  38764. * Backing field
  38765. */
  38766. _mainSoundTrack: SoundTrack;
  38767. /**
  38768. * The main sound track played by the scene.
  38769. * It cotains your primary collection of sounds.
  38770. */
  38771. mainSoundTrack: SoundTrack;
  38772. /**
  38773. * The list of sound tracks added to the scene
  38774. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38775. */
  38776. soundTracks: Nullable<Array<SoundTrack>>;
  38777. /**
  38778. * Gets a sound using a given name
  38779. * @param name defines the name to search for
  38780. * @return the found sound or null if not found at all.
  38781. */
  38782. getSoundByName(name: string): Nullable<Sound>;
  38783. /**
  38784. * Gets or sets if audio support is enabled
  38785. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38786. */
  38787. audioEnabled: boolean;
  38788. /**
  38789. * Gets or sets if audio will be output to headphones
  38790. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38791. */
  38792. headphone: boolean;
  38793. /**
  38794. * Gets or sets custom audio listener position provider
  38795. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38796. */
  38797. audioListenerPositionProvider: Nullable<() => Vector3>;
  38798. /**
  38799. * Gets or sets a refresh rate when using 3D audio positioning
  38800. */
  38801. audioPositioningRefreshRate: number;
  38802. }
  38803. }
  38804. /**
  38805. * Defines the sound scene component responsible to manage any sounds
  38806. * in a given scene.
  38807. */
  38808. export class AudioSceneComponent implements ISceneSerializableComponent {
  38809. /**
  38810. * The component name helpfull to identify the component in the list of scene components.
  38811. */
  38812. readonly name: string;
  38813. /**
  38814. * The scene the component belongs to.
  38815. */
  38816. scene: Scene;
  38817. private _audioEnabled;
  38818. /**
  38819. * Gets whether audio is enabled or not.
  38820. * Please use related enable/disable method to switch state.
  38821. */
  38822. get audioEnabled(): boolean;
  38823. private _headphone;
  38824. /**
  38825. * Gets whether audio is outputing to headphone or not.
  38826. * Please use the according Switch methods to change output.
  38827. */
  38828. get headphone(): boolean;
  38829. /**
  38830. * Gets or sets a refresh rate when using 3D audio positioning
  38831. */
  38832. audioPositioningRefreshRate: number;
  38833. private _audioListenerPositionProvider;
  38834. /**
  38835. * Gets the current audio listener position provider
  38836. */
  38837. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38838. /**
  38839. * Sets a custom listener position for all sounds in the scene
  38840. * By default, this is the position of the first active camera
  38841. */
  38842. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38843. /**
  38844. * Creates a new instance of the component for the given scene
  38845. * @param scene Defines the scene to register the component in
  38846. */
  38847. constructor(scene: Scene);
  38848. /**
  38849. * Registers the component in a given scene
  38850. */
  38851. register(): void;
  38852. /**
  38853. * Rebuilds the elements related to this component in case of
  38854. * context lost for instance.
  38855. */
  38856. rebuild(): void;
  38857. /**
  38858. * Serializes the component data to the specified json object
  38859. * @param serializationObject The object to serialize to
  38860. */
  38861. serialize(serializationObject: any): void;
  38862. /**
  38863. * Adds all the elements from the container to the scene
  38864. * @param container the container holding the elements
  38865. */
  38866. addFromContainer(container: AbstractScene): void;
  38867. /**
  38868. * Removes all the elements in the container from the scene
  38869. * @param container contains the elements to remove
  38870. * @param dispose if the removed element should be disposed (default: false)
  38871. */
  38872. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38873. /**
  38874. * Disposes the component and the associated ressources.
  38875. */
  38876. dispose(): void;
  38877. /**
  38878. * Disables audio in the associated scene.
  38879. */
  38880. disableAudio(): void;
  38881. /**
  38882. * Enables audio in the associated scene.
  38883. */
  38884. enableAudio(): void;
  38885. /**
  38886. * Switch audio to headphone output.
  38887. */
  38888. switchAudioModeForHeadphones(): void;
  38889. /**
  38890. * Switch audio to normal speakers.
  38891. */
  38892. switchAudioModeForNormalSpeakers(): void;
  38893. private _cachedCameraDirection;
  38894. private _cachedCameraPosition;
  38895. private _lastCheck;
  38896. private _afterRender;
  38897. }
  38898. }
  38899. declare module "babylonjs/Audio/weightedsound" {
  38900. import { Sound } from "babylonjs/Audio/sound";
  38901. /**
  38902. * Wraps one or more Sound objects and selects one with random weight for playback.
  38903. */
  38904. export class WeightedSound {
  38905. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38906. loop: boolean;
  38907. private _coneInnerAngle;
  38908. private _coneOuterAngle;
  38909. private _volume;
  38910. /** A Sound is currently playing. */
  38911. isPlaying: boolean;
  38912. /** A Sound is currently paused. */
  38913. isPaused: boolean;
  38914. private _sounds;
  38915. private _weights;
  38916. private _currentIndex?;
  38917. /**
  38918. * Creates a new WeightedSound from the list of sounds given.
  38919. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38920. * @param sounds Array of Sounds that will be selected from.
  38921. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38922. */
  38923. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38924. /**
  38925. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38926. */
  38927. get directionalConeInnerAngle(): number;
  38928. /**
  38929. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38930. */
  38931. set directionalConeInnerAngle(value: number);
  38932. /**
  38933. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38934. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38935. */
  38936. get directionalConeOuterAngle(): number;
  38937. /**
  38938. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38939. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38940. */
  38941. set directionalConeOuterAngle(value: number);
  38942. /**
  38943. * Playback volume.
  38944. */
  38945. get volume(): number;
  38946. /**
  38947. * Playback volume.
  38948. */
  38949. set volume(value: number);
  38950. private _onended;
  38951. /**
  38952. * Suspend playback
  38953. */
  38954. pause(): void;
  38955. /**
  38956. * Stop playback
  38957. */
  38958. stop(): void;
  38959. /**
  38960. * Start playback.
  38961. * @param startOffset Position the clip head at a specific time in seconds.
  38962. */
  38963. play(startOffset?: number): void;
  38964. }
  38965. }
  38966. declare module "babylonjs/Audio/index" {
  38967. export * from "babylonjs/Audio/analyser";
  38968. export * from "babylonjs/Audio/audioEngine";
  38969. export * from "babylonjs/Audio/audioSceneComponent";
  38970. export * from "babylonjs/Audio/sound";
  38971. export * from "babylonjs/Audio/soundTrack";
  38972. export * from "babylonjs/Audio/weightedsound";
  38973. }
  38974. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  38975. import { Behavior } from "babylonjs/Behaviors/behavior";
  38976. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38977. import { BackEase } from "babylonjs/Animations/easing";
  38978. /**
  38979. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38980. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38981. */
  38982. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38983. /**
  38984. * Gets the name of the behavior.
  38985. */
  38986. get name(): string;
  38987. /**
  38988. * The easing function used by animations
  38989. */
  38990. static EasingFunction: BackEase;
  38991. /**
  38992. * The easing mode used by animations
  38993. */
  38994. static EasingMode: number;
  38995. /**
  38996. * The duration of the animation, in milliseconds
  38997. */
  38998. transitionDuration: number;
  38999. /**
  39000. * Length of the distance animated by the transition when lower radius is reached
  39001. */
  39002. lowerRadiusTransitionRange: number;
  39003. /**
  39004. * Length of the distance animated by the transition when upper radius is reached
  39005. */
  39006. upperRadiusTransitionRange: number;
  39007. private _autoTransitionRange;
  39008. /**
  39009. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39010. */
  39011. get autoTransitionRange(): boolean;
  39012. /**
  39013. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39014. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39015. */
  39016. set autoTransitionRange(value: boolean);
  39017. private _attachedCamera;
  39018. private _onAfterCheckInputsObserver;
  39019. private _onMeshTargetChangedObserver;
  39020. /**
  39021. * Initializes the behavior.
  39022. */
  39023. init(): void;
  39024. /**
  39025. * Attaches the behavior to its arc rotate camera.
  39026. * @param camera Defines the camera to attach the behavior to
  39027. */
  39028. attach(camera: ArcRotateCamera): void;
  39029. /**
  39030. * Detaches the behavior from its current arc rotate camera.
  39031. */
  39032. detach(): void;
  39033. private _radiusIsAnimating;
  39034. private _radiusBounceTransition;
  39035. private _animatables;
  39036. private _cachedWheelPrecision;
  39037. /**
  39038. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39039. * @param radiusLimit The limit to check against.
  39040. * @return Bool to indicate if at limit.
  39041. */
  39042. private _isRadiusAtLimit;
  39043. /**
  39044. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39045. * @param radiusDelta The delta by which to animate to. Can be negative.
  39046. */
  39047. private _applyBoundRadiusAnimation;
  39048. /**
  39049. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39050. */
  39051. protected _clearAnimationLocks(): void;
  39052. /**
  39053. * Stops and removes all animations that have been applied to the camera
  39054. */
  39055. stopAllAnimations(): void;
  39056. }
  39057. }
  39058. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39059. import { Behavior } from "babylonjs/Behaviors/behavior";
  39060. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39061. import { ExponentialEase } from "babylonjs/Animations/easing";
  39062. import { Nullable } from "babylonjs/types";
  39063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39064. import { Vector3 } from "babylonjs/Maths/math.vector";
  39065. /**
  39066. * 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.
  39067. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39068. */
  39069. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39070. /**
  39071. * Gets the name of the behavior.
  39072. */
  39073. get name(): string;
  39074. private _mode;
  39075. private _radiusScale;
  39076. private _positionScale;
  39077. private _defaultElevation;
  39078. private _elevationReturnTime;
  39079. private _elevationReturnWaitTime;
  39080. private _zoomStopsAnimation;
  39081. private _framingTime;
  39082. /**
  39083. * The easing function used by animations
  39084. */
  39085. static EasingFunction: ExponentialEase;
  39086. /**
  39087. * The easing mode used by animations
  39088. */
  39089. static EasingMode: number;
  39090. /**
  39091. * Sets the current mode used by the behavior
  39092. */
  39093. set mode(mode: number);
  39094. /**
  39095. * Gets current mode used by the behavior.
  39096. */
  39097. get mode(): number;
  39098. /**
  39099. * Sets the scale applied to the radius (1 by default)
  39100. */
  39101. set radiusScale(radius: number);
  39102. /**
  39103. * Gets the scale applied to the radius
  39104. */
  39105. get radiusScale(): number;
  39106. /**
  39107. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39108. */
  39109. set positionScale(scale: number);
  39110. /**
  39111. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39112. */
  39113. get positionScale(): number;
  39114. /**
  39115. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39116. * behaviour is triggered, in radians.
  39117. */
  39118. set defaultElevation(elevation: number);
  39119. /**
  39120. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39121. * behaviour is triggered, in radians.
  39122. */
  39123. get defaultElevation(): number;
  39124. /**
  39125. * Sets the time (in milliseconds) taken to return to the default beta position.
  39126. * Negative value indicates camera should not return to default.
  39127. */
  39128. set elevationReturnTime(speed: number);
  39129. /**
  39130. * Gets the time (in milliseconds) taken to return to the default beta position.
  39131. * Negative value indicates camera should not return to default.
  39132. */
  39133. get elevationReturnTime(): number;
  39134. /**
  39135. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39136. */
  39137. set elevationReturnWaitTime(time: number);
  39138. /**
  39139. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39140. */
  39141. get elevationReturnWaitTime(): number;
  39142. /**
  39143. * Sets the flag that indicates if user zooming should stop animation.
  39144. */
  39145. set zoomStopsAnimation(flag: boolean);
  39146. /**
  39147. * Gets the flag that indicates if user zooming should stop animation.
  39148. */
  39149. get zoomStopsAnimation(): boolean;
  39150. /**
  39151. * Sets the transition time when framing the mesh, in milliseconds
  39152. */
  39153. set framingTime(time: number);
  39154. /**
  39155. * Gets the transition time when framing the mesh, in milliseconds
  39156. */
  39157. get framingTime(): number;
  39158. /**
  39159. * Define if the behavior should automatically change the configured
  39160. * camera limits and sensibilities.
  39161. */
  39162. autoCorrectCameraLimitsAndSensibility: boolean;
  39163. private _onPrePointerObservableObserver;
  39164. private _onAfterCheckInputsObserver;
  39165. private _onMeshTargetChangedObserver;
  39166. private _attachedCamera;
  39167. private _isPointerDown;
  39168. private _lastInteractionTime;
  39169. /**
  39170. * Initializes the behavior.
  39171. */
  39172. init(): void;
  39173. /**
  39174. * Attaches the behavior to its arc rotate camera.
  39175. * @param camera Defines the camera to attach the behavior to
  39176. */
  39177. attach(camera: ArcRotateCamera): void;
  39178. /**
  39179. * Detaches the behavior from its current arc rotate camera.
  39180. */
  39181. detach(): void;
  39182. private _animatables;
  39183. private _betaIsAnimating;
  39184. private _betaTransition;
  39185. private _radiusTransition;
  39186. private _vectorTransition;
  39187. /**
  39188. * Targets the given mesh and updates zoom level accordingly.
  39189. * @param mesh The mesh to target.
  39190. * @param radius Optional. If a cached radius position already exists, overrides default.
  39191. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39192. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39193. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39194. */
  39195. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39196. /**
  39197. * Targets the given mesh with its children and updates zoom level accordingly.
  39198. * @param mesh The mesh to target.
  39199. * @param radius Optional. If a cached radius position already exists, overrides default.
  39200. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39201. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39202. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39203. */
  39204. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39205. /**
  39206. * Targets the given meshes with their children and updates zoom level accordingly.
  39207. * @param meshes The mesh to target.
  39208. * @param radius Optional. If a cached radius position already exists, overrides default.
  39209. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39210. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39211. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39212. */
  39213. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39214. /**
  39215. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39216. * @param minimumWorld Determines the smaller position of the bounding box extend
  39217. * @param maximumWorld Determines the bigger position of the bounding box extend
  39218. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39219. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39220. */
  39221. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39222. /**
  39223. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39224. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39225. * frustum width.
  39226. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39227. * to fully enclose the mesh in the viewing frustum.
  39228. */
  39229. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39230. /**
  39231. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39232. * is automatically returned to its default position (expected to be above ground plane).
  39233. */
  39234. private _maintainCameraAboveGround;
  39235. /**
  39236. * Returns the frustum slope based on the canvas ratio and camera FOV
  39237. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39238. */
  39239. private _getFrustumSlope;
  39240. /**
  39241. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39242. */
  39243. private _clearAnimationLocks;
  39244. /**
  39245. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39246. */
  39247. private _applyUserInteraction;
  39248. /**
  39249. * Stops and removes all animations that have been applied to the camera
  39250. */
  39251. stopAllAnimations(): void;
  39252. /**
  39253. * Gets a value indicating if the user is moving the camera
  39254. */
  39255. get isUserIsMoving(): boolean;
  39256. /**
  39257. * The camera can move all the way towards the mesh.
  39258. */
  39259. static IgnoreBoundsSizeMode: number;
  39260. /**
  39261. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39262. */
  39263. static FitFrustumSidesMode: number;
  39264. }
  39265. }
  39266. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39267. import { Nullable } from "babylonjs/types";
  39268. import { Camera } from "babylonjs/Cameras/camera";
  39269. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39270. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39271. /**
  39272. * Base class for Camera Pointer Inputs.
  39273. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39274. * for example usage.
  39275. */
  39276. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39277. /**
  39278. * Defines the camera the input is attached to.
  39279. */
  39280. abstract camera: Camera;
  39281. /**
  39282. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39283. */
  39284. protected _altKey: boolean;
  39285. protected _ctrlKey: boolean;
  39286. protected _metaKey: boolean;
  39287. protected _shiftKey: boolean;
  39288. /**
  39289. * Which mouse buttons were pressed at time of last mouse event.
  39290. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39291. */
  39292. protected _buttonsPressed: number;
  39293. /**
  39294. * Defines the buttons associated with the input to handle camera move.
  39295. */
  39296. buttons: number[];
  39297. /**
  39298. * Attach the input controls to a specific dom element to get the input from.
  39299. * @param element Defines the element the controls should be listened from
  39300. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39301. */
  39302. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39303. /**
  39304. * Detach the current controls from the specified dom element.
  39305. * @param element Defines the element to stop listening the inputs from
  39306. */
  39307. detachControl(element: Nullable<HTMLElement>): void;
  39308. /**
  39309. * Gets the class name of the current input.
  39310. * @returns the class name
  39311. */
  39312. getClassName(): string;
  39313. /**
  39314. * Get the friendly name associated with the input class.
  39315. * @returns the input friendly name
  39316. */
  39317. getSimpleName(): string;
  39318. /**
  39319. * Called on pointer POINTERDOUBLETAP event.
  39320. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39321. */
  39322. protected onDoubleTap(type: string): void;
  39323. /**
  39324. * Called on pointer POINTERMOVE event if only a single touch is active.
  39325. * Override this method to provide functionality.
  39326. */
  39327. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39328. /**
  39329. * Called on pointer POINTERMOVE event if multiple touches are active.
  39330. * Override this method to provide functionality.
  39331. */
  39332. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39333. /**
  39334. * Called on JS contextmenu event.
  39335. * Override this method to provide functionality.
  39336. */
  39337. protected onContextMenu(evt: PointerEvent): void;
  39338. /**
  39339. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39340. * press.
  39341. * Override this method to provide functionality.
  39342. */
  39343. protected onButtonDown(evt: PointerEvent): void;
  39344. /**
  39345. * Called each time a new POINTERUP event occurs. Ie, for each button
  39346. * release.
  39347. * Override this method to provide functionality.
  39348. */
  39349. protected onButtonUp(evt: PointerEvent): void;
  39350. /**
  39351. * Called when window becomes inactive.
  39352. * Override this method to provide functionality.
  39353. */
  39354. protected onLostFocus(): void;
  39355. private _pointerInput;
  39356. private _observer;
  39357. private _onLostFocus;
  39358. private pointA;
  39359. private pointB;
  39360. }
  39361. }
  39362. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39363. import { Nullable } from "babylonjs/types";
  39364. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39365. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39366. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39367. /**
  39368. * Manage the pointers inputs to control an arc rotate camera.
  39369. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39370. */
  39371. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39372. /**
  39373. * Defines the camera the input is attached to.
  39374. */
  39375. camera: ArcRotateCamera;
  39376. /**
  39377. * Gets the class name of the current input.
  39378. * @returns the class name
  39379. */
  39380. getClassName(): string;
  39381. /**
  39382. * Defines the buttons associated with the input to handle camera move.
  39383. */
  39384. buttons: number[];
  39385. /**
  39386. * Defines the pointer angular sensibility along the X axis or how fast is
  39387. * the camera rotating.
  39388. */
  39389. angularSensibilityX: number;
  39390. /**
  39391. * Defines the pointer angular sensibility along the Y axis or how fast is
  39392. * the camera rotating.
  39393. */
  39394. angularSensibilityY: number;
  39395. /**
  39396. * Defines the pointer pinch precision or how fast is the camera zooming.
  39397. */
  39398. pinchPrecision: number;
  39399. /**
  39400. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39401. * from 0.
  39402. * It defines the percentage of current camera.radius to use as delta when
  39403. * pinch zoom is used.
  39404. */
  39405. pinchDeltaPercentage: number;
  39406. /**
  39407. * Defines the pointer panning sensibility or how fast is the camera moving.
  39408. */
  39409. panningSensibility: number;
  39410. /**
  39411. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39412. */
  39413. multiTouchPanning: boolean;
  39414. /**
  39415. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39416. * zoom (pinch) through multitouch.
  39417. */
  39418. multiTouchPanAndZoom: boolean;
  39419. /**
  39420. * Revers pinch action direction.
  39421. */
  39422. pinchInwards: boolean;
  39423. private _isPanClick;
  39424. private _twoFingerActivityCount;
  39425. private _isPinching;
  39426. /**
  39427. * Called on pointer POINTERMOVE event if only a single touch is active.
  39428. */
  39429. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39430. /**
  39431. * Called on pointer POINTERDOUBLETAP event.
  39432. */
  39433. protected onDoubleTap(type: string): void;
  39434. /**
  39435. * Called on pointer POINTERMOVE event if multiple touches are active.
  39436. */
  39437. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39438. /**
  39439. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39440. * press.
  39441. */
  39442. protected onButtonDown(evt: PointerEvent): void;
  39443. /**
  39444. * Called each time a new POINTERUP event occurs. Ie, for each button
  39445. * release.
  39446. */
  39447. protected onButtonUp(evt: PointerEvent): void;
  39448. /**
  39449. * Called when window becomes inactive.
  39450. */
  39451. protected onLostFocus(): void;
  39452. }
  39453. }
  39454. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39455. import { Nullable } from "babylonjs/types";
  39456. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39457. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39458. /**
  39459. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39460. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39461. */
  39462. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39463. /**
  39464. * Defines the camera the input is attached to.
  39465. */
  39466. camera: ArcRotateCamera;
  39467. /**
  39468. * Defines the list of key codes associated with the up action (increase alpha)
  39469. */
  39470. keysUp: number[];
  39471. /**
  39472. * Defines the list of key codes associated with the down action (decrease alpha)
  39473. */
  39474. keysDown: number[];
  39475. /**
  39476. * Defines the list of key codes associated with the left action (increase beta)
  39477. */
  39478. keysLeft: number[];
  39479. /**
  39480. * Defines the list of key codes associated with the right action (decrease beta)
  39481. */
  39482. keysRight: number[];
  39483. /**
  39484. * Defines the list of key codes associated with the reset action.
  39485. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39486. */
  39487. keysReset: number[];
  39488. /**
  39489. * Defines the panning sensibility of the inputs.
  39490. * (How fast is the camera panning)
  39491. */
  39492. panningSensibility: number;
  39493. /**
  39494. * Defines the zooming sensibility of the inputs.
  39495. * (How fast is the camera zooming)
  39496. */
  39497. zoomingSensibility: number;
  39498. /**
  39499. * Defines whether maintaining the alt key down switch the movement mode from
  39500. * orientation to zoom.
  39501. */
  39502. useAltToZoom: boolean;
  39503. /**
  39504. * Rotation speed of the camera
  39505. */
  39506. angularSpeed: number;
  39507. private _keys;
  39508. private _ctrlPressed;
  39509. private _altPressed;
  39510. private _onCanvasBlurObserver;
  39511. private _onKeyboardObserver;
  39512. private _engine;
  39513. private _scene;
  39514. /**
  39515. * Attach the input controls to a specific dom element to get the input from.
  39516. * @param element Defines the element the controls should be listened from
  39517. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39518. */
  39519. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39520. /**
  39521. * Detach the current controls from the specified dom element.
  39522. * @param element Defines the element to stop listening the inputs from
  39523. */
  39524. detachControl(element: Nullable<HTMLElement>): void;
  39525. /**
  39526. * Update the current camera state depending on the inputs that have been used this frame.
  39527. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39528. */
  39529. checkInputs(): void;
  39530. /**
  39531. * Gets the class name of the current intput.
  39532. * @returns the class name
  39533. */
  39534. getClassName(): string;
  39535. /**
  39536. * Get the friendly name associated with the input class.
  39537. * @returns the input friendly name
  39538. */
  39539. getSimpleName(): string;
  39540. }
  39541. }
  39542. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39543. import { Nullable } from "babylonjs/types";
  39544. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39545. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39546. /**
  39547. * Manage the mouse wheel inputs to control an arc rotate camera.
  39548. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39549. */
  39550. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39551. /**
  39552. * Defines the camera the input is attached to.
  39553. */
  39554. camera: ArcRotateCamera;
  39555. /**
  39556. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39557. */
  39558. wheelPrecision: number;
  39559. /**
  39560. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39561. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39562. */
  39563. wheelDeltaPercentage: number;
  39564. private _wheel;
  39565. private _observer;
  39566. private computeDeltaFromMouseWheelLegacyEvent;
  39567. /**
  39568. * Attach the input controls to a specific dom element to get the input from.
  39569. * @param element Defines the element the controls should be listened from
  39570. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39571. */
  39572. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39573. /**
  39574. * Detach the current controls from the specified dom element.
  39575. * @param element Defines the element to stop listening the inputs from
  39576. */
  39577. detachControl(element: Nullable<HTMLElement>): void;
  39578. /**
  39579. * Gets the class name of the current intput.
  39580. * @returns the class name
  39581. */
  39582. getClassName(): string;
  39583. /**
  39584. * Get the friendly name associated with the input class.
  39585. * @returns the input friendly name
  39586. */
  39587. getSimpleName(): string;
  39588. }
  39589. }
  39590. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39591. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39592. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39593. /**
  39594. * Default Inputs manager for the ArcRotateCamera.
  39595. * It groups all the default supported inputs for ease of use.
  39596. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39597. */
  39598. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39599. /**
  39600. * Instantiates a new ArcRotateCameraInputsManager.
  39601. * @param camera Defines the camera the inputs belong to
  39602. */
  39603. constructor(camera: ArcRotateCamera);
  39604. /**
  39605. * Add mouse wheel input support to the input manager.
  39606. * @returns the current input manager
  39607. */
  39608. addMouseWheel(): ArcRotateCameraInputsManager;
  39609. /**
  39610. * Add pointers input support to the input manager.
  39611. * @returns the current input manager
  39612. */
  39613. addPointers(): ArcRotateCameraInputsManager;
  39614. /**
  39615. * Add keyboard input support to the input manager.
  39616. * @returns the current input manager
  39617. */
  39618. addKeyboard(): ArcRotateCameraInputsManager;
  39619. }
  39620. }
  39621. declare module "babylonjs/Cameras/arcRotateCamera" {
  39622. import { Observable } from "babylonjs/Misc/observable";
  39623. import { Nullable } from "babylonjs/types";
  39624. import { Scene } from "babylonjs/scene";
  39625. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39627. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39628. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39629. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39630. import { Camera } from "babylonjs/Cameras/camera";
  39631. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39632. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39633. import { Collider } from "babylonjs/Collisions/collider";
  39634. /**
  39635. * This represents an orbital type of camera.
  39636. *
  39637. * 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.
  39638. * 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.
  39639. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39640. */
  39641. export class ArcRotateCamera extends TargetCamera {
  39642. /**
  39643. * Defines the rotation angle of the camera along the longitudinal axis.
  39644. */
  39645. alpha: number;
  39646. /**
  39647. * Defines the rotation angle of the camera along the latitudinal axis.
  39648. */
  39649. beta: number;
  39650. /**
  39651. * Defines the radius of the camera from it s target point.
  39652. */
  39653. radius: number;
  39654. protected _target: Vector3;
  39655. protected _targetHost: Nullable<AbstractMesh>;
  39656. /**
  39657. * Defines the target point of the camera.
  39658. * The camera looks towards it form the radius distance.
  39659. */
  39660. get target(): Vector3;
  39661. set target(value: Vector3);
  39662. /**
  39663. * Define the current local position of the camera in the scene
  39664. */
  39665. get position(): Vector3;
  39666. set position(newPosition: Vector3);
  39667. protected _upVector: Vector3;
  39668. protected _upToYMatrix: Matrix;
  39669. protected _YToUpMatrix: Matrix;
  39670. /**
  39671. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39672. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39673. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39674. */
  39675. set upVector(vec: Vector3);
  39676. get upVector(): Vector3;
  39677. /**
  39678. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39679. */
  39680. setMatUp(): void;
  39681. /**
  39682. * Current inertia value on the longitudinal axis.
  39683. * The bigger this number the longer it will take for the camera to stop.
  39684. */
  39685. inertialAlphaOffset: number;
  39686. /**
  39687. * Current inertia value on the latitudinal axis.
  39688. * The bigger this number the longer it will take for the camera to stop.
  39689. */
  39690. inertialBetaOffset: number;
  39691. /**
  39692. * Current inertia value on the radius axis.
  39693. * The bigger this number the longer it will take for the camera to stop.
  39694. */
  39695. inertialRadiusOffset: number;
  39696. /**
  39697. * Minimum allowed angle on the longitudinal axis.
  39698. * This can help limiting how the Camera is able to move in the scene.
  39699. */
  39700. lowerAlphaLimit: Nullable<number>;
  39701. /**
  39702. * Maximum allowed angle on the longitudinal axis.
  39703. * This can help limiting how the Camera is able to move in the scene.
  39704. */
  39705. upperAlphaLimit: Nullable<number>;
  39706. /**
  39707. * Minimum allowed angle on the latitudinal axis.
  39708. * This can help limiting how the Camera is able to move in the scene.
  39709. */
  39710. lowerBetaLimit: number;
  39711. /**
  39712. * Maximum allowed angle on the latitudinal axis.
  39713. * This can help limiting how the Camera is able to move in the scene.
  39714. */
  39715. upperBetaLimit: number;
  39716. /**
  39717. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39718. * This can help limiting how the Camera is able to move in the scene.
  39719. */
  39720. lowerRadiusLimit: Nullable<number>;
  39721. /**
  39722. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39723. * This can help limiting how the Camera is able to move in the scene.
  39724. */
  39725. upperRadiusLimit: Nullable<number>;
  39726. /**
  39727. * Defines the current inertia value used during panning of the camera along the X axis.
  39728. */
  39729. inertialPanningX: number;
  39730. /**
  39731. * Defines the current inertia value used during panning of the camera along the Y axis.
  39732. */
  39733. inertialPanningY: number;
  39734. /**
  39735. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39736. * Basically if your fingers moves away from more than this distance you will be considered
  39737. * in pinch mode.
  39738. */
  39739. pinchToPanMaxDistance: number;
  39740. /**
  39741. * Defines the maximum distance the camera can pan.
  39742. * This could help keeping the cammera always in your scene.
  39743. */
  39744. panningDistanceLimit: Nullable<number>;
  39745. /**
  39746. * Defines the target of the camera before paning.
  39747. */
  39748. panningOriginTarget: Vector3;
  39749. /**
  39750. * Defines the value of the inertia used during panning.
  39751. * 0 would mean stop inertia and one would mean no decelleration at all.
  39752. */
  39753. panningInertia: number;
  39754. /**
  39755. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39756. */
  39757. get angularSensibilityX(): number;
  39758. set angularSensibilityX(value: number);
  39759. /**
  39760. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39761. */
  39762. get angularSensibilityY(): number;
  39763. set angularSensibilityY(value: number);
  39764. /**
  39765. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39766. */
  39767. get pinchPrecision(): number;
  39768. set pinchPrecision(value: number);
  39769. /**
  39770. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39771. * It will be used instead of pinchDeltaPrecision if different from 0.
  39772. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39773. */
  39774. get pinchDeltaPercentage(): number;
  39775. set pinchDeltaPercentage(value: number);
  39776. /**
  39777. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39778. */
  39779. get panningSensibility(): number;
  39780. set panningSensibility(value: number);
  39781. /**
  39782. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39783. */
  39784. get keysUp(): number[];
  39785. set keysUp(value: number[]);
  39786. /**
  39787. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39788. */
  39789. get keysDown(): number[];
  39790. set keysDown(value: number[]);
  39791. /**
  39792. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39793. */
  39794. get keysLeft(): number[];
  39795. set keysLeft(value: number[]);
  39796. /**
  39797. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39798. */
  39799. get keysRight(): number[];
  39800. set keysRight(value: number[]);
  39801. /**
  39802. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39803. */
  39804. get wheelPrecision(): number;
  39805. set wheelPrecision(value: number);
  39806. /**
  39807. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39808. * It will be used instead of pinchDeltaPrecision if different from 0.
  39809. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39810. */
  39811. get wheelDeltaPercentage(): number;
  39812. set wheelDeltaPercentage(value: number);
  39813. /**
  39814. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39815. */
  39816. zoomOnFactor: number;
  39817. /**
  39818. * Defines a screen offset for the camera position.
  39819. */
  39820. targetScreenOffset: Vector2;
  39821. /**
  39822. * Allows the camera to be completely reversed.
  39823. * If false the camera can not arrive upside down.
  39824. */
  39825. allowUpsideDown: boolean;
  39826. /**
  39827. * Define if double tap/click is used to restore the previously saved state of the camera.
  39828. */
  39829. useInputToRestoreState: boolean;
  39830. /** @hidden */
  39831. _viewMatrix: Matrix;
  39832. /** @hidden */
  39833. _useCtrlForPanning: boolean;
  39834. /** @hidden */
  39835. _panningMouseButton: number;
  39836. /**
  39837. * Defines the input associated to the camera.
  39838. */
  39839. inputs: ArcRotateCameraInputsManager;
  39840. /** @hidden */
  39841. _reset: () => void;
  39842. /**
  39843. * Defines the allowed panning axis.
  39844. */
  39845. panningAxis: Vector3;
  39846. protected _localDirection: Vector3;
  39847. protected _transformedDirection: Vector3;
  39848. private _bouncingBehavior;
  39849. /**
  39850. * Gets the bouncing behavior of the camera if it has been enabled.
  39851. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39852. */
  39853. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39854. /**
  39855. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39856. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39857. */
  39858. get useBouncingBehavior(): boolean;
  39859. set useBouncingBehavior(value: boolean);
  39860. private _framingBehavior;
  39861. /**
  39862. * Gets the framing behavior of the camera if it has been enabled.
  39863. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39864. */
  39865. get framingBehavior(): Nullable<FramingBehavior>;
  39866. /**
  39867. * Defines if the framing behavior of the camera is enabled on the camera.
  39868. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39869. */
  39870. get useFramingBehavior(): boolean;
  39871. set useFramingBehavior(value: boolean);
  39872. private _autoRotationBehavior;
  39873. /**
  39874. * Gets the auto rotation behavior of the camera if it has been enabled.
  39875. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39876. */
  39877. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39878. /**
  39879. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39880. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39881. */
  39882. get useAutoRotationBehavior(): boolean;
  39883. set useAutoRotationBehavior(value: boolean);
  39884. /**
  39885. * Observable triggered when the mesh target has been changed on the camera.
  39886. */
  39887. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39888. /**
  39889. * Event raised when the camera is colliding with a mesh.
  39890. */
  39891. onCollide: (collidedMesh: AbstractMesh) => void;
  39892. /**
  39893. * Defines whether the camera should check collision with the objects oh the scene.
  39894. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39895. */
  39896. checkCollisions: boolean;
  39897. /**
  39898. * Defines the collision radius of the camera.
  39899. * This simulates a sphere around the camera.
  39900. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39901. */
  39902. collisionRadius: Vector3;
  39903. protected _collider: Collider;
  39904. protected _previousPosition: Vector3;
  39905. protected _collisionVelocity: Vector3;
  39906. protected _newPosition: Vector3;
  39907. protected _previousAlpha: number;
  39908. protected _previousBeta: number;
  39909. protected _previousRadius: number;
  39910. protected _collisionTriggered: boolean;
  39911. protected _targetBoundingCenter: Nullable<Vector3>;
  39912. private _computationVector;
  39913. /**
  39914. * Instantiates a new ArcRotateCamera in a given scene
  39915. * @param name Defines the name of the camera
  39916. * @param alpha Defines the camera rotation along the logitudinal axis
  39917. * @param beta Defines the camera rotation along the latitudinal axis
  39918. * @param radius Defines the camera distance from its target
  39919. * @param target Defines the camera target
  39920. * @param scene Defines the scene the camera belongs to
  39921. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39922. */
  39923. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39924. /** @hidden */
  39925. _initCache(): void;
  39926. /** @hidden */
  39927. _updateCache(ignoreParentClass?: boolean): void;
  39928. protected _getTargetPosition(): Vector3;
  39929. private _storedAlpha;
  39930. private _storedBeta;
  39931. private _storedRadius;
  39932. private _storedTarget;
  39933. private _storedTargetScreenOffset;
  39934. /**
  39935. * Stores the current state of the camera (alpha, beta, radius and target)
  39936. * @returns the camera itself
  39937. */
  39938. storeState(): Camera;
  39939. /**
  39940. * @hidden
  39941. * Restored camera state. You must call storeState() first
  39942. */
  39943. _restoreStateValues(): boolean;
  39944. /** @hidden */
  39945. _isSynchronizedViewMatrix(): boolean;
  39946. /**
  39947. * Attached controls to the current camera.
  39948. * @param element Defines the element the controls should be listened from
  39949. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39950. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39951. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39952. */
  39953. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39954. /**
  39955. * Detach the current controls from the camera.
  39956. * The camera will stop reacting to inputs.
  39957. * @param element Defines the element to stop listening the inputs from
  39958. */
  39959. detachControl(element: HTMLElement): void;
  39960. /** @hidden */
  39961. _checkInputs(): void;
  39962. protected _checkLimits(): void;
  39963. /**
  39964. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39965. */
  39966. rebuildAnglesAndRadius(): void;
  39967. /**
  39968. * Use a position to define the current camera related information like alpha, beta and radius
  39969. * @param position Defines the position to set the camera at
  39970. */
  39971. setPosition(position: Vector3): void;
  39972. /**
  39973. * Defines the target the camera should look at.
  39974. * This will automatically adapt alpha beta and radius to fit within the new target.
  39975. * @param target Defines the new target as a Vector or a mesh
  39976. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  39977. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39978. */
  39979. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39980. /** @hidden */
  39981. _getViewMatrix(): Matrix;
  39982. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39983. /**
  39984. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39985. * @param meshes Defines the mesh to zoom on
  39986. * @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)
  39987. */
  39988. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39989. /**
  39990. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39991. * The target will be changed but the radius
  39992. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39993. * @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)
  39994. */
  39995. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39996. min: Vector3;
  39997. max: Vector3;
  39998. distance: number;
  39999. }, doNotUpdateMaxZ?: boolean): void;
  40000. /**
  40001. * @override
  40002. * Override Camera.createRigCamera
  40003. */
  40004. createRigCamera(name: string, cameraIndex: number): Camera;
  40005. /**
  40006. * @hidden
  40007. * @override
  40008. * Override Camera._updateRigCameras
  40009. */
  40010. _updateRigCameras(): void;
  40011. /**
  40012. * Destroy the camera and release the current resources hold by it.
  40013. */
  40014. dispose(): void;
  40015. /**
  40016. * Gets the current object class name.
  40017. * @return the class name
  40018. */
  40019. getClassName(): string;
  40020. }
  40021. }
  40022. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40023. import { Behavior } from "babylonjs/Behaviors/behavior";
  40024. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40025. /**
  40026. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40027. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40028. */
  40029. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40030. /**
  40031. * Gets the name of the behavior.
  40032. */
  40033. get name(): string;
  40034. private _zoomStopsAnimation;
  40035. private _idleRotationSpeed;
  40036. private _idleRotationWaitTime;
  40037. private _idleRotationSpinupTime;
  40038. /**
  40039. * Sets the flag that indicates if user zooming should stop animation.
  40040. */
  40041. set zoomStopsAnimation(flag: boolean);
  40042. /**
  40043. * Gets the flag that indicates if user zooming should stop animation.
  40044. */
  40045. get zoomStopsAnimation(): boolean;
  40046. /**
  40047. * Sets the default speed at which the camera rotates around the model.
  40048. */
  40049. set idleRotationSpeed(speed: number);
  40050. /**
  40051. * Gets the default speed at which the camera rotates around the model.
  40052. */
  40053. get idleRotationSpeed(): number;
  40054. /**
  40055. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40056. */
  40057. set idleRotationWaitTime(time: number);
  40058. /**
  40059. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40060. */
  40061. get idleRotationWaitTime(): number;
  40062. /**
  40063. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40064. */
  40065. set idleRotationSpinupTime(time: number);
  40066. /**
  40067. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40068. */
  40069. get idleRotationSpinupTime(): number;
  40070. /**
  40071. * Gets a value indicating if the camera is currently rotating because of this behavior
  40072. */
  40073. get rotationInProgress(): boolean;
  40074. private _onPrePointerObservableObserver;
  40075. private _onAfterCheckInputsObserver;
  40076. private _attachedCamera;
  40077. private _isPointerDown;
  40078. private _lastFrameTime;
  40079. private _lastInteractionTime;
  40080. private _cameraRotationSpeed;
  40081. /**
  40082. * Initializes the behavior.
  40083. */
  40084. init(): void;
  40085. /**
  40086. * Attaches the behavior to its arc rotate camera.
  40087. * @param camera Defines the camera to attach the behavior to
  40088. */
  40089. attach(camera: ArcRotateCamera): void;
  40090. /**
  40091. * Detaches the behavior from its current arc rotate camera.
  40092. */
  40093. detach(): void;
  40094. /**
  40095. * Returns true if user is scrolling.
  40096. * @return true if user is scrolling.
  40097. */
  40098. private _userIsZooming;
  40099. private _lastFrameRadius;
  40100. private _shouldAnimationStopForInteraction;
  40101. /**
  40102. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40103. */
  40104. private _applyUserInteraction;
  40105. private _userIsMoving;
  40106. }
  40107. }
  40108. declare module "babylonjs/Behaviors/Cameras/index" {
  40109. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40110. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40111. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40112. }
  40113. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40114. import { Mesh } from "babylonjs/Meshes/mesh";
  40115. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40116. import { Behavior } from "babylonjs/Behaviors/behavior";
  40117. /**
  40118. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40119. */
  40120. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40121. private ui;
  40122. /**
  40123. * The name of the behavior
  40124. */
  40125. name: string;
  40126. /**
  40127. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40128. */
  40129. distanceAwayFromFace: number;
  40130. /**
  40131. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40132. */
  40133. distanceAwayFromBottomOfFace: number;
  40134. private _faceVectors;
  40135. private _target;
  40136. private _scene;
  40137. private _onRenderObserver;
  40138. private _tmpMatrix;
  40139. private _tmpVector;
  40140. /**
  40141. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40142. * @param ui The transform node that should be attched to the mesh
  40143. */
  40144. constructor(ui: TransformNode);
  40145. /**
  40146. * Initializes the behavior
  40147. */
  40148. init(): void;
  40149. private _closestFace;
  40150. private _zeroVector;
  40151. private _lookAtTmpMatrix;
  40152. private _lookAtToRef;
  40153. /**
  40154. * Attaches the AttachToBoxBehavior to the passed in mesh
  40155. * @param target The mesh that the specified node will be attached to
  40156. */
  40157. attach(target: Mesh): void;
  40158. /**
  40159. * Detaches the behavior from the mesh
  40160. */
  40161. detach(): void;
  40162. }
  40163. }
  40164. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40165. import { Behavior } from "babylonjs/Behaviors/behavior";
  40166. import { Mesh } from "babylonjs/Meshes/mesh";
  40167. /**
  40168. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40169. */
  40170. export class FadeInOutBehavior implements Behavior<Mesh> {
  40171. /**
  40172. * Time in milliseconds to delay before fading in (Default: 0)
  40173. */
  40174. delay: number;
  40175. /**
  40176. * Time in milliseconds for the mesh to fade in (Default: 300)
  40177. */
  40178. fadeInTime: number;
  40179. private _millisecondsPerFrame;
  40180. private _hovered;
  40181. private _hoverValue;
  40182. private _ownerNode;
  40183. /**
  40184. * Instatiates the FadeInOutBehavior
  40185. */
  40186. constructor();
  40187. /**
  40188. * The name of the behavior
  40189. */
  40190. get name(): string;
  40191. /**
  40192. * Initializes the behavior
  40193. */
  40194. init(): void;
  40195. /**
  40196. * Attaches the fade behavior on the passed in mesh
  40197. * @param ownerNode The mesh that will be faded in/out once attached
  40198. */
  40199. attach(ownerNode: Mesh): void;
  40200. /**
  40201. * Detaches the behavior from the mesh
  40202. */
  40203. detach(): void;
  40204. /**
  40205. * Triggers the mesh to begin fading in or out
  40206. * @param value if the object should fade in or out (true to fade in)
  40207. */
  40208. fadeIn(value: boolean): void;
  40209. private _update;
  40210. private _setAllVisibility;
  40211. }
  40212. }
  40213. declare module "babylonjs/Misc/pivotTools" {
  40214. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40215. /**
  40216. * Class containing a set of static utilities functions for managing Pivots
  40217. * @hidden
  40218. */
  40219. export class PivotTools {
  40220. private static _PivotCached;
  40221. private static _OldPivotPoint;
  40222. private static _PivotTranslation;
  40223. private static _PivotTmpVector;
  40224. /** @hidden */
  40225. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40226. /** @hidden */
  40227. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40228. }
  40229. }
  40230. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40231. import { Scene } from "babylonjs/scene";
  40232. import { Vector4 } from "babylonjs/Maths/math.vector";
  40233. import { Mesh } from "babylonjs/Meshes/mesh";
  40234. import { Nullable } from "babylonjs/types";
  40235. import { Plane } from "babylonjs/Maths/math.plane";
  40236. /**
  40237. * Class containing static functions to help procedurally build meshes
  40238. */
  40239. export class PlaneBuilder {
  40240. /**
  40241. * Creates a plane mesh
  40242. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40243. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40244. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40245. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40246. * * 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
  40247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40248. * @param name defines the name of the mesh
  40249. * @param options defines the options used to create the mesh
  40250. * @param scene defines the hosting scene
  40251. * @returns the plane mesh
  40252. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40253. */
  40254. static CreatePlane(name: string, options: {
  40255. size?: number;
  40256. width?: number;
  40257. height?: number;
  40258. sideOrientation?: number;
  40259. frontUVs?: Vector4;
  40260. backUVs?: Vector4;
  40261. updatable?: boolean;
  40262. sourcePlane?: Plane;
  40263. }, scene?: Nullable<Scene>): Mesh;
  40264. }
  40265. }
  40266. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40267. import { Behavior } from "babylonjs/Behaviors/behavior";
  40268. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40269. import { Observable } from "babylonjs/Misc/observable";
  40270. import { Vector3 } from "babylonjs/Maths/math.vector";
  40271. import { Ray } from "babylonjs/Culling/ray";
  40272. import "babylonjs/Meshes/Builders/planeBuilder";
  40273. /**
  40274. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40275. */
  40276. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40277. private static _AnyMouseID;
  40278. /**
  40279. * Abstract mesh the behavior is set on
  40280. */
  40281. attachedNode: AbstractMesh;
  40282. private _dragPlane;
  40283. private _scene;
  40284. private _pointerObserver;
  40285. private _beforeRenderObserver;
  40286. private static _planeScene;
  40287. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40288. /**
  40289. * 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)
  40290. */
  40291. maxDragAngle: number;
  40292. /**
  40293. * @hidden
  40294. */
  40295. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40296. /**
  40297. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40298. */
  40299. currentDraggingPointerID: number;
  40300. /**
  40301. * The last position where the pointer hit the drag plane in world space
  40302. */
  40303. lastDragPosition: Vector3;
  40304. /**
  40305. * If the behavior is currently in a dragging state
  40306. */
  40307. dragging: boolean;
  40308. /**
  40309. * 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)
  40310. */
  40311. dragDeltaRatio: number;
  40312. /**
  40313. * If the drag plane orientation should be updated during the dragging (Default: true)
  40314. */
  40315. updateDragPlane: boolean;
  40316. private _debugMode;
  40317. private _moving;
  40318. /**
  40319. * Fires each time the attached mesh is dragged with the pointer
  40320. * * delta between last drag position and current drag position in world space
  40321. * * dragDistance along the drag axis
  40322. * * dragPlaneNormal normal of the current drag plane used during the drag
  40323. * * dragPlanePoint in world space where the drag intersects the drag plane
  40324. */
  40325. onDragObservable: Observable<{
  40326. delta: Vector3;
  40327. dragPlanePoint: Vector3;
  40328. dragPlaneNormal: Vector3;
  40329. dragDistance: number;
  40330. pointerId: number;
  40331. }>;
  40332. /**
  40333. * Fires each time a drag begins (eg. mouse down on mesh)
  40334. */
  40335. onDragStartObservable: Observable<{
  40336. dragPlanePoint: Vector3;
  40337. pointerId: number;
  40338. }>;
  40339. /**
  40340. * Fires each time a drag ends (eg. mouse release after drag)
  40341. */
  40342. onDragEndObservable: Observable<{
  40343. dragPlanePoint: Vector3;
  40344. pointerId: number;
  40345. }>;
  40346. /**
  40347. * If the attached mesh should be moved when dragged
  40348. */
  40349. moveAttached: boolean;
  40350. /**
  40351. * If the drag behavior will react to drag events (Default: true)
  40352. */
  40353. enabled: boolean;
  40354. /**
  40355. * If pointer events should start and release the drag (Default: true)
  40356. */
  40357. startAndReleaseDragOnPointerEvents: boolean;
  40358. /**
  40359. * If camera controls should be detached during the drag
  40360. */
  40361. detachCameraControls: boolean;
  40362. /**
  40363. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40364. */
  40365. useObjectOrientationForDragging: boolean;
  40366. private _options;
  40367. /**
  40368. * Gets the options used by the behavior
  40369. */
  40370. get options(): {
  40371. dragAxis?: Vector3;
  40372. dragPlaneNormal?: Vector3;
  40373. };
  40374. /**
  40375. * Sets the options used by the behavior
  40376. */
  40377. set options(options: {
  40378. dragAxis?: Vector3;
  40379. dragPlaneNormal?: Vector3;
  40380. });
  40381. /**
  40382. * Creates a pointer drag behavior that can be attached to a mesh
  40383. * @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)
  40384. */
  40385. constructor(options?: {
  40386. dragAxis?: Vector3;
  40387. dragPlaneNormal?: Vector3;
  40388. });
  40389. /**
  40390. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40391. */
  40392. validateDrag: (targetPosition: Vector3) => boolean;
  40393. /**
  40394. * The name of the behavior
  40395. */
  40396. get name(): string;
  40397. /**
  40398. * Initializes the behavior
  40399. */
  40400. init(): void;
  40401. private _tmpVector;
  40402. private _alternatePickedPoint;
  40403. private _worldDragAxis;
  40404. private _targetPosition;
  40405. private _attachedElement;
  40406. /**
  40407. * Attaches the drag behavior the passed in mesh
  40408. * @param ownerNode The mesh that will be dragged around once attached
  40409. * @param predicate Predicate to use for pick filtering
  40410. */
  40411. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40412. /**
  40413. * Force relase the drag action by code.
  40414. */
  40415. releaseDrag(): void;
  40416. private _startDragRay;
  40417. private _lastPointerRay;
  40418. /**
  40419. * Simulates the start of a pointer drag event on the behavior
  40420. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40421. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40422. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40423. */
  40424. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40425. private _startDrag;
  40426. private _dragDelta;
  40427. private _moveDrag;
  40428. private _pickWithRayOnDragPlane;
  40429. private _pointA;
  40430. private _pointB;
  40431. private _pointC;
  40432. private _lineA;
  40433. private _lineB;
  40434. private _localAxis;
  40435. private _lookAt;
  40436. private _updateDragPlanePosition;
  40437. /**
  40438. * Detaches the behavior from the mesh
  40439. */
  40440. detach(): void;
  40441. }
  40442. }
  40443. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40444. import { Mesh } from "babylonjs/Meshes/mesh";
  40445. import { Behavior } from "babylonjs/Behaviors/behavior";
  40446. /**
  40447. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40448. */
  40449. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40450. private _dragBehaviorA;
  40451. private _dragBehaviorB;
  40452. private _startDistance;
  40453. private _initialScale;
  40454. private _targetScale;
  40455. private _ownerNode;
  40456. private _sceneRenderObserver;
  40457. /**
  40458. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40459. */
  40460. constructor();
  40461. /**
  40462. * The name of the behavior
  40463. */
  40464. get name(): string;
  40465. /**
  40466. * Initializes the behavior
  40467. */
  40468. init(): void;
  40469. private _getCurrentDistance;
  40470. /**
  40471. * Attaches the scale behavior the passed in mesh
  40472. * @param ownerNode The mesh that will be scaled around once attached
  40473. */
  40474. attach(ownerNode: Mesh): void;
  40475. /**
  40476. * Detaches the behavior from the mesh
  40477. */
  40478. detach(): void;
  40479. }
  40480. }
  40481. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40482. import { Behavior } from "babylonjs/Behaviors/behavior";
  40483. import { Mesh } from "babylonjs/Meshes/mesh";
  40484. import { Observable } from "babylonjs/Misc/observable";
  40485. /**
  40486. * 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
  40487. */
  40488. export class SixDofDragBehavior implements Behavior<Mesh> {
  40489. private static _virtualScene;
  40490. private _ownerNode;
  40491. private _sceneRenderObserver;
  40492. private _scene;
  40493. private _targetPosition;
  40494. private _virtualOriginMesh;
  40495. private _virtualDragMesh;
  40496. private _pointerObserver;
  40497. private _moving;
  40498. private _startingOrientation;
  40499. /**
  40500. * 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)
  40501. */
  40502. private zDragFactor;
  40503. /**
  40504. * If the object should rotate to face the drag origin
  40505. */
  40506. rotateDraggedObject: boolean;
  40507. /**
  40508. * If the behavior is currently in a dragging state
  40509. */
  40510. dragging: boolean;
  40511. /**
  40512. * 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)
  40513. */
  40514. dragDeltaRatio: number;
  40515. /**
  40516. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40517. */
  40518. currentDraggingPointerID: number;
  40519. /**
  40520. * If camera controls should be detached during the drag
  40521. */
  40522. detachCameraControls: boolean;
  40523. /**
  40524. * Fires each time a drag starts
  40525. */
  40526. onDragStartObservable: Observable<{}>;
  40527. /**
  40528. * Fires each time a drag ends (eg. mouse release after drag)
  40529. */
  40530. onDragEndObservable: Observable<{}>;
  40531. /**
  40532. * 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
  40533. */
  40534. constructor();
  40535. /**
  40536. * The name of the behavior
  40537. */
  40538. get name(): string;
  40539. /**
  40540. * Initializes the behavior
  40541. */
  40542. init(): void;
  40543. /**
  40544. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40545. */
  40546. private get _pointerCamera();
  40547. /**
  40548. * Attaches the scale behavior the passed in mesh
  40549. * @param ownerNode The mesh that will be scaled around once attached
  40550. */
  40551. attach(ownerNode: Mesh): void;
  40552. /**
  40553. * Detaches the behavior from the mesh
  40554. */
  40555. detach(): void;
  40556. }
  40557. }
  40558. declare module "babylonjs/Behaviors/Meshes/index" {
  40559. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40560. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40561. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40562. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40563. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40564. }
  40565. declare module "babylonjs/Behaviors/index" {
  40566. export * from "babylonjs/Behaviors/behavior";
  40567. export * from "babylonjs/Behaviors/Cameras/index";
  40568. export * from "babylonjs/Behaviors/Meshes/index";
  40569. }
  40570. declare module "babylonjs/Bones/boneIKController" {
  40571. import { Bone } from "babylonjs/Bones/bone";
  40572. import { Vector3 } from "babylonjs/Maths/math.vector";
  40573. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40574. import { Nullable } from "babylonjs/types";
  40575. /**
  40576. * Class used to apply inverse kinematics to bones
  40577. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40578. */
  40579. export class BoneIKController {
  40580. private static _tmpVecs;
  40581. private static _tmpQuat;
  40582. private static _tmpMats;
  40583. /**
  40584. * Gets or sets the target mesh
  40585. */
  40586. targetMesh: AbstractMesh;
  40587. /** Gets or sets the mesh used as pole */
  40588. poleTargetMesh: AbstractMesh;
  40589. /**
  40590. * Gets or sets the bone used as pole
  40591. */
  40592. poleTargetBone: Nullable<Bone>;
  40593. /**
  40594. * Gets or sets the target position
  40595. */
  40596. targetPosition: Vector3;
  40597. /**
  40598. * Gets or sets the pole target position
  40599. */
  40600. poleTargetPosition: Vector3;
  40601. /**
  40602. * Gets or sets the pole target local offset
  40603. */
  40604. poleTargetLocalOffset: Vector3;
  40605. /**
  40606. * Gets or sets the pole angle
  40607. */
  40608. poleAngle: number;
  40609. /**
  40610. * Gets or sets the mesh associated with the controller
  40611. */
  40612. mesh: AbstractMesh;
  40613. /**
  40614. * 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)
  40615. */
  40616. slerpAmount: number;
  40617. private _bone1Quat;
  40618. private _bone1Mat;
  40619. private _bone2Ang;
  40620. private _bone1;
  40621. private _bone2;
  40622. private _bone1Length;
  40623. private _bone2Length;
  40624. private _maxAngle;
  40625. private _maxReach;
  40626. private _rightHandedSystem;
  40627. private _bendAxis;
  40628. private _slerping;
  40629. private _adjustRoll;
  40630. /**
  40631. * Gets or sets maximum allowed angle
  40632. */
  40633. get maxAngle(): number;
  40634. set maxAngle(value: number);
  40635. /**
  40636. * Creates a new BoneIKController
  40637. * @param mesh defines the mesh to control
  40638. * @param bone defines the bone to control
  40639. * @param options defines options to set up the controller
  40640. */
  40641. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40642. targetMesh?: AbstractMesh;
  40643. poleTargetMesh?: AbstractMesh;
  40644. poleTargetBone?: Bone;
  40645. poleTargetLocalOffset?: Vector3;
  40646. poleAngle?: number;
  40647. bendAxis?: Vector3;
  40648. maxAngle?: number;
  40649. slerpAmount?: number;
  40650. });
  40651. private _setMaxAngle;
  40652. /**
  40653. * Force the controller to update the bones
  40654. */
  40655. update(): void;
  40656. }
  40657. }
  40658. declare module "babylonjs/Bones/boneLookController" {
  40659. import { Vector3 } from "babylonjs/Maths/math.vector";
  40660. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40661. import { Bone } from "babylonjs/Bones/bone";
  40662. import { Space } from "babylonjs/Maths/math.axis";
  40663. /**
  40664. * Class used to make a bone look toward a point in space
  40665. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40666. */
  40667. export class BoneLookController {
  40668. private static _tmpVecs;
  40669. private static _tmpQuat;
  40670. private static _tmpMats;
  40671. /**
  40672. * The target Vector3 that the bone will look at
  40673. */
  40674. target: Vector3;
  40675. /**
  40676. * The mesh that the bone is attached to
  40677. */
  40678. mesh: AbstractMesh;
  40679. /**
  40680. * The bone that will be looking to the target
  40681. */
  40682. bone: Bone;
  40683. /**
  40684. * The up axis of the coordinate system that is used when the bone is rotated
  40685. */
  40686. upAxis: Vector3;
  40687. /**
  40688. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40689. */
  40690. upAxisSpace: Space;
  40691. /**
  40692. * Used to make an adjustment to the yaw of the bone
  40693. */
  40694. adjustYaw: number;
  40695. /**
  40696. * Used to make an adjustment to the pitch of the bone
  40697. */
  40698. adjustPitch: number;
  40699. /**
  40700. * Used to make an adjustment to the roll of the bone
  40701. */
  40702. adjustRoll: number;
  40703. /**
  40704. * 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)
  40705. */
  40706. slerpAmount: number;
  40707. private _minYaw;
  40708. private _maxYaw;
  40709. private _minPitch;
  40710. private _maxPitch;
  40711. private _minYawSin;
  40712. private _minYawCos;
  40713. private _maxYawSin;
  40714. private _maxYawCos;
  40715. private _midYawConstraint;
  40716. private _minPitchTan;
  40717. private _maxPitchTan;
  40718. private _boneQuat;
  40719. private _slerping;
  40720. private _transformYawPitch;
  40721. private _transformYawPitchInv;
  40722. private _firstFrameSkipped;
  40723. private _yawRange;
  40724. private _fowardAxis;
  40725. /**
  40726. * Gets or sets the minimum yaw angle that the bone can look to
  40727. */
  40728. get minYaw(): number;
  40729. set minYaw(value: number);
  40730. /**
  40731. * Gets or sets the maximum yaw angle that the bone can look to
  40732. */
  40733. get maxYaw(): number;
  40734. set maxYaw(value: number);
  40735. /**
  40736. * Gets or sets the minimum pitch angle that the bone can look to
  40737. */
  40738. get minPitch(): number;
  40739. set minPitch(value: number);
  40740. /**
  40741. * Gets or sets the maximum pitch angle that the bone can look to
  40742. */
  40743. get maxPitch(): number;
  40744. set maxPitch(value: number);
  40745. /**
  40746. * Create a BoneLookController
  40747. * @param mesh the mesh that the bone belongs to
  40748. * @param bone the bone that will be looking to the target
  40749. * @param target the target Vector3 to look at
  40750. * @param options optional settings:
  40751. * * maxYaw: the maximum angle the bone will yaw to
  40752. * * minYaw: the minimum angle the bone will yaw to
  40753. * * maxPitch: the maximum angle the bone will pitch to
  40754. * * minPitch: the minimum angle the bone will yaw to
  40755. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40756. * * upAxis: the up axis of the coordinate system
  40757. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40758. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40759. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40760. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40761. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40762. * * adjustRoll: used to make an adjustment to the roll of the bone
  40763. **/
  40764. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40765. maxYaw?: number;
  40766. minYaw?: number;
  40767. maxPitch?: number;
  40768. minPitch?: number;
  40769. slerpAmount?: number;
  40770. upAxis?: Vector3;
  40771. upAxisSpace?: Space;
  40772. yawAxis?: Vector3;
  40773. pitchAxis?: Vector3;
  40774. adjustYaw?: number;
  40775. adjustPitch?: number;
  40776. adjustRoll?: number;
  40777. });
  40778. /**
  40779. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40780. */
  40781. update(): void;
  40782. private _getAngleDiff;
  40783. private _getAngleBetween;
  40784. private _isAngleBetween;
  40785. }
  40786. }
  40787. declare module "babylonjs/Bones/index" {
  40788. export * from "babylonjs/Bones/bone";
  40789. export * from "babylonjs/Bones/boneIKController";
  40790. export * from "babylonjs/Bones/boneLookController";
  40791. export * from "babylonjs/Bones/skeleton";
  40792. }
  40793. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40794. import { Nullable } from "babylonjs/types";
  40795. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40796. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40797. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40798. /**
  40799. * Manage the gamepad inputs to control an arc rotate camera.
  40800. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40801. */
  40802. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40803. /**
  40804. * Defines the camera the input is attached to.
  40805. */
  40806. camera: ArcRotateCamera;
  40807. /**
  40808. * Defines the gamepad the input is gathering event from.
  40809. */
  40810. gamepad: Nullable<Gamepad>;
  40811. /**
  40812. * Defines the gamepad rotation sensiblity.
  40813. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40814. */
  40815. gamepadRotationSensibility: number;
  40816. /**
  40817. * Defines the gamepad move sensiblity.
  40818. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40819. */
  40820. gamepadMoveSensibility: number;
  40821. private _yAxisScale;
  40822. /**
  40823. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40824. */
  40825. get invertYAxis(): boolean;
  40826. set invertYAxis(value: boolean);
  40827. private _onGamepadConnectedObserver;
  40828. private _onGamepadDisconnectedObserver;
  40829. /**
  40830. * Attach the input controls to a specific dom element to get the input from.
  40831. * @param element Defines the element the controls should be listened from
  40832. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40833. */
  40834. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40835. /**
  40836. * Detach the current controls from the specified dom element.
  40837. * @param element Defines the element to stop listening the inputs from
  40838. */
  40839. detachControl(element: Nullable<HTMLElement>): void;
  40840. /**
  40841. * Update the current camera state depending on the inputs that have been used this frame.
  40842. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40843. */
  40844. checkInputs(): void;
  40845. /**
  40846. * Gets the class name of the current intput.
  40847. * @returns the class name
  40848. */
  40849. getClassName(): string;
  40850. /**
  40851. * Get the friendly name associated with the input class.
  40852. * @returns the input friendly name
  40853. */
  40854. getSimpleName(): string;
  40855. }
  40856. }
  40857. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40858. import { Nullable } from "babylonjs/types";
  40859. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40860. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40861. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40862. interface ArcRotateCameraInputsManager {
  40863. /**
  40864. * Add orientation input support to the input manager.
  40865. * @returns the current input manager
  40866. */
  40867. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40868. }
  40869. }
  40870. /**
  40871. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40872. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40873. */
  40874. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40875. /**
  40876. * Defines the camera the input is attached to.
  40877. */
  40878. camera: ArcRotateCamera;
  40879. /**
  40880. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40881. */
  40882. alphaCorrection: number;
  40883. /**
  40884. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40885. */
  40886. gammaCorrection: number;
  40887. private _alpha;
  40888. private _gamma;
  40889. private _dirty;
  40890. private _deviceOrientationHandler;
  40891. /**
  40892. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40893. */
  40894. constructor();
  40895. /**
  40896. * Attach the input controls to a specific dom element to get the input from.
  40897. * @param element Defines the element the controls should be listened from
  40898. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40899. */
  40900. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40901. /** @hidden */
  40902. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40903. /**
  40904. * Update the current camera state depending on the inputs that have been used this frame.
  40905. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40906. */
  40907. checkInputs(): void;
  40908. /**
  40909. * Detach the current controls from the specified dom element.
  40910. * @param element Defines the element to stop listening the inputs from
  40911. */
  40912. detachControl(element: Nullable<HTMLElement>): void;
  40913. /**
  40914. * Gets the class name of the current intput.
  40915. * @returns the class name
  40916. */
  40917. getClassName(): string;
  40918. /**
  40919. * Get the friendly name associated with the input class.
  40920. * @returns the input friendly name
  40921. */
  40922. getSimpleName(): string;
  40923. }
  40924. }
  40925. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  40926. import { Nullable } from "babylonjs/types";
  40927. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40928. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40929. /**
  40930. * Listen to mouse events to control the camera.
  40931. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40932. */
  40933. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40934. /**
  40935. * Defines the camera the input is attached to.
  40936. */
  40937. camera: FlyCamera;
  40938. /**
  40939. * Defines if touch is enabled. (Default is true.)
  40940. */
  40941. touchEnabled: boolean;
  40942. /**
  40943. * Defines the buttons associated with the input to handle camera rotation.
  40944. */
  40945. buttons: number[];
  40946. /**
  40947. * Assign buttons for Yaw control.
  40948. */
  40949. buttonsYaw: number[];
  40950. /**
  40951. * Assign buttons for Pitch control.
  40952. */
  40953. buttonsPitch: number[];
  40954. /**
  40955. * Assign buttons for Roll control.
  40956. */
  40957. buttonsRoll: number[];
  40958. /**
  40959. * Detect if any button is being pressed while mouse is moved.
  40960. * -1 = Mouse locked.
  40961. * 0 = Left button.
  40962. * 1 = Middle Button.
  40963. * 2 = Right Button.
  40964. */
  40965. activeButton: number;
  40966. /**
  40967. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40968. * Higher values reduce its sensitivity.
  40969. */
  40970. angularSensibility: number;
  40971. private _mousemoveCallback;
  40972. private _observer;
  40973. private _rollObserver;
  40974. private previousPosition;
  40975. private noPreventDefault;
  40976. private element;
  40977. /**
  40978. * Listen to mouse events to control the camera.
  40979. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40980. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40981. */
  40982. constructor(touchEnabled?: boolean);
  40983. /**
  40984. * Attach the mouse control to the HTML DOM element.
  40985. * @param element Defines the element that listens to the input events.
  40986. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40987. */
  40988. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40989. /**
  40990. * Detach the current controls from the specified dom element.
  40991. * @param element Defines the element to stop listening the inputs from
  40992. */
  40993. detachControl(element: Nullable<HTMLElement>): void;
  40994. /**
  40995. * Gets the class name of the current input.
  40996. * @returns the class name.
  40997. */
  40998. getClassName(): string;
  40999. /**
  41000. * Get the friendly name associated with the input class.
  41001. * @returns the input's friendly name.
  41002. */
  41003. getSimpleName(): string;
  41004. private _pointerInput;
  41005. private _onMouseMove;
  41006. /**
  41007. * Rotate camera by mouse offset.
  41008. */
  41009. private rotateCamera;
  41010. }
  41011. }
  41012. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41013. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41014. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41015. /**
  41016. * Default Inputs manager for the FlyCamera.
  41017. * It groups all the default supported inputs for ease of use.
  41018. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41019. */
  41020. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41021. /**
  41022. * Instantiates a new FlyCameraInputsManager.
  41023. * @param camera Defines the camera the inputs belong to.
  41024. */
  41025. constructor(camera: FlyCamera);
  41026. /**
  41027. * Add keyboard input support to the input manager.
  41028. * @returns the new FlyCameraKeyboardMoveInput().
  41029. */
  41030. addKeyboard(): FlyCameraInputsManager;
  41031. /**
  41032. * Add mouse input support to the input manager.
  41033. * @param touchEnabled Enable touch screen support.
  41034. * @returns the new FlyCameraMouseInput().
  41035. */
  41036. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41037. }
  41038. }
  41039. declare module "babylonjs/Cameras/flyCamera" {
  41040. import { Scene } from "babylonjs/scene";
  41041. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41043. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41044. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41045. /**
  41046. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41047. * such as in a 3D Space Shooter or a Flight Simulator.
  41048. */
  41049. export class FlyCamera extends TargetCamera {
  41050. /**
  41051. * Define the collision ellipsoid of the camera.
  41052. * This is helpful for simulating a camera body, like a player's body.
  41053. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41054. */
  41055. ellipsoid: Vector3;
  41056. /**
  41057. * Define an offset for the position of the ellipsoid around the camera.
  41058. * This can be helpful if the camera is attached away from the player's body center,
  41059. * such as at its head.
  41060. */
  41061. ellipsoidOffset: Vector3;
  41062. /**
  41063. * Enable or disable collisions of the camera with the rest of the scene objects.
  41064. */
  41065. checkCollisions: boolean;
  41066. /**
  41067. * Enable or disable gravity on the camera.
  41068. */
  41069. applyGravity: boolean;
  41070. /**
  41071. * Define the current direction the camera is moving to.
  41072. */
  41073. cameraDirection: Vector3;
  41074. /**
  41075. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41076. * This overrides and empties cameraRotation.
  41077. */
  41078. rotationQuaternion: Quaternion;
  41079. /**
  41080. * Track Roll to maintain the wanted Rolling when looking around.
  41081. */
  41082. _trackRoll: number;
  41083. /**
  41084. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41085. */
  41086. rollCorrect: number;
  41087. /**
  41088. * Mimic a banked turn, Rolling the camera when Yawing.
  41089. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41090. */
  41091. bankedTurn: boolean;
  41092. /**
  41093. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41094. */
  41095. bankedTurnLimit: number;
  41096. /**
  41097. * Value of 0 disables the banked Roll.
  41098. * Value of 1 is equal to the Yaw angle in radians.
  41099. */
  41100. bankedTurnMultiplier: number;
  41101. /**
  41102. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41103. */
  41104. inputs: FlyCameraInputsManager;
  41105. /**
  41106. * Gets the input sensibility for mouse input.
  41107. * Higher values reduce sensitivity.
  41108. */
  41109. get angularSensibility(): number;
  41110. /**
  41111. * Sets the input sensibility for a mouse input.
  41112. * Higher values reduce sensitivity.
  41113. */
  41114. set angularSensibility(value: number);
  41115. /**
  41116. * Get the keys for camera movement forward.
  41117. */
  41118. get keysForward(): number[];
  41119. /**
  41120. * Set the keys for camera movement forward.
  41121. */
  41122. set keysForward(value: number[]);
  41123. /**
  41124. * Get the keys for camera movement backward.
  41125. */
  41126. get keysBackward(): number[];
  41127. set keysBackward(value: number[]);
  41128. /**
  41129. * Get the keys for camera movement up.
  41130. */
  41131. get keysUp(): number[];
  41132. /**
  41133. * Set the keys for camera movement up.
  41134. */
  41135. set keysUp(value: number[]);
  41136. /**
  41137. * Get the keys for camera movement down.
  41138. */
  41139. get keysDown(): number[];
  41140. /**
  41141. * Set the keys for camera movement down.
  41142. */
  41143. set keysDown(value: number[]);
  41144. /**
  41145. * Get the keys for camera movement left.
  41146. */
  41147. get keysLeft(): number[];
  41148. /**
  41149. * Set the keys for camera movement left.
  41150. */
  41151. set keysLeft(value: number[]);
  41152. /**
  41153. * Set the keys for camera movement right.
  41154. */
  41155. get keysRight(): number[];
  41156. /**
  41157. * Set the keys for camera movement right.
  41158. */
  41159. set keysRight(value: number[]);
  41160. /**
  41161. * Event raised when the camera collides with a mesh in the scene.
  41162. */
  41163. onCollide: (collidedMesh: AbstractMesh) => void;
  41164. private _collider;
  41165. private _needMoveForGravity;
  41166. private _oldPosition;
  41167. private _diffPosition;
  41168. private _newPosition;
  41169. /** @hidden */
  41170. _localDirection: Vector3;
  41171. /** @hidden */
  41172. _transformedDirection: Vector3;
  41173. /**
  41174. * Instantiates a FlyCamera.
  41175. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41176. * such as in a 3D Space Shooter or a Flight Simulator.
  41177. * @param name Define the name of the camera in the scene.
  41178. * @param position Define the starting position of the camera in the scene.
  41179. * @param scene Define the scene the camera belongs to.
  41180. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41181. */
  41182. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41183. /**
  41184. * Attach a control to the HTML DOM element.
  41185. * @param element Defines the element that listens to the input events.
  41186. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41187. */
  41188. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41189. /**
  41190. * Detach a control from the HTML DOM element.
  41191. * The camera will stop reacting to that input.
  41192. * @param element Defines the element that listens to the input events.
  41193. */
  41194. detachControl(element: HTMLElement): void;
  41195. private _collisionMask;
  41196. /**
  41197. * Get the mask that the camera ignores in collision events.
  41198. */
  41199. get collisionMask(): number;
  41200. /**
  41201. * Set the mask that the camera ignores in collision events.
  41202. */
  41203. set collisionMask(mask: number);
  41204. /** @hidden */
  41205. _collideWithWorld(displacement: Vector3): void;
  41206. /** @hidden */
  41207. private _onCollisionPositionChange;
  41208. /** @hidden */
  41209. _checkInputs(): void;
  41210. /** @hidden */
  41211. _decideIfNeedsToMove(): boolean;
  41212. /** @hidden */
  41213. _updatePosition(): void;
  41214. /**
  41215. * Restore the Roll to its target value at the rate specified.
  41216. * @param rate - Higher means slower restoring.
  41217. * @hidden
  41218. */
  41219. restoreRoll(rate: number): void;
  41220. /**
  41221. * Destroy the camera and release the current resources held by it.
  41222. */
  41223. dispose(): void;
  41224. /**
  41225. * Get the current object class name.
  41226. * @returns the class name.
  41227. */
  41228. getClassName(): string;
  41229. }
  41230. }
  41231. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41232. import { Nullable } from "babylonjs/types";
  41233. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41234. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41235. /**
  41236. * Listen to keyboard events to control the camera.
  41237. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41238. */
  41239. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41240. /**
  41241. * Defines the camera the input is attached to.
  41242. */
  41243. camera: FlyCamera;
  41244. /**
  41245. * The list of keyboard keys used to control the forward move of the camera.
  41246. */
  41247. keysForward: number[];
  41248. /**
  41249. * The list of keyboard keys used to control the backward move of the camera.
  41250. */
  41251. keysBackward: number[];
  41252. /**
  41253. * The list of keyboard keys used to control the forward move of the camera.
  41254. */
  41255. keysUp: number[];
  41256. /**
  41257. * The list of keyboard keys used to control the backward move of the camera.
  41258. */
  41259. keysDown: number[];
  41260. /**
  41261. * The list of keyboard keys used to control the right strafe move of the camera.
  41262. */
  41263. keysRight: number[];
  41264. /**
  41265. * The list of keyboard keys used to control the left strafe move of the camera.
  41266. */
  41267. keysLeft: number[];
  41268. private _keys;
  41269. private _onCanvasBlurObserver;
  41270. private _onKeyboardObserver;
  41271. private _engine;
  41272. private _scene;
  41273. /**
  41274. * Attach the input controls to a specific dom element to get the input from.
  41275. * @param element Defines the element the controls should be listened from
  41276. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41277. */
  41278. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41279. /**
  41280. * Detach the current controls from the specified dom element.
  41281. * @param element Defines the element to stop listening the inputs from
  41282. */
  41283. detachControl(element: Nullable<HTMLElement>): void;
  41284. /**
  41285. * Gets the class name of the current intput.
  41286. * @returns the class name
  41287. */
  41288. getClassName(): string;
  41289. /** @hidden */
  41290. _onLostFocus(e: FocusEvent): void;
  41291. /**
  41292. * Get the friendly name associated with the input class.
  41293. * @returns the input friendly name
  41294. */
  41295. getSimpleName(): string;
  41296. /**
  41297. * Update the current camera state depending on the inputs that have been used this frame.
  41298. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41299. */
  41300. checkInputs(): void;
  41301. }
  41302. }
  41303. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41304. import { Nullable } from "babylonjs/types";
  41305. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41306. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41307. /**
  41308. * Manage the mouse wheel inputs to control a follow camera.
  41309. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41310. */
  41311. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41312. /**
  41313. * Defines the camera the input is attached to.
  41314. */
  41315. camera: FollowCamera;
  41316. /**
  41317. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41318. */
  41319. axisControlRadius: boolean;
  41320. /**
  41321. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41322. */
  41323. axisControlHeight: boolean;
  41324. /**
  41325. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41326. */
  41327. axisControlRotation: boolean;
  41328. /**
  41329. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41330. * relation to mouseWheel events.
  41331. */
  41332. wheelPrecision: number;
  41333. /**
  41334. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41335. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41336. */
  41337. wheelDeltaPercentage: number;
  41338. private _wheel;
  41339. private _observer;
  41340. /**
  41341. * Attach the input controls to a specific dom element to get the input from.
  41342. * @param element Defines the element the controls should be listened from
  41343. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41344. */
  41345. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41346. /**
  41347. * Detach the current controls from the specified dom element.
  41348. * @param element Defines the element to stop listening the inputs from
  41349. */
  41350. detachControl(element: Nullable<HTMLElement>): void;
  41351. /**
  41352. * Gets the class name of the current intput.
  41353. * @returns the class name
  41354. */
  41355. getClassName(): string;
  41356. /**
  41357. * Get the friendly name associated with the input class.
  41358. * @returns the input friendly name
  41359. */
  41360. getSimpleName(): string;
  41361. }
  41362. }
  41363. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41364. import { Nullable } from "babylonjs/types";
  41365. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41366. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41367. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41368. /**
  41369. * Manage the pointers inputs to control an follow camera.
  41370. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41371. */
  41372. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41373. /**
  41374. * Defines the camera the input is attached to.
  41375. */
  41376. camera: FollowCamera;
  41377. /**
  41378. * Gets the class name of the current input.
  41379. * @returns the class name
  41380. */
  41381. getClassName(): string;
  41382. /**
  41383. * Defines the pointer angular sensibility along the X axis or how fast is
  41384. * the camera rotating.
  41385. * A negative number will reverse the axis direction.
  41386. */
  41387. angularSensibilityX: number;
  41388. /**
  41389. * Defines the pointer angular sensibility along the Y axis or how fast is
  41390. * the camera rotating.
  41391. * A negative number will reverse the axis direction.
  41392. */
  41393. angularSensibilityY: number;
  41394. /**
  41395. * Defines the pointer pinch precision or how fast is the camera zooming.
  41396. * A negative number will reverse the axis direction.
  41397. */
  41398. pinchPrecision: number;
  41399. /**
  41400. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41401. * from 0.
  41402. * It defines the percentage of current camera.radius to use as delta when
  41403. * pinch zoom is used.
  41404. */
  41405. pinchDeltaPercentage: number;
  41406. /**
  41407. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41408. */
  41409. axisXControlRadius: boolean;
  41410. /**
  41411. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41412. */
  41413. axisXControlHeight: boolean;
  41414. /**
  41415. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41416. */
  41417. axisXControlRotation: boolean;
  41418. /**
  41419. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41420. */
  41421. axisYControlRadius: boolean;
  41422. /**
  41423. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41424. */
  41425. axisYControlHeight: boolean;
  41426. /**
  41427. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41428. */
  41429. axisYControlRotation: boolean;
  41430. /**
  41431. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41432. */
  41433. axisPinchControlRadius: boolean;
  41434. /**
  41435. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41436. */
  41437. axisPinchControlHeight: boolean;
  41438. /**
  41439. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41440. */
  41441. axisPinchControlRotation: boolean;
  41442. /**
  41443. * Log error messages if basic misconfiguration has occurred.
  41444. */
  41445. warningEnable: boolean;
  41446. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41447. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41448. private _warningCounter;
  41449. private _warning;
  41450. }
  41451. }
  41452. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41453. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41454. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41455. /**
  41456. * Default Inputs manager for the FollowCamera.
  41457. * It groups all the default supported inputs for ease of use.
  41458. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41459. */
  41460. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41461. /**
  41462. * Instantiates a new FollowCameraInputsManager.
  41463. * @param camera Defines the camera the inputs belong to
  41464. */
  41465. constructor(camera: FollowCamera);
  41466. /**
  41467. * Add keyboard input support to the input manager.
  41468. * @returns the current input manager
  41469. */
  41470. addKeyboard(): FollowCameraInputsManager;
  41471. /**
  41472. * Add mouse wheel input support to the input manager.
  41473. * @returns the current input manager
  41474. */
  41475. addMouseWheel(): FollowCameraInputsManager;
  41476. /**
  41477. * Add pointers input support to the input manager.
  41478. * @returns the current input manager
  41479. */
  41480. addPointers(): FollowCameraInputsManager;
  41481. /**
  41482. * Add orientation input support to the input manager.
  41483. * @returns the current input manager
  41484. */
  41485. addVRDeviceOrientation(): FollowCameraInputsManager;
  41486. }
  41487. }
  41488. declare module "babylonjs/Cameras/followCamera" {
  41489. import { Nullable } from "babylonjs/types";
  41490. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41491. import { Scene } from "babylonjs/scene";
  41492. import { Vector3 } from "babylonjs/Maths/math.vector";
  41493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41494. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41495. /**
  41496. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41497. * an arc rotate version arcFollowCamera are available.
  41498. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41499. */
  41500. export class FollowCamera extends TargetCamera {
  41501. /**
  41502. * Distance the follow camera should follow an object at
  41503. */
  41504. radius: number;
  41505. /**
  41506. * Minimum allowed distance of the camera to the axis of rotation
  41507. * (The camera can not get closer).
  41508. * This can help limiting how the Camera is able to move in the scene.
  41509. */
  41510. lowerRadiusLimit: Nullable<number>;
  41511. /**
  41512. * Maximum allowed distance of the camera to the axis of rotation
  41513. * (The camera can not get further).
  41514. * This can help limiting how the Camera is able to move in the scene.
  41515. */
  41516. upperRadiusLimit: Nullable<number>;
  41517. /**
  41518. * Define a rotation offset between the camera and the object it follows
  41519. */
  41520. rotationOffset: number;
  41521. /**
  41522. * Minimum allowed angle to camera position relative to target object.
  41523. * This can help limiting how the Camera is able to move in the scene.
  41524. */
  41525. lowerRotationOffsetLimit: Nullable<number>;
  41526. /**
  41527. * Maximum allowed angle to camera position relative to target object.
  41528. * This can help limiting how the Camera is able to move in the scene.
  41529. */
  41530. upperRotationOffsetLimit: Nullable<number>;
  41531. /**
  41532. * Define a height offset between the camera and the object it follows.
  41533. * It can help following an object from the top (like a car chaing a plane)
  41534. */
  41535. heightOffset: number;
  41536. /**
  41537. * Minimum allowed height of camera position relative to target object.
  41538. * This can help limiting how the Camera is able to move in the scene.
  41539. */
  41540. lowerHeightOffsetLimit: Nullable<number>;
  41541. /**
  41542. * Maximum allowed height of camera position relative to target object.
  41543. * This can help limiting how the Camera is able to move in the scene.
  41544. */
  41545. upperHeightOffsetLimit: Nullable<number>;
  41546. /**
  41547. * Define how fast the camera can accelerate to follow it s target.
  41548. */
  41549. cameraAcceleration: number;
  41550. /**
  41551. * Define the speed limit of the camera following an object.
  41552. */
  41553. maxCameraSpeed: number;
  41554. /**
  41555. * Define the target of the camera.
  41556. */
  41557. lockedTarget: Nullable<AbstractMesh>;
  41558. /**
  41559. * Defines the input associated with the camera.
  41560. */
  41561. inputs: FollowCameraInputsManager;
  41562. /**
  41563. * Instantiates the follow camera.
  41564. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41565. * @param name Define the name of the camera in the scene
  41566. * @param position Define the position of the camera
  41567. * @param scene Define the scene the camera belong to
  41568. * @param lockedTarget Define the target of the camera
  41569. */
  41570. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41571. private _follow;
  41572. /**
  41573. * Attached controls to the current camera.
  41574. * @param element Defines the element the controls should be listened from
  41575. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41576. */
  41577. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41578. /**
  41579. * Detach the current controls from the camera.
  41580. * The camera will stop reacting to inputs.
  41581. * @param element Defines the element to stop listening the inputs from
  41582. */
  41583. detachControl(element: HTMLElement): void;
  41584. /** @hidden */
  41585. _checkInputs(): void;
  41586. private _checkLimits;
  41587. /**
  41588. * Gets the camera class name.
  41589. * @returns the class name
  41590. */
  41591. getClassName(): string;
  41592. }
  41593. /**
  41594. * Arc Rotate version of the follow camera.
  41595. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41596. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41597. */
  41598. export class ArcFollowCamera extends TargetCamera {
  41599. /** The longitudinal angle of the camera */
  41600. alpha: number;
  41601. /** The latitudinal angle of the camera */
  41602. beta: number;
  41603. /** The radius of the camera from its target */
  41604. radius: number;
  41605. /** Define the camera target (the messh it should follow) */
  41606. target: Nullable<AbstractMesh>;
  41607. private _cartesianCoordinates;
  41608. /**
  41609. * Instantiates a new ArcFollowCamera
  41610. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41611. * @param name Define the name of the camera
  41612. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41613. * @param beta Define the rotation angle of the camera around the elevation axis
  41614. * @param radius Define the radius of the camera from its target point
  41615. * @param target Define the target of the camera
  41616. * @param scene Define the scene the camera belongs to
  41617. */
  41618. constructor(name: string,
  41619. /** The longitudinal angle of the camera */
  41620. alpha: number,
  41621. /** The latitudinal angle of the camera */
  41622. beta: number,
  41623. /** The radius of the camera from its target */
  41624. radius: number,
  41625. /** Define the camera target (the messh it should follow) */
  41626. target: Nullable<AbstractMesh>, scene: Scene);
  41627. private _follow;
  41628. /** @hidden */
  41629. _checkInputs(): void;
  41630. /**
  41631. * Returns the class name of the object.
  41632. * It is mostly used internally for serialization purposes.
  41633. */
  41634. getClassName(): string;
  41635. }
  41636. }
  41637. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41638. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41639. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41640. import { Nullable } from "babylonjs/types";
  41641. /**
  41642. * Manage the keyboard inputs to control the movement of a follow camera.
  41643. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41644. */
  41645. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41646. /**
  41647. * Defines the camera the input is attached to.
  41648. */
  41649. camera: FollowCamera;
  41650. /**
  41651. * Defines the list of key codes associated with the up action (increase heightOffset)
  41652. */
  41653. keysHeightOffsetIncr: number[];
  41654. /**
  41655. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41656. */
  41657. keysHeightOffsetDecr: number[];
  41658. /**
  41659. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41660. */
  41661. keysHeightOffsetModifierAlt: boolean;
  41662. /**
  41663. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41664. */
  41665. keysHeightOffsetModifierCtrl: boolean;
  41666. /**
  41667. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41668. */
  41669. keysHeightOffsetModifierShift: boolean;
  41670. /**
  41671. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41672. */
  41673. keysRotationOffsetIncr: number[];
  41674. /**
  41675. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41676. */
  41677. keysRotationOffsetDecr: number[];
  41678. /**
  41679. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41680. */
  41681. keysRotationOffsetModifierAlt: boolean;
  41682. /**
  41683. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41684. */
  41685. keysRotationOffsetModifierCtrl: boolean;
  41686. /**
  41687. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41688. */
  41689. keysRotationOffsetModifierShift: boolean;
  41690. /**
  41691. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41692. */
  41693. keysRadiusIncr: number[];
  41694. /**
  41695. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41696. */
  41697. keysRadiusDecr: number[];
  41698. /**
  41699. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41700. */
  41701. keysRadiusModifierAlt: boolean;
  41702. /**
  41703. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41704. */
  41705. keysRadiusModifierCtrl: boolean;
  41706. /**
  41707. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41708. */
  41709. keysRadiusModifierShift: boolean;
  41710. /**
  41711. * Defines the rate of change of heightOffset.
  41712. */
  41713. heightSensibility: number;
  41714. /**
  41715. * Defines the rate of change of rotationOffset.
  41716. */
  41717. rotationSensibility: number;
  41718. /**
  41719. * Defines the rate of change of radius.
  41720. */
  41721. radiusSensibility: number;
  41722. private _keys;
  41723. private _ctrlPressed;
  41724. private _altPressed;
  41725. private _shiftPressed;
  41726. private _onCanvasBlurObserver;
  41727. private _onKeyboardObserver;
  41728. private _engine;
  41729. private _scene;
  41730. /**
  41731. * Attach the input controls to a specific dom element to get the input from.
  41732. * @param element Defines the element the controls should be listened from
  41733. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41734. */
  41735. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41736. /**
  41737. * Detach the current controls from the specified dom element.
  41738. * @param element Defines the element to stop listening the inputs from
  41739. */
  41740. detachControl(element: Nullable<HTMLElement>): void;
  41741. /**
  41742. * Update the current camera state depending on the inputs that have been used this frame.
  41743. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41744. */
  41745. checkInputs(): void;
  41746. /**
  41747. * Gets the class name of the current input.
  41748. * @returns the class name
  41749. */
  41750. getClassName(): string;
  41751. /**
  41752. * Get the friendly name associated with the input class.
  41753. * @returns the input friendly name
  41754. */
  41755. getSimpleName(): string;
  41756. /**
  41757. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41758. * allow modification of the heightOffset value.
  41759. */
  41760. private _modifierHeightOffset;
  41761. /**
  41762. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41763. * allow modification of the rotationOffset value.
  41764. */
  41765. private _modifierRotationOffset;
  41766. /**
  41767. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41768. * allow modification of the radius value.
  41769. */
  41770. private _modifierRadius;
  41771. }
  41772. }
  41773. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41774. import { Nullable } from "babylonjs/types";
  41775. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41776. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41777. import { Observable } from "babylonjs/Misc/observable";
  41778. module "babylonjs/Cameras/freeCameraInputsManager" {
  41779. interface FreeCameraInputsManager {
  41780. /**
  41781. * @hidden
  41782. */
  41783. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41784. /**
  41785. * Add orientation input support to the input manager.
  41786. * @returns the current input manager
  41787. */
  41788. addDeviceOrientation(): FreeCameraInputsManager;
  41789. }
  41790. }
  41791. /**
  41792. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41793. * Screen rotation is taken into account.
  41794. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41795. */
  41796. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41797. private _camera;
  41798. private _screenOrientationAngle;
  41799. private _constantTranform;
  41800. private _screenQuaternion;
  41801. private _alpha;
  41802. private _beta;
  41803. private _gamma;
  41804. /**
  41805. * Can be used to detect if a device orientation sensor is available on a device
  41806. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41807. * @returns a promise that will resolve on orientation change
  41808. */
  41809. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41810. /**
  41811. * @hidden
  41812. */
  41813. _onDeviceOrientationChangedObservable: Observable<void>;
  41814. /**
  41815. * Instantiates a new input
  41816. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41817. */
  41818. constructor();
  41819. /**
  41820. * Define the camera controlled by the input.
  41821. */
  41822. get camera(): FreeCamera;
  41823. set camera(camera: FreeCamera);
  41824. /**
  41825. * Attach the input controls to a specific dom element to get the input from.
  41826. * @param element Defines the element the controls should be listened from
  41827. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41828. */
  41829. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41830. private _orientationChanged;
  41831. private _deviceOrientation;
  41832. /**
  41833. * Detach the current controls from the specified dom element.
  41834. * @param element Defines the element to stop listening the inputs from
  41835. */
  41836. detachControl(element: Nullable<HTMLElement>): void;
  41837. /**
  41838. * Update the current camera state depending on the inputs that have been used this frame.
  41839. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41840. */
  41841. checkInputs(): void;
  41842. /**
  41843. * Gets the class name of the current intput.
  41844. * @returns the class name
  41845. */
  41846. getClassName(): string;
  41847. /**
  41848. * Get the friendly name associated with the input class.
  41849. * @returns the input friendly name
  41850. */
  41851. getSimpleName(): string;
  41852. }
  41853. }
  41854. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41855. import { Nullable } from "babylonjs/types";
  41856. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41857. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41858. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41859. /**
  41860. * Manage the gamepad inputs to control a free camera.
  41861. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41862. */
  41863. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41864. /**
  41865. * Define the camera the input is attached to.
  41866. */
  41867. camera: FreeCamera;
  41868. /**
  41869. * Define the Gamepad controlling the input
  41870. */
  41871. gamepad: Nullable<Gamepad>;
  41872. /**
  41873. * Defines the gamepad rotation sensiblity.
  41874. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41875. */
  41876. gamepadAngularSensibility: number;
  41877. /**
  41878. * Defines the gamepad move sensiblity.
  41879. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41880. */
  41881. gamepadMoveSensibility: number;
  41882. private _yAxisScale;
  41883. /**
  41884. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41885. */
  41886. get invertYAxis(): boolean;
  41887. set invertYAxis(value: boolean);
  41888. private _onGamepadConnectedObserver;
  41889. private _onGamepadDisconnectedObserver;
  41890. private _cameraTransform;
  41891. private _deltaTransform;
  41892. private _vector3;
  41893. private _vector2;
  41894. /**
  41895. * Attach the input controls to a specific dom element to get the input from.
  41896. * @param element Defines the element the controls should be listened from
  41897. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41898. */
  41899. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41900. /**
  41901. * Detach the current controls from the specified dom element.
  41902. * @param element Defines the element to stop listening the inputs from
  41903. */
  41904. detachControl(element: Nullable<HTMLElement>): void;
  41905. /**
  41906. * Update the current camera state depending on the inputs that have been used this frame.
  41907. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41908. */
  41909. checkInputs(): void;
  41910. /**
  41911. * Gets the class name of the current intput.
  41912. * @returns the class name
  41913. */
  41914. getClassName(): string;
  41915. /**
  41916. * Get the friendly name associated with the input class.
  41917. * @returns the input friendly name
  41918. */
  41919. getSimpleName(): string;
  41920. }
  41921. }
  41922. declare module "babylonjs/Misc/virtualJoystick" {
  41923. import { Nullable } from "babylonjs/types";
  41924. import { Vector3 } from "babylonjs/Maths/math.vector";
  41925. /**
  41926. * Defines the potential axis of a Joystick
  41927. */
  41928. export enum JoystickAxis {
  41929. /** X axis */
  41930. X = 0,
  41931. /** Y axis */
  41932. Y = 1,
  41933. /** Z axis */
  41934. Z = 2
  41935. }
  41936. /**
  41937. * Class used to define virtual joystick (used in touch mode)
  41938. */
  41939. export class VirtualJoystick {
  41940. /**
  41941. * Gets or sets a boolean indicating that left and right values must be inverted
  41942. */
  41943. reverseLeftRight: boolean;
  41944. /**
  41945. * Gets or sets a boolean indicating that up and down values must be inverted
  41946. */
  41947. reverseUpDown: boolean;
  41948. /**
  41949. * Gets the offset value for the position (ie. the change of the position value)
  41950. */
  41951. deltaPosition: Vector3;
  41952. /**
  41953. * Gets a boolean indicating if the virtual joystick was pressed
  41954. */
  41955. pressed: boolean;
  41956. /**
  41957. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41958. */
  41959. static Canvas: Nullable<HTMLCanvasElement>;
  41960. private static _globalJoystickIndex;
  41961. private static vjCanvasContext;
  41962. private static vjCanvasWidth;
  41963. private static vjCanvasHeight;
  41964. private static halfWidth;
  41965. private _action;
  41966. private _axisTargetedByLeftAndRight;
  41967. private _axisTargetedByUpAndDown;
  41968. private _joystickSensibility;
  41969. private _inversedSensibility;
  41970. private _joystickPointerID;
  41971. private _joystickColor;
  41972. private _joystickPointerPos;
  41973. private _joystickPreviousPointerPos;
  41974. private _joystickPointerStartPos;
  41975. private _deltaJoystickVector;
  41976. private _leftJoystick;
  41977. private _touches;
  41978. private _onPointerDownHandlerRef;
  41979. private _onPointerMoveHandlerRef;
  41980. private _onPointerUpHandlerRef;
  41981. private _onResize;
  41982. /**
  41983. * Creates a new virtual joystick
  41984. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41985. */
  41986. constructor(leftJoystick?: boolean);
  41987. /**
  41988. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41989. * @param newJoystickSensibility defines the new sensibility
  41990. */
  41991. setJoystickSensibility(newJoystickSensibility: number): void;
  41992. private _onPointerDown;
  41993. private _onPointerMove;
  41994. private _onPointerUp;
  41995. /**
  41996. * Change the color of the virtual joystick
  41997. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41998. */
  41999. setJoystickColor(newColor: string): void;
  42000. /**
  42001. * Defines a callback to call when the joystick is touched
  42002. * @param action defines the callback
  42003. */
  42004. setActionOnTouch(action: () => any): void;
  42005. /**
  42006. * Defines which axis you'd like to control for left & right
  42007. * @param axis defines the axis to use
  42008. */
  42009. setAxisForLeftRight(axis: JoystickAxis): void;
  42010. /**
  42011. * Defines which axis you'd like to control for up & down
  42012. * @param axis defines the axis to use
  42013. */
  42014. setAxisForUpDown(axis: JoystickAxis): void;
  42015. private _drawVirtualJoystick;
  42016. /**
  42017. * Release internal HTML canvas
  42018. */
  42019. releaseCanvas(): void;
  42020. }
  42021. }
  42022. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42023. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42024. import { Nullable } from "babylonjs/types";
  42025. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42026. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42027. module "babylonjs/Cameras/freeCameraInputsManager" {
  42028. interface FreeCameraInputsManager {
  42029. /**
  42030. * Add virtual joystick input support to the input manager.
  42031. * @returns the current input manager
  42032. */
  42033. addVirtualJoystick(): FreeCameraInputsManager;
  42034. }
  42035. }
  42036. /**
  42037. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42038. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42039. */
  42040. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42041. /**
  42042. * Defines the camera the input is attached to.
  42043. */
  42044. camera: FreeCamera;
  42045. private _leftjoystick;
  42046. private _rightjoystick;
  42047. /**
  42048. * Gets the left stick of the virtual joystick.
  42049. * @returns The virtual Joystick
  42050. */
  42051. getLeftJoystick(): VirtualJoystick;
  42052. /**
  42053. * Gets the right stick of the virtual joystick.
  42054. * @returns The virtual Joystick
  42055. */
  42056. getRightJoystick(): VirtualJoystick;
  42057. /**
  42058. * Update the current camera state depending on the inputs that have been used this frame.
  42059. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42060. */
  42061. checkInputs(): void;
  42062. /**
  42063. * Attach the input controls to a specific dom element to get the input from.
  42064. * @param element Defines the element the controls should be listened from
  42065. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42066. */
  42067. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42068. /**
  42069. * Detach the current controls from the specified dom element.
  42070. * @param element Defines the element to stop listening the inputs from
  42071. */
  42072. detachControl(element: Nullable<HTMLElement>): void;
  42073. /**
  42074. * Gets the class name of the current intput.
  42075. * @returns the class name
  42076. */
  42077. getClassName(): string;
  42078. /**
  42079. * Get the friendly name associated with the input class.
  42080. * @returns the input friendly name
  42081. */
  42082. getSimpleName(): string;
  42083. }
  42084. }
  42085. declare module "babylonjs/Cameras/Inputs/index" {
  42086. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42087. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42088. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42089. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42090. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42091. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42092. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42093. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42094. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42095. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42096. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42097. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42098. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42099. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42100. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42101. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42102. }
  42103. declare module "babylonjs/Cameras/touchCamera" {
  42104. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42105. import { Scene } from "babylonjs/scene";
  42106. import { Vector3 } from "babylonjs/Maths/math.vector";
  42107. /**
  42108. * This represents a FPS type of camera controlled by touch.
  42109. * This is like a universal camera minus the Gamepad controls.
  42110. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42111. */
  42112. export class TouchCamera extends FreeCamera {
  42113. /**
  42114. * Defines the touch sensibility for rotation.
  42115. * The higher the faster.
  42116. */
  42117. get touchAngularSensibility(): number;
  42118. set touchAngularSensibility(value: number);
  42119. /**
  42120. * Defines the touch sensibility for move.
  42121. * The higher the faster.
  42122. */
  42123. get touchMoveSensibility(): number;
  42124. set touchMoveSensibility(value: number);
  42125. /**
  42126. * Instantiates a new touch camera.
  42127. * This represents a FPS type of camera controlled by touch.
  42128. * This is like a universal camera minus the Gamepad controls.
  42129. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42130. * @param name Define the name of the camera in the scene
  42131. * @param position Define the start position of the camera in the scene
  42132. * @param scene Define the scene the camera belongs to
  42133. */
  42134. constructor(name: string, position: Vector3, scene: Scene);
  42135. /**
  42136. * Gets the current object class name.
  42137. * @return the class name
  42138. */
  42139. getClassName(): string;
  42140. /** @hidden */
  42141. _setupInputs(): void;
  42142. }
  42143. }
  42144. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42145. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42146. import { Scene } from "babylonjs/scene";
  42147. import { Vector3 } from "babylonjs/Maths/math.vector";
  42148. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42149. import { Axis } from "babylonjs/Maths/math.axis";
  42150. /**
  42151. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42152. * being tilted forward or back and left or right.
  42153. */
  42154. export class DeviceOrientationCamera extends FreeCamera {
  42155. private _initialQuaternion;
  42156. private _quaternionCache;
  42157. private _tmpDragQuaternion;
  42158. private _disablePointerInputWhenUsingDeviceOrientation;
  42159. /**
  42160. * Creates a new device orientation camera
  42161. * @param name The name of the camera
  42162. * @param position The start position camera
  42163. * @param scene The scene the camera belongs to
  42164. */
  42165. constructor(name: string, position: Vector3, scene: Scene);
  42166. /**
  42167. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42168. */
  42169. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42170. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42171. private _dragFactor;
  42172. /**
  42173. * Enabled turning on the y axis when the orientation sensor is active
  42174. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42175. */
  42176. enableHorizontalDragging(dragFactor?: number): void;
  42177. /**
  42178. * Gets the current instance class name ("DeviceOrientationCamera").
  42179. * This helps avoiding instanceof at run time.
  42180. * @returns the class name
  42181. */
  42182. getClassName(): string;
  42183. /**
  42184. * @hidden
  42185. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42186. */
  42187. _checkInputs(): void;
  42188. /**
  42189. * Reset the camera to its default orientation on the specified axis only.
  42190. * @param axis The axis to reset
  42191. */
  42192. resetToCurrentRotation(axis?: Axis): void;
  42193. }
  42194. }
  42195. declare module "babylonjs/Gamepads/xboxGamepad" {
  42196. import { Observable } from "babylonjs/Misc/observable";
  42197. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42198. /**
  42199. * Defines supported buttons for XBox360 compatible gamepads
  42200. */
  42201. export enum Xbox360Button {
  42202. /** A */
  42203. A = 0,
  42204. /** B */
  42205. B = 1,
  42206. /** X */
  42207. X = 2,
  42208. /** Y */
  42209. Y = 3,
  42210. /** Start */
  42211. Start = 4,
  42212. /** Back */
  42213. Back = 5,
  42214. /** Left button */
  42215. LB = 6,
  42216. /** Right button */
  42217. RB = 7,
  42218. /** Left stick */
  42219. LeftStick = 8,
  42220. /** Right stick */
  42221. RightStick = 9
  42222. }
  42223. /** Defines values for XBox360 DPad */
  42224. export enum Xbox360Dpad {
  42225. /** Up */
  42226. Up = 0,
  42227. /** Down */
  42228. Down = 1,
  42229. /** Left */
  42230. Left = 2,
  42231. /** Right */
  42232. Right = 3
  42233. }
  42234. /**
  42235. * Defines a XBox360 gamepad
  42236. */
  42237. export class Xbox360Pad extends Gamepad {
  42238. private _leftTrigger;
  42239. private _rightTrigger;
  42240. private _onlefttriggerchanged;
  42241. private _onrighttriggerchanged;
  42242. private _onbuttondown;
  42243. private _onbuttonup;
  42244. private _ondpaddown;
  42245. private _ondpadup;
  42246. /** Observable raised when a button is pressed */
  42247. onButtonDownObservable: Observable<Xbox360Button>;
  42248. /** Observable raised when a button is released */
  42249. onButtonUpObservable: Observable<Xbox360Button>;
  42250. /** Observable raised when a pad is pressed */
  42251. onPadDownObservable: Observable<Xbox360Dpad>;
  42252. /** Observable raised when a pad is released */
  42253. onPadUpObservable: Observable<Xbox360Dpad>;
  42254. private _buttonA;
  42255. private _buttonB;
  42256. private _buttonX;
  42257. private _buttonY;
  42258. private _buttonBack;
  42259. private _buttonStart;
  42260. private _buttonLB;
  42261. private _buttonRB;
  42262. private _buttonLeftStick;
  42263. private _buttonRightStick;
  42264. private _dPadUp;
  42265. private _dPadDown;
  42266. private _dPadLeft;
  42267. private _dPadRight;
  42268. private _isXboxOnePad;
  42269. /**
  42270. * Creates a new XBox360 gamepad object
  42271. * @param id defines the id of this gamepad
  42272. * @param index defines its index
  42273. * @param gamepad defines the internal HTML gamepad object
  42274. * @param xboxOne defines if it is a XBox One gamepad
  42275. */
  42276. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42277. /**
  42278. * Defines the callback to call when left trigger is pressed
  42279. * @param callback defines the callback to use
  42280. */
  42281. onlefttriggerchanged(callback: (value: number) => void): void;
  42282. /**
  42283. * Defines the callback to call when right trigger is pressed
  42284. * @param callback defines the callback to use
  42285. */
  42286. onrighttriggerchanged(callback: (value: number) => void): void;
  42287. /**
  42288. * Gets the left trigger value
  42289. */
  42290. get leftTrigger(): number;
  42291. /**
  42292. * Sets the left trigger value
  42293. */
  42294. set leftTrigger(newValue: number);
  42295. /**
  42296. * Gets the right trigger value
  42297. */
  42298. get rightTrigger(): number;
  42299. /**
  42300. * Sets the right trigger value
  42301. */
  42302. set rightTrigger(newValue: number);
  42303. /**
  42304. * Defines the callback to call when a button is pressed
  42305. * @param callback defines the callback to use
  42306. */
  42307. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42308. /**
  42309. * Defines the callback to call when a button is released
  42310. * @param callback defines the callback to use
  42311. */
  42312. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42313. /**
  42314. * Defines the callback to call when a pad is pressed
  42315. * @param callback defines the callback to use
  42316. */
  42317. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42318. /**
  42319. * Defines the callback to call when a pad is released
  42320. * @param callback defines the callback to use
  42321. */
  42322. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42323. private _setButtonValue;
  42324. private _setDPadValue;
  42325. /**
  42326. * Gets the value of the `A` button
  42327. */
  42328. get buttonA(): number;
  42329. /**
  42330. * Sets the value of the `A` button
  42331. */
  42332. set buttonA(value: number);
  42333. /**
  42334. * Gets the value of the `B` button
  42335. */
  42336. get buttonB(): number;
  42337. /**
  42338. * Sets the value of the `B` button
  42339. */
  42340. set buttonB(value: number);
  42341. /**
  42342. * Gets the value of the `X` button
  42343. */
  42344. get buttonX(): number;
  42345. /**
  42346. * Sets the value of the `X` button
  42347. */
  42348. set buttonX(value: number);
  42349. /**
  42350. * Gets the value of the `Y` button
  42351. */
  42352. get buttonY(): number;
  42353. /**
  42354. * Sets the value of the `Y` button
  42355. */
  42356. set buttonY(value: number);
  42357. /**
  42358. * Gets the value of the `Start` button
  42359. */
  42360. get buttonStart(): number;
  42361. /**
  42362. * Sets the value of the `Start` button
  42363. */
  42364. set buttonStart(value: number);
  42365. /**
  42366. * Gets the value of the `Back` button
  42367. */
  42368. get buttonBack(): number;
  42369. /**
  42370. * Sets the value of the `Back` button
  42371. */
  42372. set buttonBack(value: number);
  42373. /**
  42374. * Gets the value of the `Left` button
  42375. */
  42376. get buttonLB(): number;
  42377. /**
  42378. * Sets the value of the `Left` button
  42379. */
  42380. set buttonLB(value: number);
  42381. /**
  42382. * Gets the value of the `Right` button
  42383. */
  42384. get buttonRB(): number;
  42385. /**
  42386. * Sets the value of the `Right` button
  42387. */
  42388. set buttonRB(value: number);
  42389. /**
  42390. * Gets the value of the Left joystick
  42391. */
  42392. get buttonLeftStick(): number;
  42393. /**
  42394. * Sets the value of the Left joystick
  42395. */
  42396. set buttonLeftStick(value: number);
  42397. /**
  42398. * Gets the value of the Right joystick
  42399. */
  42400. get buttonRightStick(): number;
  42401. /**
  42402. * Sets the value of the Right joystick
  42403. */
  42404. set buttonRightStick(value: number);
  42405. /**
  42406. * Gets the value of D-pad up
  42407. */
  42408. get dPadUp(): number;
  42409. /**
  42410. * Sets the value of D-pad up
  42411. */
  42412. set dPadUp(value: number);
  42413. /**
  42414. * Gets the value of D-pad down
  42415. */
  42416. get dPadDown(): number;
  42417. /**
  42418. * Sets the value of D-pad down
  42419. */
  42420. set dPadDown(value: number);
  42421. /**
  42422. * Gets the value of D-pad left
  42423. */
  42424. get dPadLeft(): number;
  42425. /**
  42426. * Sets the value of D-pad left
  42427. */
  42428. set dPadLeft(value: number);
  42429. /**
  42430. * Gets the value of D-pad right
  42431. */
  42432. get dPadRight(): number;
  42433. /**
  42434. * Sets the value of D-pad right
  42435. */
  42436. set dPadRight(value: number);
  42437. /**
  42438. * Force the gamepad to synchronize with device values
  42439. */
  42440. update(): void;
  42441. /**
  42442. * Disposes the gamepad
  42443. */
  42444. dispose(): void;
  42445. }
  42446. }
  42447. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42448. import { Observable } from "babylonjs/Misc/observable";
  42449. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42450. /**
  42451. * Defines supported buttons for DualShock compatible gamepads
  42452. */
  42453. export enum DualShockButton {
  42454. /** Cross */
  42455. Cross = 0,
  42456. /** Circle */
  42457. Circle = 1,
  42458. /** Square */
  42459. Square = 2,
  42460. /** Triangle */
  42461. Triangle = 3,
  42462. /** Options */
  42463. Options = 4,
  42464. /** Share */
  42465. Share = 5,
  42466. /** L1 */
  42467. L1 = 6,
  42468. /** R1 */
  42469. R1 = 7,
  42470. /** Left stick */
  42471. LeftStick = 8,
  42472. /** Right stick */
  42473. RightStick = 9
  42474. }
  42475. /** Defines values for DualShock DPad */
  42476. export enum DualShockDpad {
  42477. /** Up */
  42478. Up = 0,
  42479. /** Down */
  42480. Down = 1,
  42481. /** Left */
  42482. Left = 2,
  42483. /** Right */
  42484. Right = 3
  42485. }
  42486. /**
  42487. * Defines a DualShock gamepad
  42488. */
  42489. export class DualShockPad extends Gamepad {
  42490. private _leftTrigger;
  42491. private _rightTrigger;
  42492. private _onlefttriggerchanged;
  42493. private _onrighttriggerchanged;
  42494. private _onbuttondown;
  42495. private _onbuttonup;
  42496. private _ondpaddown;
  42497. private _ondpadup;
  42498. /** Observable raised when a button is pressed */
  42499. onButtonDownObservable: Observable<DualShockButton>;
  42500. /** Observable raised when a button is released */
  42501. onButtonUpObservable: Observable<DualShockButton>;
  42502. /** Observable raised when a pad is pressed */
  42503. onPadDownObservable: Observable<DualShockDpad>;
  42504. /** Observable raised when a pad is released */
  42505. onPadUpObservable: Observable<DualShockDpad>;
  42506. private _buttonCross;
  42507. private _buttonCircle;
  42508. private _buttonSquare;
  42509. private _buttonTriangle;
  42510. private _buttonShare;
  42511. private _buttonOptions;
  42512. private _buttonL1;
  42513. private _buttonR1;
  42514. private _buttonLeftStick;
  42515. private _buttonRightStick;
  42516. private _dPadUp;
  42517. private _dPadDown;
  42518. private _dPadLeft;
  42519. private _dPadRight;
  42520. /**
  42521. * Creates a new DualShock gamepad object
  42522. * @param id defines the id of this gamepad
  42523. * @param index defines its index
  42524. * @param gamepad defines the internal HTML gamepad object
  42525. */
  42526. constructor(id: string, index: number, gamepad: any);
  42527. /**
  42528. * Defines the callback to call when left trigger is pressed
  42529. * @param callback defines the callback to use
  42530. */
  42531. onlefttriggerchanged(callback: (value: number) => void): void;
  42532. /**
  42533. * Defines the callback to call when right trigger is pressed
  42534. * @param callback defines the callback to use
  42535. */
  42536. onrighttriggerchanged(callback: (value: number) => void): void;
  42537. /**
  42538. * Gets the left trigger value
  42539. */
  42540. get leftTrigger(): number;
  42541. /**
  42542. * Sets the left trigger value
  42543. */
  42544. set leftTrigger(newValue: number);
  42545. /**
  42546. * Gets the right trigger value
  42547. */
  42548. get rightTrigger(): number;
  42549. /**
  42550. * Sets the right trigger value
  42551. */
  42552. set rightTrigger(newValue: number);
  42553. /**
  42554. * Defines the callback to call when a button is pressed
  42555. * @param callback defines the callback to use
  42556. */
  42557. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42558. /**
  42559. * Defines the callback to call when a button is released
  42560. * @param callback defines the callback to use
  42561. */
  42562. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42563. /**
  42564. * Defines the callback to call when a pad is pressed
  42565. * @param callback defines the callback to use
  42566. */
  42567. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42568. /**
  42569. * Defines the callback to call when a pad is released
  42570. * @param callback defines the callback to use
  42571. */
  42572. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42573. private _setButtonValue;
  42574. private _setDPadValue;
  42575. /**
  42576. * Gets the value of the `Cross` button
  42577. */
  42578. get buttonCross(): number;
  42579. /**
  42580. * Sets the value of the `Cross` button
  42581. */
  42582. set buttonCross(value: number);
  42583. /**
  42584. * Gets the value of the `Circle` button
  42585. */
  42586. get buttonCircle(): number;
  42587. /**
  42588. * Sets the value of the `Circle` button
  42589. */
  42590. set buttonCircle(value: number);
  42591. /**
  42592. * Gets the value of the `Square` button
  42593. */
  42594. get buttonSquare(): number;
  42595. /**
  42596. * Sets the value of the `Square` button
  42597. */
  42598. set buttonSquare(value: number);
  42599. /**
  42600. * Gets the value of the `Triangle` button
  42601. */
  42602. get buttonTriangle(): number;
  42603. /**
  42604. * Sets the value of the `Triangle` button
  42605. */
  42606. set buttonTriangle(value: number);
  42607. /**
  42608. * Gets the value of the `Options` button
  42609. */
  42610. get buttonOptions(): number;
  42611. /**
  42612. * Sets the value of the `Options` button
  42613. */
  42614. set buttonOptions(value: number);
  42615. /**
  42616. * Gets the value of the `Share` button
  42617. */
  42618. get buttonShare(): number;
  42619. /**
  42620. * Sets the value of the `Share` button
  42621. */
  42622. set buttonShare(value: number);
  42623. /**
  42624. * Gets the value of the `L1` button
  42625. */
  42626. get buttonL1(): number;
  42627. /**
  42628. * Sets the value of the `L1` button
  42629. */
  42630. set buttonL1(value: number);
  42631. /**
  42632. * Gets the value of the `R1` button
  42633. */
  42634. get buttonR1(): number;
  42635. /**
  42636. * Sets the value of the `R1` button
  42637. */
  42638. set buttonR1(value: number);
  42639. /**
  42640. * Gets the value of the Left joystick
  42641. */
  42642. get buttonLeftStick(): number;
  42643. /**
  42644. * Sets the value of the Left joystick
  42645. */
  42646. set buttonLeftStick(value: number);
  42647. /**
  42648. * Gets the value of the Right joystick
  42649. */
  42650. get buttonRightStick(): number;
  42651. /**
  42652. * Sets the value of the Right joystick
  42653. */
  42654. set buttonRightStick(value: number);
  42655. /**
  42656. * Gets the value of D-pad up
  42657. */
  42658. get dPadUp(): number;
  42659. /**
  42660. * Sets the value of D-pad up
  42661. */
  42662. set dPadUp(value: number);
  42663. /**
  42664. * Gets the value of D-pad down
  42665. */
  42666. get dPadDown(): number;
  42667. /**
  42668. * Sets the value of D-pad down
  42669. */
  42670. set dPadDown(value: number);
  42671. /**
  42672. * Gets the value of D-pad left
  42673. */
  42674. get dPadLeft(): number;
  42675. /**
  42676. * Sets the value of D-pad left
  42677. */
  42678. set dPadLeft(value: number);
  42679. /**
  42680. * Gets the value of D-pad right
  42681. */
  42682. get dPadRight(): number;
  42683. /**
  42684. * Sets the value of D-pad right
  42685. */
  42686. set dPadRight(value: number);
  42687. /**
  42688. * Force the gamepad to synchronize with device values
  42689. */
  42690. update(): void;
  42691. /**
  42692. * Disposes the gamepad
  42693. */
  42694. dispose(): void;
  42695. }
  42696. }
  42697. declare module "babylonjs/Gamepads/gamepadManager" {
  42698. import { Observable } from "babylonjs/Misc/observable";
  42699. import { Nullable } from "babylonjs/types";
  42700. import { Scene } from "babylonjs/scene";
  42701. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42702. /**
  42703. * Manager for handling gamepads
  42704. */
  42705. export class GamepadManager {
  42706. private _scene?;
  42707. private _babylonGamepads;
  42708. private _oneGamepadConnected;
  42709. /** @hidden */
  42710. _isMonitoring: boolean;
  42711. private _gamepadEventSupported;
  42712. private _gamepadSupport?;
  42713. /**
  42714. * observable to be triggered when the gamepad controller has been connected
  42715. */
  42716. onGamepadConnectedObservable: Observable<Gamepad>;
  42717. /**
  42718. * observable to be triggered when the gamepad controller has been disconnected
  42719. */
  42720. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42721. private _onGamepadConnectedEvent;
  42722. private _onGamepadDisconnectedEvent;
  42723. /**
  42724. * Initializes the gamepad manager
  42725. * @param _scene BabylonJS scene
  42726. */
  42727. constructor(_scene?: Scene | undefined);
  42728. /**
  42729. * The gamepads in the game pad manager
  42730. */
  42731. get gamepads(): Gamepad[];
  42732. /**
  42733. * Get the gamepad controllers based on type
  42734. * @param type The type of gamepad controller
  42735. * @returns Nullable gamepad
  42736. */
  42737. getGamepadByType(type?: number): Nullable<Gamepad>;
  42738. /**
  42739. * Disposes the gamepad manager
  42740. */
  42741. dispose(): void;
  42742. private _addNewGamepad;
  42743. private _startMonitoringGamepads;
  42744. private _stopMonitoringGamepads;
  42745. /** @hidden */
  42746. _checkGamepadsStatus(): void;
  42747. private _updateGamepadObjects;
  42748. }
  42749. }
  42750. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42751. import { Nullable } from "babylonjs/types";
  42752. import { Scene } from "babylonjs/scene";
  42753. import { ISceneComponent } from "babylonjs/sceneComponent";
  42754. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42755. module "babylonjs/scene" {
  42756. interface Scene {
  42757. /** @hidden */
  42758. _gamepadManager: Nullable<GamepadManager>;
  42759. /**
  42760. * Gets the gamepad manager associated with the scene
  42761. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42762. */
  42763. gamepadManager: GamepadManager;
  42764. }
  42765. }
  42766. module "babylonjs/Cameras/freeCameraInputsManager" {
  42767. /**
  42768. * Interface representing a free camera inputs manager
  42769. */
  42770. interface FreeCameraInputsManager {
  42771. /**
  42772. * Adds gamepad input support to the FreeCameraInputsManager.
  42773. * @returns the FreeCameraInputsManager
  42774. */
  42775. addGamepad(): FreeCameraInputsManager;
  42776. }
  42777. }
  42778. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42779. /**
  42780. * Interface representing an arc rotate camera inputs manager
  42781. */
  42782. interface ArcRotateCameraInputsManager {
  42783. /**
  42784. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42785. * @returns the camera inputs manager
  42786. */
  42787. addGamepad(): ArcRotateCameraInputsManager;
  42788. }
  42789. }
  42790. /**
  42791. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42792. */
  42793. export class GamepadSystemSceneComponent implements ISceneComponent {
  42794. /**
  42795. * The component name helpfull to identify the component in the list of scene components.
  42796. */
  42797. readonly name: string;
  42798. /**
  42799. * The scene the component belongs to.
  42800. */
  42801. scene: Scene;
  42802. /**
  42803. * Creates a new instance of the component for the given scene
  42804. * @param scene Defines the scene to register the component in
  42805. */
  42806. constructor(scene: Scene);
  42807. /**
  42808. * Registers the component in a given scene
  42809. */
  42810. register(): void;
  42811. /**
  42812. * Rebuilds the elements related to this component in case of
  42813. * context lost for instance.
  42814. */
  42815. rebuild(): void;
  42816. /**
  42817. * Disposes the component and the associated ressources
  42818. */
  42819. dispose(): void;
  42820. private _beforeCameraUpdate;
  42821. }
  42822. }
  42823. declare module "babylonjs/Cameras/universalCamera" {
  42824. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42825. import { Scene } from "babylonjs/scene";
  42826. import { Vector3 } from "babylonjs/Maths/math.vector";
  42827. import "babylonjs/Gamepads/gamepadSceneComponent";
  42828. /**
  42829. * 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,
  42830. * which still works and will still be found in many Playgrounds.
  42831. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42832. */
  42833. export class UniversalCamera extends TouchCamera {
  42834. /**
  42835. * Defines the gamepad rotation sensiblity.
  42836. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42837. */
  42838. get gamepadAngularSensibility(): number;
  42839. set gamepadAngularSensibility(value: number);
  42840. /**
  42841. * Defines the gamepad move sensiblity.
  42842. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42843. */
  42844. get gamepadMoveSensibility(): number;
  42845. set gamepadMoveSensibility(value: number);
  42846. /**
  42847. * 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,
  42848. * which still works and will still be found in many Playgrounds.
  42849. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42850. * @param name Define the name of the camera in the scene
  42851. * @param position Define the start position of the camera in the scene
  42852. * @param scene Define the scene the camera belongs to
  42853. */
  42854. constructor(name: string, position: Vector3, scene: Scene);
  42855. /**
  42856. * Gets the current object class name.
  42857. * @return the class name
  42858. */
  42859. getClassName(): string;
  42860. }
  42861. }
  42862. declare module "babylonjs/Cameras/gamepadCamera" {
  42863. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42864. import { Scene } from "babylonjs/scene";
  42865. import { Vector3 } from "babylonjs/Maths/math.vector";
  42866. /**
  42867. * This represents a FPS type of camera. This is only here for back compat purpose.
  42868. * Please use the UniversalCamera instead as both are identical.
  42869. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42870. */
  42871. export class GamepadCamera extends UniversalCamera {
  42872. /**
  42873. * Instantiates a new Gamepad Camera
  42874. * This represents a FPS type of camera. This is only here for back compat purpose.
  42875. * Please use the UniversalCamera instead as both are identical.
  42876. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42877. * @param name Define the name of the camera in the scene
  42878. * @param position Define the start position of the camera in the scene
  42879. * @param scene Define the scene the camera belongs to
  42880. */
  42881. constructor(name: string, position: Vector3, scene: Scene);
  42882. /**
  42883. * Gets the current object class name.
  42884. * @return the class name
  42885. */
  42886. getClassName(): string;
  42887. }
  42888. }
  42889. declare module "babylonjs/Shaders/pass.fragment" {
  42890. /** @hidden */
  42891. export var passPixelShader: {
  42892. name: string;
  42893. shader: string;
  42894. };
  42895. }
  42896. declare module "babylonjs/Shaders/passCube.fragment" {
  42897. /** @hidden */
  42898. export var passCubePixelShader: {
  42899. name: string;
  42900. shader: string;
  42901. };
  42902. }
  42903. declare module "babylonjs/PostProcesses/passPostProcess" {
  42904. import { Nullable } from "babylonjs/types";
  42905. import { Camera } from "babylonjs/Cameras/camera";
  42906. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42907. import { Engine } from "babylonjs/Engines/engine";
  42908. import "babylonjs/Shaders/pass.fragment";
  42909. import "babylonjs/Shaders/passCube.fragment";
  42910. /**
  42911. * PassPostProcess which produces an output the same as it's input
  42912. */
  42913. export class PassPostProcess extends PostProcess {
  42914. /**
  42915. * Creates the PassPostProcess
  42916. * @param name The name of the effect.
  42917. * @param options The required width/height ratio to downsize to before computing the render pass.
  42918. * @param camera The camera to apply the render pass to.
  42919. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42920. * @param engine The engine which the post process will be applied. (default: current engine)
  42921. * @param reusable If the post process can be reused on the same frame. (default: false)
  42922. * @param textureType The type of texture to be used when performing the post processing.
  42923. * @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)
  42924. */
  42925. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42926. }
  42927. /**
  42928. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42929. */
  42930. export class PassCubePostProcess extends PostProcess {
  42931. private _face;
  42932. /**
  42933. * Gets or sets the cube face to display.
  42934. * * 0 is +X
  42935. * * 1 is -X
  42936. * * 2 is +Y
  42937. * * 3 is -Y
  42938. * * 4 is +Z
  42939. * * 5 is -Z
  42940. */
  42941. get face(): number;
  42942. set face(value: number);
  42943. /**
  42944. * Creates the PassCubePostProcess
  42945. * @param name The name of the effect.
  42946. * @param options The required width/height ratio to downsize to before computing the render pass.
  42947. * @param camera The camera to apply the render pass to.
  42948. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42949. * @param engine The engine which the post process will be applied. (default: current engine)
  42950. * @param reusable If the post process can be reused on the same frame. (default: false)
  42951. * @param textureType The type of texture to be used when performing the post processing.
  42952. * @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)
  42953. */
  42954. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42955. }
  42956. }
  42957. declare module "babylonjs/Shaders/anaglyph.fragment" {
  42958. /** @hidden */
  42959. export var anaglyphPixelShader: {
  42960. name: string;
  42961. shader: string;
  42962. };
  42963. }
  42964. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  42965. import { Engine } from "babylonjs/Engines/engine";
  42966. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42967. import { Camera } from "babylonjs/Cameras/camera";
  42968. import "babylonjs/Shaders/anaglyph.fragment";
  42969. /**
  42970. * Postprocess used to generate anaglyphic rendering
  42971. */
  42972. export class AnaglyphPostProcess extends PostProcess {
  42973. private _passedProcess;
  42974. /**
  42975. * Creates a new AnaglyphPostProcess
  42976. * @param name defines postprocess name
  42977. * @param options defines creation options or target ratio scale
  42978. * @param rigCameras defines cameras using this postprocess
  42979. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42980. * @param engine defines hosting engine
  42981. * @param reusable defines if the postprocess will be reused multiple times per frame
  42982. */
  42983. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42984. }
  42985. }
  42986. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  42987. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  42988. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42989. import { Scene } from "babylonjs/scene";
  42990. import { Vector3 } from "babylonjs/Maths/math.vector";
  42991. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42992. /**
  42993. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42994. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42995. */
  42996. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42997. /**
  42998. * Creates a new AnaglyphArcRotateCamera
  42999. * @param name defines camera name
  43000. * @param alpha defines alpha angle (in radians)
  43001. * @param beta defines beta angle (in radians)
  43002. * @param radius defines radius
  43003. * @param target defines camera target
  43004. * @param interaxialDistance defines distance between each color axis
  43005. * @param scene defines the hosting scene
  43006. */
  43007. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43008. /**
  43009. * Gets camera class name
  43010. * @returns AnaglyphArcRotateCamera
  43011. */
  43012. getClassName(): string;
  43013. }
  43014. }
  43015. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43016. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43017. import { Scene } from "babylonjs/scene";
  43018. import { Vector3 } from "babylonjs/Maths/math.vector";
  43019. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43020. /**
  43021. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  43022. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43023. */
  43024. export class AnaglyphFreeCamera extends FreeCamera {
  43025. /**
  43026. * Creates a new AnaglyphFreeCamera
  43027. * @param name defines camera name
  43028. * @param position defines initial position
  43029. * @param interaxialDistance defines distance between each color axis
  43030. * @param scene defines the hosting scene
  43031. */
  43032. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43033. /**
  43034. * Gets camera class name
  43035. * @returns AnaglyphFreeCamera
  43036. */
  43037. getClassName(): string;
  43038. }
  43039. }
  43040. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43041. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43042. import { Scene } from "babylonjs/scene";
  43043. import { Vector3 } from "babylonjs/Maths/math.vector";
  43044. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43045. /**
  43046. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43047. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43048. */
  43049. export class AnaglyphGamepadCamera extends GamepadCamera {
  43050. /**
  43051. * Creates a new AnaglyphGamepadCamera
  43052. * @param name defines camera name
  43053. * @param position defines initial position
  43054. * @param interaxialDistance defines distance between each color axis
  43055. * @param scene defines the hosting scene
  43056. */
  43057. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43058. /**
  43059. * Gets camera class name
  43060. * @returns AnaglyphGamepadCamera
  43061. */
  43062. getClassName(): string;
  43063. }
  43064. }
  43065. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43066. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43067. import { Scene } from "babylonjs/scene";
  43068. import { Vector3 } from "babylonjs/Maths/math.vector";
  43069. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43070. /**
  43071. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43072. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43073. */
  43074. export class AnaglyphUniversalCamera extends UniversalCamera {
  43075. /**
  43076. * Creates a new AnaglyphUniversalCamera
  43077. * @param name defines camera name
  43078. * @param position defines initial position
  43079. * @param interaxialDistance defines distance between each color axis
  43080. * @param scene defines the hosting scene
  43081. */
  43082. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43083. /**
  43084. * Gets camera class name
  43085. * @returns AnaglyphUniversalCamera
  43086. */
  43087. getClassName(): string;
  43088. }
  43089. }
  43090. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  43091. /** @hidden */
  43092. export var stereoscopicInterlacePixelShader: {
  43093. name: string;
  43094. shader: string;
  43095. };
  43096. }
  43097. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  43098. import { Camera } from "babylonjs/Cameras/camera";
  43099. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43100. import { Engine } from "babylonjs/Engines/engine";
  43101. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  43102. /**
  43103. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  43104. */
  43105. export class StereoscopicInterlacePostProcessI extends PostProcess {
  43106. private _stepSize;
  43107. private _passedProcess;
  43108. /**
  43109. * Initializes a StereoscopicInterlacePostProcessI
  43110. * @param name The name of the effect.
  43111. * @param rigCameras The rig cameras to be appled to the post process
  43112. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  43113. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  43114. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43115. * @param engine The engine which the post process will be applied. (default: current engine)
  43116. * @param reusable If the post process can be reused on the same frame. (default: false)
  43117. */
  43118. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43119. }
  43120. /**
  43121. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  43122. */
  43123. export class StereoscopicInterlacePostProcess extends PostProcess {
  43124. private _stepSize;
  43125. private _passedProcess;
  43126. /**
  43127. * Initializes a StereoscopicInterlacePostProcess
  43128. * @param name The name of the effect.
  43129. * @param rigCameras The rig cameras to be appled to the post process
  43130. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  43131. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43132. * @param engine The engine which the post process will be applied. (default: current engine)
  43133. * @param reusable If the post process can be reused on the same frame. (default: false)
  43134. */
  43135. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43136. }
  43137. }
  43138. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43139. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43140. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43141. import { Scene } from "babylonjs/scene";
  43142. import { Vector3 } from "babylonjs/Maths/math.vector";
  43143. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43144. /**
  43145. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43146. * @see http://doc.babylonjs.com/features/cameras
  43147. */
  43148. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43149. /**
  43150. * Creates a new StereoscopicArcRotateCamera
  43151. * @param name defines camera name
  43152. * @param alpha defines alpha angle (in radians)
  43153. * @param beta defines beta angle (in radians)
  43154. * @param radius defines radius
  43155. * @param target defines camera target
  43156. * @param interaxialDistance defines distance between each color axis
  43157. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43158. * @param scene defines the hosting scene
  43159. */
  43160. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43161. /**
  43162. * Gets camera class name
  43163. * @returns StereoscopicArcRotateCamera
  43164. */
  43165. getClassName(): string;
  43166. }
  43167. }
  43168. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43169. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43170. import { Scene } from "babylonjs/scene";
  43171. import { Vector3 } from "babylonjs/Maths/math.vector";
  43172. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43173. /**
  43174. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43175. * @see http://doc.babylonjs.com/features/cameras
  43176. */
  43177. export class StereoscopicFreeCamera extends FreeCamera {
  43178. /**
  43179. * Creates a new StereoscopicFreeCamera
  43180. * @param name defines camera name
  43181. * @param position defines initial position
  43182. * @param interaxialDistance defines distance between each color axis
  43183. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43184. * @param scene defines the hosting scene
  43185. */
  43186. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43187. /**
  43188. * Gets camera class name
  43189. * @returns StereoscopicFreeCamera
  43190. */
  43191. getClassName(): string;
  43192. }
  43193. }
  43194. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43195. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43196. import { Scene } from "babylonjs/scene";
  43197. import { Vector3 } from "babylonjs/Maths/math.vector";
  43198. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43199. /**
  43200. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43201. * @see http://doc.babylonjs.com/features/cameras
  43202. */
  43203. export class StereoscopicGamepadCamera extends GamepadCamera {
  43204. /**
  43205. * Creates a new StereoscopicGamepadCamera
  43206. * @param name defines camera name
  43207. * @param position defines initial position
  43208. * @param interaxialDistance defines distance between each color axis
  43209. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43210. * @param scene defines the hosting scene
  43211. */
  43212. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43213. /**
  43214. * Gets camera class name
  43215. * @returns StereoscopicGamepadCamera
  43216. */
  43217. getClassName(): string;
  43218. }
  43219. }
  43220. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43221. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43222. import { Scene } from "babylonjs/scene";
  43223. import { Vector3 } from "babylonjs/Maths/math.vector";
  43224. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43225. /**
  43226. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43227. * @see http://doc.babylonjs.com/features/cameras
  43228. */
  43229. export class StereoscopicUniversalCamera extends UniversalCamera {
  43230. /**
  43231. * Creates a new StereoscopicUniversalCamera
  43232. * @param name defines camera name
  43233. * @param position defines initial position
  43234. * @param interaxialDistance defines distance between each color axis
  43235. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43236. * @param scene defines the hosting scene
  43237. */
  43238. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43239. /**
  43240. * Gets camera class name
  43241. * @returns StereoscopicUniversalCamera
  43242. */
  43243. getClassName(): string;
  43244. }
  43245. }
  43246. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43247. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43248. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43249. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43250. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43251. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43252. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43253. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43254. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43255. }
  43256. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43257. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43258. import { Scene } from "babylonjs/scene";
  43259. import { Vector3 } from "babylonjs/Maths/math.vector";
  43260. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43261. /**
  43262. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43263. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43264. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43265. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43266. */
  43267. export class VirtualJoysticksCamera extends FreeCamera {
  43268. /**
  43269. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43270. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43271. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43272. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43273. * @param name Define the name of the camera in the scene
  43274. * @param position Define the start position of the camera in the scene
  43275. * @param scene Define the scene the camera belongs to
  43276. */
  43277. constructor(name: string, position: Vector3, scene: Scene);
  43278. /**
  43279. * Gets the current object class name.
  43280. * @return the class name
  43281. */
  43282. getClassName(): string;
  43283. }
  43284. }
  43285. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43286. import { Matrix } from "babylonjs/Maths/math.vector";
  43287. /**
  43288. * This represents all the required metrics to create a VR camera.
  43289. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43290. */
  43291. export class VRCameraMetrics {
  43292. /**
  43293. * Define the horizontal resolution off the screen.
  43294. */
  43295. hResolution: number;
  43296. /**
  43297. * Define the vertical resolution off the screen.
  43298. */
  43299. vResolution: number;
  43300. /**
  43301. * Define the horizontal screen size.
  43302. */
  43303. hScreenSize: number;
  43304. /**
  43305. * Define the vertical screen size.
  43306. */
  43307. vScreenSize: number;
  43308. /**
  43309. * Define the vertical screen center position.
  43310. */
  43311. vScreenCenter: number;
  43312. /**
  43313. * Define the distance of the eyes to the screen.
  43314. */
  43315. eyeToScreenDistance: number;
  43316. /**
  43317. * Define the distance between both lenses
  43318. */
  43319. lensSeparationDistance: number;
  43320. /**
  43321. * Define the distance between both viewer's eyes.
  43322. */
  43323. interpupillaryDistance: number;
  43324. /**
  43325. * Define the distortion factor of the VR postprocess.
  43326. * Please, touch with care.
  43327. */
  43328. distortionK: number[];
  43329. /**
  43330. * Define the chromatic aberration correction factors for the VR post process.
  43331. */
  43332. chromaAbCorrection: number[];
  43333. /**
  43334. * Define the scale factor of the post process.
  43335. * The smaller the better but the slower.
  43336. */
  43337. postProcessScaleFactor: number;
  43338. /**
  43339. * Define an offset for the lens center.
  43340. */
  43341. lensCenterOffset: number;
  43342. /**
  43343. * Define if the current vr camera should compensate the distortion of the lense or not.
  43344. */
  43345. compensateDistortion: boolean;
  43346. /**
  43347. * Defines if multiview should be enabled when rendering (Default: false)
  43348. */
  43349. multiviewEnabled: boolean;
  43350. /**
  43351. * Gets the rendering aspect ratio based on the provided resolutions.
  43352. */
  43353. get aspectRatio(): number;
  43354. /**
  43355. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43356. */
  43357. get aspectRatioFov(): number;
  43358. /**
  43359. * @hidden
  43360. */
  43361. get leftHMatrix(): Matrix;
  43362. /**
  43363. * @hidden
  43364. */
  43365. get rightHMatrix(): Matrix;
  43366. /**
  43367. * @hidden
  43368. */
  43369. get leftPreViewMatrix(): Matrix;
  43370. /**
  43371. * @hidden
  43372. */
  43373. get rightPreViewMatrix(): Matrix;
  43374. /**
  43375. * Get the default VRMetrics based on the most generic setup.
  43376. * @returns the default vr metrics
  43377. */
  43378. static GetDefault(): VRCameraMetrics;
  43379. }
  43380. }
  43381. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43382. /** @hidden */
  43383. export var vrDistortionCorrectionPixelShader: {
  43384. name: string;
  43385. shader: string;
  43386. };
  43387. }
  43388. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43389. import { Camera } from "babylonjs/Cameras/camera";
  43390. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43391. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43392. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43393. /**
  43394. * VRDistortionCorrectionPostProcess used for mobile VR
  43395. */
  43396. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43397. private _isRightEye;
  43398. private _distortionFactors;
  43399. private _postProcessScaleFactor;
  43400. private _lensCenterOffset;
  43401. private _scaleIn;
  43402. private _scaleFactor;
  43403. private _lensCenter;
  43404. /**
  43405. * Initializes the VRDistortionCorrectionPostProcess
  43406. * @param name The name of the effect.
  43407. * @param camera The camera to apply the render pass to.
  43408. * @param isRightEye If this is for the right eye distortion
  43409. * @param vrMetrics All the required metrics for the VR camera
  43410. */
  43411. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43412. }
  43413. }
  43414. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43415. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43416. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43417. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43418. import { Scene } from "babylonjs/scene";
  43419. import { Vector3 } from "babylonjs/Maths/math.vector";
  43420. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43421. import "babylonjs/Cameras/RigModes/vrRigMode";
  43422. /**
  43423. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43424. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43425. */
  43426. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43427. /**
  43428. * Creates a new VRDeviceOrientationArcRotateCamera
  43429. * @param name defines camera name
  43430. * @param alpha defines the camera rotation along the logitudinal axis
  43431. * @param beta defines the camera rotation along the latitudinal axis
  43432. * @param radius defines the camera distance from its target
  43433. * @param target defines the camera target
  43434. * @param scene defines the scene the camera belongs to
  43435. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43436. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43437. */
  43438. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43439. /**
  43440. * Gets camera class name
  43441. * @returns VRDeviceOrientationArcRotateCamera
  43442. */
  43443. getClassName(): string;
  43444. }
  43445. }
  43446. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43447. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43448. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43449. import { Scene } from "babylonjs/scene";
  43450. import { Vector3 } from "babylonjs/Maths/math.vector";
  43451. import "babylonjs/Cameras/RigModes/vrRigMode";
  43452. /**
  43453. * Camera used to simulate VR rendering (based on FreeCamera)
  43454. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43455. */
  43456. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43457. /**
  43458. * Creates a new VRDeviceOrientationFreeCamera
  43459. * @param name defines camera name
  43460. * @param position defines the start position of the camera
  43461. * @param scene defines the scene the camera belongs to
  43462. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43463. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43464. */
  43465. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43466. /**
  43467. * Gets camera class name
  43468. * @returns VRDeviceOrientationFreeCamera
  43469. */
  43470. getClassName(): string;
  43471. }
  43472. }
  43473. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43474. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43475. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43476. import { Scene } from "babylonjs/scene";
  43477. import { Vector3 } from "babylonjs/Maths/math.vector";
  43478. import "babylonjs/Gamepads/gamepadSceneComponent";
  43479. /**
  43480. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43481. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43482. */
  43483. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43484. /**
  43485. * Creates a new VRDeviceOrientationGamepadCamera
  43486. * @param name defines camera name
  43487. * @param position defines the start position of the camera
  43488. * @param scene defines the scene the camera belongs to
  43489. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43490. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43491. */
  43492. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43493. /**
  43494. * Gets camera class name
  43495. * @returns VRDeviceOrientationGamepadCamera
  43496. */
  43497. getClassName(): string;
  43498. }
  43499. }
  43500. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43501. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43502. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43503. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43504. /** @hidden */
  43505. export var imageProcessingPixelShader: {
  43506. name: string;
  43507. shader: string;
  43508. };
  43509. }
  43510. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43511. import { Nullable } from "babylonjs/types";
  43512. import { Color4 } from "babylonjs/Maths/math.color";
  43513. import { Camera } from "babylonjs/Cameras/camera";
  43514. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43515. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43516. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43517. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43518. import { Engine } from "babylonjs/Engines/engine";
  43519. import "babylonjs/Shaders/imageProcessing.fragment";
  43520. import "babylonjs/Shaders/postprocess.vertex";
  43521. /**
  43522. * ImageProcessingPostProcess
  43523. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43524. */
  43525. export class ImageProcessingPostProcess extends PostProcess {
  43526. /**
  43527. * Default configuration related to image processing available in the PBR Material.
  43528. */
  43529. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43530. /**
  43531. * Gets the image processing configuration used either in this material.
  43532. */
  43533. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43534. /**
  43535. * Sets the Default image processing configuration used either in the this material.
  43536. *
  43537. * If sets to null, the scene one is in use.
  43538. */
  43539. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43540. /**
  43541. * Keep track of the image processing observer to allow dispose and replace.
  43542. */
  43543. private _imageProcessingObserver;
  43544. /**
  43545. * Attaches a new image processing configuration to the PBR Material.
  43546. * @param configuration
  43547. */
  43548. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43549. /**
  43550. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43551. */
  43552. get colorCurves(): Nullable<ColorCurves>;
  43553. /**
  43554. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43555. */
  43556. set colorCurves(value: Nullable<ColorCurves>);
  43557. /**
  43558. * Gets wether the color curves effect is enabled.
  43559. */
  43560. get colorCurvesEnabled(): boolean;
  43561. /**
  43562. * Sets wether the color curves effect is enabled.
  43563. */
  43564. set colorCurvesEnabled(value: boolean);
  43565. /**
  43566. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43567. */
  43568. get colorGradingTexture(): Nullable<BaseTexture>;
  43569. /**
  43570. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43571. */
  43572. set colorGradingTexture(value: Nullable<BaseTexture>);
  43573. /**
  43574. * Gets wether the color grading effect is enabled.
  43575. */
  43576. get colorGradingEnabled(): boolean;
  43577. /**
  43578. * Gets wether the color grading effect is enabled.
  43579. */
  43580. set colorGradingEnabled(value: boolean);
  43581. /**
  43582. * Gets exposure used in the effect.
  43583. */
  43584. get exposure(): number;
  43585. /**
  43586. * Sets exposure used in the effect.
  43587. */
  43588. set exposure(value: number);
  43589. /**
  43590. * Gets wether tonemapping is enabled or not.
  43591. */
  43592. get toneMappingEnabled(): boolean;
  43593. /**
  43594. * Sets wether tonemapping is enabled or not
  43595. */
  43596. set toneMappingEnabled(value: boolean);
  43597. /**
  43598. * Gets the type of tone mapping effect.
  43599. */
  43600. get toneMappingType(): number;
  43601. /**
  43602. * Sets the type of tone mapping effect.
  43603. */
  43604. set toneMappingType(value: number);
  43605. /**
  43606. * Gets contrast used in the effect.
  43607. */
  43608. get contrast(): number;
  43609. /**
  43610. * Sets contrast used in the effect.
  43611. */
  43612. set contrast(value: number);
  43613. /**
  43614. * Gets Vignette stretch size.
  43615. */
  43616. get vignetteStretch(): number;
  43617. /**
  43618. * Sets Vignette stretch size.
  43619. */
  43620. set vignetteStretch(value: number);
  43621. /**
  43622. * Gets Vignette centre X Offset.
  43623. */
  43624. get vignetteCentreX(): number;
  43625. /**
  43626. * Sets Vignette centre X Offset.
  43627. */
  43628. set vignetteCentreX(value: number);
  43629. /**
  43630. * Gets Vignette centre Y Offset.
  43631. */
  43632. get vignetteCentreY(): number;
  43633. /**
  43634. * Sets Vignette centre Y Offset.
  43635. */
  43636. set vignetteCentreY(value: number);
  43637. /**
  43638. * Gets Vignette weight or intensity of the vignette effect.
  43639. */
  43640. get vignetteWeight(): number;
  43641. /**
  43642. * Sets Vignette weight or intensity of the vignette effect.
  43643. */
  43644. set vignetteWeight(value: number);
  43645. /**
  43646. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43647. * if vignetteEnabled is set to true.
  43648. */
  43649. get vignetteColor(): Color4;
  43650. /**
  43651. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43652. * if vignetteEnabled is set to true.
  43653. */
  43654. set vignetteColor(value: Color4);
  43655. /**
  43656. * Gets Camera field of view used by the Vignette effect.
  43657. */
  43658. get vignetteCameraFov(): number;
  43659. /**
  43660. * Sets Camera field of view used by the Vignette effect.
  43661. */
  43662. set vignetteCameraFov(value: number);
  43663. /**
  43664. * Gets the vignette blend mode allowing different kind of effect.
  43665. */
  43666. get vignetteBlendMode(): number;
  43667. /**
  43668. * Sets the vignette blend mode allowing different kind of effect.
  43669. */
  43670. set vignetteBlendMode(value: number);
  43671. /**
  43672. * Gets wether the vignette effect is enabled.
  43673. */
  43674. get vignetteEnabled(): boolean;
  43675. /**
  43676. * Sets wether the vignette effect is enabled.
  43677. */
  43678. set vignetteEnabled(value: boolean);
  43679. private _fromLinearSpace;
  43680. /**
  43681. * Gets wether the input of the processing is in Gamma or Linear Space.
  43682. */
  43683. get fromLinearSpace(): boolean;
  43684. /**
  43685. * Sets wether the input of the processing is in Gamma or Linear Space.
  43686. */
  43687. set fromLinearSpace(value: boolean);
  43688. /**
  43689. * Defines cache preventing GC.
  43690. */
  43691. private _defines;
  43692. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43693. /**
  43694. * "ImageProcessingPostProcess"
  43695. * @returns "ImageProcessingPostProcess"
  43696. */
  43697. getClassName(): string;
  43698. protected _updateParameters(): void;
  43699. dispose(camera?: Camera): void;
  43700. }
  43701. }
  43702. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43703. import { Scene } from "babylonjs/scene";
  43704. import { Color3 } from "babylonjs/Maths/math.color";
  43705. import { Mesh } from "babylonjs/Meshes/mesh";
  43706. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43707. import { Nullable } from "babylonjs/types";
  43708. /**
  43709. * Class containing static functions to help procedurally build meshes
  43710. */
  43711. export class GroundBuilder {
  43712. /**
  43713. * Creates a ground mesh
  43714. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43715. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43717. * @param name defines the name of the mesh
  43718. * @param options defines the options used to create the mesh
  43719. * @param scene defines the hosting scene
  43720. * @returns the ground mesh
  43721. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43722. */
  43723. static CreateGround(name: string, options: {
  43724. width?: number;
  43725. height?: number;
  43726. subdivisions?: number;
  43727. subdivisionsX?: number;
  43728. subdivisionsY?: number;
  43729. updatable?: boolean;
  43730. }, scene: any): Mesh;
  43731. /**
  43732. * Creates a tiled ground mesh
  43733. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43734. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43735. * * 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
  43736. * * 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
  43737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43738. * @param name defines the name of the mesh
  43739. * @param options defines the options used to create the mesh
  43740. * @param scene defines the hosting scene
  43741. * @returns the tiled ground mesh
  43742. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43743. */
  43744. static CreateTiledGround(name: string, options: {
  43745. xmin: number;
  43746. zmin: number;
  43747. xmax: number;
  43748. zmax: number;
  43749. subdivisions?: {
  43750. w: number;
  43751. h: number;
  43752. };
  43753. precision?: {
  43754. w: number;
  43755. h: number;
  43756. };
  43757. updatable?: boolean;
  43758. }, scene?: Nullable<Scene>): Mesh;
  43759. /**
  43760. * Creates a ground mesh from a height map
  43761. * * The parameter `url` sets the URL of the height map image resource.
  43762. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43763. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43764. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43765. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43766. * * 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.
  43767. * * 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).
  43768. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43770. * @param name defines the name of the mesh
  43771. * @param url defines the url to the height map
  43772. * @param options defines the options used to create the mesh
  43773. * @param scene defines the hosting scene
  43774. * @returns the ground mesh
  43775. * @see https://doc.babylonjs.com/babylon101/height_map
  43776. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43777. */
  43778. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43779. width?: number;
  43780. height?: number;
  43781. subdivisions?: number;
  43782. minHeight?: number;
  43783. maxHeight?: number;
  43784. colorFilter?: Color3;
  43785. alphaFilter?: number;
  43786. updatable?: boolean;
  43787. onReady?: (mesh: GroundMesh) => void;
  43788. }, scene?: Nullable<Scene>): GroundMesh;
  43789. }
  43790. }
  43791. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43792. import { Vector4 } from "babylonjs/Maths/math.vector";
  43793. import { Mesh } from "babylonjs/Meshes/mesh";
  43794. /**
  43795. * Class containing static functions to help procedurally build meshes
  43796. */
  43797. export class TorusBuilder {
  43798. /**
  43799. * Creates a torus mesh
  43800. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43801. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43802. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43803. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43804. * * 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
  43805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43806. * @param name defines the name of the mesh
  43807. * @param options defines the options used to create the mesh
  43808. * @param scene defines the hosting scene
  43809. * @returns the torus mesh
  43810. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43811. */
  43812. static CreateTorus(name: string, options: {
  43813. diameter?: number;
  43814. thickness?: number;
  43815. tessellation?: number;
  43816. updatable?: boolean;
  43817. sideOrientation?: number;
  43818. frontUVs?: Vector4;
  43819. backUVs?: Vector4;
  43820. }, scene: any): Mesh;
  43821. }
  43822. }
  43823. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43824. import { Vector4 } from "babylonjs/Maths/math.vector";
  43825. import { Color4 } from "babylonjs/Maths/math.color";
  43826. import { Mesh } from "babylonjs/Meshes/mesh";
  43827. /**
  43828. * Class containing static functions to help procedurally build meshes
  43829. */
  43830. export class CylinderBuilder {
  43831. /**
  43832. * Creates a cylinder or a cone mesh
  43833. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43834. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43835. * * 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.
  43836. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43837. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43838. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43839. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43840. * * 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).
  43841. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43842. * * 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).
  43843. * * 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
  43844. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43845. * * 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
  43846. * * 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.
  43847. * * If `enclose` is false, a ring surface is one element.
  43848. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43849. * * 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
  43850. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43851. * * 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
  43852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43853. * @param name defines the name of the mesh
  43854. * @param options defines the options used to create the mesh
  43855. * @param scene defines the hosting scene
  43856. * @returns the cylinder mesh
  43857. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43858. */
  43859. static CreateCylinder(name: string, options: {
  43860. height?: number;
  43861. diameterTop?: number;
  43862. diameterBottom?: number;
  43863. diameter?: number;
  43864. tessellation?: number;
  43865. subdivisions?: number;
  43866. arc?: number;
  43867. faceColors?: Color4[];
  43868. faceUV?: Vector4[];
  43869. updatable?: boolean;
  43870. hasRings?: boolean;
  43871. enclose?: boolean;
  43872. cap?: number;
  43873. sideOrientation?: number;
  43874. frontUVs?: Vector4;
  43875. backUVs?: Vector4;
  43876. }, scene: any): Mesh;
  43877. }
  43878. }
  43879. declare module "babylonjs/XR/webXRTypes" {
  43880. import { Nullable } from "babylonjs/types";
  43881. import { IDisposable } from "babylonjs/scene";
  43882. /**
  43883. * States of the webXR experience
  43884. */
  43885. export enum WebXRState {
  43886. /**
  43887. * Transitioning to being in XR mode
  43888. */
  43889. ENTERING_XR = 0,
  43890. /**
  43891. * Transitioning to non XR mode
  43892. */
  43893. EXITING_XR = 1,
  43894. /**
  43895. * In XR mode and presenting
  43896. */
  43897. IN_XR = 2,
  43898. /**
  43899. * Not entered XR mode
  43900. */
  43901. NOT_IN_XR = 3
  43902. }
  43903. /**
  43904. * Abstraction of the XR render target
  43905. */
  43906. export interface WebXRRenderTarget extends IDisposable {
  43907. /**
  43908. * xrpresent context of the canvas which can be used to display/mirror xr content
  43909. */
  43910. canvasContext: WebGLRenderingContext;
  43911. /**
  43912. * xr layer for the canvas
  43913. */
  43914. xrLayer: Nullable<XRWebGLLayer>;
  43915. /**
  43916. * Initializes the xr layer for the session
  43917. * @param xrSession xr session
  43918. * @returns a promise that will resolve once the XR Layer has been created
  43919. */
  43920. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43921. }
  43922. }
  43923. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  43924. import { Nullable } from "babylonjs/types";
  43925. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  43926. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  43927. /**
  43928. * COnfiguration object for WebXR output canvas
  43929. */
  43930. export class WebXRManagedOutputCanvasOptions {
  43931. /**
  43932. * Options for this XR Layer output
  43933. */
  43934. canvasOptions?: XRWebGLLayerOptions;
  43935. /**
  43936. * CSS styling for a newly created canvas (if not provided)
  43937. */
  43938. newCanvasCssStyle?: string;
  43939. /**
  43940. * An optional canvas in case you wish to create it yourself and provide it here.
  43941. * If not provided, a new canvas will be created
  43942. */
  43943. canvasElement?: HTMLCanvasElement;
  43944. /**
  43945. * Get the default values of the configuration object
  43946. * @returns default values of this configuration object
  43947. */
  43948. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43949. }
  43950. /**
  43951. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43952. */
  43953. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43954. private _options;
  43955. private _engine;
  43956. private _canvas;
  43957. /**
  43958. * Rendering context of the canvas which can be used to display/mirror xr content
  43959. */
  43960. canvasContext: WebGLRenderingContext;
  43961. /**
  43962. * xr layer for the canvas
  43963. */
  43964. xrLayer: Nullable<XRWebGLLayer>;
  43965. /**
  43966. * Initializes the xr layer for the session
  43967. * @param xrSession xr session
  43968. * @returns a promise that will resolve once the XR Layer has been created
  43969. */
  43970. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43971. /**
  43972. * Initializes the canvas to be added/removed upon entering/exiting xr
  43973. * @param _xrSessionManager The XR Session manager
  43974. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  43975. */
  43976. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  43977. /**
  43978. * Disposes of the object
  43979. */
  43980. dispose(): void;
  43981. private _setManagedOutputCanvas;
  43982. private _addCanvas;
  43983. private _removeCanvas;
  43984. }
  43985. }
  43986. declare module "babylonjs/XR/webXRSessionManager" {
  43987. import { Observable } from "babylonjs/Misc/observable";
  43988. import { Nullable } from "babylonjs/types";
  43989. import { IDisposable, Scene } from "babylonjs/scene";
  43990. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43991. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  43992. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  43993. /**
  43994. * Manages an XRSession to work with Babylon's engine
  43995. * @see https://doc.babylonjs.com/how_to/webxr
  43996. */
  43997. export class WebXRSessionManager implements IDisposable {
  43998. /** The scene which the session should be created for */
  43999. scene: Scene;
  44000. /**
  44001. * Fires every time a new xrFrame arrives which can be used to update the camera
  44002. */
  44003. onXRFrameObservable: Observable<XRFrame>;
  44004. /**
  44005. * Fires when the xr session is ended either by the device or manually done
  44006. */
  44007. onXRSessionEnded: Observable<any>;
  44008. /**
  44009. * Fires when the xr session is ended either by the device or manually done
  44010. */
  44011. onXRSessionInit: Observable<XRSession>;
  44012. /**
  44013. * Fires when the reference space changed
  44014. */
  44015. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44016. /**
  44017. * Underlying xr session
  44018. */
  44019. session: XRSession;
  44020. /**
  44021. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44022. * or get the offset the player is currently at.
  44023. */
  44024. viewerReferenceSpace: XRReferenceSpace;
  44025. private _referenceSpace;
  44026. /**
  44027. * The current reference space used in this session. This reference space can constantly change!
  44028. * It is mainly used to offset the camera's position.
  44029. */
  44030. get referenceSpace(): XRReferenceSpace;
  44031. /**
  44032. * Set a new reference space and triggers the observable
  44033. */
  44034. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44035. /**
  44036. * The base reference space from which the session started. good if you want to reset your
  44037. * reference space
  44038. */
  44039. baseReferenceSpace: XRReferenceSpace;
  44040. /**
  44041. * Used just in case of a failure to initialize an immersive session.
  44042. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44043. */
  44044. defaultHeightCompensation: number;
  44045. /**
  44046. * Current XR frame
  44047. */
  44048. currentFrame: Nullable<XRFrame>;
  44049. /** WebXR timestamp updated every frame */
  44050. currentTimestamp: number;
  44051. private _xrNavigator;
  44052. private baseLayer;
  44053. private _rttProvider;
  44054. private _sessionEnded;
  44055. /**
  44056. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44057. * @param scene The scene which the session should be created for
  44058. */
  44059. constructor(
  44060. /** The scene which the session should be created for */
  44061. scene: Scene);
  44062. /**
  44063. * Initializes the manager
  44064. * After initialization enterXR can be called to start an XR session
  44065. * @returns Promise which resolves after it is initialized
  44066. */
  44067. initializeAsync(): Promise<void>;
  44068. /**
  44069. * Initializes an xr session
  44070. * @param xrSessionMode mode to initialize
  44071. * @param xrSessionInit defines optional and required values to pass to the session builder
  44072. * @returns a promise which will resolve once the session has been initialized
  44073. */
  44074. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44075. /**
  44076. * Sets the reference space on the xr session
  44077. * @param referenceSpaceType space to set
  44078. * @returns a promise that will resolve once the reference space has been set
  44079. */
  44080. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44081. /**
  44082. * Resets the reference space to the one started the session
  44083. */
  44084. resetReferenceSpace(): void;
  44085. /**
  44086. * Updates the render state of the session
  44087. * @param state state to set
  44088. * @returns a promise that resolves once the render state has been updated
  44089. */
  44090. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44091. /**
  44092. * Starts rendering to the xr layer
  44093. */
  44094. runXRRenderLoop(): void;
  44095. /**
  44096. * Gets the correct render target texture to be rendered this frame for this eye
  44097. * @param eye the eye for which to get the render target
  44098. * @returns the render target for the specified eye
  44099. */
  44100. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44101. /**
  44102. * Stops the xrSession and restores the renderloop
  44103. * @returns Promise which resolves after it exits XR
  44104. */
  44105. exitXRAsync(): Promise<void>;
  44106. /**
  44107. * Checks if a session would be supported for the creation options specified
  44108. * @param sessionMode session mode to check if supported eg. immersive-vr
  44109. * @returns A Promise that resolves to true if supported and false if not
  44110. */
  44111. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44112. /**
  44113. * Creates a WebXRRenderTarget object for the XR session
  44114. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44115. * @param options optional options to provide when creating a new render target
  44116. * @returns a WebXR render target to which the session can render
  44117. */
  44118. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44119. /**
  44120. * @hidden
  44121. * Converts the render layer of xrSession to a render target
  44122. * @param session session to create render target for
  44123. * @param scene scene the new render target should be created for
  44124. * @param baseLayer the webgl layer to create the render target for
  44125. */
  44126. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  44127. /**
  44128. * Disposes of the session manager
  44129. */
  44130. dispose(): void;
  44131. /**
  44132. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44133. * @param sessionMode defines the session to test
  44134. * @returns a promise with boolean as final value
  44135. */
  44136. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44137. }
  44138. }
  44139. declare module "babylonjs/XR/webXRCamera" {
  44140. import { Scene } from "babylonjs/scene";
  44141. import { Camera } from "babylonjs/Cameras/camera";
  44142. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44143. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44144. /**
  44145. * WebXR Camera which holds the views for the xrSession
  44146. * @see https://doc.babylonjs.com/how_to/webxr_camera
  44147. */
  44148. export class WebXRCamera extends FreeCamera {
  44149. private _xrSessionManager;
  44150. private _firstFrame;
  44151. private _referenceQuaternion;
  44152. private _referencedPosition;
  44153. private _xrInvPositionCache;
  44154. private _xrInvQuaternionCache;
  44155. /**
  44156. * Should position compensation execute on first frame.
  44157. * This is used when copying the position from a native (non XR) camera
  44158. */
  44159. compensateOnFirstFrame: boolean;
  44160. /**
  44161. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44162. * @param name the name of the camera
  44163. * @param scene the scene to add the camera to
  44164. * @param _xrSessionManager a constructed xr session manager
  44165. */
  44166. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44167. /**
  44168. * Return the user's height, unrelated to the current ground.
  44169. * This will be the y position of this camera, when ground level is 0.
  44170. */
  44171. get realWorldHeight(): number;
  44172. /** @hidden */
  44173. _updateForDualEyeDebugging(): void;
  44174. /**
  44175. * Sets this camera's transformation based on a non-vr camera
  44176. * @param otherCamera the non-vr camera to copy the transformation from
  44177. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44178. */
  44179. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44180. private _updateFromXRSession;
  44181. private _updateNumberOfRigCameras;
  44182. private _updateReferenceSpace;
  44183. private _updateReferenceSpaceOffset;
  44184. }
  44185. }
  44186. declare module "babylonjs/XR/webXRFeaturesManager" {
  44187. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44188. import { IDisposable } from "babylonjs/scene";
  44189. /**
  44190. * Defining the interface required for a (webxr) feature
  44191. */
  44192. export interface IWebXRFeature extends IDisposable {
  44193. /**
  44194. * Is this feature attached
  44195. */
  44196. attached: boolean;
  44197. /**
  44198. * Should auto-attach be disabled?
  44199. */
  44200. disableAutoAttach: boolean;
  44201. /**
  44202. * Attach the feature to the session
  44203. * Will usually be called by the features manager
  44204. *
  44205. * @param force should attachment be forced (even when already attached)
  44206. * @returns true if successful.
  44207. */
  44208. attach(force?: boolean): boolean;
  44209. /**
  44210. * Detach the feature from the session
  44211. * Will usually be called by the features manager
  44212. *
  44213. * @returns true if successful.
  44214. */
  44215. detach(): boolean;
  44216. }
  44217. /**
  44218. * A list of the currently available features without referencing them
  44219. */
  44220. export class WebXRFeatureName {
  44221. /**
  44222. * The name of the hit test feature
  44223. */
  44224. static HIT_TEST: string;
  44225. /**
  44226. * The name of the anchor system feature
  44227. */
  44228. static ANCHOR_SYSTEM: string;
  44229. /**
  44230. * The name of the background remover feature
  44231. */
  44232. static BACKGROUND_REMOVER: string;
  44233. /**
  44234. * The name of the pointer selection feature
  44235. */
  44236. static POINTER_SELECTION: string;
  44237. /**
  44238. * The name of the teleportation feature
  44239. */
  44240. static TELEPORTATION: string;
  44241. /**
  44242. * The name of the plane detection feature
  44243. */
  44244. static PLANE_DETECTION: string;
  44245. /**
  44246. * physics impostors for xr controllers feature
  44247. */
  44248. static PHYSICS_CONTROLLERS: string;
  44249. }
  44250. /**
  44251. * Defining the constructor of a feature. Used to register the modules.
  44252. */
  44253. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44254. /**
  44255. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44256. * It is mainly used in AR sessions.
  44257. *
  44258. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44259. */
  44260. export class WebXRFeaturesManager implements IDisposable {
  44261. private _xrSessionManager;
  44262. private static readonly _AvailableFeatures;
  44263. /**
  44264. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44265. * Mainly used internally.
  44266. *
  44267. * @param featureName the name of the feature to register
  44268. * @param constructorFunction the function used to construct the module
  44269. * @param version the (babylon) version of the module
  44270. * @param stable is that a stable version of this module
  44271. */
  44272. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44273. /**
  44274. * Returns a constructor of a specific feature.
  44275. *
  44276. * @param featureName the name of the feature to construct
  44277. * @param version the version of the feature to load
  44278. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44279. * @param options optional options provided to the module.
  44280. * @returns a function that, when called, will return a new instance of this feature
  44281. */
  44282. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44283. /**
  44284. * Return the latest unstable version of this feature
  44285. * @param featureName the name of the feature to search
  44286. * @returns the version number. if not found will return -1
  44287. */
  44288. static GetLatestVersionOfFeature(featureName: string): number;
  44289. /**
  44290. * Return the latest stable version of this feature
  44291. * @param featureName the name of the feature to search
  44292. * @returns the version number. if not found will return -1
  44293. */
  44294. static GetStableVersionOfFeature(featureName: string): number;
  44295. /**
  44296. * Can be used to return the list of features currently registered
  44297. *
  44298. * @returns an Array of available features
  44299. */
  44300. static GetAvailableFeatures(): string[];
  44301. /**
  44302. * Gets the versions available for a specific feature
  44303. * @param featureName the name of the feature
  44304. * @returns an array with the available versions
  44305. */
  44306. static GetAvailableVersions(featureName: string): string[];
  44307. private _features;
  44308. /**
  44309. * constructs a new features manages.
  44310. *
  44311. * @param _xrSessionManager an instance of WebXRSessionManager
  44312. */
  44313. constructor(_xrSessionManager: WebXRSessionManager);
  44314. /**
  44315. * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.
  44316. * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.
  44317. *
  44318. * @param featureName the name of the feature to load or the class of the feature
  44319. * @param version optional version to load. if not provided the latest version will be enabled
  44320. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44321. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44322. * @returns a new constructed feature or throws an error if feature not found.
  44323. */
  44324. enableFeature(featureName: string | {
  44325. Name: string;
  44326. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44327. /**
  44328. * Used to disable an already-enabled feature
  44329. * The feature will be disposed and will be recreated once enabled.
  44330. * @param featureName the feature to disable
  44331. * @returns true if disable was successful
  44332. */
  44333. disableFeature(featureName: string | {
  44334. Name: string;
  44335. }): boolean;
  44336. /**
  44337. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44338. * Can be used during a session to start a feature
  44339. * @param featureName the name of feature to attach
  44340. */
  44341. attachFeature(featureName: string): void;
  44342. /**
  44343. * Can be used inside a session or when the session ends to detach a specific feature
  44344. * @param featureName the name of the feature to detach
  44345. */
  44346. detachFeature(featureName: string): void;
  44347. /**
  44348. * Get the list of enabled features
  44349. * @returns an array of enabled features
  44350. */
  44351. getEnabledFeatures(): string[];
  44352. /**
  44353. * get the implementation of an enabled feature.
  44354. * @param featureName the name of the feature to load
  44355. * @returns the feature class, if found
  44356. */
  44357. getEnabledFeature(featureName: string): IWebXRFeature;
  44358. /**
  44359. * dispose this features manager
  44360. */
  44361. dispose(): void;
  44362. }
  44363. }
  44364. declare module "babylonjs/XR/webXRExperienceHelper" {
  44365. import { Observable } from "babylonjs/Misc/observable";
  44366. import { IDisposable, Scene } from "babylonjs/scene";
  44367. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44368. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  44369. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44370. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  44371. /**
  44372. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  44373. * @see https://doc.babylonjs.com/how_to/webxr
  44374. */
  44375. export class WebXRExperienceHelper implements IDisposable {
  44376. private scene;
  44377. /**
  44378. * Camera used to render xr content
  44379. */
  44380. camera: WebXRCamera;
  44381. /**
  44382. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44383. */
  44384. state: WebXRState;
  44385. private _setState;
  44386. /**
  44387. * Fires when the state of the experience helper has changed
  44388. */
  44389. onStateChangedObservable: Observable<WebXRState>;
  44390. /**
  44391. * Observers registered here will be triggered after the camera's initial transformation is set
  44392. * This can be used to set a different ground level or an extra rotation.
  44393. *
  44394. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44395. * to the position set after this observable is done executing.
  44396. */
  44397. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44398. /** Session manager used to keep track of xr session */
  44399. sessionManager: WebXRSessionManager;
  44400. /** A features manager for this xr session */
  44401. featuresManager: WebXRFeaturesManager;
  44402. private _nonVRCamera;
  44403. private _originalSceneAutoClear;
  44404. private _supported;
  44405. /**
  44406. * Creates the experience helper
  44407. * @param scene the scene to attach the experience helper to
  44408. * @returns a promise for the experience helper
  44409. */
  44410. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44411. /**
  44412. * Creates a WebXRExperienceHelper
  44413. * @param scene The scene the helper should be created in
  44414. */
  44415. private constructor();
  44416. /**
  44417. * Exits XR mode and returns the scene to its original state
  44418. * @returns promise that resolves after xr mode has exited
  44419. */
  44420. exitXRAsync(): Promise<void>;
  44421. /**
  44422. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44423. * @param sessionMode options for the XR session
  44424. * @param referenceSpaceType frame of reference of the XR session
  44425. * @param renderTarget the output canvas that will be used to enter XR mode
  44426. * @returns promise that resolves after xr mode has entered
  44427. */
  44428. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44429. /**
  44430. * Disposes of the experience helper
  44431. */
  44432. dispose(): void;
  44433. private _nonXRToXRCamera;
  44434. }
  44435. }
  44436. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  44437. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  44438. import { Observable } from "babylonjs/Misc/observable";
  44439. import { IDisposable } from "babylonjs/scene";
  44440. /**
  44441. * X-Y values for axes in WebXR
  44442. */
  44443. export interface IWebXRMotionControllerAxesValue {
  44444. /**
  44445. * The value of the x axis
  44446. */
  44447. x: number;
  44448. /**
  44449. * The value of the y-axis
  44450. */
  44451. y: number;
  44452. }
  44453. /**
  44454. * changed / previous values for the values of this component
  44455. */
  44456. export interface IWebXRMotionControllerComponentChangesValues<T> {
  44457. /**
  44458. * current (this frame) value
  44459. */
  44460. current: T;
  44461. /**
  44462. * previous (last change) value
  44463. */
  44464. previous: T;
  44465. }
  44466. /**
  44467. * Represents changes in the component between current frame and last values recorded
  44468. */
  44469. export interface IWebXRMotionControllerComponentChanges {
  44470. /**
  44471. * will be populated with previous and current values if touched changed
  44472. */
  44473. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44474. /**
  44475. * will be populated with previous and current values if pressed changed
  44476. */
  44477. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44478. /**
  44479. * will be populated with previous and current values if value changed
  44480. */
  44481. value?: IWebXRMotionControllerComponentChangesValues<number>;
  44482. /**
  44483. * will be populated with previous and current values if axes changed
  44484. */
  44485. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  44486. }
  44487. /**
  44488. * This class represents a single component (for example button or thumbstick) of a motion controller
  44489. */
  44490. export class WebXRControllerComponent implements IDisposable {
  44491. /**
  44492. * the id of this component
  44493. */
  44494. id: string;
  44495. /**
  44496. * the type of the component
  44497. */
  44498. type: MotionControllerComponentType;
  44499. private _buttonIndex;
  44500. private _axesIndices;
  44501. /**
  44502. * Thumbstick component type
  44503. */
  44504. static THUMBSTICK: MotionControllerComponentType;
  44505. /**
  44506. * Touchpad component type
  44507. */
  44508. static TOUCHPAD: MotionControllerComponentType;
  44509. /**
  44510. * trigger component type
  44511. */
  44512. static TRIGGER: MotionControllerComponentType;
  44513. /**
  44514. * squeeze component type
  44515. */
  44516. static SQUEEZE: MotionControllerComponentType;
  44517. /**
  44518. * button component type
  44519. */
  44520. static BUTTON: MotionControllerComponentType;
  44521. /**
  44522. * Observers registered here will be triggered when the state of a button changes
  44523. * State change is either pressed / touched / value
  44524. */
  44525. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  44526. /**
  44527. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  44528. * the axes data changes
  44529. */
  44530. onAxisValueChangedObservable: Observable<{
  44531. x: number;
  44532. y: number;
  44533. }>;
  44534. private _currentValue;
  44535. private _touched;
  44536. private _pressed;
  44537. private _axes;
  44538. private _changes;
  44539. private _hasChanges;
  44540. /**
  44541. * Return whether or not the component changed the last frame
  44542. */
  44543. get hasChanges(): boolean;
  44544. /**
  44545. * Creates a new component for a motion controller.
  44546. * It is created by the motion controller itself
  44547. *
  44548. * @param id the id of this component
  44549. * @param type the type of the component
  44550. * @param _buttonIndex index in the buttons array of the gamepad
  44551. * @param _axesIndices indices of the values in the axes array of the gamepad
  44552. */
  44553. constructor(
  44554. /**
  44555. * the id of this component
  44556. */
  44557. id: string,
  44558. /**
  44559. * the type of the component
  44560. */
  44561. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  44562. /**
  44563. * Get the current value of this component
  44564. */
  44565. get value(): number;
  44566. /**
  44567. * is the button currently pressed
  44568. */
  44569. get pressed(): boolean;
  44570. /**
  44571. * is the button currently touched
  44572. */
  44573. get touched(): boolean;
  44574. /**
  44575. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  44576. */
  44577. get axes(): IWebXRMotionControllerAxesValue;
  44578. /**
  44579. * Get the changes. Elements will be populated only if they changed with their previous and current value
  44580. */
  44581. get changes(): IWebXRMotionControllerComponentChanges;
  44582. /**
  44583. * Is this component a button (hence - pressable)
  44584. * @returns true if can be pressed
  44585. */
  44586. isButton(): boolean;
  44587. /**
  44588. * Are there axes correlating to this component
  44589. * @return true is axes data is available
  44590. */
  44591. isAxes(): boolean;
  44592. /**
  44593. * update this component using the gamepad object it is in. Called on every frame
  44594. * @param nativeController the native gamepad controller object
  44595. */
  44596. update(nativeController: IMinimalMotionControllerObject): void;
  44597. /**
  44598. * Dispose this component
  44599. */
  44600. dispose(): void;
  44601. }
  44602. }
  44603. declare module "babylonjs/Loading/sceneLoader" {
  44604. import { Observable } from "babylonjs/Misc/observable";
  44605. import { Nullable } from "babylonjs/types";
  44606. import { Scene } from "babylonjs/scene";
  44607. import { Engine } from "babylonjs/Engines/engine";
  44608. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44609. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44610. import { AssetContainer } from "babylonjs/assetContainer";
  44611. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44612. import { Skeleton } from "babylonjs/Bones/skeleton";
  44613. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44614. import { WebRequest } from "babylonjs/Misc/webRequest";
  44615. /**
  44616. * Class used to represent data loading progression
  44617. */
  44618. export class SceneLoaderProgressEvent {
  44619. /** defines if data length to load can be evaluated */
  44620. readonly lengthComputable: boolean;
  44621. /** defines the loaded data length */
  44622. readonly loaded: number;
  44623. /** defines the data length to load */
  44624. readonly total: number;
  44625. /**
  44626. * Create a new progress event
  44627. * @param lengthComputable defines if data length to load can be evaluated
  44628. * @param loaded defines the loaded data length
  44629. * @param total defines the data length to load
  44630. */
  44631. constructor(
  44632. /** defines if data length to load can be evaluated */
  44633. lengthComputable: boolean,
  44634. /** defines the loaded data length */
  44635. loaded: number,
  44636. /** defines the data length to load */
  44637. total: number);
  44638. /**
  44639. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44640. * @param event defines the source event
  44641. * @returns a new SceneLoaderProgressEvent
  44642. */
  44643. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44644. }
  44645. /**
  44646. * Interface used by SceneLoader plugins to define supported file extensions
  44647. */
  44648. export interface ISceneLoaderPluginExtensions {
  44649. /**
  44650. * Defines the list of supported extensions
  44651. */
  44652. [extension: string]: {
  44653. isBinary: boolean;
  44654. };
  44655. }
  44656. /**
  44657. * Interface used by SceneLoader plugin factory
  44658. */
  44659. export interface ISceneLoaderPluginFactory {
  44660. /**
  44661. * Defines the name of the factory
  44662. */
  44663. name: string;
  44664. /**
  44665. * Function called to create a new plugin
  44666. * @return the new plugin
  44667. */
  44668. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44669. /**
  44670. * The callback that returns true if the data can be directly loaded.
  44671. * @param data string containing the file data
  44672. * @returns if the data can be loaded directly
  44673. */
  44674. canDirectLoad?(data: string): boolean;
  44675. }
  44676. /**
  44677. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44678. */
  44679. export interface ISceneLoaderPluginBase {
  44680. /**
  44681. * The friendly name of this plugin.
  44682. */
  44683. name: string;
  44684. /**
  44685. * The file extensions supported by this plugin.
  44686. */
  44687. extensions: string | ISceneLoaderPluginExtensions;
  44688. /**
  44689. * The callback called when loading from a url.
  44690. * @param scene scene loading this url
  44691. * @param url url to load
  44692. * @param onSuccess callback called when the file successfully loads
  44693. * @param onProgress callback called while file is loading (if the server supports this mode)
  44694. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44695. * @param onError callback called when the file fails to load
  44696. * @returns a file request object
  44697. */
  44698. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44699. /**
  44700. * The callback called when loading from a file object.
  44701. * @param scene scene loading this file
  44702. * @param file defines the file to load
  44703. * @param onSuccess defines the callback to call when data is loaded
  44704. * @param onProgress defines the callback to call during loading process
  44705. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44706. * @param onError defines the callback to call when an error occurs
  44707. * @returns a file request object
  44708. */
  44709. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44710. /**
  44711. * The callback that returns true if the data can be directly loaded.
  44712. * @param data string containing the file data
  44713. * @returns if the data can be loaded directly
  44714. */
  44715. canDirectLoad?(data: string): boolean;
  44716. /**
  44717. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44718. * @param scene scene loading this data
  44719. * @param data string containing the data
  44720. * @returns data to pass to the plugin
  44721. */
  44722. directLoad?(scene: Scene, data: string): any;
  44723. /**
  44724. * The callback that allows custom handling of the root url based on the response url.
  44725. * @param rootUrl the original root url
  44726. * @param responseURL the response url if available
  44727. * @returns the new root url
  44728. */
  44729. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44730. }
  44731. /**
  44732. * Interface used to define a SceneLoader plugin
  44733. */
  44734. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44735. /**
  44736. * Import meshes into a scene.
  44737. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44738. * @param scene The scene to import into
  44739. * @param data The data to import
  44740. * @param rootUrl The root url for scene and resources
  44741. * @param meshes The meshes array to import into
  44742. * @param particleSystems The particle systems array to import into
  44743. * @param skeletons The skeletons array to import into
  44744. * @param onError The callback when import fails
  44745. * @returns True if successful or false otherwise
  44746. */
  44747. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44748. /**
  44749. * Load into a scene.
  44750. * @param scene The scene to load into
  44751. * @param data The data to import
  44752. * @param rootUrl The root url for scene and resources
  44753. * @param onError The callback when import fails
  44754. * @returns True if successful or false otherwise
  44755. */
  44756. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44757. /**
  44758. * Load into an asset container.
  44759. * @param scene The scene to load into
  44760. * @param data The data to import
  44761. * @param rootUrl The root url for scene and resources
  44762. * @param onError The callback when import fails
  44763. * @returns The loaded asset container
  44764. */
  44765. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44766. }
  44767. /**
  44768. * Interface used to define an async SceneLoader plugin
  44769. */
  44770. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44771. /**
  44772. * Import meshes into a scene.
  44773. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44774. * @param scene The scene to import into
  44775. * @param data The data to import
  44776. * @param rootUrl The root url for scene and resources
  44777. * @param onProgress The callback when the load progresses
  44778. * @param fileName Defines the name of the file to load
  44779. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44780. */
  44781. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44782. meshes: AbstractMesh[];
  44783. particleSystems: IParticleSystem[];
  44784. skeletons: Skeleton[];
  44785. animationGroups: AnimationGroup[];
  44786. }>;
  44787. /**
  44788. * Load into a scene.
  44789. * @param scene The scene to load into
  44790. * @param data The data to import
  44791. * @param rootUrl The root url for scene and resources
  44792. * @param onProgress The callback when the load progresses
  44793. * @param fileName Defines the name of the file to load
  44794. * @returns Nothing
  44795. */
  44796. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44797. /**
  44798. * Load into an asset container.
  44799. * @param scene The scene to load into
  44800. * @param data The data to import
  44801. * @param rootUrl The root url for scene and resources
  44802. * @param onProgress The callback when the load progresses
  44803. * @param fileName Defines the name of the file to load
  44804. * @returns The loaded asset container
  44805. */
  44806. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44807. }
  44808. /**
  44809. * Mode that determines how to handle old animation groups before loading new ones.
  44810. */
  44811. export enum SceneLoaderAnimationGroupLoadingMode {
  44812. /**
  44813. * Reset all old animations to initial state then dispose them.
  44814. */
  44815. Clean = 0,
  44816. /**
  44817. * Stop all old animations.
  44818. */
  44819. Stop = 1,
  44820. /**
  44821. * Restart old animations from first frame.
  44822. */
  44823. Sync = 2,
  44824. /**
  44825. * Old animations remains untouched.
  44826. */
  44827. NoSync = 3
  44828. }
  44829. /**
  44830. * Class used to load scene from various file formats using registered plugins
  44831. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44832. */
  44833. export class SceneLoader {
  44834. /**
  44835. * No logging while loading
  44836. */
  44837. static readonly NO_LOGGING: number;
  44838. /**
  44839. * Minimal logging while loading
  44840. */
  44841. static readonly MINIMAL_LOGGING: number;
  44842. /**
  44843. * Summary logging while loading
  44844. */
  44845. static readonly SUMMARY_LOGGING: number;
  44846. /**
  44847. * Detailled logging while loading
  44848. */
  44849. static readonly DETAILED_LOGGING: number;
  44850. /**
  44851. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44852. */
  44853. static get ForceFullSceneLoadingForIncremental(): boolean;
  44854. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44855. /**
  44856. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44857. */
  44858. static get ShowLoadingScreen(): boolean;
  44859. static set ShowLoadingScreen(value: boolean);
  44860. /**
  44861. * Defines the current logging level (while loading the scene)
  44862. * @ignorenaming
  44863. */
  44864. static get loggingLevel(): number;
  44865. static set loggingLevel(value: number);
  44866. /**
  44867. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44868. */
  44869. static get CleanBoneMatrixWeights(): boolean;
  44870. static set CleanBoneMatrixWeights(value: boolean);
  44871. /**
  44872. * Event raised when a plugin is used to load a scene
  44873. */
  44874. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44875. private static _registeredPlugins;
  44876. private static _getDefaultPlugin;
  44877. private static _getPluginForExtension;
  44878. private static _getPluginForDirectLoad;
  44879. private static _getPluginForFilename;
  44880. private static _getDirectLoad;
  44881. private static _loadData;
  44882. private static _getFileInfo;
  44883. /**
  44884. * Gets a plugin that can load the given extension
  44885. * @param extension defines the extension to load
  44886. * @returns a plugin or null if none works
  44887. */
  44888. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44889. /**
  44890. * Gets a boolean indicating that the given extension can be loaded
  44891. * @param extension defines the extension to load
  44892. * @returns true if the extension is supported
  44893. */
  44894. static IsPluginForExtensionAvailable(extension: string): boolean;
  44895. /**
  44896. * Adds a new plugin to the list of registered plugins
  44897. * @param plugin defines the plugin to add
  44898. */
  44899. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44900. /**
  44901. * Import meshes into a scene
  44902. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44903. * @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)
  44904. * @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)
  44905. * @param scene the instance of BABYLON.Scene to append to
  44906. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44907. * @param onProgress a callback with a progress event for each file being loaded
  44908. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44909. * @param pluginExtension the extension used to determine the plugin
  44910. * @returns The loaded plugin
  44911. */
  44912. 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>;
  44913. /**
  44914. * Import meshes into a scene
  44915. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44916. * @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)
  44917. * @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)
  44918. * @param scene the instance of BABYLON.Scene to append to
  44919. * @param onProgress a callback with a progress event for each file being loaded
  44920. * @param pluginExtension the extension used to determine the plugin
  44921. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44922. */
  44923. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44924. meshes: AbstractMesh[];
  44925. particleSystems: IParticleSystem[];
  44926. skeletons: Skeleton[];
  44927. animationGroups: AnimationGroup[];
  44928. }>;
  44929. /**
  44930. * Load a scene
  44931. * @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)
  44932. * @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)
  44933. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44934. * @param onSuccess a callback with the scene when import succeeds
  44935. * @param onProgress a callback with a progress event for each file being loaded
  44936. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44937. * @param pluginExtension the extension used to determine the plugin
  44938. * @returns The loaded plugin
  44939. */
  44940. 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>;
  44941. /**
  44942. * Load a scene
  44943. * @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)
  44944. * @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)
  44945. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44946. * @param onProgress a callback with a progress event for each file being loaded
  44947. * @param pluginExtension the extension used to determine the plugin
  44948. * @returns The loaded scene
  44949. */
  44950. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44951. /**
  44952. * Append a scene
  44953. * @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)
  44954. * @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)
  44955. * @param scene is the instance of BABYLON.Scene to append to
  44956. * @param onSuccess a callback with the scene when import succeeds
  44957. * @param onProgress a callback with a progress event for each file being loaded
  44958. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44959. * @param pluginExtension the extension used to determine the plugin
  44960. * @returns The loaded plugin
  44961. */
  44962. 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>;
  44963. /**
  44964. * Append a scene
  44965. * @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)
  44966. * @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)
  44967. * @param scene is the instance of BABYLON.Scene to append to
  44968. * @param onProgress a callback with a progress event for each file being loaded
  44969. * @param pluginExtension the extension used to determine the plugin
  44970. * @returns The given scene
  44971. */
  44972. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44973. /**
  44974. * Load a scene into an asset container
  44975. * @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)
  44976. * @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)
  44977. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44978. * @param onSuccess a callback with the scene when import succeeds
  44979. * @param onProgress a callback with a progress event for each file being loaded
  44980. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44981. * @param pluginExtension the extension used to determine the plugin
  44982. * @returns The loaded plugin
  44983. */
  44984. 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>;
  44985. /**
  44986. * Load a scene into an asset container
  44987. * @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)
  44988. * @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)
  44989. * @param scene is the instance of Scene to append to
  44990. * @param onProgress a callback with a progress event for each file being loaded
  44991. * @param pluginExtension the extension used to determine the plugin
  44992. * @returns The loaded asset container
  44993. */
  44994. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44995. /**
  44996. * Import animations from a file into a scene
  44997. * @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)
  44998. * @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)
  44999. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45000. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45001. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45002. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45003. * @param onSuccess a callback with the scene when import succeeds
  45004. * @param onProgress a callback with a progress event for each file being loaded
  45005. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45006. */
  45007. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  45008. /**
  45009. * Import animations from a file into a scene
  45010. * @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)
  45011. * @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)
  45012. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45013. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45014. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45015. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45016. * @param onSuccess a callback with the scene when import succeeds
  45017. * @param onProgress a callback with a progress event for each file being loaded
  45018. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45019. * @returns the updated scene with imported animations
  45020. */
  45021. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  45022. }
  45023. }
  45024. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  45025. import { IDisposable, Scene } from "babylonjs/scene";
  45026. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45027. import { Observable } from "babylonjs/Misc/observable";
  45028. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45029. import { Nullable } from "babylonjs/types";
  45030. /**
  45031. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45032. */
  45033. export type MotionControllerHandness = "none" | "left" | "right";
  45034. /**
  45035. * The type of components available in motion controllers.
  45036. * This is not the name of the component.
  45037. */
  45038. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45039. /**
  45040. * The state of a controller component
  45041. */
  45042. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45043. /**
  45044. * The schema of motion controller layout.
  45045. * No object will be initialized using this interface
  45046. * This is used just to define the profile.
  45047. */
  45048. export interface IMotionControllerLayout {
  45049. /**
  45050. * Defines the main button component id
  45051. */
  45052. selectComponentId: string;
  45053. /**
  45054. * Available components (unsorted)
  45055. */
  45056. components: {
  45057. /**
  45058. * A map of component Ids
  45059. */
  45060. [componentId: string]: {
  45061. /**
  45062. * The type of input the component outputs
  45063. */
  45064. type: MotionControllerComponentType;
  45065. /**
  45066. * The indices of this component in the gamepad object
  45067. */
  45068. gamepadIndices: {
  45069. /**
  45070. * Index of button
  45071. */
  45072. button?: number;
  45073. /**
  45074. * If available, index of x-axis
  45075. */
  45076. xAxis?: number;
  45077. /**
  45078. * If available, index of y-axis
  45079. */
  45080. yAxis?: number;
  45081. };
  45082. /**
  45083. * The mesh's root node name
  45084. */
  45085. rootNodeName: string;
  45086. /**
  45087. * Animation definitions for this model
  45088. */
  45089. visualResponses: {
  45090. [stateKey: string]: {
  45091. /**
  45092. * What property will be animated
  45093. */
  45094. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45095. /**
  45096. * What states influence this visual reponse
  45097. */
  45098. states: MotionControllerComponentStateType[];
  45099. /**
  45100. * Type of animation - movement or visibility
  45101. */
  45102. valueNodeProperty: "transform" | "visibility";
  45103. /**
  45104. * Base node name to move. Its position will be calculated according to the min and max nodes
  45105. */
  45106. valueNodeName?: string;
  45107. /**
  45108. * Minimum movement node
  45109. */
  45110. minNodeName?: string;
  45111. /**
  45112. * Max movement node
  45113. */
  45114. maxNodeName?: string;
  45115. };
  45116. };
  45117. /**
  45118. * If touch enabled, what is the name of node to display user feedback
  45119. */
  45120. touchPointNodeName?: string;
  45121. };
  45122. };
  45123. /**
  45124. * Is it xr standard mapping or not
  45125. */
  45126. gamepadMapping: "" | "xr-standard";
  45127. /**
  45128. * Base root node of this entire model
  45129. */
  45130. rootNodeName: string;
  45131. /**
  45132. * Path to load the assets. Usually relative to the base path
  45133. */
  45134. assetPath: string;
  45135. }
  45136. /**
  45137. * A definition for the layout map in the input profile
  45138. */
  45139. export interface IMotionControllerLayoutMap {
  45140. /**
  45141. * Layouts with handness type as a key
  45142. */
  45143. [handness: string]: IMotionControllerLayout;
  45144. }
  45145. /**
  45146. * The XR Input profile schema
  45147. * Profiles can be found here:
  45148. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45149. */
  45150. export interface IMotionControllerProfile {
  45151. /**
  45152. * The id of this profile
  45153. * correlates to the profile(s) in the xrInput.profiles array
  45154. */
  45155. profileId: string;
  45156. /**
  45157. * fallback profiles for this profileId
  45158. */
  45159. fallbackProfileIds: string[];
  45160. /**
  45161. * The layout map, with handness as key
  45162. */
  45163. layouts: IMotionControllerLayoutMap;
  45164. }
  45165. /**
  45166. * A helper-interface for the 3 meshes needed for controller button animation
  45167. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45168. */
  45169. export interface IMotionControllerButtonMeshMap {
  45170. /**
  45171. * The mesh that will be changed when value changes
  45172. */
  45173. valueMesh: AbstractMesh;
  45174. /**
  45175. * the mesh that defines the pressed value mesh position.
  45176. * This is used to find the max-position of this button
  45177. */
  45178. pressedMesh: AbstractMesh;
  45179. /**
  45180. * the mesh that defines the unpressed value mesh position.
  45181. * This is used to find the min (or initial) position of this button
  45182. */
  45183. unpressedMesh: AbstractMesh;
  45184. }
  45185. /**
  45186. * A helper-interface for the 3 meshes needed for controller axis animation.
  45187. * This will be expanded when touchpad animations are fully supported
  45188. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45189. */
  45190. export interface IMotionControllerMeshMap {
  45191. /**
  45192. * The mesh that will be changed when axis value changes
  45193. */
  45194. valueMesh: AbstractMesh;
  45195. /**
  45196. * the mesh that defines the minimum value mesh position.
  45197. */
  45198. minMesh?: AbstractMesh;
  45199. /**
  45200. * the mesh that defines the maximum value mesh position.
  45201. */
  45202. maxMesh?: AbstractMesh;
  45203. }
  45204. /**
  45205. * The elements needed for change-detection of the gamepad objects in motion controllers
  45206. */
  45207. export interface IMinimalMotionControllerObject {
  45208. /**
  45209. * An array of available buttons
  45210. */
  45211. buttons: Array<{
  45212. /**
  45213. * Value of the button/trigger
  45214. */
  45215. value: number;
  45216. /**
  45217. * If the button/trigger is currently touched
  45218. */
  45219. touched: boolean;
  45220. /**
  45221. * If the button/trigger is currently pressed
  45222. */
  45223. pressed: boolean;
  45224. }>;
  45225. /**
  45226. * Available axes of this controller
  45227. */
  45228. axes: number[];
  45229. }
  45230. /**
  45231. * An Abstract Motion controller
  45232. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45233. * Each component has an observable to check for changes in value and state
  45234. */
  45235. export abstract class WebXRAbstractMotionController implements IDisposable {
  45236. protected scene: Scene;
  45237. protected layout: IMotionControllerLayout;
  45238. /**
  45239. * The gamepad object correlating to this controller
  45240. */
  45241. gamepadObject: IMinimalMotionControllerObject;
  45242. /**
  45243. * handness (left/right/none) of this controller
  45244. */
  45245. handness: MotionControllerHandness;
  45246. /**
  45247. * The profile id of this motion controller
  45248. */
  45249. abstract profileId: string;
  45250. /**
  45251. * A map of components (WebXRControllerComponent) in this motion controller
  45252. * Components have a ComponentType and can also have both button and axis definitions
  45253. */
  45254. readonly components: {
  45255. [id: string]: WebXRControllerComponent;
  45256. };
  45257. /**
  45258. * Observers registered here will be triggered when the model of this controller is done loading
  45259. */
  45260. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45261. /**
  45262. * The root mesh of the model. It is null if the model was not yet initialized
  45263. */
  45264. rootMesh: Nullable<AbstractMesh>;
  45265. /**
  45266. * Disable the model's animation. Can be set at any time.
  45267. */
  45268. disableAnimation: boolean;
  45269. private _modelReady;
  45270. /**
  45271. * constructs a new abstract motion controller
  45272. * @param scene the scene to which the model of the controller will be added
  45273. * @param layout The profile layout to load
  45274. * @param gamepadObject The gamepad object correlating to this controller
  45275. * @param handness handness (left/right/none) of this controller
  45276. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45277. */
  45278. constructor(scene: Scene, layout: IMotionControllerLayout,
  45279. /**
  45280. * The gamepad object correlating to this controller
  45281. */
  45282. gamepadObject: IMinimalMotionControllerObject,
  45283. /**
  45284. * handness (left/right/none) of this controller
  45285. */
  45286. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  45287. private _initComponent;
  45288. /**
  45289. * Update this model using the current XRFrame
  45290. * @param xrFrame the current xr frame to use and update the model
  45291. */
  45292. updateFromXRFrame(xrFrame: XRFrame): void;
  45293. /**
  45294. * Get the list of components available in this motion controller
  45295. * @returns an array of strings correlating to available components
  45296. */
  45297. getComponentIds(): string[];
  45298. /**
  45299. * Get the main (Select) component of this controller as defined in the layout
  45300. * @returns the main component of this controller
  45301. */
  45302. getMainComponent(): WebXRControllerComponent;
  45303. /**
  45304. * get a component based an its component id as defined in layout.components
  45305. * @param id the id of the component
  45306. * @returns the component correlates to the id or undefined if not found
  45307. */
  45308. getComponent(id: string): WebXRControllerComponent;
  45309. /**
  45310. * Get the first component of specific type
  45311. * @param type type of component to find
  45312. * @return a controller component or null if not found
  45313. */
  45314. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  45315. /**
  45316. * Returns all components of specific type
  45317. * @param type the type to search for
  45318. * @return an array of components with this type
  45319. */
  45320. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  45321. /**
  45322. * Loads the model correlating to this controller
  45323. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45324. * @returns A promise fulfilled with the result of the model loading
  45325. */
  45326. loadModel(): Promise<boolean>;
  45327. /**
  45328. * Update the model itself with the current frame data
  45329. * @param xrFrame the frame to use for updating the model mesh
  45330. */
  45331. protected updateModel(xrFrame: XRFrame): void;
  45332. /**
  45333. * Moves the axis on the controller mesh based on its current state
  45334. * @param axis the index of the axis
  45335. * @param axisValue the value of the axis which determines the meshes new position
  45336. * @hidden
  45337. */
  45338. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  45339. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45340. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45341. private _getGenericFilenameAndPath;
  45342. private _getGenericParentMesh;
  45343. /**
  45344. * Get the filename and path for this controller's model
  45345. * @returns a map of filename and path
  45346. */
  45347. protected abstract _getFilenameAndPath(): {
  45348. filename: string;
  45349. path: string;
  45350. };
  45351. /**
  45352. * This function will be called after the model was successfully loaded and can be used
  45353. * for mesh transformations before it is available for the user
  45354. * @param meshes the loaded meshes
  45355. */
  45356. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45357. /**
  45358. * Set the root mesh for this controller. Important for the WebXR controller class
  45359. * @param meshes the loaded meshes
  45360. */
  45361. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45362. /**
  45363. * A function executed each frame that updates the mesh (if needed)
  45364. * @param xrFrame the current xrFrame
  45365. */
  45366. protected abstract _updateModel(xrFrame: XRFrame): void;
  45367. /**
  45368. * This function is called before the mesh is loaded. It checks for loading constraints.
  45369. * For example, this function can check if the GLB loader is available
  45370. * If this function returns false, the generic controller will be loaded instead
  45371. * @returns Is the client ready to load the mesh
  45372. */
  45373. protected abstract _getModelLoadingConstraints(): boolean;
  45374. /**
  45375. * Dispose this controller, the model mesh and all its components
  45376. */
  45377. dispose(): void;
  45378. }
  45379. }
  45380. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  45381. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45383. import { Scene } from "babylonjs/scene";
  45384. /**
  45385. * A generic trigger-only motion controller for WebXR
  45386. */
  45387. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45388. /**
  45389. * Static version of the profile id of this controller
  45390. */
  45391. static ProfileId: string;
  45392. profileId: string;
  45393. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45394. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45395. protected _updateModel(): void;
  45396. protected _getFilenameAndPath(): {
  45397. filename: string;
  45398. path: string;
  45399. };
  45400. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45401. protected _getModelLoadingConstraints(): boolean;
  45402. }
  45403. }
  45404. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45405. import { Vector4 } from "babylonjs/Maths/math.vector";
  45406. import { Mesh } from "babylonjs/Meshes/mesh";
  45407. import { Scene } from "babylonjs/scene";
  45408. import { Nullable } from "babylonjs/types";
  45409. /**
  45410. * Class containing static functions to help procedurally build meshes
  45411. */
  45412. export class SphereBuilder {
  45413. /**
  45414. * Creates a sphere mesh
  45415. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45416. * * 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`)
  45417. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45418. * * 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
  45419. * * 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)
  45420. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45421. * * 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
  45422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45423. * @param name defines the name of the mesh
  45424. * @param options defines the options used to create the mesh
  45425. * @param scene defines the hosting scene
  45426. * @returns the sphere mesh
  45427. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45428. */
  45429. static CreateSphere(name: string, options: {
  45430. segments?: number;
  45431. diameter?: number;
  45432. diameterX?: number;
  45433. diameterY?: number;
  45434. diameterZ?: number;
  45435. arc?: number;
  45436. slice?: number;
  45437. sideOrientation?: number;
  45438. frontUVs?: Vector4;
  45439. backUVs?: Vector4;
  45440. updatable?: boolean;
  45441. }, scene?: Nullable<Scene>): Mesh;
  45442. }
  45443. }
  45444. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  45445. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45446. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45447. import { Scene } from "babylonjs/scene";
  45448. /**
  45449. * A profiled motion controller has its profile loaded from an online repository.
  45450. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  45451. */
  45452. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  45453. private _repositoryUrl;
  45454. /**
  45455. * The profile ID of this controller. Will be populated when the controller initializes.
  45456. */
  45457. profileId: string;
  45458. private _buttonMeshMapping;
  45459. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  45460. protected _getFilenameAndPath(): {
  45461. filename: string;
  45462. path: string;
  45463. };
  45464. private _touchDots;
  45465. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45466. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45467. protected _updateModel(_xrFrame: XRFrame): void;
  45468. protected _getModelLoadingConstraints(): boolean;
  45469. dispose(): void;
  45470. }
  45471. }
  45472. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  45473. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45474. import { Scene } from "babylonjs/scene";
  45475. /**
  45476. * A construction function type to create a new controller based on an xrInput object
  45477. */
  45478. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  45479. /**
  45480. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  45481. *
  45482. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  45483. * it should be replaced with auto-loaded controllers.
  45484. *
  45485. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  45486. */
  45487. export class WebXRMotionControllerManager {
  45488. /**
  45489. * The base URL of the online controller repository. Can be changed at any time.
  45490. */
  45491. static BaseRepositoryUrl: string;
  45492. /**
  45493. * Use the online repository, or use only locally-defined controllers
  45494. */
  45495. static UseOnlineRepository: boolean;
  45496. /**
  45497. * Which repository gets priority - local or online
  45498. */
  45499. static PrioritizeOnlineRepository: boolean;
  45500. private static _AvailableControllers;
  45501. private static _Fallbacks;
  45502. /**
  45503. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  45504. *
  45505. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  45506. *
  45507. * @param type the profile type to register
  45508. * @param constructFunction the function to be called when loading this profile
  45509. */
  45510. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  45511. /**
  45512. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  45513. * The order of search:
  45514. *
  45515. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  45516. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  45517. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  45518. * 4) return the generic trigger controller if none were found
  45519. *
  45520. * @param xrInput the xrInput to which a new controller is initialized
  45521. * @param scene the scene to which the model will be added
  45522. * @param forceProfile force a certain profile for this controller
  45523. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  45524. */
  45525. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  45526. private static _LoadProfilesFromAvailableControllers;
  45527. private static _ProfilesList;
  45528. private static _ProfileLoadingPromises;
  45529. private static _LoadProfileFromRepository;
  45530. /**
  45531. * Clear the cache used for profile loading and reload when requested again
  45532. */
  45533. static ClearProfilesCache(): void;
  45534. /**
  45535. * Will update the list of profiles available in the repository
  45536. * @return a promise that resolves to a map of profiles available online
  45537. */
  45538. static UpdateProfilesList(): Promise<{
  45539. [profile: string]: string;
  45540. }>;
  45541. /**
  45542. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  45543. * @param profileId the profile to which a fallback needs to be found
  45544. * @return an array with corresponding fallback profiles
  45545. */
  45546. static FindFallbackWithProfileId(profileId: string): string[];
  45547. /**
  45548. * Register a fallback to a specific profile.
  45549. * @param profileId the profileId that will receive the fallbacks
  45550. * @param fallbacks A list of fallback profiles
  45551. */
  45552. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  45553. /**
  45554. * Register the default fallbacks.
  45555. * This function is called automatically when this file is imported.
  45556. */
  45557. static DefaultFallbacks(): void;
  45558. }
  45559. }
  45560. declare module "babylonjs/XR/webXRInputSource" {
  45561. import { Observable } from "babylonjs/Misc/observable";
  45562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45563. import { Ray } from "babylonjs/Culling/ray";
  45564. import { Scene } from "babylonjs/scene";
  45565. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45566. /**
  45567. * Configuration options for the WebXR controller creation
  45568. */
  45569. export interface IWebXRControllerOptions {
  45570. /**
  45571. * Force a specific controller type for this controller.
  45572. * This can be used when creating your own profile or when testing different controllers
  45573. */
  45574. forceControllerProfile?: string;
  45575. /**
  45576. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  45577. */
  45578. doNotLoadControllerMesh?: boolean;
  45579. /**
  45580. * Should the controller mesh be animated when a user interacts with it
  45581. * The pressed buttons / thumbstick and touchpad animations will be disabled
  45582. */
  45583. disableMotionControllerAnimation?: boolean;
  45584. }
  45585. /**
  45586. * Represents an XR controller
  45587. */
  45588. export class WebXRInputSource {
  45589. private _scene;
  45590. /** The underlying input source for the controller */
  45591. inputSource: XRInputSource;
  45592. private _options;
  45593. /**
  45594. * 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
  45595. */
  45596. grip?: AbstractMesh;
  45597. /**
  45598. * Pointer which can be used to select objects or attach a visible laser to
  45599. */
  45600. pointer: AbstractMesh;
  45601. /**
  45602. * If available, this is the gamepad object related to this controller.
  45603. * Using this object it is possible to get click events and trackpad changes of the
  45604. * webxr controller that is currently being used.
  45605. */
  45606. motionController?: WebXRAbstractMotionController;
  45607. /**
  45608. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  45609. */
  45610. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  45611. /**
  45612. * Will be triggered when the mesh associated with the motion controller is done loading.
  45613. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  45614. * A shortened version of controller -> motion controller -> on mesh loaded.
  45615. */
  45616. onMeshLoadedObservable: Observable<AbstractMesh>;
  45617. /**
  45618. * Event that fires when the controller is removed/disposed.
  45619. * The object provided as event data is this controller, after associated assets were disposed.
  45620. * uniqueId is still available.
  45621. */
  45622. onDisposeObservable: Observable<WebXRInputSource>;
  45623. private _tmpQuaternion;
  45624. private _tmpVector;
  45625. private _uniqueId;
  45626. /**
  45627. * Creates the controller
  45628. * @see https://doc.babylonjs.com/how_to/webxr
  45629. * @param _scene the scene which the controller should be associated to
  45630. * @param inputSource the underlying input source for the controller
  45631. * @param _options options for this controller creation
  45632. */
  45633. constructor(_scene: Scene,
  45634. /** The underlying input source for the controller */
  45635. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  45636. /**
  45637. * Get this controllers unique id
  45638. */
  45639. get uniqueId(): string;
  45640. /**
  45641. * Updates the controller pose based on the given XRFrame
  45642. * @param xrFrame xr frame to update the pose with
  45643. * @param referenceSpace reference space to use
  45644. */
  45645. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  45646. /**
  45647. * Gets a world space ray coming from the pointer or grip
  45648. * @param result the resulting ray
  45649. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  45650. */
  45651. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  45652. /**
  45653. * Disposes of the object
  45654. */
  45655. dispose(): void;
  45656. }
  45657. }
  45658. declare module "babylonjs/XR/webXRInput" {
  45659. import { Observable } from "babylonjs/Misc/observable";
  45660. import { IDisposable } from "babylonjs/scene";
  45661. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  45662. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45663. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  45664. /**
  45665. * The schema for initialization options of the XR Input class
  45666. */
  45667. export interface IWebXRInputOptions {
  45668. /**
  45669. * If set to true no model will be automatically loaded
  45670. */
  45671. doNotLoadControllerMeshes?: boolean;
  45672. /**
  45673. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  45674. * If not found, the xr input profile data will be used.
  45675. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  45676. */
  45677. forceInputProfile?: string;
  45678. /**
  45679. * Do not send a request to the controlle repository to load the profile.
  45680. *
  45681. * Instead, use the controllers available in babylon itself.
  45682. */
  45683. disableOnlineControllerRepository?: boolean;
  45684. /**
  45685. * A custom URL for the controllers repository
  45686. */
  45687. customControllersRepositoryURL?: string;
  45688. /**
  45689. * Should the controller model's components not move according to the user input
  45690. */
  45691. disableControllerAnimation?: boolean;
  45692. }
  45693. /**
  45694. * XR input used to track XR inputs such as controllers/rays
  45695. */
  45696. export class WebXRInput implements IDisposable {
  45697. /**
  45698. * the xr session manager for this session
  45699. */
  45700. xrSessionManager: WebXRSessionManager;
  45701. /**
  45702. * the WebXR camera for this session. Mainly used for teleportation
  45703. */
  45704. xrCamera: WebXRCamera;
  45705. private readonly options;
  45706. /**
  45707. * XR controllers being tracked
  45708. */
  45709. controllers: Array<WebXRInputSource>;
  45710. private _frameObserver;
  45711. private _sessionEndedObserver;
  45712. private _sessionInitObserver;
  45713. /**
  45714. * Event when a controller has been connected/added
  45715. */
  45716. onControllerAddedObservable: Observable<WebXRInputSource>;
  45717. /**
  45718. * Event when a controller has been removed/disconnected
  45719. */
  45720. onControllerRemovedObservable: Observable<WebXRInputSource>;
  45721. /**
  45722. * Initializes the WebXRInput
  45723. * @param xrSessionManager the xr session manager for this session
  45724. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  45725. * @param options = initialization options for this xr input
  45726. */
  45727. constructor(
  45728. /**
  45729. * the xr session manager for this session
  45730. */
  45731. xrSessionManager: WebXRSessionManager,
  45732. /**
  45733. * the WebXR camera for this session. Mainly used for teleportation
  45734. */
  45735. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  45736. private _onInputSourcesChange;
  45737. private _addAndRemoveControllers;
  45738. /**
  45739. * Disposes of the object
  45740. */
  45741. dispose(): void;
  45742. }
  45743. }
  45744. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  45745. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  45746. import { Observable, EventState } from "babylonjs/Misc/observable";
  45747. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45748. /**
  45749. * This is the base class for all WebXR features.
  45750. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  45751. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  45752. */
  45753. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  45754. protected _xrSessionManager: WebXRSessionManager;
  45755. /**
  45756. * Construct a new (abstract) webxr feature
  45757. * @param _xrSessionManager the xr session manager for this feature
  45758. */
  45759. constructor(_xrSessionManager: WebXRSessionManager);
  45760. private _attached;
  45761. private _removeOnDetach;
  45762. /**
  45763. * Is this feature attached
  45764. */
  45765. get attached(): boolean;
  45766. /**
  45767. * Should auto-attach be disabled?
  45768. */
  45769. disableAutoAttach: boolean;
  45770. /**
  45771. * attach this feature
  45772. *
  45773. * @param force should attachment be forced (even when already attached)
  45774. * @returns true if successful, false is failed or already attached
  45775. */
  45776. attach(force?: boolean): boolean;
  45777. /**
  45778. * detach this feature.
  45779. *
  45780. * @returns true if successful, false if failed or already detached
  45781. */
  45782. detach(): boolean;
  45783. /**
  45784. * Dispose this feature and all of the resources attached
  45785. */
  45786. dispose(): void;
  45787. /**
  45788. * Code in this function will be executed on each xrFrame received from the browser.
  45789. * This function will not execute after the feature is detached.
  45790. * @param _xrFrame the current frame
  45791. */
  45792. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  45793. /**
  45794. * This is used to register callbacks that will automatically be removed when detach is called.
  45795. * @param observable the observable to which the observer will be attached
  45796. * @param callback the callback to register
  45797. */
  45798. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  45799. }
  45800. }
  45801. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  45802. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45803. import { WebXRInput } from "babylonjs/XR/webXRInput";
  45804. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  45805. import { Nullable } from "babylonjs/types";
  45806. import { Color3 } from "babylonjs/Maths/math.color";
  45807. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  45808. /**
  45809. * Options interface for the pointer selection module
  45810. */
  45811. export interface IWebXRControllerPointerSelectionOptions {
  45812. /**
  45813. * the xr input to use with this pointer selection
  45814. */
  45815. xrInput: WebXRInput;
  45816. /**
  45817. * Different button type to use instead of the main component
  45818. */
  45819. overrideButtonId?: string;
  45820. /**
  45821. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  45822. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  45823. * 3000 means 3 seconds between pointing at something and selecting it
  45824. */
  45825. timeToSelect?: number;
  45826. /**
  45827. * Disable the pointer up event when the xr controller in screen and gaze mode is disposed (meaning - when the user removed the finger from the screen)
  45828. * If not disabled, the last picked point will be used to execute a pointer up event
  45829. * If disabled, pointer up event will be triggered right after the pointer down event.
  45830. * Used in screen and gaze target ray mode only
  45831. */
  45832. disablePointerUpOnTouchOut: boolean;
  45833. /**
  45834. * For gaze mode (time to select instead of press)
  45835. */
  45836. forceGazeMode: boolean;
  45837. /**
  45838. * Factor to be applied to the pointer-moved function in the gaze mode. How sensitive should the gaze mode be when checking if the pointer moved
  45839. * to start a new countdown to the pointer down event.
  45840. * Defaults to 1.
  45841. */
  45842. gazeModePointerMovedFactor?: number;
  45843. }
  45844. /**
  45845. * A module that will enable pointer selection for motion controllers of XR Input Sources
  45846. */
  45847. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  45848. private readonly _options;
  45849. /**
  45850. * The module's name
  45851. */
  45852. static readonly Name: string;
  45853. /**
  45854. * The (Babylon) version of this module.
  45855. * This is an integer representing the implementation version.
  45856. * This number does not correspond to the webxr specs version
  45857. */
  45858. static readonly Version: number;
  45859. /**
  45860. * This color will be set to the laser pointer when selection is triggered
  45861. */
  45862. laserPointerPickedColor: Color3;
  45863. /**
  45864. * This color will be applied to the selection ring when selection is triggered
  45865. */
  45866. selectionMeshPickedColor: Color3;
  45867. /**
  45868. * default color of the selection ring
  45869. */
  45870. selectionMeshDefaultColor: Color3;
  45871. /**
  45872. * Default color of the laser pointer
  45873. */
  45874. lasterPointerDefaultColor: Color3;
  45875. /**
  45876. * Should the laser pointer be displayed
  45877. */
  45878. displayLaserPointer: boolean;
  45879. /**
  45880. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  45881. */
  45882. displaySelectionMesh: boolean;
  45883. /**
  45884. * Disable lighting on the laser pointer (so it will always be visible)
  45885. */
  45886. disablePointerLighting: boolean;
  45887. /**
  45888. * Disable lighting on the selection mesh (so it will always be visible)
  45889. */
  45890. disableSelectionMeshLighting: boolean;
  45891. private static _idCounter;
  45892. private _tmpRay;
  45893. private _controllers;
  45894. private _scene;
  45895. /**
  45896. * constructs a new background remover module
  45897. * @param _xrSessionManager the session manager for this module
  45898. * @param _options read-only options to be used in this module
  45899. */
  45900. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  45901. /**
  45902. * attach this feature
  45903. * Will usually be called by the features manager
  45904. *
  45905. * @returns true if successful.
  45906. */
  45907. attach(): boolean;
  45908. /**
  45909. * detach this feature.
  45910. * Will usually be called by the features manager
  45911. *
  45912. * @returns true if successful.
  45913. */
  45914. detach(): boolean;
  45915. /**
  45916. * Get the xr controller that correlates to the pointer id in the pointer event
  45917. *
  45918. * @param id the pointer id to search for
  45919. * @returns the controller that correlates to this id or null if not found
  45920. */
  45921. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  45922. protected _onXRFrame(_xrFrame: XRFrame): void;
  45923. private _attachController;
  45924. private _attachScreenRayMode;
  45925. private _attachGazeMode;
  45926. private _tmpVectorForPickCompare;
  45927. private _pickingMoved;
  45928. private _attachTrackedPointerRayMode;
  45929. private _detachController;
  45930. private _generateNewMeshPair;
  45931. private _convertNormalToDirectionOfRay;
  45932. private _updatePointerDistance;
  45933. }
  45934. }
  45935. declare module "babylonjs/XR/webXREnterExitUI" {
  45936. import { Nullable } from "babylonjs/types";
  45937. import { Observable } from "babylonjs/Misc/observable";
  45938. import { IDisposable, Scene } from "babylonjs/scene";
  45939. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  45940. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  45941. /**
  45942. * Button which can be used to enter a different mode of XR
  45943. */
  45944. export class WebXREnterExitUIButton {
  45945. /** button element */
  45946. element: HTMLElement;
  45947. /** XR initialization options for the button */
  45948. sessionMode: XRSessionMode;
  45949. /** Reference space type */
  45950. referenceSpaceType: XRReferenceSpaceType;
  45951. /**
  45952. * Creates a WebXREnterExitUIButton
  45953. * @param element button element
  45954. * @param sessionMode XR initialization session mode
  45955. * @param referenceSpaceType the type of reference space to be used
  45956. */
  45957. constructor(
  45958. /** button element */
  45959. element: HTMLElement,
  45960. /** XR initialization options for the button */
  45961. sessionMode: XRSessionMode,
  45962. /** Reference space type */
  45963. referenceSpaceType: XRReferenceSpaceType);
  45964. /**
  45965. * Overwritable function which can be used to update the button's visuals when the state changes
  45966. * @param activeButton the current active button in the UI
  45967. */
  45968. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  45969. }
  45970. /**
  45971. * Options to create the webXR UI
  45972. */
  45973. export class WebXREnterExitUIOptions {
  45974. /**
  45975. * Context to enter xr with
  45976. */
  45977. renderTarget?: Nullable<WebXRRenderTarget>;
  45978. /**
  45979. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  45980. */
  45981. customButtons?: Array<WebXREnterExitUIButton>;
  45982. /**
  45983. * A session mode to use when creating the default button.
  45984. * Default is immersive-vr
  45985. */
  45986. sessionMode?: XRSessionMode;
  45987. /**
  45988. * A reference space type to use when creating the default button.
  45989. * Default is local-floor
  45990. */
  45991. referenceSpaceType?: XRReferenceSpaceType;
  45992. }
  45993. /**
  45994. * UI to allow the user to enter/exit XR mode
  45995. */
  45996. export class WebXREnterExitUI implements IDisposable {
  45997. private scene;
  45998. /** version of the options passed to this UI */
  45999. options: WebXREnterExitUIOptions;
  46000. private _overlay;
  46001. private _buttons;
  46002. private _activeButton;
  46003. /**
  46004. * Fired every time the active button is changed.
  46005. *
  46006. * When xr is entered via a button that launches xr that button will be the callback parameter
  46007. *
  46008. * When exiting xr the callback parameter will be null)
  46009. */
  46010. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46011. /**
  46012. * Creates UI to allow the user to enter/exit XR mode
  46013. * @param scene the scene to add the ui to
  46014. * @param helper the xr experience helper to enter/exit xr with
  46015. * @param options options to configure the UI
  46016. * @returns the created ui
  46017. */
  46018. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  46019. /**
  46020. *
  46021. * @param scene babylon scene object to use
  46022. * @param options (read-only) version of the options passed to this UI
  46023. */
  46024. private constructor();
  46025. private _updateButtons;
  46026. /**
  46027. * Disposes of the object
  46028. */
  46029. dispose(): void;
  46030. }
  46031. }
  46032. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46033. import { Vector3 } from "babylonjs/Maths/math.vector";
  46034. import { Color4 } from "babylonjs/Maths/math.color";
  46035. import { Nullable } from "babylonjs/types";
  46036. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46037. import { Scene } from "babylonjs/scene";
  46038. /**
  46039. * Class containing static functions to help procedurally build meshes
  46040. */
  46041. export class LinesBuilder {
  46042. /**
  46043. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46044. * * 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
  46045. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46046. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46047. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46048. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46049. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46050. * * 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
  46051. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46052. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46053. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46054. * @param name defines the name of the new line system
  46055. * @param options defines the options used to create the line system
  46056. * @param scene defines the hosting scene
  46057. * @returns a new line system mesh
  46058. */
  46059. static CreateLineSystem(name: string, options: {
  46060. lines: Vector3[][];
  46061. updatable?: boolean;
  46062. instance?: Nullable<LinesMesh>;
  46063. colors?: Nullable<Color4[][]>;
  46064. useVertexAlpha?: boolean;
  46065. }, scene: Nullable<Scene>): LinesMesh;
  46066. /**
  46067. * Creates a line mesh
  46068. * 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
  46069. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46070. * * The parameter `points` is an array successive Vector3
  46071. * * 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
  46072. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46073. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46074. * * When updating an instance, remember that only point positions can change, not the number of points
  46075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46076. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46077. * @param name defines the name of the new line system
  46078. * @param options defines the options used to create the line system
  46079. * @param scene defines the hosting scene
  46080. * @returns a new line mesh
  46081. */
  46082. static CreateLines(name: string, options: {
  46083. points: Vector3[];
  46084. updatable?: boolean;
  46085. instance?: Nullable<LinesMesh>;
  46086. colors?: Color4[];
  46087. useVertexAlpha?: boolean;
  46088. }, scene?: Nullable<Scene>): LinesMesh;
  46089. /**
  46090. * Creates a dashed line mesh
  46091. * * 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
  46092. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46093. * * The parameter `points` is an array successive Vector3
  46094. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46095. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46096. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46097. * * 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
  46098. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46099. * * When updating an instance, remember that only point positions can change, not the number of points
  46100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46101. * @param name defines the name of the mesh
  46102. * @param options defines the options used to create the mesh
  46103. * @param scene defines the hosting scene
  46104. * @returns the dashed line mesh
  46105. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46106. */
  46107. static CreateDashedLines(name: string, options: {
  46108. points: Vector3[];
  46109. dashSize?: number;
  46110. gapSize?: number;
  46111. dashNb?: number;
  46112. updatable?: boolean;
  46113. instance?: LinesMesh;
  46114. useVertexAlpha?: boolean;
  46115. }, scene?: Nullable<Scene>): LinesMesh;
  46116. }
  46117. }
  46118. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  46119. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46120. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46121. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46122. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46123. import { Material } from "babylonjs/Materials/material";
  46124. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46125. /**
  46126. * The options container for the teleportation module
  46127. */
  46128. export interface IWebXRTeleportationOptions {
  46129. /**
  46130. * Babylon XR Input class for controller
  46131. */
  46132. xrInput: WebXRInput;
  46133. /**
  46134. * A list of meshes to use as floor meshes.
  46135. * Meshes can be added and removed after initializing the feature using the
  46136. * addFloorMesh and removeFloorMesh functions
  46137. * If empty, rotation will still work
  46138. */
  46139. floorMeshes?: AbstractMesh[];
  46140. /**
  46141. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  46142. * If you want to support rotation, make sure your mesh has a direction indicator.
  46143. *
  46144. * When left untouched, the default mesh will be initialized.
  46145. */
  46146. teleportationTargetMesh?: AbstractMesh;
  46147. /**
  46148. * Values to configure the default target mesh
  46149. */
  46150. defaultTargetMeshOptions?: {
  46151. /**
  46152. * Fill color of the teleportation area
  46153. */
  46154. teleportationFillColor?: string;
  46155. /**
  46156. * Border color for the teleportation area
  46157. */
  46158. teleportationBorderColor?: string;
  46159. /**
  46160. * Disable the mesh's animation sequence
  46161. */
  46162. disableAnimation?: boolean;
  46163. /**
  46164. * Disable lighting on the material or the ring and arrow
  46165. */
  46166. disableLighting?: boolean;
  46167. /**
  46168. * Override the default material of the torus and arrow
  46169. */
  46170. torusArrowMaterial?: Material;
  46171. };
  46172. /**
  46173. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  46174. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  46175. */
  46176. useMainComponentOnly?: boolean;
  46177. /**
  46178. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  46179. */
  46180. timeToTeleport?: number;
  46181. }
  46182. /**
  46183. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  46184. * When enabled and attached, the feature will allow a user to move aroundand rotate in the scene using
  46185. * the input of the attached controllers.
  46186. */
  46187. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  46188. private _options;
  46189. /**
  46190. * The module's name
  46191. */
  46192. static readonly Name: string;
  46193. /**
  46194. * The (Babylon) version of this module.
  46195. * This is an integer representing the implementation version.
  46196. * This number does not correspond to the webxr specs version
  46197. */
  46198. static readonly Version: number;
  46199. /**
  46200. * Is rotation enabled when moving forward?
  46201. * Disabling this feature will prevent the user from deciding the direction when teleporting
  46202. */
  46203. rotationEnabled: boolean;
  46204. /**
  46205. * Should the module support parabolic ray on top of direct ray
  46206. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  46207. * Very helpful when moving between floors / different heights
  46208. */
  46209. parabolicRayEnabled: boolean;
  46210. /**
  46211. * The distance from the user to the inspection point in the direction of the controller
  46212. * A higher number will allow the user to move further
  46213. * defaults to 5 (meters, in xr units)
  46214. */
  46215. parabolicCheckRadius: number;
  46216. /**
  46217. * How much rotation should be applied when rotating right and left
  46218. */
  46219. rotationAngle: number;
  46220. /**
  46221. * Is movement backwards enabled
  46222. */
  46223. backwardsMovementEnabled: boolean;
  46224. /**
  46225. * Distance to travel when moving backwards
  46226. */
  46227. backwardsTeleportationDistance: number;
  46228. /**
  46229. * Add a new mesh to the floor meshes array
  46230. * @param mesh the mesh to use as floor mesh
  46231. */
  46232. addFloorMesh(mesh: AbstractMesh): void;
  46233. /**
  46234. * Remove a mesh from the floor meshes array
  46235. * @param mesh the mesh to remove
  46236. */
  46237. removeFloorMesh(mesh: AbstractMesh): void;
  46238. /**
  46239. * Remove a mesh from the floor meshes array using its name
  46240. * @param name the mesh name to remove
  46241. */
  46242. removeFloorMeshByName(name: string): void;
  46243. private _tmpRay;
  46244. private _tmpVector;
  46245. private _floorMeshes;
  46246. private _controllers;
  46247. /**
  46248. * constructs a new anchor system
  46249. * @param _xrSessionManager an instance of WebXRSessionManager
  46250. * @param _options configuration object for this feature
  46251. */
  46252. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  46253. private _selectionFeature;
  46254. /**
  46255. * This function sets a selection feature that will be disabled when
  46256. * the forward ray is shown and will be reattached when hidden.
  46257. * This is used to remove the selection rays when moving.
  46258. * @param selectionFeature the feature to disable when forward movement is enabled
  46259. */
  46260. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  46261. attach(): boolean;
  46262. detach(): boolean;
  46263. dispose(): void;
  46264. protected _onXRFrame(_xrFrame: XRFrame): void;
  46265. private _currentTeleportationControllerId;
  46266. private _attachController;
  46267. private _teleportForward;
  46268. private _detachController;
  46269. private createDefaultTargetMesh;
  46270. private setTargetMeshVisibility;
  46271. private setTargetMeshPosition;
  46272. private _quadraticBezierCurve;
  46273. private _showParabolicPath;
  46274. }
  46275. }
  46276. declare module "babylonjs/XR/webXRDefaultExperience" {
  46277. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46278. import { Scene } from "babylonjs/scene";
  46279. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  46280. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  46281. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46282. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  46283. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46284. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  46285. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  46286. /**
  46287. * Options for the default xr helper
  46288. */
  46289. export class WebXRDefaultExperienceOptions {
  46290. /**
  46291. * Floor meshes that will be used for teleporting
  46292. */
  46293. floorMeshes?: Array<AbstractMesh>;
  46294. /**
  46295. * Enable or disable default UI to enter XR
  46296. */
  46297. disableDefaultUI?: boolean;
  46298. /**
  46299. * optional configuration for the output canvas
  46300. */
  46301. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  46302. /**
  46303. * optional UI options. This can be used among other to change session mode and reference space type
  46304. */
  46305. uiOptions?: WebXREnterExitUIOptions;
  46306. /**
  46307. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  46308. */
  46309. inputOptions?: IWebXRInputOptions;
  46310. /**
  46311. * Should teleportation not initialize. defaults to false.
  46312. */
  46313. disableTeleportation?: boolean;
  46314. /**
  46315. * If set to true, the first frame will not be used to reset position
  46316. * The first frame is mainly used when copying transformation from the old camera
  46317. * Mainly used in AR
  46318. */
  46319. ignoreNativeCameraTransformation?: boolean;
  46320. /**
  46321. * When loading teleportation and pointer select, use stable versions instead of latest.
  46322. */
  46323. useStablePlugins?: boolean;
  46324. }
  46325. /**
  46326. * Default experience which provides a similar setup to the previous webVRExperience
  46327. */
  46328. export class WebXRDefaultExperience {
  46329. /**
  46330. * Base experience
  46331. */
  46332. baseExperience: WebXRExperienceHelper;
  46333. /**
  46334. * Input experience extension
  46335. */
  46336. input: WebXRInput;
  46337. /**
  46338. * Enables laser pointer and selection
  46339. */
  46340. pointerSelection: WebXRControllerPointerSelection;
  46341. /**
  46342. * Enables teleportation
  46343. */
  46344. teleportation: WebXRMotionControllerTeleportation;
  46345. /**
  46346. * Enables ui for entering/exiting xr
  46347. */
  46348. enterExitUI: WebXREnterExitUI;
  46349. /**
  46350. * Default target xr should render to
  46351. */
  46352. renderTarget: WebXRRenderTarget;
  46353. /**
  46354. * Creates the default xr experience
  46355. * @param scene scene
  46356. * @param options options for basic configuration
  46357. * @returns resulting WebXRDefaultExperience
  46358. */
  46359. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  46360. private constructor();
  46361. /**
  46362. * DIsposes of the experience helper
  46363. */
  46364. dispose(): void;
  46365. }
  46366. }
  46367. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  46368. import { Observable } from "babylonjs/Misc/observable";
  46369. import { Nullable } from "babylonjs/types";
  46370. import { Camera } from "babylonjs/Cameras/camera";
  46371. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  46372. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46373. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  46374. import { Scene } from "babylonjs/scene";
  46375. import { Vector3 } from "babylonjs/Maths/math.vector";
  46376. import { Color3 } from "babylonjs/Maths/math.color";
  46377. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46378. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46379. import { Mesh } from "babylonjs/Meshes/mesh";
  46380. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  46381. import { EasingFunction } from "babylonjs/Animations/easing";
  46382. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46383. import "babylonjs/Meshes/Builders/groundBuilder";
  46384. import "babylonjs/Meshes/Builders/torusBuilder";
  46385. import "babylonjs/Meshes/Builders/cylinderBuilder";
  46386. import "babylonjs/Gamepads/gamepadSceneComponent";
  46387. import "babylonjs/Animations/animatable";
  46388. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  46389. /**
  46390. * Options to modify the vr teleportation behavior.
  46391. */
  46392. export interface VRTeleportationOptions {
  46393. /**
  46394. * The name of the mesh which should be used as the teleportation floor. (default: null)
  46395. */
  46396. floorMeshName?: string;
  46397. /**
  46398. * A list of meshes to be used as the teleportation floor. (default: empty)
  46399. */
  46400. floorMeshes?: Mesh[];
  46401. /**
  46402. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  46403. */
  46404. teleportationMode?: number;
  46405. /**
  46406. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  46407. */
  46408. teleportationTime?: number;
  46409. /**
  46410. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  46411. */
  46412. teleportationSpeed?: number;
  46413. /**
  46414. * The easing function used in the animation or null for Linear. (default CircleEase)
  46415. */
  46416. easingFunction?: EasingFunction;
  46417. }
  46418. /**
  46419. * Options to modify the vr experience helper's behavior.
  46420. */
  46421. export interface VRExperienceHelperOptions extends WebVROptions {
  46422. /**
  46423. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  46424. */
  46425. createDeviceOrientationCamera?: boolean;
  46426. /**
  46427. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  46428. */
  46429. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  46430. /**
  46431. * Uses the main button on the controller to toggle the laser casted. (default: true)
  46432. */
  46433. laserToggle?: boolean;
  46434. /**
  46435. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  46436. */
  46437. floorMeshes?: Mesh[];
  46438. /**
  46439. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  46440. */
  46441. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  46442. /**
  46443. * Defines if WebXR should be used instead of WebVR (if available)
  46444. */
  46445. useXR?: boolean;
  46446. }
  46447. /**
  46448. * Event containing information after VR has been entered
  46449. */
  46450. export class OnAfterEnteringVRObservableEvent {
  46451. /**
  46452. * If entering vr was successful
  46453. */
  46454. success: boolean;
  46455. }
  46456. /**
  46457. * Helps to quickly add VR support to an existing scene.
  46458. * See http://doc.babylonjs.com/how_to/webvr_helper
  46459. */
  46460. export class VRExperienceHelper {
  46461. /** Options to modify the vr experience helper's behavior. */
  46462. webVROptions: VRExperienceHelperOptions;
  46463. private _scene;
  46464. private _position;
  46465. private _btnVR;
  46466. private _btnVRDisplayed;
  46467. private _webVRsupported;
  46468. private _webVRready;
  46469. private _webVRrequesting;
  46470. private _webVRpresenting;
  46471. private _hasEnteredVR;
  46472. private _fullscreenVRpresenting;
  46473. private _inputElement;
  46474. private _webVRCamera;
  46475. private _vrDeviceOrientationCamera;
  46476. private _deviceOrientationCamera;
  46477. private _existingCamera;
  46478. private _onKeyDown;
  46479. private _onVrDisplayPresentChange;
  46480. private _onVRDisplayChanged;
  46481. private _onVRRequestPresentStart;
  46482. private _onVRRequestPresentComplete;
  46483. /**
  46484. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  46485. */
  46486. enableGazeEvenWhenNoPointerLock: boolean;
  46487. /**
  46488. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  46489. */
  46490. exitVROnDoubleTap: boolean;
  46491. /**
  46492. * Observable raised right before entering VR.
  46493. */
  46494. onEnteringVRObservable: Observable<VRExperienceHelper>;
  46495. /**
  46496. * Observable raised when entering VR has completed.
  46497. */
  46498. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  46499. /**
  46500. * Observable raised when exiting VR.
  46501. */
  46502. onExitingVRObservable: Observable<VRExperienceHelper>;
  46503. /**
  46504. * Observable raised when controller mesh is loaded.
  46505. */
  46506. onControllerMeshLoadedObservable: Observable<WebVRController>;
  46507. /** Return this.onEnteringVRObservable
  46508. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  46509. */
  46510. get onEnteringVR(): Observable<VRExperienceHelper>;
  46511. /** Return this.onExitingVRObservable
  46512. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  46513. */
  46514. get onExitingVR(): Observable<VRExperienceHelper>;
  46515. /** Return this.onControllerMeshLoadedObservable
  46516. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  46517. */
  46518. get onControllerMeshLoaded(): Observable<WebVRController>;
  46519. private _rayLength;
  46520. private _useCustomVRButton;
  46521. private _teleportationRequested;
  46522. private _teleportActive;
  46523. private _floorMeshName;
  46524. private _floorMeshesCollection;
  46525. private _teleportationMode;
  46526. private _teleportationTime;
  46527. private _teleportationSpeed;
  46528. private _teleportationEasing;
  46529. private _rotationAllowed;
  46530. private _teleportBackwardsVector;
  46531. private _teleportationTarget;
  46532. private _isDefaultTeleportationTarget;
  46533. private _postProcessMove;
  46534. private _teleportationFillColor;
  46535. private _teleportationBorderColor;
  46536. private _rotationAngle;
  46537. private _haloCenter;
  46538. private _cameraGazer;
  46539. private _padSensibilityUp;
  46540. private _padSensibilityDown;
  46541. private _leftController;
  46542. private _rightController;
  46543. private _gazeColor;
  46544. private _laserColor;
  46545. private _pickedLaserColor;
  46546. private _pickedGazeColor;
  46547. /**
  46548. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  46549. */
  46550. onNewMeshSelected: Observable<AbstractMesh>;
  46551. /**
  46552. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  46553. * This observable will provide the mesh and the controller used to select the mesh
  46554. */
  46555. onMeshSelectedWithController: Observable<{
  46556. mesh: AbstractMesh;
  46557. controller: WebVRController;
  46558. }>;
  46559. /**
  46560. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  46561. */
  46562. onNewMeshPicked: Observable<PickingInfo>;
  46563. private _circleEase;
  46564. /**
  46565. * Observable raised before camera teleportation
  46566. */
  46567. onBeforeCameraTeleport: Observable<Vector3>;
  46568. /**
  46569. * Observable raised after camera teleportation
  46570. */
  46571. onAfterCameraTeleport: Observable<Vector3>;
  46572. /**
  46573. * Observable raised when current selected mesh gets unselected
  46574. */
  46575. onSelectedMeshUnselected: Observable<AbstractMesh>;
  46576. private _raySelectionPredicate;
  46577. /**
  46578. * To be optionaly changed by user to define custom ray selection
  46579. */
  46580. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46581. /**
  46582. * To be optionaly changed by user to define custom selection logic (after ray selection)
  46583. */
  46584. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46585. /**
  46586. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  46587. */
  46588. teleportationEnabled: boolean;
  46589. private _defaultHeight;
  46590. private _teleportationInitialized;
  46591. private _interactionsEnabled;
  46592. private _interactionsRequested;
  46593. private _displayGaze;
  46594. private _displayLaserPointer;
  46595. /**
  46596. * The mesh used to display where the user is going to teleport.
  46597. */
  46598. get teleportationTarget(): Mesh;
  46599. /**
  46600. * Sets the mesh to be used to display where the user is going to teleport.
  46601. */
  46602. set teleportationTarget(value: Mesh);
  46603. /**
  46604. * 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
  46605. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  46606. * See http://doc.babylonjs.com/resources/baking_transformations
  46607. */
  46608. get gazeTrackerMesh(): Mesh;
  46609. set gazeTrackerMesh(value: Mesh);
  46610. /**
  46611. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  46612. */
  46613. updateGazeTrackerScale: boolean;
  46614. /**
  46615. * If the gaze trackers color should be updated when selecting meshes
  46616. */
  46617. updateGazeTrackerColor: boolean;
  46618. /**
  46619. * If the controller laser color should be updated when selecting meshes
  46620. */
  46621. updateControllerLaserColor: boolean;
  46622. /**
  46623. * The gaze tracking mesh corresponding to the left controller
  46624. */
  46625. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  46626. /**
  46627. * The gaze tracking mesh corresponding to the right controller
  46628. */
  46629. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  46630. /**
  46631. * If the ray of the gaze should be displayed.
  46632. */
  46633. get displayGaze(): boolean;
  46634. /**
  46635. * Sets if the ray of the gaze should be displayed.
  46636. */
  46637. set displayGaze(value: boolean);
  46638. /**
  46639. * If the ray of the LaserPointer should be displayed.
  46640. */
  46641. get displayLaserPointer(): boolean;
  46642. /**
  46643. * Sets if the ray of the LaserPointer should be displayed.
  46644. */
  46645. set displayLaserPointer(value: boolean);
  46646. /**
  46647. * The deviceOrientationCamera used as the camera when not in VR.
  46648. */
  46649. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  46650. /**
  46651. * Based on the current WebVR support, returns the current VR camera used.
  46652. */
  46653. get currentVRCamera(): Nullable<Camera>;
  46654. /**
  46655. * The webVRCamera which is used when in VR.
  46656. */
  46657. get webVRCamera(): WebVRFreeCamera;
  46658. /**
  46659. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  46660. */
  46661. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  46662. /**
  46663. * The html button that is used to trigger entering into VR.
  46664. */
  46665. get vrButton(): Nullable<HTMLButtonElement>;
  46666. private get _teleportationRequestInitiated();
  46667. /**
  46668. * Defines whether or not Pointer lock should be requested when switching to
  46669. * full screen.
  46670. */
  46671. requestPointerLockOnFullScreen: boolean;
  46672. /**
  46673. * If asking to force XR, this will be populated with the default xr experience
  46674. */
  46675. xr: WebXRDefaultExperience;
  46676. /**
  46677. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  46678. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  46679. */
  46680. xrTestDone: boolean;
  46681. /**
  46682. * Instantiates a VRExperienceHelper.
  46683. * Helps to quickly add VR support to an existing scene.
  46684. * @param scene The scene the VRExperienceHelper belongs to.
  46685. * @param webVROptions Options to modify the vr experience helper's behavior.
  46686. */
  46687. constructor(scene: Scene,
  46688. /** Options to modify the vr experience helper's behavior. */
  46689. webVROptions?: VRExperienceHelperOptions);
  46690. private completeVRInit;
  46691. private _onDefaultMeshLoaded;
  46692. private _onResize;
  46693. private _onFullscreenChange;
  46694. /**
  46695. * Gets a value indicating if we are currently in VR mode.
  46696. */
  46697. get isInVRMode(): boolean;
  46698. private onVrDisplayPresentChange;
  46699. private onVRDisplayChanged;
  46700. private moveButtonToBottomRight;
  46701. private displayVRButton;
  46702. private updateButtonVisibility;
  46703. private _cachedAngularSensibility;
  46704. /**
  46705. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  46706. * Otherwise, will use the fullscreen API.
  46707. */
  46708. enterVR(): void;
  46709. /**
  46710. * Attempt to exit VR, or fullscreen.
  46711. */
  46712. exitVR(): void;
  46713. /**
  46714. * The position of the vr experience helper.
  46715. */
  46716. get position(): Vector3;
  46717. /**
  46718. * Sets the position of the vr experience helper.
  46719. */
  46720. set position(value: Vector3);
  46721. /**
  46722. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  46723. */
  46724. enableInteractions(): void;
  46725. private get _noControllerIsActive();
  46726. private beforeRender;
  46727. private _isTeleportationFloor;
  46728. /**
  46729. * Adds a floor mesh to be used for teleportation.
  46730. * @param floorMesh the mesh to be used for teleportation.
  46731. */
  46732. addFloorMesh(floorMesh: Mesh): void;
  46733. /**
  46734. * Removes a floor mesh from being used for teleportation.
  46735. * @param floorMesh the mesh to be removed.
  46736. */
  46737. removeFloorMesh(floorMesh: Mesh): void;
  46738. /**
  46739. * Enables interactions and teleportation using the VR controllers and gaze.
  46740. * @param vrTeleportationOptions options to modify teleportation behavior.
  46741. */
  46742. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  46743. private _onNewGamepadConnected;
  46744. private _tryEnableInteractionOnController;
  46745. private _onNewGamepadDisconnected;
  46746. private _enableInteractionOnController;
  46747. private _checkTeleportWithRay;
  46748. private _checkRotate;
  46749. private _checkTeleportBackwards;
  46750. private _enableTeleportationOnController;
  46751. private _createTeleportationCircles;
  46752. private _displayTeleportationTarget;
  46753. private _hideTeleportationTarget;
  46754. private _rotateCamera;
  46755. private _moveTeleportationSelectorTo;
  46756. private _workingVector;
  46757. private _workingQuaternion;
  46758. private _workingMatrix;
  46759. /**
  46760. * Time Constant Teleportation Mode
  46761. */
  46762. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  46763. /**
  46764. * Speed Constant Teleportation Mode
  46765. */
  46766. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  46767. /**
  46768. * Teleports the users feet to the desired location
  46769. * @param location The location where the user's feet should be placed
  46770. */
  46771. teleportCamera(location: Vector3): void;
  46772. private _convertNormalToDirectionOfRay;
  46773. private _castRayAndSelectObject;
  46774. private _notifySelectedMeshUnselected;
  46775. /**
  46776. * Permanently set new colors for the laser pointer
  46777. * @param color the new laser color
  46778. * @param pickedColor the new laser color when picked mesh detected
  46779. */
  46780. setLaserColor(color: Color3, pickedColor?: Color3): void;
  46781. /**
  46782. * Set lighting enabled / disabled on the laser pointer of both controllers
  46783. * @param enabled should the lighting be enabled on the laser pointer
  46784. */
  46785. setLaserLightingState(enabled?: boolean): void;
  46786. /**
  46787. * Permanently set new colors for the gaze pointer
  46788. * @param color the new gaze color
  46789. * @param pickedColor the new gaze color when picked mesh detected
  46790. */
  46791. setGazeColor(color: Color3, pickedColor?: Color3): void;
  46792. /**
  46793. * Sets the color of the laser ray from the vr controllers.
  46794. * @param color new color for the ray.
  46795. */
  46796. changeLaserColor(color: Color3): void;
  46797. /**
  46798. * Sets the color of the ray from the vr headsets gaze.
  46799. * @param color new color for the ray.
  46800. */
  46801. changeGazeColor(color: Color3): void;
  46802. /**
  46803. * Exits VR and disposes of the vr experience helper
  46804. */
  46805. dispose(): void;
  46806. /**
  46807. * Gets the name of the VRExperienceHelper class
  46808. * @returns "VRExperienceHelper"
  46809. */
  46810. getClassName(): string;
  46811. }
  46812. }
  46813. declare module "babylonjs/Cameras/VR/index" {
  46814. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  46815. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  46816. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46817. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  46818. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  46819. export * from "babylonjs/Cameras/VR/webVRCamera";
  46820. }
  46821. declare module "babylonjs/Cameras/RigModes/index" {
  46822. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46823. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46824. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  46825. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  46826. }
  46827. declare module "babylonjs/Cameras/index" {
  46828. export * from "babylonjs/Cameras/Inputs/index";
  46829. export * from "babylonjs/Cameras/cameraInputsManager";
  46830. export * from "babylonjs/Cameras/camera";
  46831. export * from "babylonjs/Cameras/targetCamera";
  46832. export * from "babylonjs/Cameras/freeCamera";
  46833. export * from "babylonjs/Cameras/freeCameraInputsManager";
  46834. export * from "babylonjs/Cameras/touchCamera";
  46835. export * from "babylonjs/Cameras/arcRotateCamera";
  46836. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  46837. export * from "babylonjs/Cameras/deviceOrientationCamera";
  46838. export * from "babylonjs/Cameras/flyCamera";
  46839. export * from "babylonjs/Cameras/flyCameraInputsManager";
  46840. export * from "babylonjs/Cameras/followCamera";
  46841. export * from "babylonjs/Cameras/followCameraInputsManager";
  46842. export * from "babylonjs/Cameras/gamepadCamera";
  46843. export * from "babylonjs/Cameras/Stereoscopic/index";
  46844. export * from "babylonjs/Cameras/universalCamera";
  46845. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  46846. export * from "babylonjs/Cameras/VR/index";
  46847. export * from "babylonjs/Cameras/RigModes/index";
  46848. }
  46849. declare module "babylonjs/Collisions/index" {
  46850. export * from "babylonjs/Collisions/collider";
  46851. export * from "babylonjs/Collisions/collisionCoordinator";
  46852. export * from "babylonjs/Collisions/pickingInfo";
  46853. export * from "babylonjs/Collisions/intersectionInfo";
  46854. export * from "babylonjs/Collisions/meshCollisionData";
  46855. }
  46856. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  46857. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  46858. import { Vector3 } from "babylonjs/Maths/math.vector";
  46859. import { Ray } from "babylonjs/Culling/ray";
  46860. import { Plane } from "babylonjs/Maths/math.plane";
  46861. /**
  46862. * Contains an array of blocks representing the octree
  46863. */
  46864. export interface IOctreeContainer<T> {
  46865. /**
  46866. * Blocks within the octree
  46867. */
  46868. blocks: Array<OctreeBlock<T>>;
  46869. }
  46870. /**
  46871. * Class used to store a cell in an octree
  46872. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46873. */
  46874. export class OctreeBlock<T> {
  46875. /**
  46876. * Gets the content of the current block
  46877. */
  46878. entries: T[];
  46879. /**
  46880. * Gets the list of block children
  46881. */
  46882. blocks: Array<OctreeBlock<T>>;
  46883. private _depth;
  46884. private _maxDepth;
  46885. private _capacity;
  46886. private _minPoint;
  46887. private _maxPoint;
  46888. private _boundingVectors;
  46889. private _creationFunc;
  46890. /**
  46891. * Creates a new block
  46892. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  46893. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  46894. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46895. * @param depth defines the current depth of this block in the octree
  46896. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  46897. * @param creationFunc defines a callback to call when an element is added to the block
  46898. */
  46899. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  46900. /**
  46901. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46902. */
  46903. get capacity(): number;
  46904. /**
  46905. * Gets the minimum vector (in world space) of the block's bounding box
  46906. */
  46907. get minPoint(): Vector3;
  46908. /**
  46909. * Gets the maximum vector (in world space) of the block's bounding box
  46910. */
  46911. get maxPoint(): Vector3;
  46912. /**
  46913. * Add a new element to this block
  46914. * @param entry defines the element to add
  46915. */
  46916. addEntry(entry: T): void;
  46917. /**
  46918. * Remove an element from this block
  46919. * @param entry defines the element to remove
  46920. */
  46921. removeEntry(entry: T): void;
  46922. /**
  46923. * Add an array of elements to this block
  46924. * @param entries defines the array of elements to add
  46925. */
  46926. addEntries(entries: T[]): void;
  46927. /**
  46928. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  46929. * @param frustumPlanes defines the frustum planes to test
  46930. * @param selection defines the array to store current content if selection is positive
  46931. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46932. */
  46933. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46934. /**
  46935. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  46936. * @param sphereCenter defines the bounding sphere center
  46937. * @param sphereRadius defines the bounding sphere radius
  46938. * @param selection defines the array to store current content if selection is positive
  46939. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46940. */
  46941. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46942. /**
  46943. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  46944. * @param ray defines the ray to test with
  46945. * @param selection defines the array to store current content if selection is positive
  46946. */
  46947. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  46948. /**
  46949. * Subdivide the content into child blocks (this block will then be empty)
  46950. */
  46951. createInnerBlocks(): void;
  46952. /**
  46953. * @hidden
  46954. */
  46955. 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;
  46956. }
  46957. }
  46958. declare module "babylonjs/Culling/Octrees/octree" {
  46959. import { SmartArray } from "babylonjs/Misc/smartArray";
  46960. import { Vector3 } from "babylonjs/Maths/math.vector";
  46961. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46962. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46963. import { Ray } from "babylonjs/Culling/ray";
  46964. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  46965. import { Plane } from "babylonjs/Maths/math.plane";
  46966. /**
  46967. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  46968. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46969. */
  46970. export class Octree<T> {
  46971. /** 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.) */
  46972. maxDepth: number;
  46973. /**
  46974. * Blocks within the octree containing objects
  46975. */
  46976. blocks: Array<OctreeBlock<T>>;
  46977. /**
  46978. * Content stored in the octree
  46979. */
  46980. dynamicContent: T[];
  46981. private _maxBlockCapacity;
  46982. private _selectionContent;
  46983. private _creationFunc;
  46984. /**
  46985. * Creates a octree
  46986. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46987. * @param creationFunc function to be used to instatiate the octree
  46988. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  46989. * @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.)
  46990. */
  46991. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  46992. /** 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.) */
  46993. maxDepth?: number);
  46994. /**
  46995. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  46996. * @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);
  46997. * @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);
  46998. * @param entries meshes to be added to the octree blocks
  46999. */
  47000. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47001. /**
  47002. * Adds a mesh to the octree
  47003. * @param entry Mesh to add to the octree
  47004. */
  47005. addMesh(entry: T): void;
  47006. /**
  47007. * Remove an element from the octree
  47008. * @param entry defines the element to remove
  47009. */
  47010. removeMesh(entry: T): void;
  47011. /**
  47012. * Selects an array of meshes within the frustum
  47013. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47014. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47015. * @returns array of meshes within the frustum
  47016. */
  47017. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47018. /**
  47019. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47020. * @param sphereCenter defines the bounding sphere center
  47021. * @param sphereRadius defines the bounding sphere radius
  47022. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47023. * @returns an array of objects that intersect the sphere
  47024. */
  47025. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47026. /**
  47027. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47028. * @param ray defines the ray to test with
  47029. * @returns array of intersected objects
  47030. */
  47031. intersectsRay(ray: Ray): SmartArray<T>;
  47032. /**
  47033. * Adds a mesh into the octree block if it intersects the block
  47034. */
  47035. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47036. /**
  47037. * Adds a submesh into the octree block if it intersects the block
  47038. */
  47039. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47040. }
  47041. }
  47042. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47043. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47044. import { Scene } from "babylonjs/scene";
  47045. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47046. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47047. import { Ray } from "babylonjs/Culling/ray";
  47048. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47049. import { Collider } from "babylonjs/Collisions/collider";
  47050. module "babylonjs/scene" {
  47051. interface Scene {
  47052. /**
  47053. * @hidden
  47054. * Backing Filed
  47055. */
  47056. _selectionOctree: Octree<AbstractMesh>;
  47057. /**
  47058. * Gets the octree used to boost mesh selection (picking)
  47059. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47060. */
  47061. selectionOctree: Octree<AbstractMesh>;
  47062. /**
  47063. * Creates or updates the octree used to boost selection (picking)
  47064. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47065. * @param maxCapacity defines the maximum capacity per leaf
  47066. * @param maxDepth defines the maximum depth of the octree
  47067. * @returns an octree of AbstractMesh
  47068. */
  47069. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47070. }
  47071. }
  47072. module "babylonjs/Meshes/abstractMesh" {
  47073. interface AbstractMesh {
  47074. /**
  47075. * @hidden
  47076. * Backing Field
  47077. */
  47078. _submeshesOctree: Octree<SubMesh>;
  47079. /**
  47080. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47081. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47082. * @param maxCapacity defines the maximum size of each block (64 by default)
  47083. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47084. * @returns the new octree
  47085. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47086. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47087. */
  47088. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47089. }
  47090. }
  47091. /**
  47092. * Defines the octree scene component responsible to manage any octrees
  47093. * in a given scene.
  47094. */
  47095. export class OctreeSceneComponent {
  47096. /**
  47097. * The component name help to identify the component in the list of scene components.
  47098. */
  47099. readonly name: string;
  47100. /**
  47101. * The scene the component belongs to.
  47102. */
  47103. scene: Scene;
  47104. /**
  47105. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47106. */
  47107. readonly checksIsEnabled: boolean;
  47108. /**
  47109. * Creates a new instance of the component for the given scene
  47110. * @param scene Defines the scene to register the component in
  47111. */
  47112. constructor(scene: Scene);
  47113. /**
  47114. * Registers the component in a given scene
  47115. */
  47116. register(): void;
  47117. /**
  47118. * Return the list of active meshes
  47119. * @returns the list of active meshes
  47120. */
  47121. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47122. /**
  47123. * Return the list of active sub meshes
  47124. * @param mesh The mesh to get the candidates sub meshes from
  47125. * @returns the list of active sub meshes
  47126. */
  47127. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47128. private _tempRay;
  47129. /**
  47130. * Return the list of sub meshes intersecting with a given local ray
  47131. * @param mesh defines the mesh to find the submesh for
  47132. * @param localRay defines the ray in local space
  47133. * @returns the list of intersecting sub meshes
  47134. */
  47135. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47136. /**
  47137. * Return the list of sub meshes colliding with a collider
  47138. * @param mesh defines the mesh to find the submesh for
  47139. * @param collider defines the collider to evaluate the collision against
  47140. * @returns the list of colliding sub meshes
  47141. */
  47142. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47143. /**
  47144. * Rebuilds the elements related to this component in case of
  47145. * context lost for instance.
  47146. */
  47147. rebuild(): void;
  47148. /**
  47149. * Disposes the component and the associated ressources.
  47150. */
  47151. dispose(): void;
  47152. }
  47153. }
  47154. declare module "babylonjs/Culling/Octrees/index" {
  47155. export * from "babylonjs/Culling/Octrees/octree";
  47156. export * from "babylonjs/Culling/Octrees/octreeBlock";
  47157. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  47158. }
  47159. declare module "babylonjs/Culling/index" {
  47160. export * from "babylonjs/Culling/boundingBox";
  47161. export * from "babylonjs/Culling/boundingInfo";
  47162. export * from "babylonjs/Culling/boundingSphere";
  47163. export * from "babylonjs/Culling/Octrees/index";
  47164. export * from "babylonjs/Culling/ray";
  47165. }
  47166. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  47167. import { IDisposable, Scene } from "babylonjs/scene";
  47168. import { Nullable } from "babylonjs/types";
  47169. import { Observable } from "babylonjs/Misc/observable";
  47170. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47171. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  47172. import { Camera } from "babylonjs/Cameras/camera";
  47173. /**
  47174. * Renders a layer on top of an existing scene
  47175. */
  47176. export class UtilityLayerRenderer implements IDisposable {
  47177. /** the original scene that will be rendered on top of */
  47178. originalScene: Scene;
  47179. private _pointerCaptures;
  47180. private _lastPointerEvents;
  47181. private static _DefaultUtilityLayer;
  47182. private static _DefaultKeepDepthUtilityLayer;
  47183. private _sharedGizmoLight;
  47184. private _renderCamera;
  47185. /**
  47186. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  47187. * @returns the camera that is used when rendering the utility layer
  47188. */
  47189. getRenderCamera(): Camera;
  47190. /**
  47191. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  47192. * @param cam the camera that should be used when rendering the utility layer
  47193. */
  47194. setRenderCamera(cam: Nullable<Camera>): void;
  47195. /**
  47196. * @hidden
  47197. * Light which used by gizmos to get light shading
  47198. */
  47199. _getSharedGizmoLight(): HemisphericLight;
  47200. /**
  47201. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  47202. */
  47203. pickUtilitySceneFirst: boolean;
  47204. /**
  47205. * 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)
  47206. */
  47207. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  47208. /**
  47209. * 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)
  47210. */
  47211. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  47212. /**
  47213. * The scene that is rendered on top of the original scene
  47214. */
  47215. utilityLayerScene: Scene;
  47216. /**
  47217. * If the utility layer should automatically be rendered on top of existing scene
  47218. */
  47219. shouldRender: boolean;
  47220. /**
  47221. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  47222. */
  47223. onlyCheckPointerDownEvents: boolean;
  47224. /**
  47225. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  47226. */
  47227. processAllEvents: boolean;
  47228. /**
  47229. * Observable raised when the pointer move from the utility layer scene to the main scene
  47230. */
  47231. onPointerOutObservable: Observable<number>;
  47232. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  47233. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  47234. private _afterRenderObserver;
  47235. private _sceneDisposeObserver;
  47236. private _originalPointerObserver;
  47237. /**
  47238. * Instantiates a UtilityLayerRenderer
  47239. * @param originalScene the original scene that will be rendered on top of
  47240. * @param handleEvents boolean indicating if the utility layer should handle events
  47241. */
  47242. constructor(
  47243. /** the original scene that will be rendered on top of */
  47244. originalScene: Scene, handleEvents?: boolean);
  47245. private _notifyObservers;
  47246. /**
  47247. * Renders the utility layers scene on top of the original scene
  47248. */
  47249. render(): void;
  47250. /**
  47251. * Disposes of the renderer
  47252. */
  47253. dispose(): void;
  47254. private _updateCamera;
  47255. }
  47256. }
  47257. declare module "babylonjs/Gizmos/gizmo" {
  47258. import { Nullable } from "babylonjs/types";
  47259. import { IDisposable } from "babylonjs/scene";
  47260. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47261. import { Mesh } from "babylonjs/Meshes/mesh";
  47262. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47263. /**
  47264. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47265. */
  47266. export class Gizmo implements IDisposable {
  47267. /** The utility layer the gizmo will be added to */
  47268. gizmoLayer: UtilityLayerRenderer;
  47269. /**
  47270. * The root mesh of the gizmo
  47271. */
  47272. _rootMesh: Mesh;
  47273. private _attachedMesh;
  47274. /**
  47275. * Ratio for the scale of the gizmo (Default: 1)
  47276. */
  47277. scaleRatio: number;
  47278. /**
  47279. * If a custom mesh has been set (Default: false)
  47280. */
  47281. protected _customMeshSet: boolean;
  47282. /**
  47283. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47284. * * When set, interactions will be enabled
  47285. */
  47286. get attachedMesh(): Nullable<AbstractMesh>;
  47287. set attachedMesh(value: Nullable<AbstractMesh>);
  47288. /**
  47289. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47290. * @param mesh The mesh to replace the default mesh of the gizmo
  47291. */
  47292. setCustomMesh(mesh: Mesh): void;
  47293. /**
  47294. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47295. */
  47296. updateGizmoRotationToMatchAttachedMesh: boolean;
  47297. /**
  47298. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47299. */
  47300. updateGizmoPositionToMatchAttachedMesh: boolean;
  47301. /**
  47302. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47303. */
  47304. updateScale: boolean;
  47305. protected _interactionsEnabled: boolean;
  47306. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47307. private _beforeRenderObserver;
  47308. private _tempVector;
  47309. /**
  47310. * Creates a gizmo
  47311. * @param gizmoLayer The utility layer the gizmo will be added to
  47312. */
  47313. constructor(
  47314. /** The utility layer the gizmo will be added to */
  47315. gizmoLayer?: UtilityLayerRenderer);
  47316. /**
  47317. * Updates the gizmo to match the attached mesh's position/rotation
  47318. */
  47319. protected _update(): void;
  47320. /**
  47321. * Disposes of the gizmo
  47322. */
  47323. dispose(): void;
  47324. }
  47325. }
  47326. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47327. import { Observable } from "babylonjs/Misc/observable";
  47328. import { Nullable } from "babylonjs/types";
  47329. import { Vector3 } from "babylonjs/Maths/math.vector";
  47330. import { Color3 } from "babylonjs/Maths/math.color";
  47331. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47333. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47334. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47335. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47336. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47337. import { Scene } from "babylonjs/scene";
  47338. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47339. /**
  47340. * Single plane drag gizmo
  47341. */
  47342. export class PlaneDragGizmo extends Gizmo {
  47343. /**
  47344. * Drag behavior responsible for the gizmos dragging interactions
  47345. */
  47346. dragBehavior: PointerDragBehavior;
  47347. private _pointerObserver;
  47348. /**
  47349. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47350. */
  47351. snapDistance: number;
  47352. /**
  47353. * Event that fires each time the gizmo snaps to a new location.
  47354. * * snapDistance is the the change in distance
  47355. */
  47356. onSnapObservable: Observable<{
  47357. snapDistance: number;
  47358. }>;
  47359. private _plane;
  47360. private _coloredMaterial;
  47361. private _hoverMaterial;
  47362. private _isEnabled;
  47363. private _parent;
  47364. /** @hidden */
  47365. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  47366. /** @hidden */
  47367. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47368. /**
  47369. * Creates a PlaneDragGizmo
  47370. * @param gizmoLayer The utility layer the gizmo will be added to
  47371. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  47372. * @param color The color of the gizmo
  47373. */
  47374. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47375. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47376. /**
  47377. * If the gizmo is enabled
  47378. */
  47379. set isEnabled(value: boolean);
  47380. get isEnabled(): boolean;
  47381. /**
  47382. * Disposes of the gizmo
  47383. */
  47384. dispose(): void;
  47385. }
  47386. }
  47387. declare module "babylonjs/Gizmos/positionGizmo" {
  47388. import { Observable } from "babylonjs/Misc/observable";
  47389. import { Nullable } from "babylonjs/types";
  47390. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47391. import { Mesh } from "babylonjs/Meshes/mesh";
  47392. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47393. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  47394. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  47395. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47396. /**
  47397. * Gizmo that enables dragging a mesh along 3 axis
  47398. */
  47399. export class PositionGizmo extends Gizmo {
  47400. /**
  47401. * Internal gizmo used for interactions on the x axis
  47402. */
  47403. xGizmo: AxisDragGizmo;
  47404. /**
  47405. * Internal gizmo used for interactions on the y axis
  47406. */
  47407. yGizmo: AxisDragGizmo;
  47408. /**
  47409. * Internal gizmo used for interactions on the z axis
  47410. */
  47411. zGizmo: AxisDragGizmo;
  47412. /**
  47413. * Internal gizmo used for interactions on the yz plane
  47414. */
  47415. xPlaneGizmo: PlaneDragGizmo;
  47416. /**
  47417. * Internal gizmo used for interactions on the xz plane
  47418. */
  47419. yPlaneGizmo: PlaneDragGizmo;
  47420. /**
  47421. * Internal gizmo used for interactions on the xy plane
  47422. */
  47423. zPlaneGizmo: PlaneDragGizmo;
  47424. /**
  47425. * private variables
  47426. */
  47427. private _meshAttached;
  47428. private _updateGizmoRotationToMatchAttachedMesh;
  47429. private _snapDistance;
  47430. private _scaleRatio;
  47431. /** Fires an event when any of it's sub gizmos are dragged */
  47432. onDragStartObservable: Observable<unknown>;
  47433. /** Fires an event when any of it's sub gizmos are released from dragging */
  47434. onDragEndObservable: Observable<unknown>;
  47435. /**
  47436. * If set to true, planar drag is enabled
  47437. */
  47438. private _planarGizmoEnabled;
  47439. get attachedMesh(): Nullable<AbstractMesh>;
  47440. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47441. /**
  47442. * Creates a PositionGizmo
  47443. * @param gizmoLayer The utility layer the gizmo will be added to
  47444. */
  47445. constructor(gizmoLayer?: UtilityLayerRenderer);
  47446. /**
  47447. * If the planar drag gizmo is enabled
  47448. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  47449. */
  47450. set planarGizmoEnabled(value: boolean);
  47451. get planarGizmoEnabled(): boolean;
  47452. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47453. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47454. /**
  47455. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47456. */
  47457. set snapDistance(value: number);
  47458. get snapDistance(): number;
  47459. /**
  47460. * Ratio for the scale of the gizmo (Default: 1)
  47461. */
  47462. set scaleRatio(value: number);
  47463. get scaleRatio(): number;
  47464. /**
  47465. * Disposes of the gizmo
  47466. */
  47467. dispose(): void;
  47468. /**
  47469. * CustomMeshes are not supported by this gizmo
  47470. * @param mesh The mesh to replace the default mesh of the gizmo
  47471. */
  47472. setCustomMesh(mesh: Mesh): void;
  47473. }
  47474. }
  47475. declare module "babylonjs/Gizmos/axisDragGizmo" {
  47476. import { Observable } from "babylonjs/Misc/observable";
  47477. import { Nullable } from "babylonjs/types";
  47478. import { Vector3 } from "babylonjs/Maths/math.vector";
  47479. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47480. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47481. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47482. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47483. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47484. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47485. import { Scene } from "babylonjs/scene";
  47486. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47487. import { Color3 } from "babylonjs/Maths/math.color";
  47488. /**
  47489. * Single axis drag gizmo
  47490. */
  47491. export class AxisDragGizmo extends Gizmo {
  47492. /**
  47493. * Drag behavior responsible for the gizmos dragging interactions
  47494. */
  47495. dragBehavior: PointerDragBehavior;
  47496. private _pointerObserver;
  47497. /**
  47498. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47499. */
  47500. snapDistance: number;
  47501. /**
  47502. * Event that fires each time the gizmo snaps to a new location.
  47503. * * snapDistance is the the change in distance
  47504. */
  47505. onSnapObservable: Observable<{
  47506. snapDistance: number;
  47507. }>;
  47508. private _isEnabled;
  47509. private _parent;
  47510. private _arrow;
  47511. private _coloredMaterial;
  47512. private _hoverMaterial;
  47513. /** @hidden */
  47514. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  47515. /** @hidden */
  47516. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47517. /**
  47518. * Creates an AxisDragGizmo
  47519. * @param gizmoLayer The utility layer the gizmo will be added to
  47520. * @param dragAxis The axis which the gizmo will be able to drag on
  47521. * @param color The color of the gizmo
  47522. */
  47523. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47524. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47525. /**
  47526. * If the gizmo is enabled
  47527. */
  47528. set isEnabled(value: boolean);
  47529. get isEnabled(): boolean;
  47530. /**
  47531. * Disposes of the gizmo
  47532. */
  47533. dispose(): void;
  47534. }
  47535. }
  47536. declare module "babylonjs/Debug/axesViewer" {
  47537. import { Vector3 } from "babylonjs/Maths/math.vector";
  47538. import { Nullable } from "babylonjs/types";
  47539. import { Scene } from "babylonjs/scene";
  47540. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47541. /**
  47542. * The Axes viewer will show 3 axes in a specific point in space
  47543. */
  47544. export class AxesViewer {
  47545. private _xAxis;
  47546. private _yAxis;
  47547. private _zAxis;
  47548. private _scaleLinesFactor;
  47549. private _instanced;
  47550. /**
  47551. * Gets the hosting scene
  47552. */
  47553. scene: Scene;
  47554. /**
  47555. * Gets or sets a number used to scale line length
  47556. */
  47557. scaleLines: number;
  47558. /** Gets the node hierarchy used to render x-axis */
  47559. get xAxis(): TransformNode;
  47560. /** Gets the node hierarchy used to render y-axis */
  47561. get yAxis(): TransformNode;
  47562. /** Gets the node hierarchy used to render z-axis */
  47563. get zAxis(): TransformNode;
  47564. /**
  47565. * Creates a new AxesViewer
  47566. * @param scene defines the hosting scene
  47567. * @param scaleLines defines a number used to scale line length (1 by default)
  47568. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  47569. * @param xAxis defines the node hierarchy used to render the x-axis
  47570. * @param yAxis defines the node hierarchy used to render the y-axis
  47571. * @param zAxis defines the node hierarchy used to render the z-axis
  47572. */
  47573. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  47574. /**
  47575. * Force the viewer to update
  47576. * @param position defines the position of the viewer
  47577. * @param xaxis defines the x axis of the viewer
  47578. * @param yaxis defines the y axis of the viewer
  47579. * @param zaxis defines the z axis of the viewer
  47580. */
  47581. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  47582. /**
  47583. * Creates an instance of this axes viewer.
  47584. * @returns a new axes viewer with instanced meshes
  47585. */
  47586. createInstance(): AxesViewer;
  47587. /** Releases resources */
  47588. dispose(): void;
  47589. private static _SetRenderingGroupId;
  47590. }
  47591. }
  47592. declare module "babylonjs/Debug/boneAxesViewer" {
  47593. import { Nullable } from "babylonjs/types";
  47594. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  47595. import { Vector3 } from "babylonjs/Maths/math.vector";
  47596. import { Mesh } from "babylonjs/Meshes/mesh";
  47597. import { Bone } from "babylonjs/Bones/bone";
  47598. import { Scene } from "babylonjs/scene";
  47599. /**
  47600. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  47601. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  47602. */
  47603. export class BoneAxesViewer extends AxesViewer {
  47604. /**
  47605. * Gets or sets the target mesh where to display the axes viewer
  47606. */
  47607. mesh: Nullable<Mesh>;
  47608. /**
  47609. * Gets or sets the target bone where to display the axes viewer
  47610. */
  47611. bone: Nullable<Bone>;
  47612. /** Gets current position */
  47613. pos: Vector3;
  47614. /** Gets direction of X axis */
  47615. xaxis: Vector3;
  47616. /** Gets direction of Y axis */
  47617. yaxis: Vector3;
  47618. /** Gets direction of Z axis */
  47619. zaxis: Vector3;
  47620. /**
  47621. * Creates a new BoneAxesViewer
  47622. * @param scene defines the hosting scene
  47623. * @param bone defines the target bone
  47624. * @param mesh defines the target mesh
  47625. * @param scaleLines defines a scaling factor for line length (1 by default)
  47626. */
  47627. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  47628. /**
  47629. * Force the viewer to update
  47630. */
  47631. update(): void;
  47632. /** Releases resources */
  47633. dispose(): void;
  47634. }
  47635. }
  47636. declare module "babylonjs/Debug/debugLayer" {
  47637. import { Scene } from "babylonjs/scene";
  47638. /**
  47639. * Interface used to define scene explorer extensibility option
  47640. */
  47641. export interface IExplorerExtensibilityOption {
  47642. /**
  47643. * Define the option label
  47644. */
  47645. label: string;
  47646. /**
  47647. * Defines the action to execute on click
  47648. */
  47649. action: (entity: any) => void;
  47650. }
  47651. /**
  47652. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  47653. */
  47654. export interface IExplorerExtensibilityGroup {
  47655. /**
  47656. * Defines a predicate to test if a given type mut be extended
  47657. */
  47658. predicate: (entity: any) => boolean;
  47659. /**
  47660. * Gets the list of options added to a type
  47661. */
  47662. entries: IExplorerExtensibilityOption[];
  47663. }
  47664. /**
  47665. * Interface used to define the options to use to create the Inspector
  47666. */
  47667. export interface IInspectorOptions {
  47668. /**
  47669. * Display in overlay mode (default: false)
  47670. */
  47671. overlay?: boolean;
  47672. /**
  47673. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  47674. */
  47675. globalRoot?: HTMLElement;
  47676. /**
  47677. * Display the Scene explorer
  47678. */
  47679. showExplorer?: boolean;
  47680. /**
  47681. * Display the property inspector
  47682. */
  47683. showInspector?: boolean;
  47684. /**
  47685. * Display in embed mode (both panes on the right)
  47686. */
  47687. embedMode?: boolean;
  47688. /**
  47689. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  47690. */
  47691. handleResize?: boolean;
  47692. /**
  47693. * Allow the panes to popup (default: true)
  47694. */
  47695. enablePopup?: boolean;
  47696. /**
  47697. * Allow the panes to be closed by users (default: true)
  47698. */
  47699. enableClose?: boolean;
  47700. /**
  47701. * Optional list of extensibility entries
  47702. */
  47703. explorerExtensibility?: IExplorerExtensibilityGroup[];
  47704. /**
  47705. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  47706. */
  47707. inspectorURL?: string;
  47708. /**
  47709. * Optional initial tab (default to DebugLayerTab.Properties)
  47710. */
  47711. initialTab?: DebugLayerTab;
  47712. }
  47713. module "babylonjs/scene" {
  47714. interface Scene {
  47715. /**
  47716. * @hidden
  47717. * Backing field
  47718. */
  47719. _debugLayer: DebugLayer;
  47720. /**
  47721. * Gets the debug layer (aka Inspector) associated with the scene
  47722. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47723. */
  47724. debugLayer: DebugLayer;
  47725. }
  47726. }
  47727. /**
  47728. * Enum of inspector action tab
  47729. */
  47730. export enum DebugLayerTab {
  47731. /**
  47732. * Properties tag (default)
  47733. */
  47734. Properties = 0,
  47735. /**
  47736. * Debug tab
  47737. */
  47738. Debug = 1,
  47739. /**
  47740. * Statistics tab
  47741. */
  47742. Statistics = 2,
  47743. /**
  47744. * Tools tab
  47745. */
  47746. Tools = 3,
  47747. /**
  47748. * Settings tab
  47749. */
  47750. Settings = 4
  47751. }
  47752. /**
  47753. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47754. * what is happening in your scene
  47755. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47756. */
  47757. export class DebugLayer {
  47758. /**
  47759. * Define the url to get the inspector script from.
  47760. * By default it uses the babylonjs CDN.
  47761. * @ignoreNaming
  47762. */
  47763. static InspectorURL: string;
  47764. private _scene;
  47765. private BJSINSPECTOR;
  47766. private _onPropertyChangedObservable?;
  47767. /**
  47768. * Observable triggered when a property is changed through the inspector.
  47769. */
  47770. get onPropertyChangedObservable(): any;
  47771. /**
  47772. * Instantiates a new debug layer.
  47773. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47774. * what is happening in your scene
  47775. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47776. * @param scene Defines the scene to inspect
  47777. */
  47778. constructor(scene: Scene);
  47779. /** Creates the inspector window. */
  47780. private _createInspector;
  47781. /**
  47782. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  47783. * @param entity defines the entity to select
  47784. * @param lineContainerTitle defines the specific block to highlight
  47785. */
  47786. select(entity: any, lineContainerTitle?: string): void;
  47787. /** Get the inspector from bundle or global */
  47788. private _getGlobalInspector;
  47789. /**
  47790. * Get if the inspector is visible or not.
  47791. * @returns true if visible otherwise, false
  47792. */
  47793. isVisible(): boolean;
  47794. /**
  47795. * Hide the inspector and close its window.
  47796. */
  47797. hide(): void;
  47798. /**
  47799. * Launch the debugLayer.
  47800. * @param config Define the configuration of the inspector
  47801. * @return a promise fulfilled when the debug layer is visible
  47802. */
  47803. show(config?: IInspectorOptions): Promise<DebugLayer>;
  47804. }
  47805. }
  47806. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  47807. import { Nullable } from "babylonjs/types";
  47808. import { Scene } from "babylonjs/scene";
  47809. import { Vector4 } from "babylonjs/Maths/math.vector";
  47810. import { Color4 } from "babylonjs/Maths/math.color";
  47811. import { Mesh } from "babylonjs/Meshes/mesh";
  47812. /**
  47813. * Class containing static functions to help procedurally build meshes
  47814. */
  47815. export class BoxBuilder {
  47816. /**
  47817. * Creates a box mesh
  47818. * * The parameter `size` sets the size (float) of each box side (default 1)
  47819. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  47820. * * 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)
  47821. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47822. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47823. * * 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
  47824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47825. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  47826. * @param name defines the name of the mesh
  47827. * @param options defines the options used to create the mesh
  47828. * @param scene defines the hosting scene
  47829. * @returns the box mesh
  47830. */
  47831. static CreateBox(name: string, options: {
  47832. size?: number;
  47833. width?: number;
  47834. height?: number;
  47835. depth?: number;
  47836. faceUV?: Vector4[];
  47837. faceColors?: Color4[];
  47838. sideOrientation?: number;
  47839. frontUVs?: Vector4;
  47840. backUVs?: Vector4;
  47841. wrap?: boolean;
  47842. topBaseAt?: number;
  47843. bottomBaseAt?: number;
  47844. updatable?: boolean;
  47845. }, scene?: Nullable<Scene>): Mesh;
  47846. }
  47847. }
  47848. declare module "babylonjs/Debug/physicsViewer" {
  47849. import { Nullable } from "babylonjs/types";
  47850. import { Scene } from "babylonjs/scene";
  47851. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47852. import { Mesh } from "babylonjs/Meshes/mesh";
  47853. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  47854. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47855. /**
  47856. * Used to show the physics impostor around the specific mesh
  47857. */
  47858. export class PhysicsViewer {
  47859. /** @hidden */
  47860. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  47861. /** @hidden */
  47862. protected _meshes: Array<Nullable<AbstractMesh>>;
  47863. /** @hidden */
  47864. protected _scene: Nullable<Scene>;
  47865. /** @hidden */
  47866. protected _numMeshes: number;
  47867. /** @hidden */
  47868. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  47869. private _renderFunction;
  47870. private _utilityLayer;
  47871. private _debugBoxMesh;
  47872. private _debugSphereMesh;
  47873. private _debugCylinderMesh;
  47874. private _debugMaterial;
  47875. private _debugMeshMeshes;
  47876. /**
  47877. * Creates a new PhysicsViewer
  47878. * @param scene defines the hosting scene
  47879. */
  47880. constructor(scene: Scene);
  47881. /** @hidden */
  47882. protected _updateDebugMeshes(): void;
  47883. /**
  47884. * Renders a specified physic impostor
  47885. * @param impostor defines the impostor to render
  47886. * @param targetMesh defines the mesh represented by the impostor
  47887. * @returns the new debug mesh used to render the impostor
  47888. */
  47889. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  47890. /**
  47891. * Hides a specified physic impostor
  47892. * @param impostor defines the impostor to hide
  47893. */
  47894. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  47895. private _getDebugMaterial;
  47896. private _getDebugBoxMesh;
  47897. private _getDebugSphereMesh;
  47898. private _getDebugCylinderMesh;
  47899. private _getDebugMeshMesh;
  47900. private _getDebugMesh;
  47901. /** Releases all resources */
  47902. dispose(): void;
  47903. }
  47904. }
  47905. declare module "babylonjs/Debug/rayHelper" {
  47906. import { Nullable } from "babylonjs/types";
  47907. import { Ray } from "babylonjs/Culling/ray";
  47908. import { Vector3 } from "babylonjs/Maths/math.vector";
  47909. import { Color3 } from "babylonjs/Maths/math.color";
  47910. import { Scene } from "babylonjs/scene";
  47911. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47912. import "babylonjs/Meshes/Builders/linesBuilder";
  47913. /**
  47914. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  47915. * in order to better appreciate the issue one might have.
  47916. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  47917. */
  47918. export class RayHelper {
  47919. /**
  47920. * Defines the ray we are currently tryin to visualize.
  47921. */
  47922. ray: Nullable<Ray>;
  47923. private _renderPoints;
  47924. private _renderLine;
  47925. private _renderFunction;
  47926. private _scene;
  47927. private _updateToMeshFunction;
  47928. private _attachedToMesh;
  47929. private _meshSpaceDirection;
  47930. private _meshSpaceOrigin;
  47931. /**
  47932. * Helper function to create a colored helper in a scene in one line.
  47933. * @param ray Defines the ray we are currently tryin to visualize
  47934. * @param scene Defines the scene the ray is used in
  47935. * @param color Defines the color we want to see the ray in
  47936. * @returns The newly created ray helper.
  47937. */
  47938. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  47939. /**
  47940. * Instantiate a new ray helper.
  47941. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  47942. * in order to better appreciate the issue one might have.
  47943. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  47944. * @param ray Defines the ray we are currently tryin to visualize
  47945. */
  47946. constructor(ray: Ray);
  47947. /**
  47948. * Shows the ray we are willing to debug.
  47949. * @param scene Defines the scene the ray needs to be rendered in
  47950. * @param color Defines the color the ray needs to be rendered in
  47951. */
  47952. show(scene: Scene, color?: Color3): void;
  47953. /**
  47954. * Hides the ray we are debugging.
  47955. */
  47956. hide(): void;
  47957. private _render;
  47958. /**
  47959. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  47960. * @param mesh Defines the mesh we want the helper attached to
  47961. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  47962. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  47963. * @param length Defines the length of the ray
  47964. */
  47965. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  47966. /**
  47967. * Detach the ray helper from the mesh it has previously been attached to.
  47968. */
  47969. detachFromMesh(): void;
  47970. private _updateToMesh;
  47971. /**
  47972. * Dispose the helper and release its associated resources.
  47973. */
  47974. dispose(): void;
  47975. }
  47976. }
  47977. declare module "babylonjs/Debug/skeletonViewer" {
  47978. import { Color3 } from "babylonjs/Maths/math.color";
  47979. import { Scene } from "babylonjs/scene";
  47980. import { Nullable } from "babylonjs/types";
  47981. import { Skeleton } from "babylonjs/Bones/skeleton";
  47982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47983. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  47984. /**
  47985. * Class used to render a debug view of a given skeleton
  47986. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  47987. */
  47988. export class SkeletonViewer {
  47989. /** defines the skeleton to render */
  47990. skeleton: Skeleton;
  47991. /** defines the mesh attached to the skeleton */
  47992. mesh: AbstractMesh;
  47993. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  47994. autoUpdateBonesMatrices: boolean;
  47995. /** defines the rendering group id to use with the viewer */
  47996. renderingGroupId: number;
  47997. /** Gets or sets the color used to render the skeleton */
  47998. color: Color3;
  47999. private _scene;
  48000. private _debugLines;
  48001. private _debugMesh;
  48002. private _isEnabled;
  48003. private _renderFunction;
  48004. private _utilityLayer;
  48005. /**
  48006. * Returns the mesh used to render the bones
  48007. */
  48008. get debugMesh(): Nullable<LinesMesh>;
  48009. /**
  48010. * Creates a new SkeletonViewer
  48011. * @param skeleton defines the skeleton to render
  48012. * @param mesh defines the mesh attached to the skeleton
  48013. * @param scene defines the hosting scene
  48014. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48015. * @param renderingGroupId defines the rendering group id to use with the viewer
  48016. */
  48017. constructor(
  48018. /** defines the skeleton to render */
  48019. skeleton: Skeleton,
  48020. /** defines the mesh attached to the skeleton */
  48021. mesh: AbstractMesh, scene: Scene,
  48022. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48023. autoUpdateBonesMatrices?: boolean,
  48024. /** defines the rendering group id to use with the viewer */
  48025. renderingGroupId?: number);
  48026. /** Gets or sets a boolean indicating if the viewer is enabled */
  48027. set isEnabled(value: boolean);
  48028. get isEnabled(): boolean;
  48029. private _getBonePosition;
  48030. private _getLinesForBonesWithLength;
  48031. private _getLinesForBonesNoLength;
  48032. /** Update the viewer to sync with current skeleton state */
  48033. update(): void;
  48034. /** Release associated resources */
  48035. dispose(): void;
  48036. }
  48037. }
  48038. declare module "babylonjs/Debug/index" {
  48039. export * from "babylonjs/Debug/axesViewer";
  48040. export * from "babylonjs/Debug/boneAxesViewer";
  48041. export * from "babylonjs/Debug/debugLayer";
  48042. export * from "babylonjs/Debug/physicsViewer";
  48043. export * from "babylonjs/Debug/rayHelper";
  48044. export * from "babylonjs/Debug/skeletonViewer";
  48045. }
  48046. declare module "babylonjs/Engines/nullEngine" {
  48047. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48048. import { Scene } from "babylonjs/scene";
  48049. import { Engine } from "babylonjs/Engines/engine";
  48050. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48051. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48052. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48053. import { Effect } from "babylonjs/Materials/effect";
  48054. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48055. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48056. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48057. /**
  48058. * Options to create the null engine
  48059. */
  48060. export class NullEngineOptions {
  48061. /**
  48062. * Render width (Default: 512)
  48063. */
  48064. renderWidth: number;
  48065. /**
  48066. * Render height (Default: 256)
  48067. */
  48068. renderHeight: number;
  48069. /**
  48070. * Texture size (Default: 512)
  48071. */
  48072. textureSize: number;
  48073. /**
  48074. * If delta time between frames should be constant
  48075. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48076. */
  48077. deterministicLockstep: boolean;
  48078. /**
  48079. * Maximum about of steps between frames (Default: 4)
  48080. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48081. */
  48082. lockstepMaxSteps: number;
  48083. }
  48084. /**
  48085. * The null engine class provides support for headless version of babylon.js.
  48086. * This can be used in server side scenario or for testing purposes
  48087. */
  48088. export class NullEngine extends Engine {
  48089. private _options;
  48090. /**
  48091. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48092. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48093. * @returns true if engine is in deterministic lock step mode
  48094. */
  48095. isDeterministicLockStep(): boolean;
  48096. /**
  48097. * Gets the max steps when engine is running in deterministic lock step
  48098. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48099. * @returns the max steps
  48100. */
  48101. getLockstepMaxSteps(): number;
  48102. /**
  48103. * Gets the current hardware scaling level.
  48104. * By default the hardware scaling level is computed from the window device ratio.
  48105. * 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.
  48106. * @returns a number indicating the current hardware scaling level
  48107. */
  48108. getHardwareScalingLevel(): number;
  48109. constructor(options?: NullEngineOptions);
  48110. /**
  48111. * Creates a vertex buffer
  48112. * @param vertices the data for the vertex buffer
  48113. * @returns the new WebGL static buffer
  48114. */
  48115. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48116. /**
  48117. * Creates a new index buffer
  48118. * @param indices defines the content of the index buffer
  48119. * @param updatable defines if the index buffer must be updatable
  48120. * @returns a new webGL buffer
  48121. */
  48122. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48123. /**
  48124. * Clear the current render buffer or the current render target (if any is set up)
  48125. * @param color defines the color to use
  48126. * @param backBuffer defines if the back buffer must be cleared
  48127. * @param depth defines if the depth buffer must be cleared
  48128. * @param stencil defines if the stencil buffer must be cleared
  48129. */
  48130. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48131. /**
  48132. * Gets the current render width
  48133. * @param useScreen defines if screen size must be used (or the current render target if any)
  48134. * @returns a number defining the current render width
  48135. */
  48136. getRenderWidth(useScreen?: boolean): number;
  48137. /**
  48138. * Gets the current render height
  48139. * @param useScreen defines if screen size must be used (or the current render target if any)
  48140. * @returns a number defining the current render height
  48141. */
  48142. getRenderHeight(useScreen?: boolean): number;
  48143. /**
  48144. * Set the WebGL's viewport
  48145. * @param viewport defines the viewport element to be used
  48146. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48147. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48148. */
  48149. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48150. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48151. /**
  48152. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48153. * @param pipelineContext defines the pipeline context to use
  48154. * @param uniformsNames defines the list of uniform names
  48155. * @returns an array of webGL uniform locations
  48156. */
  48157. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48158. /**
  48159. * Gets the lsit of active attributes for a given webGL program
  48160. * @param pipelineContext defines the pipeline context to use
  48161. * @param attributesNames defines the list of attribute names to get
  48162. * @returns an array of indices indicating the offset of each attribute
  48163. */
  48164. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48165. /**
  48166. * Binds an effect to the webGL context
  48167. * @param effect defines the effect to bind
  48168. */
  48169. bindSamplers(effect: Effect): void;
  48170. /**
  48171. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48172. * @param effect defines the effect to activate
  48173. */
  48174. enableEffect(effect: Effect): void;
  48175. /**
  48176. * Set various states to the webGL context
  48177. * @param culling defines backface culling state
  48178. * @param zOffset defines the value to apply to zOffset (0 by default)
  48179. * @param force defines if states must be applied even if cache is up to date
  48180. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48181. */
  48182. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48183. /**
  48184. * Set the value of an uniform to an array of int32
  48185. * @param uniform defines the webGL uniform location where to store the value
  48186. * @param array defines the array of int32 to store
  48187. */
  48188. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48189. /**
  48190. * Set the value of an uniform to an array of int32 (stored as vec2)
  48191. * @param uniform defines the webGL uniform location where to store the value
  48192. * @param array defines the array of int32 to store
  48193. */
  48194. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48195. /**
  48196. * Set the value of an uniform to an array of int32 (stored as vec3)
  48197. * @param uniform defines the webGL uniform location where to store the value
  48198. * @param array defines the array of int32 to store
  48199. */
  48200. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48201. /**
  48202. * Set the value of an uniform to an array of int32 (stored as vec4)
  48203. * @param uniform defines the webGL uniform location where to store the value
  48204. * @param array defines the array of int32 to store
  48205. */
  48206. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48207. /**
  48208. * Set the value of an uniform to an array of float32
  48209. * @param uniform defines the webGL uniform location where to store the value
  48210. * @param array defines the array of float32 to store
  48211. */
  48212. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48213. /**
  48214. * Set the value of an uniform to an array of float32 (stored as vec2)
  48215. * @param uniform defines the webGL uniform location where to store the value
  48216. * @param array defines the array of float32 to store
  48217. */
  48218. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48219. /**
  48220. * Set the value of an uniform to an array of float32 (stored as vec3)
  48221. * @param uniform defines the webGL uniform location where to store the value
  48222. * @param array defines the array of float32 to store
  48223. */
  48224. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48225. /**
  48226. * Set the value of an uniform to an array of float32 (stored as vec4)
  48227. * @param uniform defines the webGL uniform location where to store the value
  48228. * @param array defines the array of float32 to store
  48229. */
  48230. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48231. /**
  48232. * Set the value of an uniform to an array of number
  48233. * @param uniform defines the webGL uniform location where to store the value
  48234. * @param array defines the array of number to store
  48235. */
  48236. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48237. /**
  48238. * Set the value of an uniform to an array of number (stored as vec2)
  48239. * @param uniform defines the webGL uniform location where to store the value
  48240. * @param array defines the array of number to store
  48241. */
  48242. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48243. /**
  48244. * Set the value of an uniform to an array of number (stored as vec3)
  48245. * @param uniform defines the webGL uniform location where to store the value
  48246. * @param array defines the array of number to store
  48247. */
  48248. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48249. /**
  48250. * Set the value of an uniform to an array of number (stored as vec4)
  48251. * @param uniform defines the webGL uniform location where to store the value
  48252. * @param array defines the array of number to store
  48253. */
  48254. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48255. /**
  48256. * Set the value of an uniform to an array of float32 (stored as matrices)
  48257. * @param uniform defines the webGL uniform location where to store the value
  48258. * @param matrices defines the array of float32 to store
  48259. */
  48260. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48261. /**
  48262. * Set the value of an uniform to a matrix (3x3)
  48263. * @param uniform defines the webGL uniform location where to store the value
  48264. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  48265. */
  48266. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48267. /**
  48268. * Set the value of an uniform to a matrix (2x2)
  48269. * @param uniform defines the webGL uniform location where to store the value
  48270. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  48271. */
  48272. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48273. /**
  48274. * Set the value of an uniform to a number (float)
  48275. * @param uniform defines the webGL uniform location where to store the value
  48276. * @param value defines the float number to store
  48277. */
  48278. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48279. /**
  48280. * Set the value of an uniform to a vec2
  48281. * @param uniform defines the webGL uniform location where to store the value
  48282. * @param x defines the 1st component of the value
  48283. * @param y defines the 2nd component of the value
  48284. */
  48285. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48286. /**
  48287. * Set the value of an uniform to a vec3
  48288. * @param uniform defines the webGL uniform location where to store the value
  48289. * @param x defines the 1st component of the value
  48290. * @param y defines the 2nd component of the value
  48291. * @param z defines the 3rd component of the value
  48292. */
  48293. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48294. /**
  48295. * Set the value of an uniform to a boolean
  48296. * @param uniform defines the webGL uniform location where to store the value
  48297. * @param bool defines the boolean to store
  48298. */
  48299. setBool(uniform: WebGLUniformLocation, bool: number): void;
  48300. /**
  48301. * Set the value of an uniform to a vec4
  48302. * @param uniform defines the webGL uniform location where to store the value
  48303. * @param x defines the 1st component of the value
  48304. * @param y defines the 2nd component of the value
  48305. * @param z defines the 3rd component of the value
  48306. * @param w defines the 4th component of the value
  48307. */
  48308. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48309. /**
  48310. * Sets the current alpha mode
  48311. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  48312. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48313. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48314. */
  48315. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48316. /**
  48317. * Bind webGl buffers directly to the webGL context
  48318. * @param vertexBuffers defines the vertex buffer to bind
  48319. * @param indexBuffer defines the index buffer to bind
  48320. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  48321. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  48322. * @param effect defines the effect associated with the vertex buffer
  48323. */
  48324. bindBuffers(vertexBuffers: {
  48325. [key: string]: VertexBuffer;
  48326. }, indexBuffer: DataBuffer, effect: Effect): void;
  48327. /**
  48328. * Force the entire cache to be cleared
  48329. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  48330. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  48331. */
  48332. wipeCaches(bruteForce?: boolean): void;
  48333. /**
  48334. * Send a draw order
  48335. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  48336. * @param indexStart defines the starting index
  48337. * @param indexCount defines the number of index to draw
  48338. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48339. */
  48340. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  48341. /**
  48342. * Draw a list of indexed primitives
  48343. * @param fillMode defines the primitive to use
  48344. * @param indexStart defines the starting index
  48345. * @param indexCount defines the number of index to draw
  48346. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48347. */
  48348. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48349. /**
  48350. * Draw a list of unindexed primitives
  48351. * @param fillMode defines the primitive to use
  48352. * @param verticesStart defines the index of first vertex to draw
  48353. * @param verticesCount defines the count of vertices to draw
  48354. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48355. */
  48356. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48357. /** @hidden */
  48358. _createTexture(): WebGLTexture;
  48359. /** @hidden */
  48360. _releaseTexture(texture: InternalTexture): void;
  48361. /**
  48362. * Usually called from Texture.ts.
  48363. * Passed information to create a WebGLTexture
  48364. * @param urlArg defines a value which contains one of the following:
  48365. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48366. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48367. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48368. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48369. * @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)
  48370. * @param scene needed for loading to the correct scene
  48371. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48372. * @param onLoad optional callback to be called upon successful completion
  48373. * @param onError optional callback to be called upon failure
  48374. * @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
  48375. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48376. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48377. * @param forcedExtension defines the extension to use to pick the right loader
  48378. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  48379. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48380. */
  48381. 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;
  48382. /**
  48383. * Creates a new render target texture
  48384. * @param size defines the size of the texture
  48385. * @param options defines the options used to create the texture
  48386. * @returns a new render target texture stored in an InternalTexture
  48387. */
  48388. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  48389. /**
  48390. * Update the sampling mode of a given texture
  48391. * @param samplingMode defines the required sampling mode
  48392. * @param texture defines the texture to update
  48393. */
  48394. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48395. /**
  48396. * Binds the frame buffer to the specified texture.
  48397. * @param texture The texture to render to or null for the default canvas
  48398. * @param faceIndex The face of the texture to render to in case of cube texture
  48399. * @param requiredWidth The width of the target to render to
  48400. * @param requiredHeight The height of the target to render to
  48401. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  48402. * @param lodLevel defines le lod level to bind to the frame buffer
  48403. */
  48404. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48405. /**
  48406. * Unbind the current render target texture from the webGL context
  48407. * @param texture defines the render target texture to unbind
  48408. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48409. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48410. */
  48411. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48412. /**
  48413. * Creates a dynamic vertex buffer
  48414. * @param vertices the data for the dynamic vertex buffer
  48415. * @returns the new WebGL dynamic buffer
  48416. */
  48417. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  48418. /**
  48419. * Update the content of a dynamic texture
  48420. * @param texture defines the texture to update
  48421. * @param canvas defines the canvas containing the source
  48422. * @param invertY defines if data must be stored with Y axis inverted
  48423. * @param premulAlpha defines if alpha is stored as premultiplied
  48424. * @param format defines the format of the data
  48425. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  48426. */
  48427. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  48428. /**
  48429. * Gets a boolean indicating if all created effects are ready
  48430. * @returns true if all effects are ready
  48431. */
  48432. areAllEffectsReady(): boolean;
  48433. /**
  48434. * @hidden
  48435. * Get the current error code of the webGL context
  48436. * @returns the error code
  48437. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  48438. */
  48439. getError(): number;
  48440. /** @hidden */
  48441. _getUnpackAlignement(): number;
  48442. /** @hidden */
  48443. _unpackFlipY(value: boolean): void;
  48444. /**
  48445. * Update a dynamic index buffer
  48446. * @param indexBuffer defines the target index buffer
  48447. * @param indices defines the data to update
  48448. * @param offset defines the offset in the target index buffer where update should start
  48449. */
  48450. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  48451. /**
  48452. * Updates a dynamic vertex buffer.
  48453. * @param vertexBuffer the vertex buffer to update
  48454. * @param vertices the data used to update the vertex buffer
  48455. * @param byteOffset the byte offset of the data (optional)
  48456. * @param byteLength the byte length of the data (optional)
  48457. */
  48458. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  48459. /** @hidden */
  48460. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  48461. /** @hidden */
  48462. _bindTexture(channel: number, texture: InternalTexture): void;
  48463. protected _deleteBuffer(buffer: WebGLBuffer): void;
  48464. /**
  48465. * 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
  48466. */
  48467. releaseEffects(): void;
  48468. displayLoadingUI(): void;
  48469. hideLoadingUI(): void;
  48470. /** @hidden */
  48471. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48472. /** @hidden */
  48473. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48474. /** @hidden */
  48475. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48476. /** @hidden */
  48477. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48478. }
  48479. }
  48480. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  48481. import { Nullable, int } from "babylonjs/types";
  48482. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  48483. /** @hidden */
  48484. export class _OcclusionDataStorage {
  48485. /** @hidden */
  48486. occlusionInternalRetryCounter: number;
  48487. /** @hidden */
  48488. isOcclusionQueryInProgress: boolean;
  48489. /** @hidden */
  48490. isOccluded: boolean;
  48491. /** @hidden */
  48492. occlusionRetryCount: number;
  48493. /** @hidden */
  48494. occlusionType: number;
  48495. /** @hidden */
  48496. occlusionQueryAlgorithmType: number;
  48497. }
  48498. module "babylonjs/Engines/engine" {
  48499. interface Engine {
  48500. /**
  48501. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  48502. * @return the new query
  48503. */
  48504. createQuery(): WebGLQuery;
  48505. /**
  48506. * Delete and release a webGL query
  48507. * @param query defines the query to delete
  48508. * @return the current engine
  48509. */
  48510. deleteQuery(query: WebGLQuery): Engine;
  48511. /**
  48512. * Check if a given query has resolved and got its value
  48513. * @param query defines the query to check
  48514. * @returns true if the query got its value
  48515. */
  48516. isQueryResultAvailable(query: WebGLQuery): boolean;
  48517. /**
  48518. * Gets the value of a given query
  48519. * @param query defines the query to check
  48520. * @returns the value of the query
  48521. */
  48522. getQueryResult(query: WebGLQuery): number;
  48523. /**
  48524. * Initiates an occlusion query
  48525. * @param algorithmType defines the algorithm to use
  48526. * @param query defines the query to use
  48527. * @returns the current engine
  48528. * @see http://doc.babylonjs.com/features/occlusionquery
  48529. */
  48530. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  48531. /**
  48532. * Ends an occlusion query
  48533. * @see http://doc.babylonjs.com/features/occlusionquery
  48534. * @param algorithmType defines the algorithm to use
  48535. * @returns the current engine
  48536. */
  48537. endOcclusionQuery(algorithmType: number): Engine;
  48538. /**
  48539. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  48540. * Please note that only one query can be issued at a time
  48541. * @returns a time token used to track the time span
  48542. */
  48543. startTimeQuery(): Nullable<_TimeToken>;
  48544. /**
  48545. * Ends a time query
  48546. * @param token defines the token used to measure the time span
  48547. * @returns the time spent (in ns)
  48548. */
  48549. endTimeQuery(token: _TimeToken): int;
  48550. /** @hidden */
  48551. _currentNonTimestampToken: Nullable<_TimeToken>;
  48552. /** @hidden */
  48553. _createTimeQuery(): WebGLQuery;
  48554. /** @hidden */
  48555. _deleteTimeQuery(query: WebGLQuery): void;
  48556. /** @hidden */
  48557. _getGlAlgorithmType(algorithmType: number): number;
  48558. /** @hidden */
  48559. _getTimeQueryResult(query: WebGLQuery): any;
  48560. /** @hidden */
  48561. _getTimeQueryAvailability(query: WebGLQuery): any;
  48562. }
  48563. }
  48564. module "babylonjs/Meshes/abstractMesh" {
  48565. interface AbstractMesh {
  48566. /**
  48567. * Backing filed
  48568. * @hidden
  48569. */
  48570. __occlusionDataStorage: _OcclusionDataStorage;
  48571. /**
  48572. * Access property
  48573. * @hidden
  48574. */
  48575. _occlusionDataStorage: _OcclusionDataStorage;
  48576. /**
  48577. * 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.
  48578. * The default value is -1 which means don't break the query and wait till the result
  48579. * @see http://doc.babylonjs.com/features/occlusionquery
  48580. */
  48581. occlusionRetryCount: number;
  48582. /**
  48583. * 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:
  48584. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48585. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48586. * * 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.
  48587. * @see http://doc.babylonjs.com/features/occlusionquery
  48588. */
  48589. occlusionType: number;
  48590. /**
  48591. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48592. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48593. * * 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.
  48594. * @see http://doc.babylonjs.com/features/occlusionquery
  48595. */
  48596. occlusionQueryAlgorithmType: number;
  48597. /**
  48598. * 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
  48599. * @see http://doc.babylonjs.com/features/occlusionquery
  48600. */
  48601. isOccluded: boolean;
  48602. /**
  48603. * Flag to check the progress status of the query
  48604. * @see http://doc.babylonjs.com/features/occlusionquery
  48605. */
  48606. isOcclusionQueryInProgress: boolean;
  48607. }
  48608. }
  48609. }
  48610. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48611. import { Nullable } from "babylonjs/types";
  48612. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48613. /** @hidden */
  48614. export var _forceTransformFeedbackToBundle: boolean;
  48615. module "babylonjs/Engines/engine" {
  48616. interface Engine {
  48617. /**
  48618. * Creates a webGL transform feedback object
  48619. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48620. * @returns the webGL transform feedback object
  48621. */
  48622. createTransformFeedback(): WebGLTransformFeedback;
  48623. /**
  48624. * Delete a webGL transform feedback object
  48625. * @param value defines the webGL transform feedback object to delete
  48626. */
  48627. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48628. /**
  48629. * Bind a webGL transform feedback object to the webgl context
  48630. * @param value defines the webGL transform feedback object to bind
  48631. */
  48632. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48633. /**
  48634. * Begins a transform feedback operation
  48635. * @param usePoints defines if points or triangles must be used
  48636. */
  48637. beginTransformFeedback(usePoints: boolean): void;
  48638. /**
  48639. * Ends a transform feedback operation
  48640. */
  48641. endTransformFeedback(): void;
  48642. /**
  48643. * Specify the varyings to use with transform feedback
  48644. * @param program defines the associated webGL program
  48645. * @param value defines the list of strings representing the varying names
  48646. */
  48647. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  48648. /**
  48649. * Bind a webGL buffer for a transform feedback operation
  48650. * @param value defines the webGL buffer to bind
  48651. */
  48652. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  48653. }
  48654. }
  48655. }
  48656. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  48657. import { Scene } from "babylonjs/scene";
  48658. import { Engine } from "babylonjs/Engines/engine";
  48659. import { Texture } from "babylonjs/Materials/Textures/texture";
  48660. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48661. import "babylonjs/Engines/Extensions/engine.multiRender";
  48662. /**
  48663. * Creation options of the multi render target texture.
  48664. */
  48665. export interface IMultiRenderTargetOptions {
  48666. /**
  48667. * Define if the texture needs to create mip maps after render.
  48668. */
  48669. generateMipMaps?: boolean;
  48670. /**
  48671. * Define the types of all the draw buffers we want to create
  48672. */
  48673. types?: number[];
  48674. /**
  48675. * Define the sampling modes of all the draw buffers we want to create
  48676. */
  48677. samplingModes?: number[];
  48678. /**
  48679. * Define if a depth buffer is required
  48680. */
  48681. generateDepthBuffer?: boolean;
  48682. /**
  48683. * Define if a stencil buffer is required
  48684. */
  48685. generateStencilBuffer?: boolean;
  48686. /**
  48687. * Define if a depth texture is required instead of a depth buffer
  48688. */
  48689. generateDepthTexture?: boolean;
  48690. /**
  48691. * Define the number of desired draw buffers
  48692. */
  48693. textureCount?: number;
  48694. /**
  48695. * Define if aspect ratio should be adapted to the texture or stay the scene one
  48696. */
  48697. doNotChangeAspectRatio?: boolean;
  48698. /**
  48699. * Define the default type of the buffers we are creating
  48700. */
  48701. defaultType?: number;
  48702. }
  48703. /**
  48704. * A multi render target, like a render target provides the ability to render to a texture.
  48705. * Unlike the render target, it can render to several draw buffers in one draw.
  48706. * This is specially interesting in deferred rendering or for any effects requiring more than
  48707. * just one color from a single pass.
  48708. */
  48709. export class MultiRenderTarget extends RenderTargetTexture {
  48710. private _internalTextures;
  48711. private _textures;
  48712. private _multiRenderTargetOptions;
  48713. /**
  48714. * Get if draw buffers are currently supported by the used hardware and browser.
  48715. */
  48716. get isSupported(): boolean;
  48717. /**
  48718. * Get the list of textures generated by the multi render target.
  48719. */
  48720. get textures(): Texture[];
  48721. /**
  48722. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  48723. */
  48724. get depthTexture(): Texture;
  48725. /**
  48726. * Set the wrapping mode on U of all the textures we are rendering to.
  48727. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48728. */
  48729. set wrapU(wrap: number);
  48730. /**
  48731. * Set the wrapping mode on V of all the textures we are rendering to.
  48732. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48733. */
  48734. set wrapV(wrap: number);
  48735. /**
  48736. * Instantiate a new multi render target texture.
  48737. * A multi render target, like a render target provides the ability to render to a texture.
  48738. * Unlike the render target, it can render to several draw buffers in one draw.
  48739. * This is specially interesting in deferred rendering or for any effects requiring more than
  48740. * just one color from a single pass.
  48741. * @param name Define the name of the texture
  48742. * @param size Define the size of the buffers to render to
  48743. * @param count Define the number of target we are rendering into
  48744. * @param scene Define the scene the texture belongs to
  48745. * @param options Define the options used to create the multi render target
  48746. */
  48747. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  48748. /** @hidden */
  48749. _rebuild(): void;
  48750. private _createInternalTextures;
  48751. private _createTextures;
  48752. /**
  48753. * Define the number of samples used if MSAA is enabled.
  48754. */
  48755. get samples(): number;
  48756. set samples(value: number);
  48757. /**
  48758. * Resize all the textures in the multi render target.
  48759. * Be carrefull as it will recreate all the data in the new texture.
  48760. * @param size Define the new size
  48761. */
  48762. resize(size: any): void;
  48763. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48764. /**
  48765. * Dispose the render targets and their associated resources
  48766. */
  48767. dispose(): void;
  48768. /**
  48769. * Release all the underlying texture used as draw buffers.
  48770. */
  48771. releaseInternalTextures(): void;
  48772. }
  48773. }
  48774. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  48775. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48776. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  48777. import { Nullable } from "babylonjs/types";
  48778. module "babylonjs/Engines/thinEngine" {
  48779. interface ThinEngine {
  48780. /**
  48781. * Unbind a list of render target textures from the webGL context
  48782. * This is used only when drawBuffer extension or webGL2 are active
  48783. * @param textures defines the render target textures to unbind
  48784. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48785. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48786. */
  48787. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  48788. /**
  48789. * Create a multi render target texture
  48790. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  48791. * @param size defines the size of the texture
  48792. * @param options defines the creation options
  48793. * @returns the cube texture as an InternalTexture
  48794. */
  48795. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  48796. /**
  48797. * Update the sample count for a given multiple render target texture
  48798. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  48799. * @param textures defines the textures to update
  48800. * @param samples defines the sample count to set
  48801. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  48802. */
  48803. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  48804. }
  48805. }
  48806. }
  48807. declare module "babylonjs/Engines/Extensions/engine.views" {
  48808. import { Camera } from "babylonjs/Cameras/camera";
  48809. import { Nullable } from "babylonjs/types";
  48810. /**
  48811. * Class used to define an additional view for the engine
  48812. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48813. */
  48814. export class EngineView {
  48815. /** Defines the canvas where to render the view */
  48816. target: HTMLCanvasElement;
  48817. /** Defines an optional camera used to render the view (will use active camera else) */
  48818. camera?: Camera;
  48819. }
  48820. module "babylonjs/Engines/engine" {
  48821. interface Engine {
  48822. /**
  48823. * Gets or sets the HTML element to use for attaching events
  48824. */
  48825. inputElement: Nullable<HTMLElement>;
  48826. /**
  48827. * Gets the current engine view
  48828. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48829. */
  48830. activeView: Nullable<EngineView>;
  48831. /** Gets or sets the list of views */
  48832. views: EngineView[];
  48833. /**
  48834. * Register a new child canvas
  48835. * @param canvas defines the canvas to register
  48836. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  48837. * @returns the associated view
  48838. */
  48839. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  48840. /**
  48841. * Remove a registered child canvas
  48842. * @param canvas defines the canvas to remove
  48843. * @returns the current engine
  48844. */
  48845. unRegisterView(canvas: HTMLCanvasElement): Engine;
  48846. }
  48847. }
  48848. }
  48849. declare module "babylonjs/Engines/Extensions/index" {
  48850. export * from "babylonjs/Engines/Extensions/engine.alpha";
  48851. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  48852. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  48853. export * from "babylonjs/Engines/Extensions/engine.multiview";
  48854. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  48855. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48856. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  48857. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  48858. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  48859. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  48860. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  48861. export * from "babylonjs/Engines/Extensions/engine.webVR";
  48862. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  48863. export * from "babylonjs/Engines/Extensions/engine.views";
  48864. }
  48865. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  48866. import { Nullable } from "babylonjs/types";
  48867. /**
  48868. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  48869. */
  48870. export interface CubeMapInfo {
  48871. /**
  48872. * The pixel array for the front face.
  48873. * This is stored in format, left to right, up to down format.
  48874. */
  48875. front: Nullable<ArrayBufferView>;
  48876. /**
  48877. * The pixel array for the back face.
  48878. * This is stored in format, left to right, up to down format.
  48879. */
  48880. back: Nullable<ArrayBufferView>;
  48881. /**
  48882. * The pixel array for the left face.
  48883. * This is stored in format, left to right, up to down format.
  48884. */
  48885. left: Nullable<ArrayBufferView>;
  48886. /**
  48887. * The pixel array for the right face.
  48888. * This is stored in format, left to right, up to down format.
  48889. */
  48890. right: Nullable<ArrayBufferView>;
  48891. /**
  48892. * The pixel array for the up face.
  48893. * This is stored in format, left to right, up to down format.
  48894. */
  48895. up: Nullable<ArrayBufferView>;
  48896. /**
  48897. * The pixel array for the down face.
  48898. * This is stored in format, left to right, up to down format.
  48899. */
  48900. down: Nullable<ArrayBufferView>;
  48901. /**
  48902. * The size of the cubemap stored.
  48903. *
  48904. * Each faces will be size * size pixels.
  48905. */
  48906. size: number;
  48907. /**
  48908. * The format of the texture.
  48909. *
  48910. * RGBA, RGB.
  48911. */
  48912. format: number;
  48913. /**
  48914. * The type of the texture data.
  48915. *
  48916. * UNSIGNED_INT, FLOAT.
  48917. */
  48918. type: number;
  48919. /**
  48920. * Specifies whether the texture is in gamma space.
  48921. */
  48922. gammaSpace: boolean;
  48923. }
  48924. /**
  48925. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  48926. */
  48927. export class PanoramaToCubeMapTools {
  48928. private static FACE_FRONT;
  48929. private static FACE_BACK;
  48930. private static FACE_RIGHT;
  48931. private static FACE_LEFT;
  48932. private static FACE_DOWN;
  48933. private static FACE_UP;
  48934. /**
  48935. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  48936. *
  48937. * @param float32Array The source data.
  48938. * @param inputWidth The width of the input panorama.
  48939. * @param inputHeight The height of the input panorama.
  48940. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  48941. * @return The cubemap data
  48942. */
  48943. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  48944. private static CreateCubemapTexture;
  48945. private static CalcProjectionSpherical;
  48946. }
  48947. }
  48948. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  48949. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48950. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48951. import { Nullable } from "babylonjs/types";
  48952. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  48953. /**
  48954. * Helper class dealing with the extraction of spherical polynomial dataArray
  48955. * from a cube map.
  48956. */
  48957. export class CubeMapToSphericalPolynomialTools {
  48958. private static FileFaces;
  48959. /**
  48960. * Converts a texture to the according Spherical Polynomial data.
  48961. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48962. *
  48963. * @param texture The texture to extract the information from.
  48964. * @return The Spherical Polynomial data.
  48965. */
  48966. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  48967. /**
  48968. * Converts a cubemap to the according Spherical Polynomial data.
  48969. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48970. *
  48971. * @param cubeInfo The Cube map to extract the information from.
  48972. * @return The Spherical Polynomial data.
  48973. */
  48974. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  48975. }
  48976. }
  48977. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  48978. import { Nullable } from "babylonjs/types";
  48979. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48980. module "babylonjs/Materials/Textures/baseTexture" {
  48981. interface BaseTexture {
  48982. /**
  48983. * Get the polynomial representation of the texture data.
  48984. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  48985. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  48986. */
  48987. sphericalPolynomial: Nullable<SphericalPolynomial>;
  48988. }
  48989. }
  48990. }
  48991. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48992. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48993. /** @hidden */
  48994. export var rgbdEncodePixelShader: {
  48995. name: string;
  48996. shader: string;
  48997. };
  48998. }
  48999. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49000. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49001. /** @hidden */
  49002. export var rgbdDecodePixelShader: {
  49003. name: string;
  49004. shader: string;
  49005. };
  49006. }
  49007. declare module "babylonjs/Misc/environmentTextureTools" {
  49008. import { Nullable } from "babylonjs/types";
  49009. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49010. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49011. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49012. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49013. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49014. import "babylonjs/Shaders/rgbdEncode.fragment";
  49015. import "babylonjs/Shaders/rgbdDecode.fragment";
  49016. /**
  49017. * Raw texture data and descriptor sufficient for WebGL texture upload
  49018. */
  49019. export interface EnvironmentTextureInfo {
  49020. /**
  49021. * Version of the environment map
  49022. */
  49023. version: number;
  49024. /**
  49025. * Width of image
  49026. */
  49027. width: number;
  49028. /**
  49029. * Irradiance information stored in the file.
  49030. */
  49031. irradiance: any;
  49032. /**
  49033. * Specular information stored in the file.
  49034. */
  49035. specular: any;
  49036. }
  49037. /**
  49038. * Defines One Image in the file. It requires only the position in the file
  49039. * as well as the length.
  49040. */
  49041. interface BufferImageData {
  49042. /**
  49043. * Length of the image data.
  49044. */
  49045. length: number;
  49046. /**
  49047. * Position of the data from the null terminator delimiting the end of the JSON.
  49048. */
  49049. position: number;
  49050. }
  49051. /**
  49052. * Defines the specular data enclosed in the file.
  49053. * This corresponds to the version 1 of the data.
  49054. */
  49055. export interface EnvironmentTextureSpecularInfoV1 {
  49056. /**
  49057. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49058. */
  49059. specularDataPosition?: number;
  49060. /**
  49061. * This contains all the images data needed to reconstruct the cubemap.
  49062. */
  49063. mipmaps: Array<BufferImageData>;
  49064. /**
  49065. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49066. */
  49067. lodGenerationScale: number;
  49068. }
  49069. /**
  49070. * Sets of helpers addressing the serialization and deserialization of environment texture
  49071. * stored in a BabylonJS env file.
  49072. * Those files are usually stored as .env files.
  49073. */
  49074. export class EnvironmentTextureTools {
  49075. /**
  49076. * Magic number identifying the env file.
  49077. */
  49078. private static _MagicBytes;
  49079. /**
  49080. * Gets the environment info from an env file.
  49081. * @param data The array buffer containing the .env bytes.
  49082. * @returns the environment file info (the json header) if successfully parsed.
  49083. */
  49084. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  49085. /**
  49086. * Creates an environment texture from a loaded cube texture.
  49087. * @param texture defines the cube texture to convert in env file
  49088. * @return a promise containing the environment data if succesfull.
  49089. */
  49090. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49091. /**
  49092. * Creates a JSON representation of the spherical data.
  49093. * @param texture defines the texture containing the polynomials
  49094. * @return the JSON representation of the spherical info
  49095. */
  49096. private static _CreateEnvTextureIrradiance;
  49097. /**
  49098. * Creates the ArrayBufferViews used for initializing environment texture image data.
  49099. * @param data the image data
  49100. * @param info parameters that determine what views will be created for accessing the underlying buffer
  49101. * @return the views described by info providing access to the underlying buffer
  49102. */
  49103. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  49104. /**
  49105. * Uploads the texture info contained in the env file to the GPU.
  49106. * @param texture defines the internal texture to upload to
  49107. * @param data defines the data to load
  49108. * @param info defines the texture info retrieved through the GetEnvInfo method
  49109. * @returns a promise
  49110. */
  49111. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  49112. private static _OnImageReadyAsync;
  49113. /**
  49114. * Uploads the levels of image data to the GPU.
  49115. * @param texture defines the internal texture to upload to
  49116. * @param imageData defines the array buffer views of image data [mipmap][face]
  49117. * @returns a promise
  49118. */
  49119. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49120. /**
  49121. * Uploads spherical polynomials information to the texture.
  49122. * @param texture defines the texture we are trying to upload the information to
  49123. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49124. */
  49125. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49126. /** @hidden */
  49127. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49128. }
  49129. }
  49130. declare module "babylonjs/Maths/math.vertexFormat" {
  49131. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49132. /**
  49133. * Contains position and normal vectors for a vertex
  49134. */
  49135. export class PositionNormalVertex {
  49136. /** the position of the vertex (defaut: 0,0,0) */
  49137. position: Vector3;
  49138. /** the normal of the vertex (defaut: 0,1,0) */
  49139. normal: Vector3;
  49140. /**
  49141. * Creates a PositionNormalVertex
  49142. * @param position the position of the vertex (defaut: 0,0,0)
  49143. * @param normal the normal of the vertex (defaut: 0,1,0)
  49144. */
  49145. constructor(
  49146. /** the position of the vertex (defaut: 0,0,0) */
  49147. position?: Vector3,
  49148. /** the normal of the vertex (defaut: 0,1,0) */
  49149. normal?: Vector3);
  49150. /**
  49151. * Clones the PositionNormalVertex
  49152. * @returns the cloned PositionNormalVertex
  49153. */
  49154. clone(): PositionNormalVertex;
  49155. }
  49156. /**
  49157. * Contains position, normal and uv vectors for a vertex
  49158. */
  49159. export class PositionNormalTextureVertex {
  49160. /** the position of the vertex (defaut: 0,0,0) */
  49161. position: Vector3;
  49162. /** the normal of the vertex (defaut: 0,1,0) */
  49163. normal: Vector3;
  49164. /** the uv of the vertex (default: 0,0) */
  49165. uv: Vector2;
  49166. /**
  49167. * Creates a PositionNormalTextureVertex
  49168. * @param position the position of the vertex (defaut: 0,0,0)
  49169. * @param normal the normal of the vertex (defaut: 0,1,0)
  49170. * @param uv the uv of the vertex (default: 0,0)
  49171. */
  49172. constructor(
  49173. /** the position of the vertex (defaut: 0,0,0) */
  49174. position?: Vector3,
  49175. /** the normal of the vertex (defaut: 0,1,0) */
  49176. normal?: Vector3,
  49177. /** the uv of the vertex (default: 0,0) */
  49178. uv?: Vector2);
  49179. /**
  49180. * Clones the PositionNormalTextureVertex
  49181. * @returns the cloned PositionNormalTextureVertex
  49182. */
  49183. clone(): PositionNormalTextureVertex;
  49184. }
  49185. }
  49186. declare module "babylonjs/Maths/math" {
  49187. export * from "babylonjs/Maths/math.axis";
  49188. export * from "babylonjs/Maths/math.color";
  49189. export * from "babylonjs/Maths/math.constants";
  49190. export * from "babylonjs/Maths/math.frustum";
  49191. export * from "babylonjs/Maths/math.path";
  49192. export * from "babylonjs/Maths/math.plane";
  49193. export * from "babylonjs/Maths/math.size";
  49194. export * from "babylonjs/Maths/math.vector";
  49195. export * from "babylonjs/Maths/math.vertexFormat";
  49196. export * from "babylonjs/Maths/math.viewport";
  49197. }
  49198. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  49199. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49200. /** @hidden */
  49201. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  49202. private _genericAttributeLocation;
  49203. private _varyingLocationCount;
  49204. private _varyingLocationMap;
  49205. private _replacements;
  49206. private _textureCount;
  49207. private _uniforms;
  49208. lineProcessor(line: string): string;
  49209. attributeProcessor(attribute: string): string;
  49210. varyingProcessor(varying: string, isFragment: boolean): string;
  49211. uniformProcessor(uniform: string): string;
  49212. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  49213. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  49214. }
  49215. }
  49216. declare module "babylonjs/Engines/nativeEngine" {
  49217. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  49218. import { Engine } from "babylonjs/Engines/engine";
  49219. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49220. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49221. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49222. import { Effect } from "babylonjs/Materials/effect";
  49223. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49224. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  49225. import { IColor4Like } from "babylonjs/Maths/math.like";
  49226. import { Scene } from "babylonjs/scene";
  49227. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49228. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49229. /**
  49230. * Container for accessors for natively-stored mesh data buffers.
  49231. */
  49232. class NativeDataBuffer extends DataBuffer {
  49233. /**
  49234. * Accessor value used to identify/retrieve a natively-stored index buffer.
  49235. */
  49236. nativeIndexBuffer?: any;
  49237. /**
  49238. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  49239. */
  49240. nativeVertexBuffer?: any;
  49241. }
  49242. /** @hidden */
  49243. class NativeTexture extends InternalTexture {
  49244. getInternalTexture(): InternalTexture;
  49245. getViewCount(): number;
  49246. }
  49247. /** @hidden */
  49248. export class NativeEngine extends Engine {
  49249. private readonly _native;
  49250. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  49251. private readonly INVALID_HANDLE;
  49252. getHardwareScalingLevel(): number;
  49253. constructor();
  49254. /**
  49255. * Can be used to override the current requestAnimationFrame requester.
  49256. * @hidden
  49257. */
  49258. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  49259. /**
  49260. * Override default engine behavior.
  49261. * @param color
  49262. * @param backBuffer
  49263. * @param depth
  49264. * @param stencil
  49265. */
  49266. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  49267. /**
  49268. * Gets host document
  49269. * @returns the host document object
  49270. */
  49271. getHostDocument(): Nullable<Document>;
  49272. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49273. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  49274. createVertexBuffer(data: DataArray): NativeDataBuffer;
  49275. recordVertexArrayObject(vertexBuffers: {
  49276. [key: string]: VertexBuffer;
  49277. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  49278. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49279. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49280. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49281. /**
  49282. * Draw a list of indexed primitives
  49283. * @param fillMode defines the primitive to use
  49284. * @param indexStart defines the starting index
  49285. * @param indexCount defines the number of index to draw
  49286. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49287. */
  49288. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49289. /**
  49290. * Draw a list of unindexed primitives
  49291. * @param fillMode defines the primitive to use
  49292. * @param verticesStart defines the index of first vertex to draw
  49293. * @param verticesCount defines the count of vertices to draw
  49294. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49295. */
  49296. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49297. createPipelineContext(): IPipelineContext;
  49298. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  49299. /** @hidden */
  49300. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  49301. /** @hidden */
  49302. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  49303. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49304. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49305. protected _setProgram(program: WebGLProgram): void;
  49306. _releaseEffect(effect: Effect): void;
  49307. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  49308. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  49309. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  49310. bindSamplers(effect: Effect): void;
  49311. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  49312. getRenderWidth(useScreen?: boolean): number;
  49313. getRenderHeight(useScreen?: boolean): number;
  49314. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  49315. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49316. /**
  49317. * Set the z offset to apply to current rendering
  49318. * @param value defines the offset to apply
  49319. */
  49320. setZOffset(value: number): void;
  49321. /**
  49322. * Gets the current value of the zOffset
  49323. * @returns the current zOffset state
  49324. */
  49325. getZOffset(): number;
  49326. /**
  49327. * Enable or disable depth buffering
  49328. * @param enable defines the state to set
  49329. */
  49330. setDepthBuffer(enable: boolean): void;
  49331. /**
  49332. * Gets a boolean indicating if depth writing is enabled
  49333. * @returns the current depth writing state
  49334. */
  49335. getDepthWrite(): boolean;
  49336. /**
  49337. * Enable or disable depth writing
  49338. * @param enable defines the state to set
  49339. */
  49340. setDepthWrite(enable: boolean): void;
  49341. /**
  49342. * Enable or disable color writing
  49343. * @param enable defines the state to set
  49344. */
  49345. setColorWrite(enable: boolean): void;
  49346. /**
  49347. * Gets a boolean indicating if color writing is enabled
  49348. * @returns the current color writing state
  49349. */
  49350. getColorWrite(): boolean;
  49351. /**
  49352. * Sets alpha constants used by some alpha blending modes
  49353. * @param r defines the red component
  49354. * @param g defines the green component
  49355. * @param b defines the blue component
  49356. * @param a defines the alpha component
  49357. */
  49358. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  49359. /**
  49360. * Sets the current alpha mode
  49361. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  49362. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49363. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49364. */
  49365. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49366. /**
  49367. * Gets the current alpha mode
  49368. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49369. * @returns the current alpha mode
  49370. */
  49371. getAlphaMode(): number;
  49372. setInt(uniform: WebGLUniformLocation, int: number): void;
  49373. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49374. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49375. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49376. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49377. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49378. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49379. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49380. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49381. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49382. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49383. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49384. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49385. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49386. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49387. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49388. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49389. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49390. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49391. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49392. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  49393. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  49394. wipeCaches(bruteForce?: boolean): void;
  49395. _createTexture(): WebGLTexture;
  49396. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  49397. /**
  49398. * Usually called from BABYLON.Texture.ts.
  49399. * Passed information to create a WebGLTexture
  49400. * @param urlArg defines a value which contains one of the following:
  49401. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49402. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49403. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49404. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49405. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  49406. * @param scene needed for loading to the correct scene
  49407. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  49408. * @param onLoad optional callback to be called upon successful completion
  49409. * @param onError optional callback to be called upon failure
  49410. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  49411. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49412. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49413. * @param forcedExtension defines the extension to use to pick the right loader
  49414. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49415. */
  49416. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  49417. /**
  49418. * Creates a cube texture
  49419. * @param rootUrl defines the url where the files to load is located
  49420. * @param scene defines the current scene
  49421. * @param files defines the list of files to load (1 per face)
  49422. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  49423. * @param onLoad defines an optional callback raised when the texture is loaded
  49424. * @param onError defines an optional callback raised if there is an issue to load the texture
  49425. * @param format defines the format of the data
  49426. * @param forcedExtension defines the extension to use to pick the right loader
  49427. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  49428. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49429. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49430. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  49431. * @returns the cube texture as an InternalTexture
  49432. */
  49433. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  49434. private _getSamplingFilter;
  49435. private static _GetNativeTextureFormat;
  49436. createRenderTargetTexture(size: number | {
  49437. width: number;
  49438. height: number;
  49439. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  49440. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49441. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49442. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49443. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  49444. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  49445. /**
  49446. * Updates a dynamic vertex buffer.
  49447. * @param vertexBuffer the vertex buffer to update
  49448. * @param data the data used to update the vertex buffer
  49449. * @param byteOffset the byte offset of the data (optional)
  49450. * @param byteLength the byte length of the data (optional)
  49451. */
  49452. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  49453. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  49454. private _updateAnisotropicLevel;
  49455. private _getAddressMode;
  49456. /** @hidden */
  49457. _bindTexture(channel: number, texture: InternalTexture): void;
  49458. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  49459. releaseEffects(): void;
  49460. /** @hidden */
  49461. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49462. /** @hidden */
  49463. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49464. /** @hidden */
  49465. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49466. /** @hidden */
  49467. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49468. }
  49469. }
  49470. declare module "babylonjs/Engines/index" {
  49471. export * from "babylonjs/Engines/constants";
  49472. export * from "babylonjs/Engines/engineCapabilities";
  49473. export * from "babylonjs/Engines/instancingAttributeInfo";
  49474. export * from "babylonjs/Engines/thinEngine";
  49475. export * from "babylonjs/Engines/engine";
  49476. export * from "babylonjs/Engines/engineStore";
  49477. export * from "babylonjs/Engines/nullEngine";
  49478. export * from "babylonjs/Engines/Extensions/index";
  49479. export * from "babylonjs/Engines/IPipelineContext";
  49480. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  49481. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49482. export * from "babylonjs/Engines/nativeEngine";
  49483. }
  49484. declare module "babylonjs/Events/clipboardEvents" {
  49485. /**
  49486. * Gather the list of clipboard event types as constants.
  49487. */
  49488. export class ClipboardEventTypes {
  49489. /**
  49490. * The clipboard event is fired when a copy command is active (pressed).
  49491. */
  49492. static readonly COPY: number;
  49493. /**
  49494. * The clipboard event is fired when a cut command is active (pressed).
  49495. */
  49496. static readonly CUT: number;
  49497. /**
  49498. * The clipboard event is fired when a paste command is active (pressed).
  49499. */
  49500. static readonly PASTE: number;
  49501. }
  49502. /**
  49503. * This class is used to store clipboard related info for the onClipboardObservable event.
  49504. */
  49505. export class ClipboardInfo {
  49506. /**
  49507. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49508. */
  49509. type: number;
  49510. /**
  49511. * Defines the related dom event
  49512. */
  49513. event: ClipboardEvent;
  49514. /**
  49515. *Creates an instance of ClipboardInfo.
  49516. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  49517. * @param event Defines the related dom event
  49518. */
  49519. constructor(
  49520. /**
  49521. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49522. */
  49523. type: number,
  49524. /**
  49525. * Defines the related dom event
  49526. */
  49527. event: ClipboardEvent);
  49528. /**
  49529. * Get the clipboard event's type from the keycode.
  49530. * @param keyCode Defines the keyCode for the current keyboard event.
  49531. * @return {number}
  49532. */
  49533. static GetTypeFromCharacter(keyCode: number): number;
  49534. }
  49535. }
  49536. declare module "babylonjs/Events/index" {
  49537. export * from "babylonjs/Events/keyboardEvents";
  49538. export * from "babylonjs/Events/pointerEvents";
  49539. export * from "babylonjs/Events/clipboardEvents";
  49540. }
  49541. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  49542. import { Scene } from "babylonjs/scene";
  49543. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49544. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49545. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49546. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49547. /**
  49548. * Google Daydream controller
  49549. */
  49550. export class DaydreamController extends WebVRController {
  49551. /**
  49552. * Base Url for the controller model.
  49553. */
  49554. static MODEL_BASE_URL: string;
  49555. /**
  49556. * File name for the controller model.
  49557. */
  49558. static MODEL_FILENAME: string;
  49559. /**
  49560. * Gamepad Id prefix used to identify Daydream Controller.
  49561. */
  49562. static readonly GAMEPAD_ID_PREFIX: string;
  49563. /**
  49564. * Creates a new DaydreamController from a gamepad
  49565. * @param vrGamepad the gamepad that the controller should be created from
  49566. */
  49567. constructor(vrGamepad: any);
  49568. /**
  49569. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49570. * @param scene scene in which to add meshes
  49571. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49572. */
  49573. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49574. /**
  49575. * Called once for each button that changed state since the last frame
  49576. * @param buttonIdx Which button index changed
  49577. * @param state New state of the button
  49578. * @param changes Which properties on the state changed since last frame
  49579. */
  49580. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49581. }
  49582. }
  49583. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49584. import { Scene } from "babylonjs/scene";
  49585. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49586. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49587. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49588. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49589. /**
  49590. * Gear VR Controller
  49591. */
  49592. export class GearVRController extends WebVRController {
  49593. /**
  49594. * Base Url for the controller model.
  49595. */
  49596. static MODEL_BASE_URL: string;
  49597. /**
  49598. * File name for the controller model.
  49599. */
  49600. static MODEL_FILENAME: string;
  49601. /**
  49602. * Gamepad Id prefix used to identify this controller.
  49603. */
  49604. static readonly GAMEPAD_ID_PREFIX: string;
  49605. private readonly _buttonIndexToObservableNameMap;
  49606. /**
  49607. * Creates a new GearVRController from a gamepad
  49608. * @param vrGamepad the gamepad that the controller should be created from
  49609. */
  49610. constructor(vrGamepad: any);
  49611. /**
  49612. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49613. * @param scene scene in which to add meshes
  49614. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49615. */
  49616. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49617. /**
  49618. * Called once for each button that changed state since the last frame
  49619. * @param buttonIdx Which button index changed
  49620. * @param state New state of the button
  49621. * @param changes Which properties on the state changed since last frame
  49622. */
  49623. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49624. }
  49625. }
  49626. declare module "babylonjs/Gamepads/Controllers/genericController" {
  49627. import { Scene } from "babylonjs/scene";
  49628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49629. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49630. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49631. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49632. /**
  49633. * Generic Controller
  49634. */
  49635. export class GenericController extends WebVRController {
  49636. /**
  49637. * Base Url for the controller model.
  49638. */
  49639. static readonly MODEL_BASE_URL: string;
  49640. /**
  49641. * File name for the controller model.
  49642. */
  49643. static readonly MODEL_FILENAME: string;
  49644. /**
  49645. * Creates a new GenericController from a gamepad
  49646. * @param vrGamepad the gamepad that the controller should be created from
  49647. */
  49648. constructor(vrGamepad: any);
  49649. /**
  49650. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49651. * @param scene scene in which to add meshes
  49652. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49653. */
  49654. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49655. /**
  49656. * Called once for each button that changed state since the last frame
  49657. * @param buttonIdx Which button index changed
  49658. * @param state New state of the button
  49659. * @param changes Which properties on the state changed since last frame
  49660. */
  49661. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49662. }
  49663. }
  49664. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  49665. import { Observable } from "babylonjs/Misc/observable";
  49666. import { Scene } from "babylonjs/scene";
  49667. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49668. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49669. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49670. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49671. /**
  49672. * Oculus Touch Controller
  49673. */
  49674. export class OculusTouchController extends WebVRController {
  49675. /**
  49676. * Base Url for the controller model.
  49677. */
  49678. static MODEL_BASE_URL: string;
  49679. /**
  49680. * File name for the left controller model.
  49681. */
  49682. static MODEL_LEFT_FILENAME: string;
  49683. /**
  49684. * File name for the right controller model.
  49685. */
  49686. static MODEL_RIGHT_FILENAME: string;
  49687. /**
  49688. * Base Url for the Quest controller model.
  49689. */
  49690. static QUEST_MODEL_BASE_URL: string;
  49691. /**
  49692. * @hidden
  49693. * If the controllers are running on a device that needs the updated Quest controller models
  49694. */
  49695. static _IsQuest: boolean;
  49696. /**
  49697. * Fired when the secondary trigger on this controller is modified
  49698. */
  49699. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  49700. /**
  49701. * Fired when the thumb rest on this controller is modified
  49702. */
  49703. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  49704. /**
  49705. * Creates a new OculusTouchController from a gamepad
  49706. * @param vrGamepad the gamepad that the controller should be created from
  49707. */
  49708. constructor(vrGamepad: any);
  49709. /**
  49710. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49711. * @param scene scene in which to add meshes
  49712. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49713. */
  49714. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49715. /**
  49716. * Fired when the A button on this controller is modified
  49717. */
  49718. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49719. /**
  49720. * Fired when the B button on this controller is modified
  49721. */
  49722. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49723. /**
  49724. * Fired when the X button on this controller is modified
  49725. */
  49726. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49727. /**
  49728. * Fired when the Y button on this controller is modified
  49729. */
  49730. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49731. /**
  49732. * Called once for each button that changed state since the last frame
  49733. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  49734. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  49735. * 2) secondary trigger (same)
  49736. * 3) A (right) X (left), touch, pressed = value
  49737. * 4) B / Y
  49738. * 5) thumb rest
  49739. * @param buttonIdx Which button index changed
  49740. * @param state New state of the button
  49741. * @param changes Which properties on the state changed since last frame
  49742. */
  49743. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49744. }
  49745. }
  49746. declare module "babylonjs/Gamepads/Controllers/viveController" {
  49747. import { Scene } from "babylonjs/scene";
  49748. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49749. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49750. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49751. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49752. import { Observable } from "babylonjs/Misc/observable";
  49753. /**
  49754. * Vive Controller
  49755. */
  49756. export class ViveController extends WebVRController {
  49757. /**
  49758. * Base Url for the controller model.
  49759. */
  49760. static MODEL_BASE_URL: string;
  49761. /**
  49762. * File name for the controller model.
  49763. */
  49764. static MODEL_FILENAME: string;
  49765. /**
  49766. * Creates a new ViveController from a gamepad
  49767. * @param vrGamepad the gamepad that the controller should be created from
  49768. */
  49769. constructor(vrGamepad: any);
  49770. /**
  49771. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49772. * @param scene scene in which to add meshes
  49773. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49774. */
  49775. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49776. /**
  49777. * Fired when the left button on this controller is modified
  49778. */
  49779. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49780. /**
  49781. * Fired when the right button on this controller is modified
  49782. */
  49783. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49784. /**
  49785. * Fired when the menu button on this controller is modified
  49786. */
  49787. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49788. /**
  49789. * Called once for each button that changed state since the last frame
  49790. * Vive mapping:
  49791. * 0: touchpad
  49792. * 1: trigger
  49793. * 2: left AND right buttons
  49794. * 3: menu button
  49795. * @param buttonIdx Which button index changed
  49796. * @param state New state of the button
  49797. * @param changes Which properties on the state changed since last frame
  49798. */
  49799. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49800. }
  49801. }
  49802. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  49803. import { Observable } from "babylonjs/Misc/observable";
  49804. import { Scene } from "babylonjs/scene";
  49805. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49806. import { Ray } from "babylonjs/Culling/ray";
  49807. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49808. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49809. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49810. /**
  49811. * Defines the WindowsMotionController object that the state of the windows motion controller
  49812. */
  49813. export class WindowsMotionController extends WebVRController {
  49814. /**
  49815. * The base url used to load the left and right controller models
  49816. */
  49817. static MODEL_BASE_URL: string;
  49818. /**
  49819. * The name of the left controller model file
  49820. */
  49821. static MODEL_LEFT_FILENAME: string;
  49822. /**
  49823. * The name of the right controller model file
  49824. */
  49825. static MODEL_RIGHT_FILENAME: string;
  49826. /**
  49827. * The controller name prefix for this controller type
  49828. */
  49829. static readonly GAMEPAD_ID_PREFIX: string;
  49830. /**
  49831. * The controller id pattern for this controller type
  49832. */
  49833. private static readonly GAMEPAD_ID_PATTERN;
  49834. private _loadedMeshInfo;
  49835. protected readonly _mapping: {
  49836. buttons: string[];
  49837. buttonMeshNames: {
  49838. 'trigger': string;
  49839. 'menu': string;
  49840. 'grip': string;
  49841. 'thumbstick': string;
  49842. 'trackpad': string;
  49843. };
  49844. buttonObservableNames: {
  49845. 'trigger': string;
  49846. 'menu': string;
  49847. 'grip': string;
  49848. 'thumbstick': string;
  49849. 'trackpad': string;
  49850. };
  49851. axisMeshNames: string[];
  49852. pointingPoseMeshName: string;
  49853. };
  49854. /**
  49855. * Fired when the trackpad on this controller is clicked
  49856. */
  49857. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  49858. /**
  49859. * Fired when the trackpad on this controller is modified
  49860. */
  49861. onTrackpadValuesChangedObservable: Observable<StickValues>;
  49862. /**
  49863. * The current x and y values of this controller's trackpad
  49864. */
  49865. trackpad: StickValues;
  49866. /**
  49867. * Creates a new WindowsMotionController from a gamepad
  49868. * @param vrGamepad the gamepad that the controller should be created from
  49869. */
  49870. constructor(vrGamepad: any);
  49871. /**
  49872. * Fired when the trigger on this controller is modified
  49873. */
  49874. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49875. /**
  49876. * Fired when the menu button on this controller is modified
  49877. */
  49878. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49879. /**
  49880. * Fired when the grip button on this controller is modified
  49881. */
  49882. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49883. /**
  49884. * Fired when the thumbstick button on this controller is modified
  49885. */
  49886. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49887. /**
  49888. * Fired when the touchpad button on this controller is modified
  49889. */
  49890. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49891. /**
  49892. * Fired when the touchpad values on this controller are modified
  49893. */
  49894. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  49895. protected _updateTrackpad(): void;
  49896. /**
  49897. * Called once per frame by the engine.
  49898. */
  49899. update(): void;
  49900. /**
  49901. * Called once for each button that changed state since the last frame
  49902. * @param buttonIdx Which button index changed
  49903. * @param state New state of the button
  49904. * @param changes Which properties on the state changed since last frame
  49905. */
  49906. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49907. /**
  49908. * Moves the buttons on the controller mesh based on their current state
  49909. * @param buttonName the name of the button to move
  49910. * @param buttonValue the value of the button which determines the buttons new position
  49911. */
  49912. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  49913. /**
  49914. * Moves the axis on the controller mesh based on its current state
  49915. * @param axis the index of the axis
  49916. * @param axisValue the value of the axis which determines the meshes new position
  49917. * @hidden
  49918. */
  49919. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  49920. /**
  49921. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49922. * @param scene scene in which to add meshes
  49923. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49924. */
  49925. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  49926. /**
  49927. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  49928. * can be transformed by button presses and axes values, based on this._mapping.
  49929. *
  49930. * @param scene scene in which the meshes exist
  49931. * @param meshes list of meshes that make up the controller model to process
  49932. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  49933. */
  49934. private processModel;
  49935. private createMeshInfo;
  49936. /**
  49937. * Gets the ray of the controller in the direction the controller is pointing
  49938. * @param length the length the resulting ray should be
  49939. * @returns a ray in the direction the controller is pointing
  49940. */
  49941. getForwardRay(length?: number): Ray;
  49942. /**
  49943. * Disposes of the controller
  49944. */
  49945. dispose(): void;
  49946. }
  49947. /**
  49948. * This class represents a new windows motion controller in XR.
  49949. */
  49950. export class XRWindowsMotionController extends WindowsMotionController {
  49951. /**
  49952. * Changing the original WIndowsMotionController mapping to fir the new mapping
  49953. */
  49954. protected readonly _mapping: {
  49955. buttons: string[];
  49956. buttonMeshNames: {
  49957. 'trigger': string;
  49958. 'menu': string;
  49959. 'grip': string;
  49960. 'thumbstick': string;
  49961. 'trackpad': string;
  49962. };
  49963. buttonObservableNames: {
  49964. 'trigger': string;
  49965. 'menu': string;
  49966. 'grip': string;
  49967. 'thumbstick': string;
  49968. 'trackpad': string;
  49969. };
  49970. axisMeshNames: string[];
  49971. pointingPoseMeshName: string;
  49972. };
  49973. /**
  49974. * Construct a new XR-Based windows motion controller
  49975. *
  49976. * @param gamepadInfo the gamepad object from the browser
  49977. */
  49978. constructor(gamepadInfo: any);
  49979. /**
  49980. * holds the thumbstick values (X,Y)
  49981. */
  49982. thumbstickValues: StickValues;
  49983. /**
  49984. * Fired when the thumbstick on this controller is clicked
  49985. */
  49986. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  49987. /**
  49988. * Fired when the thumbstick on this controller is modified
  49989. */
  49990. onThumbstickValuesChangedObservable: Observable<StickValues>;
  49991. /**
  49992. * Fired when the touchpad button on this controller is modified
  49993. */
  49994. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  49995. /**
  49996. * Fired when the touchpad values on this controller are modified
  49997. */
  49998. onTrackpadValuesChangedObservable: Observable<StickValues>;
  49999. /**
  50000. * Fired when the thumbstick button on this controller is modified
  50001. * here to prevent breaking changes
  50002. */
  50003. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50004. /**
  50005. * updating the thumbstick(!) and not the trackpad.
  50006. * This is named this way due to the difference between WebVR and XR and to avoid
  50007. * changing the parent class.
  50008. */
  50009. protected _updateTrackpad(): void;
  50010. /**
  50011. * Disposes the class with joy
  50012. */
  50013. dispose(): void;
  50014. }
  50015. }
  50016. declare module "babylonjs/Gamepads/Controllers/index" {
  50017. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50018. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50019. export * from "babylonjs/Gamepads/Controllers/genericController";
  50020. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50021. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50022. export * from "babylonjs/Gamepads/Controllers/viveController";
  50023. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50024. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50025. }
  50026. declare module "babylonjs/Gamepads/index" {
  50027. export * from "babylonjs/Gamepads/Controllers/index";
  50028. export * from "babylonjs/Gamepads/gamepad";
  50029. export * from "babylonjs/Gamepads/gamepadManager";
  50030. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50031. export * from "babylonjs/Gamepads/xboxGamepad";
  50032. export * from "babylonjs/Gamepads/dualShockGamepad";
  50033. }
  50034. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50035. import { Scene } from "babylonjs/scene";
  50036. import { Vector4 } from "babylonjs/Maths/math.vector";
  50037. import { Color4 } from "babylonjs/Maths/math.color";
  50038. import { Mesh } from "babylonjs/Meshes/mesh";
  50039. import { Nullable } from "babylonjs/types";
  50040. /**
  50041. * Class containing static functions to help procedurally build meshes
  50042. */
  50043. export class PolyhedronBuilder {
  50044. /**
  50045. * Creates a polyhedron mesh
  50046. * * 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
  50047. * * The parameter `size` (positive float, default 1) sets the polygon size
  50048. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50049. * * 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`
  50050. * * 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
  50051. * * 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)`)
  50052. * * 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
  50053. * * 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
  50054. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50055. * * 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
  50056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50057. * @param name defines the name of the mesh
  50058. * @param options defines the options used to create the mesh
  50059. * @param scene defines the hosting scene
  50060. * @returns the polyhedron mesh
  50061. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50062. */
  50063. static CreatePolyhedron(name: string, options: {
  50064. type?: number;
  50065. size?: number;
  50066. sizeX?: number;
  50067. sizeY?: number;
  50068. sizeZ?: number;
  50069. custom?: any;
  50070. faceUV?: Vector4[];
  50071. faceColors?: Color4[];
  50072. flat?: boolean;
  50073. updatable?: boolean;
  50074. sideOrientation?: number;
  50075. frontUVs?: Vector4;
  50076. backUVs?: Vector4;
  50077. }, scene?: Nullable<Scene>): Mesh;
  50078. }
  50079. }
  50080. declare module "babylonjs/Gizmos/scaleGizmo" {
  50081. import { Observable } from "babylonjs/Misc/observable";
  50082. import { Nullable } from "babylonjs/types";
  50083. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50084. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50085. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  50086. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50087. /**
  50088. * Gizmo that enables scaling a mesh along 3 axis
  50089. */
  50090. export class ScaleGizmo extends Gizmo {
  50091. /**
  50092. * Internal gizmo used for interactions on the x axis
  50093. */
  50094. xGizmo: AxisScaleGizmo;
  50095. /**
  50096. * Internal gizmo used for interactions on the y axis
  50097. */
  50098. yGizmo: AxisScaleGizmo;
  50099. /**
  50100. * Internal gizmo used for interactions on the z axis
  50101. */
  50102. zGizmo: AxisScaleGizmo;
  50103. /**
  50104. * Internal gizmo used to scale all axis equally
  50105. */
  50106. uniformScaleGizmo: AxisScaleGizmo;
  50107. private _meshAttached;
  50108. private _updateGizmoRotationToMatchAttachedMesh;
  50109. private _snapDistance;
  50110. private _scaleRatio;
  50111. private _uniformScalingMesh;
  50112. private _octahedron;
  50113. private _sensitivity;
  50114. /** Fires an event when any of it's sub gizmos are dragged */
  50115. onDragStartObservable: Observable<unknown>;
  50116. /** Fires an event when any of it's sub gizmos are released from dragging */
  50117. onDragEndObservable: Observable<unknown>;
  50118. get attachedMesh(): Nullable<AbstractMesh>;
  50119. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50120. /**
  50121. * Creates a ScaleGizmo
  50122. * @param gizmoLayer The utility layer the gizmo will be added to
  50123. */
  50124. constructor(gizmoLayer?: UtilityLayerRenderer);
  50125. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50126. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50127. /**
  50128. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50129. */
  50130. set snapDistance(value: number);
  50131. get snapDistance(): number;
  50132. /**
  50133. * Ratio for the scale of the gizmo (Default: 1)
  50134. */
  50135. set scaleRatio(value: number);
  50136. get scaleRatio(): number;
  50137. /**
  50138. * Sensitivity factor for dragging (Default: 1)
  50139. */
  50140. set sensitivity(value: number);
  50141. get sensitivity(): number;
  50142. /**
  50143. * Disposes of the gizmo
  50144. */
  50145. dispose(): void;
  50146. }
  50147. }
  50148. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50149. import { Observable } from "babylonjs/Misc/observable";
  50150. import { Nullable } from "babylonjs/types";
  50151. import { Vector3 } from "babylonjs/Maths/math.vector";
  50152. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50153. import { Mesh } from "babylonjs/Meshes/mesh";
  50154. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50155. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50156. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50157. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50158. import { Color3 } from "babylonjs/Maths/math.color";
  50159. /**
  50160. * Single axis scale gizmo
  50161. */
  50162. export class AxisScaleGizmo extends Gizmo {
  50163. /**
  50164. * Drag behavior responsible for the gizmos dragging interactions
  50165. */
  50166. dragBehavior: PointerDragBehavior;
  50167. private _pointerObserver;
  50168. /**
  50169. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50170. */
  50171. snapDistance: number;
  50172. /**
  50173. * Event that fires each time the gizmo snaps to a new location.
  50174. * * snapDistance is the the change in distance
  50175. */
  50176. onSnapObservable: Observable<{
  50177. snapDistance: number;
  50178. }>;
  50179. /**
  50180. * If the scaling operation should be done on all axis (default: false)
  50181. */
  50182. uniformScaling: boolean;
  50183. /**
  50184. * Custom sensitivity value for the drag strength
  50185. */
  50186. sensitivity: number;
  50187. private _isEnabled;
  50188. private _parent;
  50189. private _arrow;
  50190. private _coloredMaterial;
  50191. private _hoverMaterial;
  50192. /**
  50193. * Creates an AxisScaleGizmo
  50194. * @param gizmoLayer The utility layer the gizmo will be added to
  50195. * @param dragAxis The axis which the gizmo will be able to scale on
  50196. * @param color The color of the gizmo
  50197. */
  50198. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  50199. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50200. /**
  50201. * If the gizmo is enabled
  50202. */
  50203. set isEnabled(value: boolean);
  50204. get isEnabled(): boolean;
  50205. /**
  50206. * Disposes of the gizmo
  50207. */
  50208. dispose(): void;
  50209. /**
  50210. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50211. * @param mesh The mesh to replace the default mesh of the gizmo
  50212. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  50213. */
  50214. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  50215. }
  50216. }
  50217. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  50218. import { Observable } from "babylonjs/Misc/observable";
  50219. import { Nullable } from "babylonjs/types";
  50220. import { Vector3 } from "babylonjs/Maths/math.vector";
  50221. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50222. import { Mesh } from "babylonjs/Meshes/mesh";
  50223. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50224. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50225. import { Color3 } from "babylonjs/Maths/math.color";
  50226. import "babylonjs/Meshes/Builders/boxBuilder";
  50227. /**
  50228. * Bounding box gizmo
  50229. */
  50230. export class BoundingBoxGizmo extends Gizmo {
  50231. private _lineBoundingBox;
  50232. private _rotateSpheresParent;
  50233. private _scaleBoxesParent;
  50234. private _boundingDimensions;
  50235. private _renderObserver;
  50236. private _pointerObserver;
  50237. private _scaleDragSpeed;
  50238. private _tmpQuaternion;
  50239. private _tmpVector;
  50240. private _tmpRotationMatrix;
  50241. /**
  50242. * 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)
  50243. */
  50244. ignoreChildren: boolean;
  50245. /**
  50246. * 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)
  50247. */
  50248. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  50249. /**
  50250. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  50251. */
  50252. rotationSphereSize: number;
  50253. /**
  50254. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  50255. */
  50256. scaleBoxSize: number;
  50257. /**
  50258. * 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)
  50259. */
  50260. fixedDragMeshScreenSize: boolean;
  50261. /**
  50262. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  50263. */
  50264. fixedDragMeshScreenSizeDistanceFactor: number;
  50265. /**
  50266. * Fired when a rotation sphere or scale box is dragged
  50267. */
  50268. onDragStartObservable: Observable<{}>;
  50269. /**
  50270. * Fired when a scale box is dragged
  50271. */
  50272. onScaleBoxDragObservable: Observable<{}>;
  50273. /**
  50274. * Fired when a scale box drag is ended
  50275. */
  50276. onScaleBoxDragEndObservable: Observable<{}>;
  50277. /**
  50278. * Fired when a rotation sphere is dragged
  50279. */
  50280. onRotationSphereDragObservable: Observable<{}>;
  50281. /**
  50282. * Fired when a rotation sphere drag is ended
  50283. */
  50284. onRotationSphereDragEndObservable: Observable<{}>;
  50285. /**
  50286. * 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)
  50287. */
  50288. scalePivot: Nullable<Vector3>;
  50289. /**
  50290. * Mesh used as a pivot to rotate the attached mesh
  50291. */
  50292. private _anchorMesh;
  50293. private _existingMeshScale;
  50294. private _dragMesh;
  50295. private pointerDragBehavior;
  50296. private coloredMaterial;
  50297. private hoverColoredMaterial;
  50298. /**
  50299. * Sets the color of the bounding box gizmo
  50300. * @param color the color to set
  50301. */
  50302. setColor(color: Color3): void;
  50303. /**
  50304. * Creates an BoundingBoxGizmo
  50305. * @param gizmoLayer The utility layer the gizmo will be added to
  50306. * @param color The color of the gizmo
  50307. */
  50308. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  50309. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50310. private _selectNode;
  50311. /**
  50312. * Updates the bounding box information for the Gizmo
  50313. */
  50314. updateBoundingBox(): void;
  50315. private _updateRotationSpheres;
  50316. private _updateScaleBoxes;
  50317. /**
  50318. * Enables rotation on the specified axis and disables rotation on the others
  50319. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  50320. */
  50321. setEnabledRotationAxis(axis: string): void;
  50322. /**
  50323. * Enables/disables scaling
  50324. * @param enable if scaling should be enabled
  50325. */
  50326. setEnabledScaling(enable: boolean): void;
  50327. private _updateDummy;
  50328. /**
  50329. * Enables a pointer drag behavior on the bounding box of the gizmo
  50330. */
  50331. enableDragBehavior(): void;
  50332. /**
  50333. * Disposes of the gizmo
  50334. */
  50335. dispose(): void;
  50336. /**
  50337. * 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)
  50338. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  50339. * @returns the bounding box mesh with the passed in mesh as a child
  50340. */
  50341. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  50342. /**
  50343. * CustomMeshes are not supported by this gizmo
  50344. * @param mesh The mesh to replace the default mesh of the gizmo
  50345. */
  50346. setCustomMesh(mesh: Mesh): void;
  50347. }
  50348. }
  50349. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  50350. import { Observable } from "babylonjs/Misc/observable";
  50351. import { Nullable } from "babylonjs/types";
  50352. import { Vector3 } from "babylonjs/Maths/math.vector";
  50353. import { Color3 } from "babylonjs/Maths/math.color";
  50354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50355. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50356. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50357. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50358. import "babylonjs/Meshes/Builders/linesBuilder";
  50359. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50360. /**
  50361. * Single plane rotation gizmo
  50362. */
  50363. export class PlaneRotationGizmo extends Gizmo {
  50364. /**
  50365. * Drag behavior responsible for the gizmos dragging interactions
  50366. */
  50367. dragBehavior: PointerDragBehavior;
  50368. private _pointerObserver;
  50369. /**
  50370. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  50371. */
  50372. snapDistance: number;
  50373. /**
  50374. * Event that fires each time the gizmo snaps to a new location.
  50375. * * snapDistance is the the change in distance
  50376. */
  50377. onSnapObservable: Observable<{
  50378. snapDistance: number;
  50379. }>;
  50380. private _isEnabled;
  50381. private _parent;
  50382. /**
  50383. * Creates a PlaneRotationGizmo
  50384. * @param gizmoLayer The utility layer the gizmo will be added to
  50385. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  50386. * @param color The color of the gizmo
  50387. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50388. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50389. */
  50390. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  50391. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50392. /**
  50393. * If the gizmo is enabled
  50394. */
  50395. set isEnabled(value: boolean);
  50396. get isEnabled(): boolean;
  50397. /**
  50398. * Disposes of the gizmo
  50399. */
  50400. dispose(): void;
  50401. }
  50402. }
  50403. declare module "babylonjs/Gizmos/rotationGizmo" {
  50404. import { Observable } from "babylonjs/Misc/observable";
  50405. import { Nullable } from "babylonjs/types";
  50406. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50407. import { Mesh } from "babylonjs/Meshes/mesh";
  50408. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50409. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  50410. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50411. /**
  50412. * Gizmo that enables rotating a mesh along 3 axis
  50413. */
  50414. export class RotationGizmo extends Gizmo {
  50415. /**
  50416. * Internal gizmo used for interactions on the x axis
  50417. */
  50418. xGizmo: PlaneRotationGizmo;
  50419. /**
  50420. * Internal gizmo used for interactions on the y axis
  50421. */
  50422. yGizmo: PlaneRotationGizmo;
  50423. /**
  50424. * Internal gizmo used for interactions on the z axis
  50425. */
  50426. zGizmo: PlaneRotationGizmo;
  50427. /** Fires an event when any of it's sub gizmos are dragged */
  50428. onDragStartObservable: Observable<unknown>;
  50429. /** Fires an event when any of it's sub gizmos are released from dragging */
  50430. onDragEndObservable: Observable<unknown>;
  50431. private _meshAttached;
  50432. get attachedMesh(): Nullable<AbstractMesh>;
  50433. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50434. /**
  50435. * Creates a RotationGizmo
  50436. * @param gizmoLayer The utility layer the gizmo will be added to
  50437. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50438. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50439. */
  50440. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  50441. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50442. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50443. /**
  50444. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50445. */
  50446. set snapDistance(value: number);
  50447. get snapDistance(): number;
  50448. /**
  50449. * Ratio for the scale of the gizmo (Default: 1)
  50450. */
  50451. set scaleRatio(value: number);
  50452. get scaleRatio(): number;
  50453. /**
  50454. * Disposes of the gizmo
  50455. */
  50456. dispose(): void;
  50457. /**
  50458. * CustomMeshes are not supported by this gizmo
  50459. * @param mesh The mesh to replace the default mesh of the gizmo
  50460. */
  50461. setCustomMesh(mesh: Mesh): void;
  50462. }
  50463. }
  50464. declare module "babylonjs/Gizmos/gizmoManager" {
  50465. import { Observable } from "babylonjs/Misc/observable";
  50466. import { Nullable } from "babylonjs/types";
  50467. import { Scene, IDisposable } from "babylonjs/scene";
  50468. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50469. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50470. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  50471. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50472. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50473. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50474. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  50475. /**
  50476. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  50477. */
  50478. export class GizmoManager implements IDisposable {
  50479. private scene;
  50480. /**
  50481. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  50482. */
  50483. gizmos: {
  50484. positionGizmo: Nullable<PositionGizmo>;
  50485. rotationGizmo: Nullable<RotationGizmo>;
  50486. scaleGizmo: Nullable<ScaleGizmo>;
  50487. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  50488. };
  50489. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  50490. clearGizmoOnEmptyPointerEvent: boolean;
  50491. /** Fires an event when the manager is attached to a mesh */
  50492. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  50493. private _gizmosEnabled;
  50494. private _pointerObserver;
  50495. private _attachedMesh;
  50496. private _boundingBoxColor;
  50497. private _defaultUtilityLayer;
  50498. private _defaultKeepDepthUtilityLayer;
  50499. /**
  50500. * When bounding box gizmo is enabled, this can be used to track drag/end events
  50501. */
  50502. boundingBoxDragBehavior: SixDofDragBehavior;
  50503. /**
  50504. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  50505. */
  50506. attachableMeshes: Nullable<Array<AbstractMesh>>;
  50507. /**
  50508. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  50509. */
  50510. usePointerToAttachGizmos: boolean;
  50511. /**
  50512. * Utility layer that the bounding box gizmo belongs to
  50513. */
  50514. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  50515. /**
  50516. * Utility layer that all gizmos besides bounding box belong to
  50517. */
  50518. get utilityLayer(): UtilityLayerRenderer;
  50519. /**
  50520. * Instatiates a gizmo manager
  50521. * @param scene the scene to overlay the gizmos on top of
  50522. */
  50523. constructor(scene: Scene);
  50524. /**
  50525. * Attaches a set of gizmos to the specified mesh
  50526. * @param mesh The mesh the gizmo's should be attached to
  50527. */
  50528. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50529. /**
  50530. * If the position gizmo is enabled
  50531. */
  50532. set positionGizmoEnabled(value: boolean);
  50533. get positionGizmoEnabled(): boolean;
  50534. /**
  50535. * If the rotation gizmo is enabled
  50536. */
  50537. set rotationGizmoEnabled(value: boolean);
  50538. get rotationGizmoEnabled(): boolean;
  50539. /**
  50540. * If the scale gizmo is enabled
  50541. */
  50542. set scaleGizmoEnabled(value: boolean);
  50543. get scaleGizmoEnabled(): boolean;
  50544. /**
  50545. * If the boundingBox gizmo is enabled
  50546. */
  50547. set boundingBoxGizmoEnabled(value: boolean);
  50548. get boundingBoxGizmoEnabled(): boolean;
  50549. /**
  50550. * Disposes of the gizmo manager
  50551. */
  50552. dispose(): void;
  50553. }
  50554. }
  50555. declare module "babylonjs/Lights/directionalLight" {
  50556. import { Camera } from "babylonjs/Cameras/camera";
  50557. import { Scene } from "babylonjs/scene";
  50558. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50560. import { Light } from "babylonjs/Lights/light";
  50561. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50562. import { Effect } from "babylonjs/Materials/effect";
  50563. /**
  50564. * A directional light is defined by a direction (what a surprise!).
  50565. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  50566. * 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.
  50567. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50568. */
  50569. export class DirectionalLight extends ShadowLight {
  50570. private _shadowFrustumSize;
  50571. /**
  50572. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  50573. */
  50574. get shadowFrustumSize(): number;
  50575. /**
  50576. * Specifies a fix frustum size for the shadow generation.
  50577. */
  50578. set shadowFrustumSize(value: number);
  50579. private _shadowOrthoScale;
  50580. /**
  50581. * Gets the shadow projection scale against the optimal computed one.
  50582. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50583. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50584. */
  50585. get shadowOrthoScale(): number;
  50586. /**
  50587. * Sets the shadow projection scale against the optimal computed one.
  50588. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50589. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50590. */
  50591. set shadowOrthoScale(value: number);
  50592. /**
  50593. * Automatically compute the projection matrix to best fit (including all the casters)
  50594. * on each frame.
  50595. */
  50596. autoUpdateExtends: boolean;
  50597. /**
  50598. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  50599. * on each frame. autoUpdateExtends must be set to true for this to work
  50600. */
  50601. autoCalcShadowZBounds: boolean;
  50602. private _orthoLeft;
  50603. private _orthoRight;
  50604. private _orthoTop;
  50605. private _orthoBottom;
  50606. /**
  50607. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  50608. * The directional light is emitted from everywhere in the given direction.
  50609. * It can cast shadows.
  50610. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50611. * @param name The friendly name of the light
  50612. * @param direction The direction of the light
  50613. * @param scene The scene the light belongs to
  50614. */
  50615. constructor(name: string, direction: Vector3, scene: Scene);
  50616. /**
  50617. * Returns the string "DirectionalLight".
  50618. * @return The class name
  50619. */
  50620. getClassName(): string;
  50621. /**
  50622. * Returns the integer 1.
  50623. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50624. */
  50625. getTypeID(): number;
  50626. /**
  50627. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  50628. * Returns the DirectionalLight Shadow projection matrix.
  50629. */
  50630. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50631. /**
  50632. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  50633. * Returns the DirectionalLight Shadow projection matrix.
  50634. */
  50635. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  50636. /**
  50637. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  50638. * Returns the DirectionalLight Shadow projection matrix.
  50639. */
  50640. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50641. protected _buildUniformLayout(): void;
  50642. /**
  50643. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  50644. * @param effect The effect to update
  50645. * @param lightIndex The index of the light in the effect to update
  50646. * @returns The directional light
  50647. */
  50648. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  50649. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  50650. /**
  50651. * Gets the minZ used for shadow according to both the scene and the light.
  50652. *
  50653. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50654. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50655. * @param activeCamera The camera we are returning the min for
  50656. * @returns the depth min z
  50657. */
  50658. getDepthMinZ(activeCamera: Camera): number;
  50659. /**
  50660. * Gets the maxZ used for shadow according to both the scene and the light.
  50661. *
  50662. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50663. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50664. * @param activeCamera The camera we are returning the max for
  50665. * @returns the depth max z
  50666. */
  50667. getDepthMaxZ(activeCamera: Camera): number;
  50668. /**
  50669. * Prepares the list of defines specific to the light type.
  50670. * @param defines the list of defines
  50671. * @param lightIndex defines the index of the light for the effect
  50672. */
  50673. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50674. }
  50675. }
  50676. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  50677. import { Mesh } from "babylonjs/Meshes/mesh";
  50678. /**
  50679. * Class containing static functions to help procedurally build meshes
  50680. */
  50681. export class HemisphereBuilder {
  50682. /**
  50683. * Creates a hemisphere mesh
  50684. * @param name defines the name of the mesh
  50685. * @param options defines the options used to create the mesh
  50686. * @param scene defines the hosting scene
  50687. * @returns the hemisphere mesh
  50688. */
  50689. static CreateHemisphere(name: string, options: {
  50690. segments?: number;
  50691. diameter?: number;
  50692. sideOrientation?: number;
  50693. }, scene: any): Mesh;
  50694. }
  50695. }
  50696. declare module "babylonjs/Lights/spotLight" {
  50697. import { Nullable } from "babylonjs/types";
  50698. import { Scene } from "babylonjs/scene";
  50699. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50701. import { Effect } from "babylonjs/Materials/effect";
  50702. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50703. import { Light } from "babylonjs/Lights/light";
  50704. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50705. /**
  50706. * A spot light is defined by a position, a direction, an angle, and an exponent.
  50707. * These values define a cone of light starting from the position, emitting toward the direction.
  50708. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  50709. * and the exponent defines the speed of the decay of the light with distance (reach).
  50710. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50711. */
  50712. export class SpotLight extends ShadowLight {
  50713. private _angle;
  50714. private _innerAngle;
  50715. private _cosHalfAngle;
  50716. private _lightAngleScale;
  50717. private _lightAngleOffset;
  50718. /**
  50719. * Gets the cone angle of the spot light in Radians.
  50720. */
  50721. get angle(): number;
  50722. /**
  50723. * Sets the cone angle of the spot light in Radians.
  50724. */
  50725. set angle(value: number);
  50726. /**
  50727. * Only used in gltf falloff mode, this defines the angle where
  50728. * the directional falloff will start before cutting at angle which could be seen
  50729. * as outer angle.
  50730. */
  50731. get innerAngle(): number;
  50732. /**
  50733. * Only used in gltf falloff mode, this defines the angle where
  50734. * the directional falloff will start before cutting at angle which could be seen
  50735. * as outer angle.
  50736. */
  50737. set innerAngle(value: number);
  50738. private _shadowAngleScale;
  50739. /**
  50740. * Allows scaling the angle of the light for shadow generation only.
  50741. */
  50742. get shadowAngleScale(): number;
  50743. /**
  50744. * Allows scaling the angle of the light for shadow generation only.
  50745. */
  50746. set shadowAngleScale(value: number);
  50747. /**
  50748. * The light decay speed with the distance from the emission spot.
  50749. */
  50750. exponent: number;
  50751. private _projectionTextureMatrix;
  50752. /**
  50753. * Allows reading the projecton texture
  50754. */
  50755. get projectionTextureMatrix(): Matrix;
  50756. protected _projectionTextureLightNear: number;
  50757. /**
  50758. * Gets the near clip of the Spotlight for texture projection.
  50759. */
  50760. get projectionTextureLightNear(): number;
  50761. /**
  50762. * Sets the near clip of the Spotlight for texture projection.
  50763. */
  50764. set projectionTextureLightNear(value: number);
  50765. protected _projectionTextureLightFar: number;
  50766. /**
  50767. * Gets the far clip of the Spotlight for texture projection.
  50768. */
  50769. get projectionTextureLightFar(): number;
  50770. /**
  50771. * Sets the far clip of the Spotlight for texture projection.
  50772. */
  50773. set projectionTextureLightFar(value: number);
  50774. protected _projectionTextureUpDirection: Vector3;
  50775. /**
  50776. * Gets the Up vector of the Spotlight for texture projection.
  50777. */
  50778. get projectionTextureUpDirection(): Vector3;
  50779. /**
  50780. * Sets the Up vector of the Spotlight for texture projection.
  50781. */
  50782. set projectionTextureUpDirection(value: Vector3);
  50783. private _projectionTexture;
  50784. /**
  50785. * Gets the projection texture of the light.
  50786. */
  50787. get projectionTexture(): Nullable<BaseTexture>;
  50788. /**
  50789. * Sets the projection texture of the light.
  50790. */
  50791. set projectionTexture(value: Nullable<BaseTexture>);
  50792. private _projectionTextureViewLightDirty;
  50793. private _projectionTextureProjectionLightDirty;
  50794. private _projectionTextureDirty;
  50795. private _projectionTextureViewTargetVector;
  50796. private _projectionTextureViewLightMatrix;
  50797. private _projectionTextureProjectionLightMatrix;
  50798. private _projectionTextureScalingMatrix;
  50799. /**
  50800. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  50801. * It can cast shadows.
  50802. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50803. * @param name The light friendly name
  50804. * @param position The position of the spot light in the scene
  50805. * @param direction The direction of the light in the scene
  50806. * @param angle The cone angle of the light in Radians
  50807. * @param exponent The light decay speed with the distance from the emission spot
  50808. * @param scene The scene the lights belongs to
  50809. */
  50810. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  50811. /**
  50812. * Returns the string "SpotLight".
  50813. * @returns the class name
  50814. */
  50815. getClassName(): string;
  50816. /**
  50817. * Returns the integer 2.
  50818. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50819. */
  50820. getTypeID(): number;
  50821. /**
  50822. * Overrides the direction setter to recompute the projection texture view light Matrix.
  50823. */
  50824. protected _setDirection(value: Vector3): void;
  50825. /**
  50826. * Overrides the position setter to recompute the projection texture view light Matrix.
  50827. */
  50828. protected _setPosition(value: Vector3): void;
  50829. /**
  50830. * 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.
  50831. * Returns the SpotLight.
  50832. */
  50833. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50834. protected _computeProjectionTextureViewLightMatrix(): void;
  50835. protected _computeProjectionTextureProjectionLightMatrix(): void;
  50836. /**
  50837. * Main function for light texture projection matrix computing.
  50838. */
  50839. protected _computeProjectionTextureMatrix(): void;
  50840. protected _buildUniformLayout(): void;
  50841. private _computeAngleValues;
  50842. /**
  50843. * Sets the passed Effect "effect" with the Light textures.
  50844. * @param effect The effect to update
  50845. * @param lightIndex The index of the light in the effect to update
  50846. * @returns The light
  50847. */
  50848. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  50849. /**
  50850. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  50851. * @param effect The effect to update
  50852. * @param lightIndex The index of the light in the effect to update
  50853. * @returns The spot light
  50854. */
  50855. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  50856. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50857. /**
  50858. * Disposes the light and the associated resources.
  50859. */
  50860. dispose(): void;
  50861. /**
  50862. * Prepares the list of defines specific to the light type.
  50863. * @param defines the list of defines
  50864. * @param lightIndex defines the index of the light for the effect
  50865. */
  50866. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50867. }
  50868. }
  50869. declare module "babylonjs/Gizmos/lightGizmo" {
  50870. import { Nullable } from "babylonjs/types";
  50871. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50872. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50873. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  50874. import { Light } from "babylonjs/Lights/light";
  50875. /**
  50876. * Gizmo that enables viewing a light
  50877. */
  50878. export class LightGizmo extends Gizmo {
  50879. private _lightMesh;
  50880. private _material;
  50881. private _cachedPosition;
  50882. private _cachedForward;
  50883. private _attachedMeshParent;
  50884. /**
  50885. * Creates a LightGizmo
  50886. * @param gizmoLayer The utility layer the gizmo will be added to
  50887. */
  50888. constructor(gizmoLayer?: UtilityLayerRenderer);
  50889. private _light;
  50890. /**
  50891. * The light that the gizmo is attached to
  50892. */
  50893. set light(light: Nullable<Light>);
  50894. get light(): Nullable<Light>;
  50895. /**
  50896. * Gets the material used to render the light gizmo
  50897. */
  50898. get material(): StandardMaterial;
  50899. /**
  50900. * @hidden
  50901. * Updates the gizmo to match the attached mesh's position/rotation
  50902. */
  50903. protected _update(): void;
  50904. private static _Scale;
  50905. /**
  50906. * Creates the lines for a light mesh
  50907. */
  50908. private static _CreateLightLines;
  50909. /**
  50910. * Disposes of the light gizmo
  50911. */
  50912. dispose(): void;
  50913. private static _CreateHemisphericLightMesh;
  50914. private static _CreatePointLightMesh;
  50915. private static _CreateSpotLightMesh;
  50916. private static _CreateDirectionalLightMesh;
  50917. }
  50918. }
  50919. declare module "babylonjs/Gizmos/index" {
  50920. export * from "babylonjs/Gizmos/axisDragGizmo";
  50921. export * from "babylonjs/Gizmos/axisScaleGizmo";
  50922. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  50923. export * from "babylonjs/Gizmos/gizmo";
  50924. export * from "babylonjs/Gizmos/gizmoManager";
  50925. export * from "babylonjs/Gizmos/planeRotationGizmo";
  50926. export * from "babylonjs/Gizmos/positionGizmo";
  50927. export * from "babylonjs/Gizmos/rotationGizmo";
  50928. export * from "babylonjs/Gizmos/scaleGizmo";
  50929. export * from "babylonjs/Gizmos/lightGizmo";
  50930. export * from "babylonjs/Gizmos/planeDragGizmo";
  50931. }
  50932. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  50933. /** @hidden */
  50934. export var backgroundFragmentDeclaration: {
  50935. name: string;
  50936. shader: string;
  50937. };
  50938. }
  50939. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  50940. /** @hidden */
  50941. export var backgroundUboDeclaration: {
  50942. name: string;
  50943. shader: string;
  50944. };
  50945. }
  50946. declare module "babylonjs/Shaders/background.fragment" {
  50947. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  50948. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  50949. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  50950. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50951. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50952. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50953. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50954. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  50955. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  50956. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50957. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  50958. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  50959. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50960. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  50961. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  50962. /** @hidden */
  50963. export var backgroundPixelShader: {
  50964. name: string;
  50965. shader: string;
  50966. };
  50967. }
  50968. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  50969. /** @hidden */
  50970. export var backgroundVertexDeclaration: {
  50971. name: string;
  50972. shader: string;
  50973. };
  50974. }
  50975. declare module "babylonjs/Shaders/background.vertex" {
  50976. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  50977. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  50978. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50979. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50980. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50981. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  50982. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  50983. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50984. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50985. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50986. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50987. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50988. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  50989. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  50990. /** @hidden */
  50991. export var backgroundVertexShader: {
  50992. name: string;
  50993. shader: string;
  50994. };
  50995. }
  50996. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  50997. import { Nullable, int, float } from "babylonjs/types";
  50998. import { Scene } from "babylonjs/scene";
  50999. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51000. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51001. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51002. import { Mesh } from "babylonjs/Meshes/mesh";
  51003. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51004. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51005. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51006. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51007. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51008. import { Color3 } from "babylonjs/Maths/math.color";
  51009. import "babylonjs/Shaders/background.fragment";
  51010. import "babylonjs/Shaders/background.vertex";
  51011. /**
  51012. * Background material used to create an efficient environement around your scene.
  51013. */
  51014. export class BackgroundMaterial extends PushMaterial {
  51015. /**
  51016. * Standard reflectance value at parallel view angle.
  51017. */
  51018. static StandardReflectance0: number;
  51019. /**
  51020. * Standard reflectance value at grazing angle.
  51021. */
  51022. static StandardReflectance90: number;
  51023. protected _primaryColor: Color3;
  51024. /**
  51025. * Key light Color (multiply against the environement texture)
  51026. */
  51027. primaryColor: Color3;
  51028. protected __perceptualColor: Nullable<Color3>;
  51029. /**
  51030. * Experimental Internal Use Only.
  51031. *
  51032. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51033. * This acts as a helper to set the primary color to a more "human friendly" value.
  51034. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51035. * output color as close as possible from the chosen value.
  51036. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51037. * part of lighting setup.)
  51038. */
  51039. get _perceptualColor(): Nullable<Color3>;
  51040. set _perceptualColor(value: Nullable<Color3>);
  51041. protected _primaryColorShadowLevel: float;
  51042. /**
  51043. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51044. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51045. */
  51046. get primaryColorShadowLevel(): float;
  51047. set primaryColorShadowLevel(value: float);
  51048. protected _primaryColorHighlightLevel: float;
  51049. /**
  51050. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51051. * The primary color is used at the level chosen to define what the white area would look.
  51052. */
  51053. get primaryColorHighlightLevel(): float;
  51054. set primaryColorHighlightLevel(value: float);
  51055. protected _reflectionTexture: Nullable<BaseTexture>;
  51056. /**
  51057. * Reflection Texture used in the material.
  51058. * Should be author in a specific way for the best result (refer to the documentation).
  51059. */
  51060. reflectionTexture: Nullable<BaseTexture>;
  51061. protected _reflectionBlur: float;
  51062. /**
  51063. * Reflection Texture level of blur.
  51064. *
  51065. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51066. * texture twice.
  51067. */
  51068. reflectionBlur: float;
  51069. protected _diffuseTexture: Nullable<BaseTexture>;
  51070. /**
  51071. * Diffuse Texture used in the material.
  51072. * Should be author in a specific way for the best result (refer to the documentation).
  51073. */
  51074. diffuseTexture: Nullable<BaseTexture>;
  51075. protected _shadowLights: Nullable<IShadowLight[]>;
  51076. /**
  51077. * Specify the list of lights casting shadow on the material.
  51078. * All scene shadow lights will be included if null.
  51079. */
  51080. shadowLights: Nullable<IShadowLight[]>;
  51081. protected _shadowLevel: float;
  51082. /**
  51083. * Helps adjusting the shadow to a softer level if required.
  51084. * 0 means black shadows and 1 means no shadows.
  51085. */
  51086. shadowLevel: float;
  51087. protected _sceneCenter: Vector3;
  51088. /**
  51089. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  51090. * It is usually zero but might be interesting to modify according to your setup.
  51091. */
  51092. sceneCenter: Vector3;
  51093. protected _opacityFresnel: boolean;
  51094. /**
  51095. * This helps specifying that the material is falling off to the sky box at grazing angle.
  51096. * This helps ensuring a nice transition when the camera goes under the ground.
  51097. */
  51098. opacityFresnel: boolean;
  51099. protected _reflectionFresnel: boolean;
  51100. /**
  51101. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  51102. * This helps adding a mirror texture on the ground.
  51103. */
  51104. reflectionFresnel: boolean;
  51105. protected _reflectionFalloffDistance: number;
  51106. /**
  51107. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51108. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51109. */
  51110. reflectionFalloffDistance: number;
  51111. protected _reflectionAmount: number;
  51112. /**
  51113. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51114. */
  51115. reflectionAmount: number;
  51116. protected _reflectionReflectance0: number;
  51117. /**
  51118. * This specifies the weight of the reflection at grazing angle.
  51119. */
  51120. reflectionReflectance0: number;
  51121. protected _reflectionReflectance90: number;
  51122. /**
  51123. * This specifies the weight of the reflection at a perpendicular point of view.
  51124. */
  51125. reflectionReflectance90: number;
  51126. /**
  51127. * Sets the reflection reflectance fresnel values according to the default standard
  51128. * empirically know to work well :-)
  51129. */
  51130. set reflectionStandardFresnelWeight(value: number);
  51131. protected _useRGBColor: boolean;
  51132. /**
  51133. * Helps to directly use the maps channels instead of their level.
  51134. */
  51135. useRGBColor: boolean;
  51136. protected _enableNoise: boolean;
  51137. /**
  51138. * This helps reducing the banding effect that could occur on the background.
  51139. */
  51140. enableNoise: boolean;
  51141. /**
  51142. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51143. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51144. * Recommended to be keep at 1.0 except for special cases.
  51145. */
  51146. get fovMultiplier(): number;
  51147. set fovMultiplier(value: number);
  51148. private _fovMultiplier;
  51149. /**
  51150. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51151. */
  51152. useEquirectangularFOV: boolean;
  51153. private _maxSimultaneousLights;
  51154. /**
  51155. * Number of Simultaneous lights allowed on the material.
  51156. */
  51157. maxSimultaneousLights: int;
  51158. /**
  51159. * Default configuration related to image processing available in the Background Material.
  51160. */
  51161. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51162. /**
  51163. * Keep track of the image processing observer to allow dispose and replace.
  51164. */
  51165. private _imageProcessingObserver;
  51166. /**
  51167. * Attaches a new image processing configuration to the PBR Material.
  51168. * @param configuration (if null the scene configuration will be use)
  51169. */
  51170. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51171. /**
  51172. * Gets the image processing configuration used either in this material.
  51173. */
  51174. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51175. /**
  51176. * Sets the Default image processing configuration used either in the this material.
  51177. *
  51178. * If sets to null, the scene one is in use.
  51179. */
  51180. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51181. /**
  51182. * Gets wether the color curves effect is enabled.
  51183. */
  51184. get cameraColorCurvesEnabled(): boolean;
  51185. /**
  51186. * Sets wether the color curves effect is enabled.
  51187. */
  51188. set cameraColorCurvesEnabled(value: boolean);
  51189. /**
  51190. * Gets wether the color grading effect is enabled.
  51191. */
  51192. get cameraColorGradingEnabled(): boolean;
  51193. /**
  51194. * Gets wether the color grading effect is enabled.
  51195. */
  51196. set cameraColorGradingEnabled(value: boolean);
  51197. /**
  51198. * Gets wether tonemapping is enabled or not.
  51199. */
  51200. get cameraToneMappingEnabled(): boolean;
  51201. /**
  51202. * Sets wether tonemapping is enabled or not
  51203. */
  51204. set cameraToneMappingEnabled(value: boolean);
  51205. /**
  51206. * The camera exposure used on this material.
  51207. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51208. * This corresponds to a photographic exposure.
  51209. */
  51210. get cameraExposure(): float;
  51211. /**
  51212. * The camera exposure used on this material.
  51213. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51214. * This corresponds to a photographic exposure.
  51215. */
  51216. set cameraExposure(value: float);
  51217. /**
  51218. * Gets The camera contrast used on this material.
  51219. */
  51220. get cameraContrast(): float;
  51221. /**
  51222. * Sets The camera contrast used on this material.
  51223. */
  51224. set cameraContrast(value: float);
  51225. /**
  51226. * Gets the Color Grading 2D Lookup Texture.
  51227. */
  51228. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51229. /**
  51230. * Sets the Color Grading 2D Lookup Texture.
  51231. */
  51232. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51233. /**
  51234. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51235. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51236. * 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;
  51237. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51238. */
  51239. get cameraColorCurves(): Nullable<ColorCurves>;
  51240. /**
  51241. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51242. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51243. * 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;
  51244. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51245. */
  51246. set cameraColorCurves(value: Nullable<ColorCurves>);
  51247. /**
  51248. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51249. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51250. */
  51251. switchToBGR: boolean;
  51252. private _renderTargets;
  51253. private _reflectionControls;
  51254. private _white;
  51255. private _primaryShadowColor;
  51256. private _primaryHighlightColor;
  51257. /**
  51258. * Instantiates a Background Material in the given scene
  51259. * @param name The friendly name of the material
  51260. * @param scene The scene to add the material to
  51261. */
  51262. constructor(name: string, scene: Scene);
  51263. /**
  51264. * Gets a boolean indicating that current material needs to register RTT
  51265. */
  51266. get hasRenderTargetTextures(): boolean;
  51267. /**
  51268. * The entire material has been created in order to prevent overdraw.
  51269. * @returns false
  51270. */
  51271. needAlphaTesting(): boolean;
  51272. /**
  51273. * The entire material has been created in order to prevent overdraw.
  51274. * @returns true if blending is enable
  51275. */
  51276. needAlphaBlending(): boolean;
  51277. /**
  51278. * Checks wether the material is ready to be rendered for a given mesh.
  51279. * @param mesh The mesh to render
  51280. * @param subMesh The submesh to check against
  51281. * @param useInstances Specify wether or not the material is used with instances
  51282. * @returns true if all the dependencies are ready (Textures, Effects...)
  51283. */
  51284. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51285. /**
  51286. * Compute the primary color according to the chosen perceptual color.
  51287. */
  51288. private _computePrimaryColorFromPerceptualColor;
  51289. /**
  51290. * Compute the highlights and shadow colors according to their chosen levels.
  51291. */
  51292. private _computePrimaryColors;
  51293. /**
  51294. * Build the uniform buffer used in the material.
  51295. */
  51296. buildUniformLayout(): void;
  51297. /**
  51298. * Unbind the material.
  51299. */
  51300. unbind(): void;
  51301. /**
  51302. * Bind only the world matrix to the material.
  51303. * @param world The world matrix to bind.
  51304. */
  51305. bindOnlyWorldMatrix(world: Matrix): void;
  51306. /**
  51307. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51308. * @param world The world matrix to bind.
  51309. * @param subMesh The submesh to bind for.
  51310. */
  51311. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51312. /**
  51313. * Checks to see if a texture is used in the material.
  51314. * @param texture - Base texture to use.
  51315. * @returns - Boolean specifying if a texture is used in the material.
  51316. */
  51317. hasTexture(texture: BaseTexture): boolean;
  51318. /**
  51319. * Dispose the material.
  51320. * @param forceDisposeEffect Force disposal of the associated effect.
  51321. * @param forceDisposeTextures Force disposal of the associated textures.
  51322. */
  51323. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51324. /**
  51325. * Clones the material.
  51326. * @param name The cloned name.
  51327. * @returns The cloned material.
  51328. */
  51329. clone(name: string): BackgroundMaterial;
  51330. /**
  51331. * Serializes the current material to its JSON representation.
  51332. * @returns The JSON representation.
  51333. */
  51334. serialize(): any;
  51335. /**
  51336. * Gets the class name of the material
  51337. * @returns "BackgroundMaterial"
  51338. */
  51339. getClassName(): string;
  51340. /**
  51341. * Parse a JSON input to create back a background material.
  51342. * @param source The JSON data to parse
  51343. * @param scene The scene to create the parsed material in
  51344. * @param rootUrl The root url of the assets the material depends upon
  51345. * @returns the instantiated BackgroundMaterial.
  51346. */
  51347. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  51348. }
  51349. }
  51350. declare module "babylonjs/Helpers/environmentHelper" {
  51351. import { Observable } from "babylonjs/Misc/observable";
  51352. import { Nullable } from "babylonjs/types";
  51353. import { Scene } from "babylonjs/scene";
  51354. import { Vector3 } from "babylonjs/Maths/math.vector";
  51355. import { Color3 } from "babylonjs/Maths/math.color";
  51356. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51357. import { Mesh } from "babylonjs/Meshes/mesh";
  51358. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51359. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  51360. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51361. import "babylonjs/Meshes/Builders/planeBuilder";
  51362. import "babylonjs/Meshes/Builders/boxBuilder";
  51363. /**
  51364. * Represents the different options available during the creation of
  51365. * a Environment helper.
  51366. *
  51367. * This can control the default ground, skybox and image processing setup of your scene.
  51368. */
  51369. export interface IEnvironmentHelperOptions {
  51370. /**
  51371. * Specifies whether or not to create a ground.
  51372. * True by default.
  51373. */
  51374. createGround: boolean;
  51375. /**
  51376. * Specifies the ground size.
  51377. * 15 by default.
  51378. */
  51379. groundSize: number;
  51380. /**
  51381. * The texture used on the ground for the main color.
  51382. * Comes from the BabylonJS CDN by default.
  51383. *
  51384. * Remarks: Can be either a texture or a url.
  51385. */
  51386. groundTexture: string | BaseTexture;
  51387. /**
  51388. * The color mixed in the ground texture by default.
  51389. * BabylonJS clearColor by default.
  51390. */
  51391. groundColor: Color3;
  51392. /**
  51393. * Specifies the ground opacity.
  51394. * 1 by default.
  51395. */
  51396. groundOpacity: number;
  51397. /**
  51398. * Enables the ground to receive shadows.
  51399. * True by default.
  51400. */
  51401. enableGroundShadow: boolean;
  51402. /**
  51403. * Helps preventing the shadow to be fully black on the ground.
  51404. * 0.5 by default.
  51405. */
  51406. groundShadowLevel: number;
  51407. /**
  51408. * Creates a mirror texture attach to the ground.
  51409. * false by default.
  51410. */
  51411. enableGroundMirror: boolean;
  51412. /**
  51413. * Specifies the ground mirror size ratio.
  51414. * 0.3 by default as the default kernel is 64.
  51415. */
  51416. groundMirrorSizeRatio: number;
  51417. /**
  51418. * Specifies the ground mirror blur kernel size.
  51419. * 64 by default.
  51420. */
  51421. groundMirrorBlurKernel: number;
  51422. /**
  51423. * Specifies the ground mirror visibility amount.
  51424. * 1 by default
  51425. */
  51426. groundMirrorAmount: number;
  51427. /**
  51428. * Specifies the ground mirror reflectance weight.
  51429. * This uses the standard weight of the background material to setup the fresnel effect
  51430. * of the mirror.
  51431. * 1 by default.
  51432. */
  51433. groundMirrorFresnelWeight: number;
  51434. /**
  51435. * Specifies the ground mirror Falloff distance.
  51436. * This can helps reducing the size of the reflection.
  51437. * 0 by Default.
  51438. */
  51439. groundMirrorFallOffDistance: number;
  51440. /**
  51441. * Specifies the ground mirror texture type.
  51442. * Unsigned Int by Default.
  51443. */
  51444. groundMirrorTextureType: number;
  51445. /**
  51446. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  51447. * the shown objects.
  51448. */
  51449. groundYBias: number;
  51450. /**
  51451. * Specifies whether or not to create a skybox.
  51452. * True by default.
  51453. */
  51454. createSkybox: boolean;
  51455. /**
  51456. * Specifies the skybox size.
  51457. * 20 by default.
  51458. */
  51459. skyboxSize: number;
  51460. /**
  51461. * The texture used on the skybox for the main color.
  51462. * Comes from the BabylonJS CDN by default.
  51463. *
  51464. * Remarks: Can be either a texture or a url.
  51465. */
  51466. skyboxTexture: string | BaseTexture;
  51467. /**
  51468. * The color mixed in the skybox texture by default.
  51469. * BabylonJS clearColor by default.
  51470. */
  51471. skyboxColor: Color3;
  51472. /**
  51473. * The background rotation around the Y axis of the scene.
  51474. * This helps aligning the key lights of your scene with the background.
  51475. * 0 by default.
  51476. */
  51477. backgroundYRotation: number;
  51478. /**
  51479. * Compute automatically the size of the elements to best fit with the scene.
  51480. */
  51481. sizeAuto: boolean;
  51482. /**
  51483. * Default position of the rootMesh if autoSize is not true.
  51484. */
  51485. rootPosition: Vector3;
  51486. /**
  51487. * Sets up the image processing in the scene.
  51488. * true by default.
  51489. */
  51490. setupImageProcessing: boolean;
  51491. /**
  51492. * The texture used as your environment texture in the scene.
  51493. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  51494. *
  51495. * Remarks: Can be either a texture or a url.
  51496. */
  51497. environmentTexture: string | BaseTexture;
  51498. /**
  51499. * The value of the exposure to apply to the scene.
  51500. * 0.6 by default if setupImageProcessing is true.
  51501. */
  51502. cameraExposure: number;
  51503. /**
  51504. * The value of the contrast to apply to the scene.
  51505. * 1.6 by default if setupImageProcessing is true.
  51506. */
  51507. cameraContrast: number;
  51508. /**
  51509. * Specifies whether or not tonemapping should be enabled in the scene.
  51510. * true by default if setupImageProcessing is true.
  51511. */
  51512. toneMappingEnabled: boolean;
  51513. }
  51514. /**
  51515. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  51516. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  51517. * It also helps with the default setup of your imageProcessing configuration.
  51518. */
  51519. export class EnvironmentHelper {
  51520. /**
  51521. * Default ground texture URL.
  51522. */
  51523. private static _groundTextureCDNUrl;
  51524. /**
  51525. * Default skybox texture URL.
  51526. */
  51527. private static _skyboxTextureCDNUrl;
  51528. /**
  51529. * Default environment texture URL.
  51530. */
  51531. private static _environmentTextureCDNUrl;
  51532. /**
  51533. * Creates the default options for the helper.
  51534. */
  51535. private static _getDefaultOptions;
  51536. private _rootMesh;
  51537. /**
  51538. * Gets the root mesh created by the helper.
  51539. */
  51540. get rootMesh(): Mesh;
  51541. private _skybox;
  51542. /**
  51543. * Gets the skybox created by the helper.
  51544. */
  51545. get skybox(): Nullable<Mesh>;
  51546. private _skyboxTexture;
  51547. /**
  51548. * Gets the skybox texture created by the helper.
  51549. */
  51550. get skyboxTexture(): Nullable<BaseTexture>;
  51551. private _skyboxMaterial;
  51552. /**
  51553. * Gets the skybox material created by the helper.
  51554. */
  51555. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  51556. private _ground;
  51557. /**
  51558. * Gets the ground mesh created by the helper.
  51559. */
  51560. get ground(): Nullable<Mesh>;
  51561. private _groundTexture;
  51562. /**
  51563. * Gets the ground texture created by the helper.
  51564. */
  51565. get groundTexture(): Nullable<BaseTexture>;
  51566. private _groundMirror;
  51567. /**
  51568. * Gets the ground mirror created by the helper.
  51569. */
  51570. get groundMirror(): Nullable<MirrorTexture>;
  51571. /**
  51572. * Gets the ground mirror render list to helps pushing the meshes
  51573. * you wish in the ground reflection.
  51574. */
  51575. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  51576. private _groundMaterial;
  51577. /**
  51578. * Gets the ground material created by the helper.
  51579. */
  51580. get groundMaterial(): Nullable<BackgroundMaterial>;
  51581. /**
  51582. * Stores the creation options.
  51583. */
  51584. private readonly _scene;
  51585. private _options;
  51586. /**
  51587. * This observable will be notified with any error during the creation of the environment,
  51588. * mainly texture creation errors.
  51589. */
  51590. onErrorObservable: Observable<{
  51591. message?: string;
  51592. exception?: any;
  51593. }>;
  51594. /**
  51595. * constructor
  51596. * @param options Defines the options we want to customize the helper
  51597. * @param scene The scene to add the material to
  51598. */
  51599. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  51600. /**
  51601. * Updates the background according to the new options
  51602. * @param options
  51603. */
  51604. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  51605. /**
  51606. * Sets the primary color of all the available elements.
  51607. * @param color the main color to affect to the ground and the background
  51608. */
  51609. setMainColor(color: Color3): void;
  51610. /**
  51611. * Setup the image processing according to the specified options.
  51612. */
  51613. private _setupImageProcessing;
  51614. /**
  51615. * Setup the environment texture according to the specified options.
  51616. */
  51617. private _setupEnvironmentTexture;
  51618. /**
  51619. * Setup the background according to the specified options.
  51620. */
  51621. private _setupBackground;
  51622. /**
  51623. * Get the scene sizes according to the setup.
  51624. */
  51625. private _getSceneSize;
  51626. /**
  51627. * Setup the ground according to the specified options.
  51628. */
  51629. private _setupGround;
  51630. /**
  51631. * Setup the ground material according to the specified options.
  51632. */
  51633. private _setupGroundMaterial;
  51634. /**
  51635. * Setup the ground diffuse texture according to the specified options.
  51636. */
  51637. private _setupGroundDiffuseTexture;
  51638. /**
  51639. * Setup the ground mirror texture according to the specified options.
  51640. */
  51641. private _setupGroundMirrorTexture;
  51642. /**
  51643. * Setup the ground to receive the mirror texture.
  51644. */
  51645. private _setupMirrorInGroundMaterial;
  51646. /**
  51647. * Setup the skybox according to the specified options.
  51648. */
  51649. private _setupSkybox;
  51650. /**
  51651. * Setup the skybox material according to the specified options.
  51652. */
  51653. private _setupSkyboxMaterial;
  51654. /**
  51655. * Setup the skybox reflection texture according to the specified options.
  51656. */
  51657. private _setupSkyboxReflectionTexture;
  51658. private _errorHandler;
  51659. /**
  51660. * Dispose all the elements created by the Helper.
  51661. */
  51662. dispose(): void;
  51663. }
  51664. }
  51665. declare module "babylonjs/Helpers/photoDome" {
  51666. import { Observable } from "babylonjs/Misc/observable";
  51667. import { Nullable } from "babylonjs/types";
  51668. import { Scene } from "babylonjs/scene";
  51669. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51670. import { Mesh } from "babylonjs/Meshes/mesh";
  51671. import { Texture } from "babylonjs/Materials/Textures/texture";
  51672. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51673. import "babylonjs/Meshes/Builders/sphereBuilder";
  51674. /**
  51675. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  51676. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  51677. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  51678. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51679. */
  51680. export class PhotoDome extends TransformNode {
  51681. /**
  51682. * Define the image as a Monoscopic panoramic 360 image.
  51683. */
  51684. static readonly MODE_MONOSCOPIC: number;
  51685. /**
  51686. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51687. */
  51688. static readonly MODE_TOPBOTTOM: number;
  51689. /**
  51690. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51691. */
  51692. static readonly MODE_SIDEBYSIDE: number;
  51693. private _useDirectMapping;
  51694. /**
  51695. * The texture being displayed on the sphere
  51696. */
  51697. protected _photoTexture: Texture;
  51698. /**
  51699. * Gets or sets the texture being displayed on the sphere
  51700. */
  51701. get photoTexture(): Texture;
  51702. set photoTexture(value: Texture);
  51703. /**
  51704. * Observable raised when an error occured while loading the 360 image
  51705. */
  51706. onLoadErrorObservable: Observable<string>;
  51707. /**
  51708. * The skybox material
  51709. */
  51710. protected _material: BackgroundMaterial;
  51711. /**
  51712. * The surface used for the skybox
  51713. */
  51714. protected _mesh: Mesh;
  51715. /**
  51716. * Gets the mesh used for the skybox.
  51717. */
  51718. get mesh(): Mesh;
  51719. /**
  51720. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51721. * Also see the options.resolution property.
  51722. */
  51723. get fovMultiplier(): number;
  51724. set fovMultiplier(value: number);
  51725. private _imageMode;
  51726. /**
  51727. * Gets or set the current video mode for the video. It can be:
  51728. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  51729. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51730. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51731. */
  51732. get imageMode(): number;
  51733. set imageMode(value: number);
  51734. /**
  51735. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  51736. * @param name Element's name, child elements will append suffixes for their own names.
  51737. * @param urlsOfPhoto defines the url of the photo to display
  51738. * @param options defines an object containing optional or exposed sub element properties
  51739. * @param onError defines a callback called when an error occured while loading the texture
  51740. */
  51741. constructor(name: string, urlOfPhoto: string, options: {
  51742. resolution?: number;
  51743. size?: number;
  51744. useDirectMapping?: boolean;
  51745. faceForward?: boolean;
  51746. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  51747. private _onBeforeCameraRenderObserver;
  51748. private _changeImageMode;
  51749. /**
  51750. * Releases resources associated with this node.
  51751. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51752. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51753. */
  51754. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51755. }
  51756. }
  51757. declare module "babylonjs/Misc/rgbdTextureTools" {
  51758. import "babylonjs/Shaders/rgbdDecode.fragment";
  51759. import "babylonjs/Engines/Extensions/engine.renderTarget";
  51760. import { Texture } from "babylonjs/Materials/Textures/texture";
  51761. /**
  51762. * Class used to host RGBD texture specific utilities
  51763. */
  51764. export class RGBDTextureTools {
  51765. /**
  51766. * Expand the RGBD Texture from RGBD to Half Float if possible.
  51767. * @param texture the texture to expand.
  51768. */
  51769. static ExpandRGBDTexture(texture: Texture): void;
  51770. }
  51771. }
  51772. declare module "babylonjs/Misc/brdfTextureTools" {
  51773. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51774. import { Scene } from "babylonjs/scene";
  51775. /**
  51776. * Class used to host texture specific utilities
  51777. */
  51778. export class BRDFTextureTools {
  51779. /**
  51780. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  51781. * @param scene defines the hosting scene
  51782. * @returns the environment BRDF texture
  51783. */
  51784. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  51785. private static _environmentBRDFBase64Texture;
  51786. }
  51787. }
  51788. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  51789. import { Nullable } from "babylonjs/types";
  51790. import { Color3 } from "babylonjs/Maths/math.color";
  51791. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51792. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51793. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51794. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51795. import { Engine } from "babylonjs/Engines/engine";
  51796. import { Scene } from "babylonjs/scene";
  51797. /**
  51798. * @hidden
  51799. */
  51800. export interface IMaterialClearCoatDefines {
  51801. CLEARCOAT: boolean;
  51802. CLEARCOAT_DEFAULTIOR: boolean;
  51803. CLEARCOAT_TEXTURE: boolean;
  51804. CLEARCOAT_TEXTUREDIRECTUV: number;
  51805. CLEARCOAT_BUMP: boolean;
  51806. CLEARCOAT_BUMPDIRECTUV: number;
  51807. CLEARCOAT_TINT: boolean;
  51808. CLEARCOAT_TINT_TEXTURE: boolean;
  51809. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51810. /** @hidden */
  51811. _areTexturesDirty: boolean;
  51812. }
  51813. /**
  51814. * Define the code related to the clear coat parameters of the pbr material.
  51815. */
  51816. export class PBRClearCoatConfiguration {
  51817. /**
  51818. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  51819. * The default fits with a polyurethane material.
  51820. */
  51821. private static readonly _DefaultIndexOfRefraction;
  51822. private _isEnabled;
  51823. /**
  51824. * Defines if the clear coat is enabled in the material.
  51825. */
  51826. isEnabled: boolean;
  51827. /**
  51828. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  51829. */
  51830. intensity: number;
  51831. /**
  51832. * Defines the clear coat layer roughness.
  51833. */
  51834. roughness: number;
  51835. private _indexOfRefraction;
  51836. /**
  51837. * Defines the index of refraction of the clear coat.
  51838. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  51839. * The default fits with a polyurethane material.
  51840. * Changing the default value is more performance intensive.
  51841. */
  51842. indexOfRefraction: number;
  51843. private _texture;
  51844. /**
  51845. * Stores the clear coat values in a texture.
  51846. */
  51847. texture: Nullable<BaseTexture>;
  51848. private _bumpTexture;
  51849. /**
  51850. * Define the clear coat specific bump texture.
  51851. */
  51852. bumpTexture: Nullable<BaseTexture>;
  51853. private _isTintEnabled;
  51854. /**
  51855. * Defines if the clear coat tint is enabled in the material.
  51856. */
  51857. isTintEnabled: boolean;
  51858. /**
  51859. * Defines the clear coat tint of the material.
  51860. * This is only use if tint is enabled
  51861. */
  51862. tintColor: Color3;
  51863. /**
  51864. * Defines the distance at which the tint color should be found in the
  51865. * clear coat media.
  51866. * This is only use if tint is enabled
  51867. */
  51868. tintColorAtDistance: number;
  51869. /**
  51870. * Defines the clear coat layer thickness.
  51871. * This is only use if tint is enabled
  51872. */
  51873. tintThickness: number;
  51874. private _tintTexture;
  51875. /**
  51876. * Stores the clear tint values in a texture.
  51877. * rgb is tint
  51878. * a is a thickness factor
  51879. */
  51880. tintTexture: Nullable<BaseTexture>;
  51881. /** @hidden */
  51882. private _internalMarkAllSubMeshesAsTexturesDirty;
  51883. /** @hidden */
  51884. _markAllSubMeshesAsTexturesDirty(): void;
  51885. /**
  51886. * Instantiate a new istance of clear coat configuration.
  51887. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51888. */
  51889. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51890. /**
  51891. * Gets wehter the submesh is ready to be used or not.
  51892. * @param defines the list of "defines" to update.
  51893. * @param scene defines the scene the material belongs to.
  51894. * @param engine defines the engine the material belongs to.
  51895. * @param disableBumpMap defines wether the material disables bump or not.
  51896. * @returns - boolean indicating that the submesh is ready or not.
  51897. */
  51898. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  51899. /**
  51900. * Checks to see if a texture is used in the material.
  51901. * @param defines the list of "defines" to update.
  51902. * @param scene defines the scene to the material belongs to.
  51903. */
  51904. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  51905. /**
  51906. * Binds the material data.
  51907. * @param uniformBuffer defines the Uniform buffer to fill in.
  51908. * @param scene defines the scene the material belongs to.
  51909. * @param engine defines the engine the material belongs to.
  51910. * @param disableBumpMap defines wether the material disables bump or not.
  51911. * @param isFrozen defines wether the material is frozen or not.
  51912. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51913. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51914. */
  51915. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  51916. /**
  51917. * Checks to see if a texture is used in the material.
  51918. * @param texture - Base texture to use.
  51919. * @returns - Boolean specifying if a texture is used in the material.
  51920. */
  51921. hasTexture(texture: BaseTexture): boolean;
  51922. /**
  51923. * Returns an array of the actively used textures.
  51924. * @param activeTextures Array of BaseTextures
  51925. */
  51926. getActiveTextures(activeTextures: BaseTexture[]): void;
  51927. /**
  51928. * Returns the animatable textures.
  51929. * @param animatables Array of animatable textures.
  51930. */
  51931. getAnimatables(animatables: IAnimatable[]): void;
  51932. /**
  51933. * Disposes the resources of the material.
  51934. * @param forceDisposeTextures - Forces the disposal of all textures.
  51935. */
  51936. dispose(forceDisposeTextures?: boolean): void;
  51937. /**
  51938. * Get the current class name of the texture useful for serialization or dynamic coding.
  51939. * @returns "PBRClearCoatConfiguration"
  51940. */
  51941. getClassName(): string;
  51942. /**
  51943. * Add fallbacks to the effect fallbacks list.
  51944. * @param defines defines the Base texture to use.
  51945. * @param fallbacks defines the current fallback list.
  51946. * @param currentRank defines the current fallback rank.
  51947. * @returns the new fallback rank.
  51948. */
  51949. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51950. /**
  51951. * Add the required uniforms to the current list.
  51952. * @param uniforms defines the current uniform list.
  51953. */
  51954. static AddUniforms(uniforms: string[]): void;
  51955. /**
  51956. * Add the required samplers to the current list.
  51957. * @param samplers defines the current sampler list.
  51958. */
  51959. static AddSamplers(samplers: string[]): void;
  51960. /**
  51961. * Add the required uniforms to the current buffer.
  51962. * @param uniformBuffer defines the current uniform buffer.
  51963. */
  51964. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51965. /**
  51966. * Makes a duplicate of the current configuration into another one.
  51967. * @param clearCoatConfiguration define the config where to copy the info
  51968. */
  51969. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  51970. /**
  51971. * Serializes this clear coat configuration.
  51972. * @returns - An object with the serialized config.
  51973. */
  51974. serialize(): any;
  51975. /**
  51976. * Parses a anisotropy Configuration from a serialized object.
  51977. * @param source - Serialized object.
  51978. * @param scene Defines the scene we are parsing for
  51979. * @param rootUrl Defines the rootUrl to load from
  51980. */
  51981. parse(source: any, scene: Scene, rootUrl: string): void;
  51982. }
  51983. }
  51984. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  51985. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51987. import { Vector2 } from "babylonjs/Maths/math.vector";
  51988. import { Scene } from "babylonjs/scene";
  51989. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51990. import { Nullable } from "babylonjs/types";
  51991. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51992. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51993. /**
  51994. * @hidden
  51995. */
  51996. export interface IMaterialAnisotropicDefines {
  51997. ANISOTROPIC: boolean;
  51998. ANISOTROPIC_TEXTURE: boolean;
  51999. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52000. MAINUV1: boolean;
  52001. _areTexturesDirty: boolean;
  52002. _needUVs: boolean;
  52003. }
  52004. /**
  52005. * Define the code related to the anisotropic parameters of the pbr material.
  52006. */
  52007. export class PBRAnisotropicConfiguration {
  52008. private _isEnabled;
  52009. /**
  52010. * Defines if the anisotropy is enabled in the material.
  52011. */
  52012. isEnabled: boolean;
  52013. /**
  52014. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52015. */
  52016. intensity: number;
  52017. /**
  52018. * Defines if the effect is along the tangents, bitangents or in between.
  52019. * By default, the effect is "strectching" the highlights along the tangents.
  52020. */
  52021. direction: Vector2;
  52022. private _texture;
  52023. /**
  52024. * Stores the anisotropy values in a texture.
  52025. * rg is direction (like normal from -1 to 1)
  52026. * b is a intensity
  52027. */
  52028. texture: Nullable<BaseTexture>;
  52029. /** @hidden */
  52030. private _internalMarkAllSubMeshesAsTexturesDirty;
  52031. /** @hidden */
  52032. _markAllSubMeshesAsTexturesDirty(): void;
  52033. /**
  52034. * Instantiate a new istance of anisotropy configuration.
  52035. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52036. */
  52037. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52038. /**
  52039. * Specifies that the submesh is ready to be used.
  52040. * @param defines the list of "defines" to update.
  52041. * @param scene defines the scene the material belongs to.
  52042. * @returns - boolean indicating that the submesh is ready or not.
  52043. */
  52044. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52045. /**
  52046. * Checks to see if a texture is used in the material.
  52047. * @param defines the list of "defines" to update.
  52048. * @param mesh the mesh we are preparing the defines for.
  52049. * @param scene defines the scene the material belongs to.
  52050. */
  52051. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52052. /**
  52053. * Binds the material data.
  52054. * @param uniformBuffer defines the Uniform buffer to fill in.
  52055. * @param scene defines the scene the material belongs to.
  52056. * @param isFrozen defines wether the material is frozen or not.
  52057. */
  52058. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52059. /**
  52060. * Checks to see if a texture is used in the material.
  52061. * @param texture - Base texture to use.
  52062. * @returns - Boolean specifying if a texture is used in the material.
  52063. */
  52064. hasTexture(texture: BaseTexture): boolean;
  52065. /**
  52066. * Returns an array of the actively used textures.
  52067. * @param activeTextures Array of BaseTextures
  52068. */
  52069. getActiveTextures(activeTextures: BaseTexture[]): void;
  52070. /**
  52071. * Returns the animatable textures.
  52072. * @param animatables Array of animatable textures.
  52073. */
  52074. getAnimatables(animatables: IAnimatable[]): void;
  52075. /**
  52076. * Disposes the resources of the material.
  52077. * @param forceDisposeTextures - Forces the disposal of all textures.
  52078. */
  52079. dispose(forceDisposeTextures?: boolean): void;
  52080. /**
  52081. * Get the current class name of the texture useful for serialization or dynamic coding.
  52082. * @returns "PBRAnisotropicConfiguration"
  52083. */
  52084. getClassName(): string;
  52085. /**
  52086. * Add fallbacks to the effect fallbacks list.
  52087. * @param defines defines the Base texture to use.
  52088. * @param fallbacks defines the current fallback list.
  52089. * @param currentRank defines the current fallback rank.
  52090. * @returns the new fallback rank.
  52091. */
  52092. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52093. /**
  52094. * Add the required uniforms to the current list.
  52095. * @param uniforms defines the current uniform list.
  52096. */
  52097. static AddUniforms(uniforms: string[]): void;
  52098. /**
  52099. * Add the required uniforms to the current buffer.
  52100. * @param uniformBuffer defines the current uniform buffer.
  52101. */
  52102. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52103. /**
  52104. * Add the required samplers to the current list.
  52105. * @param samplers defines the current sampler list.
  52106. */
  52107. static AddSamplers(samplers: string[]): void;
  52108. /**
  52109. * Makes a duplicate of the current configuration into another one.
  52110. * @param anisotropicConfiguration define the config where to copy the info
  52111. */
  52112. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  52113. /**
  52114. * Serializes this anisotropy configuration.
  52115. * @returns - An object with the serialized config.
  52116. */
  52117. serialize(): any;
  52118. /**
  52119. * Parses a anisotropy Configuration from a serialized object.
  52120. * @param source - Serialized object.
  52121. * @param scene Defines the scene we are parsing for
  52122. * @param rootUrl Defines the rootUrl to load from
  52123. */
  52124. parse(source: any, scene: Scene, rootUrl: string): void;
  52125. }
  52126. }
  52127. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52128. import { Scene } from "babylonjs/scene";
  52129. /**
  52130. * @hidden
  52131. */
  52132. export interface IMaterialBRDFDefines {
  52133. BRDF_V_HEIGHT_CORRELATED: boolean;
  52134. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52135. SPHERICAL_HARMONICS: boolean;
  52136. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52137. /** @hidden */
  52138. _areMiscDirty: boolean;
  52139. }
  52140. /**
  52141. * Define the code related to the BRDF parameters of the pbr material.
  52142. */
  52143. export class PBRBRDFConfiguration {
  52144. /**
  52145. * Default value used for the energy conservation.
  52146. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52147. */
  52148. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52149. /**
  52150. * Default value used for the Smith Visibility Height Correlated mode.
  52151. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52152. */
  52153. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52154. /**
  52155. * Default value used for the IBL diffuse part.
  52156. * This can help switching back to the polynomials mode globally which is a tiny bit
  52157. * less GPU intensive at the drawback of a lower quality.
  52158. */
  52159. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52160. /**
  52161. * Default value used for activating energy conservation for the specular workflow.
  52162. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52163. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52164. */
  52165. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52166. private _useEnergyConservation;
  52167. /**
  52168. * Defines if the material uses energy conservation.
  52169. */
  52170. useEnergyConservation: boolean;
  52171. private _useSmithVisibilityHeightCorrelated;
  52172. /**
  52173. * LEGACY Mode set to false
  52174. * Defines if the material uses height smith correlated visibility term.
  52175. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52176. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52177. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  52178. * Not relying on height correlated will also disable energy conservation.
  52179. */
  52180. useSmithVisibilityHeightCorrelated: boolean;
  52181. private _useSphericalHarmonics;
  52182. /**
  52183. * LEGACY Mode set to false
  52184. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  52185. * diffuse part of the IBL.
  52186. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  52187. * to the ground truth.
  52188. */
  52189. useSphericalHarmonics: boolean;
  52190. private _useSpecularGlossinessInputEnergyConservation;
  52191. /**
  52192. * Defines if the material uses energy conservation, when the specular workflow is active.
  52193. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52194. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52195. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  52196. */
  52197. useSpecularGlossinessInputEnergyConservation: boolean;
  52198. /** @hidden */
  52199. private _internalMarkAllSubMeshesAsMiscDirty;
  52200. /** @hidden */
  52201. _markAllSubMeshesAsMiscDirty(): void;
  52202. /**
  52203. * Instantiate a new istance of clear coat configuration.
  52204. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  52205. */
  52206. constructor(markAllSubMeshesAsMiscDirty: () => void);
  52207. /**
  52208. * Checks to see if a texture is used in the material.
  52209. * @param defines the list of "defines" to update.
  52210. */
  52211. prepareDefines(defines: IMaterialBRDFDefines): void;
  52212. /**
  52213. * Get the current class name of the texture useful for serialization or dynamic coding.
  52214. * @returns "PBRClearCoatConfiguration"
  52215. */
  52216. getClassName(): string;
  52217. /**
  52218. * Makes a duplicate of the current configuration into another one.
  52219. * @param brdfConfiguration define the config where to copy the info
  52220. */
  52221. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  52222. /**
  52223. * Serializes this BRDF configuration.
  52224. * @returns - An object with the serialized config.
  52225. */
  52226. serialize(): any;
  52227. /**
  52228. * Parses a anisotropy Configuration from a serialized object.
  52229. * @param source - Serialized object.
  52230. * @param scene Defines the scene we are parsing for
  52231. * @param rootUrl Defines the rootUrl to load from
  52232. */
  52233. parse(source: any, scene: Scene, rootUrl: string): void;
  52234. }
  52235. }
  52236. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  52237. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52238. import { Color3 } from "babylonjs/Maths/math.color";
  52239. import { Scene } from "babylonjs/scene";
  52240. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52241. import { Nullable } from "babylonjs/types";
  52242. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52243. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52244. /**
  52245. * @hidden
  52246. */
  52247. export interface IMaterialSheenDefines {
  52248. SHEEN: boolean;
  52249. SHEEN_TEXTURE: boolean;
  52250. SHEEN_TEXTUREDIRECTUV: number;
  52251. SHEEN_LINKWITHALBEDO: boolean;
  52252. /** @hidden */
  52253. _areTexturesDirty: boolean;
  52254. }
  52255. /**
  52256. * Define the code related to the Sheen parameters of the pbr material.
  52257. */
  52258. export class PBRSheenConfiguration {
  52259. private _isEnabled;
  52260. /**
  52261. * Defines if the material uses sheen.
  52262. */
  52263. isEnabled: boolean;
  52264. private _linkSheenWithAlbedo;
  52265. /**
  52266. * Defines if the sheen is linked to the sheen color.
  52267. */
  52268. linkSheenWithAlbedo: boolean;
  52269. /**
  52270. * Defines the sheen intensity.
  52271. */
  52272. intensity: number;
  52273. /**
  52274. * Defines the sheen color.
  52275. */
  52276. color: Color3;
  52277. private _texture;
  52278. /**
  52279. * Stores the sheen tint values in a texture.
  52280. * rgb is tint
  52281. * a is a intensity
  52282. */
  52283. texture: Nullable<BaseTexture>;
  52284. /** @hidden */
  52285. private _internalMarkAllSubMeshesAsTexturesDirty;
  52286. /** @hidden */
  52287. _markAllSubMeshesAsTexturesDirty(): void;
  52288. /**
  52289. * Instantiate a new istance of clear coat configuration.
  52290. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52291. */
  52292. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52293. /**
  52294. * Specifies that the submesh is ready to be used.
  52295. * @param defines the list of "defines" to update.
  52296. * @param scene defines the scene the material belongs to.
  52297. * @returns - boolean indicating that the submesh is ready or not.
  52298. */
  52299. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  52300. /**
  52301. * Checks to see if a texture is used in the material.
  52302. * @param defines the list of "defines" to update.
  52303. * @param scene defines the scene the material belongs to.
  52304. */
  52305. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  52306. /**
  52307. * Binds the material data.
  52308. * @param uniformBuffer defines the Uniform buffer to fill in.
  52309. * @param scene defines the scene the material belongs to.
  52310. * @param isFrozen defines wether the material is frozen or not.
  52311. */
  52312. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52313. /**
  52314. * Checks to see if a texture is used in the material.
  52315. * @param texture - Base texture to use.
  52316. * @returns - Boolean specifying if a texture is used in the material.
  52317. */
  52318. hasTexture(texture: BaseTexture): boolean;
  52319. /**
  52320. * Returns an array of the actively used textures.
  52321. * @param activeTextures Array of BaseTextures
  52322. */
  52323. getActiveTextures(activeTextures: BaseTexture[]): void;
  52324. /**
  52325. * Returns the animatable textures.
  52326. * @param animatables Array of animatable textures.
  52327. */
  52328. getAnimatables(animatables: IAnimatable[]): void;
  52329. /**
  52330. * Disposes the resources of the material.
  52331. * @param forceDisposeTextures - Forces the disposal of all textures.
  52332. */
  52333. dispose(forceDisposeTextures?: boolean): void;
  52334. /**
  52335. * Get the current class name of the texture useful for serialization or dynamic coding.
  52336. * @returns "PBRSheenConfiguration"
  52337. */
  52338. getClassName(): string;
  52339. /**
  52340. * Add fallbacks to the effect fallbacks list.
  52341. * @param defines defines the Base texture to use.
  52342. * @param fallbacks defines the current fallback list.
  52343. * @param currentRank defines the current fallback rank.
  52344. * @returns the new fallback rank.
  52345. */
  52346. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52347. /**
  52348. * Add the required uniforms to the current list.
  52349. * @param uniforms defines the current uniform list.
  52350. */
  52351. static AddUniforms(uniforms: string[]): void;
  52352. /**
  52353. * Add the required uniforms to the current buffer.
  52354. * @param uniformBuffer defines the current uniform buffer.
  52355. */
  52356. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52357. /**
  52358. * Add the required samplers to the current list.
  52359. * @param samplers defines the current sampler list.
  52360. */
  52361. static AddSamplers(samplers: string[]): void;
  52362. /**
  52363. * Makes a duplicate of the current configuration into another one.
  52364. * @param sheenConfiguration define the config where to copy the info
  52365. */
  52366. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  52367. /**
  52368. * Serializes this BRDF configuration.
  52369. * @returns - An object with the serialized config.
  52370. */
  52371. serialize(): any;
  52372. /**
  52373. * Parses a anisotropy Configuration from a serialized object.
  52374. * @param source - Serialized object.
  52375. * @param scene Defines the scene we are parsing for
  52376. * @param rootUrl Defines the rootUrl to load from
  52377. */
  52378. parse(source: any, scene: Scene, rootUrl: string): void;
  52379. }
  52380. }
  52381. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  52382. import { Nullable } from "babylonjs/types";
  52383. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52384. import { Color3 } from "babylonjs/Maths/math.color";
  52385. import { SmartArray } from "babylonjs/Misc/smartArray";
  52386. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52387. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52388. import { Effect } from "babylonjs/Materials/effect";
  52389. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52390. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52391. import { Engine } from "babylonjs/Engines/engine";
  52392. import { Scene } from "babylonjs/scene";
  52393. /**
  52394. * @hidden
  52395. */
  52396. export interface IMaterialSubSurfaceDefines {
  52397. SUBSURFACE: boolean;
  52398. SS_REFRACTION: boolean;
  52399. SS_TRANSLUCENCY: boolean;
  52400. SS_SCATERRING: boolean;
  52401. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52402. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52403. SS_REFRACTIONMAP_3D: boolean;
  52404. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52405. SS_LODINREFRACTIONALPHA: boolean;
  52406. SS_GAMMAREFRACTION: boolean;
  52407. SS_RGBDREFRACTION: boolean;
  52408. SS_LINEARSPECULARREFRACTION: boolean;
  52409. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52410. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52411. /** @hidden */
  52412. _areTexturesDirty: boolean;
  52413. }
  52414. /**
  52415. * Define the code related to the sub surface parameters of the pbr material.
  52416. */
  52417. export class PBRSubSurfaceConfiguration {
  52418. private _isRefractionEnabled;
  52419. /**
  52420. * Defines if the refraction is enabled in the material.
  52421. */
  52422. isRefractionEnabled: boolean;
  52423. private _isTranslucencyEnabled;
  52424. /**
  52425. * Defines if the translucency is enabled in the material.
  52426. */
  52427. isTranslucencyEnabled: boolean;
  52428. private _isScatteringEnabled;
  52429. /**
  52430. * Defines the refraction intensity of the material.
  52431. * The refraction when enabled replaces the Diffuse part of the material.
  52432. * The intensity helps transitionning between diffuse and refraction.
  52433. */
  52434. refractionIntensity: number;
  52435. /**
  52436. * Defines the translucency intensity of the material.
  52437. * When translucency has been enabled, this defines how much of the "translucency"
  52438. * is addded to the diffuse part of the material.
  52439. */
  52440. translucencyIntensity: number;
  52441. /**
  52442. * Defines the scattering intensity of the material.
  52443. * When scattering has been enabled, this defines how much of the "scattered light"
  52444. * is addded to the diffuse part of the material.
  52445. */
  52446. scatteringIntensity: number;
  52447. private _thicknessTexture;
  52448. /**
  52449. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  52450. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  52451. * 0 would mean minimumThickness
  52452. * 1 would mean maximumThickness
  52453. * The other channels might be use as a mask to vary the different effects intensity.
  52454. */
  52455. thicknessTexture: Nullable<BaseTexture>;
  52456. private _refractionTexture;
  52457. /**
  52458. * Defines the texture to use for refraction.
  52459. */
  52460. refractionTexture: Nullable<BaseTexture>;
  52461. private _indexOfRefraction;
  52462. /**
  52463. * Defines the index of refraction used in the material.
  52464. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  52465. */
  52466. indexOfRefraction: number;
  52467. private _invertRefractionY;
  52468. /**
  52469. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52470. */
  52471. invertRefractionY: boolean;
  52472. private _linkRefractionWithTransparency;
  52473. /**
  52474. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52475. * Materials half opaque for instance using refraction could benefit from this control.
  52476. */
  52477. linkRefractionWithTransparency: boolean;
  52478. /**
  52479. * Defines the minimum thickness stored in the thickness map.
  52480. * If no thickness map is defined, this value will be used to simulate thickness.
  52481. */
  52482. minimumThickness: number;
  52483. /**
  52484. * Defines the maximum thickness stored in the thickness map.
  52485. */
  52486. maximumThickness: number;
  52487. /**
  52488. * Defines the volume tint of the material.
  52489. * This is used for both translucency and scattering.
  52490. */
  52491. tintColor: Color3;
  52492. /**
  52493. * Defines the distance at which the tint color should be found in the media.
  52494. * This is used for refraction only.
  52495. */
  52496. tintColorAtDistance: number;
  52497. /**
  52498. * Defines how far each channel transmit through the media.
  52499. * It is defined as a color to simplify it selection.
  52500. */
  52501. diffusionDistance: Color3;
  52502. private _useMaskFromThicknessTexture;
  52503. /**
  52504. * Stores the intensity of the different subsurface effects in the thickness texture.
  52505. * * the green channel is the translucency intensity.
  52506. * * the blue channel is the scattering intensity.
  52507. * * the alpha channel is the refraction intensity.
  52508. */
  52509. useMaskFromThicknessTexture: boolean;
  52510. /** @hidden */
  52511. private _internalMarkAllSubMeshesAsTexturesDirty;
  52512. /** @hidden */
  52513. _markAllSubMeshesAsTexturesDirty(): void;
  52514. /**
  52515. * Instantiate a new istance of sub surface configuration.
  52516. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52517. */
  52518. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52519. /**
  52520. * Gets wehter the submesh is ready to be used or not.
  52521. * @param defines the list of "defines" to update.
  52522. * @param scene defines the scene the material belongs to.
  52523. * @returns - boolean indicating that the submesh is ready or not.
  52524. */
  52525. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  52526. /**
  52527. * Checks to see if a texture is used in the material.
  52528. * @param defines the list of "defines" to update.
  52529. * @param scene defines the scene to the material belongs to.
  52530. */
  52531. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  52532. /**
  52533. * Binds the material data.
  52534. * @param uniformBuffer defines the Uniform buffer to fill in.
  52535. * @param scene defines the scene the material belongs to.
  52536. * @param engine defines the engine the material belongs to.
  52537. * @param isFrozen defines wether the material is frozen or not.
  52538. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  52539. */
  52540. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  52541. /**
  52542. * Unbinds the material from the mesh.
  52543. * @param activeEffect defines the effect that should be unbound from.
  52544. * @returns true if unbound, otherwise false
  52545. */
  52546. unbind(activeEffect: Effect): boolean;
  52547. /**
  52548. * Returns the texture used for refraction or null if none is used.
  52549. * @param scene defines the scene the material belongs to.
  52550. * @returns - Refraction texture if present. If no refraction texture and refraction
  52551. * is linked with transparency, returns environment texture. Otherwise, returns null.
  52552. */
  52553. private _getRefractionTexture;
  52554. /**
  52555. * Returns true if alpha blending should be disabled.
  52556. */
  52557. get disableAlphaBlending(): boolean;
  52558. /**
  52559. * Fills the list of render target textures.
  52560. * @param renderTargets the list of render targets to update
  52561. */
  52562. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  52563. /**
  52564. * Checks to see if a texture is used in the material.
  52565. * @param texture - Base texture to use.
  52566. * @returns - Boolean specifying if a texture is used in the material.
  52567. */
  52568. hasTexture(texture: BaseTexture): boolean;
  52569. /**
  52570. * Gets a boolean indicating that current material needs to register RTT
  52571. * @returns true if this uses a render target otherwise false.
  52572. */
  52573. hasRenderTargetTextures(): boolean;
  52574. /**
  52575. * Returns an array of the actively used textures.
  52576. * @param activeTextures Array of BaseTextures
  52577. */
  52578. getActiveTextures(activeTextures: BaseTexture[]): void;
  52579. /**
  52580. * Returns the animatable textures.
  52581. * @param animatables Array of animatable textures.
  52582. */
  52583. getAnimatables(animatables: IAnimatable[]): void;
  52584. /**
  52585. * Disposes the resources of the material.
  52586. * @param forceDisposeTextures - Forces the disposal of all textures.
  52587. */
  52588. dispose(forceDisposeTextures?: boolean): void;
  52589. /**
  52590. * Get the current class name of the texture useful for serialization or dynamic coding.
  52591. * @returns "PBRSubSurfaceConfiguration"
  52592. */
  52593. getClassName(): string;
  52594. /**
  52595. * Add fallbacks to the effect fallbacks list.
  52596. * @param defines defines the Base texture to use.
  52597. * @param fallbacks defines the current fallback list.
  52598. * @param currentRank defines the current fallback rank.
  52599. * @returns the new fallback rank.
  52600. */
  52601. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52602. /**
  52603. * Add the required uniforms to the current list.
  52604. * @param uniforms defines the current uniform list.
  52605. */
  52606. static AddUniforms(uniforms: string[]): void;
  52607. /**
  52608. * Add the required samplers to the current list.
  52609. * @param samplers defines the current sampler list.
  52610. */
  52611. static AddSamplers(samplers: string[]): void;
  52612. /**
  52613. * Add the required uniforms to the current buffer.
  52614. * @param uniformBuffer defines the current uniform buffer.
  52615. */
  52616. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52617. /**
  52618. * Makes a duplicate of the current configuration into another one.
  52619. * @param configuration define the config where to copy the info
  52620. */
  52621. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  52622. /**
  52623. * Serializes this Sub Surface configuration.
  52624. * @returns - An object with the serialized config.
  52625. */
  52626. serialize(): any;
  52627. /**
  52628. * Parses a anisotropy Configuration from a serialized object.
  52629. * @param source - Serialized object.
  52630. * @param scene Defines the scene we are parsing for
  52631. * @param rootUrl Defines the rootUrl to load from
  52632. */
  52633. parse(source: any, scene: Scene, rootUrl: string): void;
  52634. }
  52635. }
  52636. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  52637. /** @hidden */
  52638. export var pbrFragmentDeclaration: {
  52639. name: string;
  52640. shader: string;
  52641. };
  52642. }
  52643. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  52644. /** @hidden */
  52645. export var pbrUboDeclaration: {
  52646. name: string;
  52647. shader: string;
  52648. };
  52649. }
  52650. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  52651. /** @hidden */
  52652. export var pbrFragmentExtraDeclaration: {
  52653. name: string;
  52654. shader: string;
  52655. };
  52656. }
  52657. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  52658. /** @hidden */
  52659. export var pbrFragmentSamplersDeclaration: {
  52660. name: string;
  52661. shader: string;
  52662. };
  52663. }
  52664. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  52665. /** @hidden */
  52666. export var pbrHelperFunctions: {
  52667. name: string;
  52668. shader: string;
  52669. };
  52670. }
  52671. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  52672. /** @hidden */
  52673. export var harmonicsFunctions: {
  52674. name: string;
  52675. shader: string;
  52676. };
  52677. }
  52678. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  52679. /** @hidden */
  52680. export var pbrDirectLightingSetupFunctions: {
  52681. name: string;
  52682. shader: string;
  52683. };
  52684. }
  52685. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  52686. /** @hidden */
  52687. export var pbrDirectLightingFalloffFunctions: {
  52688. name: string;
  52689. shader: string;
  52690. };
  52691. }
  52692. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  52693. /** @hidden */
  52694. export var pbrBRDFFunctions: {
  52695. name: string;
  52696. shader: string;
  52697. };
  52698. }
  52699. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  52700. /** @hidden */
  52701. export var pbrDirectLightingFunctions: {
  52702. name: string;
  52703. shader: string;
  52704. };
  52705. }
  52706. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  52707. /** @hidden */
  52708. export var pbrIBLFunctions: {
  52709. name: string;
  52710. shader: string;
  52711. };
  52712. }
  52713. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  52714. /** @hidden */
  52715. export var pbrDebug: {
  52716. name: string;
  52717. shader: string;
  52718. };
  52719. }
  52720. declare module "babylonjs/Shaders/pbr.fragment" {
  52721. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  52722. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52723. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  52724. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52725. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52726. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  52727. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  52728. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  52729. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52730. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  52731. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52732. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  52733. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  52734. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  52735. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52736. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  52737. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  52738. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  52739. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  52740. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  52741. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  52742. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  52743. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  52744. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  52745. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  52746. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  52747. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  52748. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  52749. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  52750. /** @hidden */
  52751. export var pbrPixelShader: {
  52752. name: string;
  52753. shader: string;
  52754. };
  52755. }
  52756. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  52757. /** @hidden */
  52758. export var pbrVertexDeclaration: {
  52759. name: string;
  52760. shader: string;
  52761. };
  52762. }
  52763. declare module "babylonjs/Shaders/pbr.vertex" {
  52764. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  52765. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52766. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52767. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52768. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52769. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52770. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  52771. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  52772. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  52773. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52774. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52775. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52776. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52777. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52778. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52779. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52780. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52781. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  52782. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  52783. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  52784. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  52785. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  52786. /** @hidden */
  52787. export var pbrVertexShader: {
  52788. name: string;
  52789. shader: string;
  52790. };
  52791. }
  52792. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  52793. import { Nullable } from "babylonjs/types";
  52794. import { Scene } from "babylonjs/scene";
  52795. import { Matrix } from "babylonjs/Maths/math.vector";
  52796. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52797. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52798. import { Mesh } from "babylonjs/Meshes/mesh";
  52799. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  52800. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  52801. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  52802. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  52803. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  52804. import { Color3 } from "babylonjs/Maths/math.color";
  52805. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  52806. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  52807. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  52808. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  52809. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52810. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52811. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  52812. import "babylonjs/Shaders/pbr.fragment";
  52813. import "babylonjs/Shaders/pbr.vertex";
  52814. /**
  52815. * Manages the defines for the PBR Material.
  52816. * @hidden
  52817. */
  52818. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  52819. PBR: boolean;
  52820. MAINUV1: boolean;
  52821. MAINUV2: boolean;
  52822. UV1: boolean;
  52823. UV2: boolean;
  52824. ALBEDO: boolean;
  52825. ALBEDODIRECTUV: number;
  52826. VERTEXCOLOR: boolean;
  52827. AMBIENT: boolean;
  52828. AMBIENTDIRECTUV: number;
  52829. AMBIENTINGRAYSCALE: boolean;
  52830. OPACITY: boolean;
  52831. VERTEXALPHA: boolean;
  52832. OPACITYDIRECTUV: number;
  52833. OPACITYRGB: boolean;
  52834. ALPHATEST: boolean;
  52835. DEPTHPREPASS: boolean;
  52836. ALPHABLEND: boolean;
  52837. ALPHAFROMALBEDO: boolean;
  52838. ALPHATESTVALUE: string;
  52839. SPECULAROVERALPHA: boolean;
  52840. RADIANCEOVERALPHA: boolean;
  52841. ALPHAFRESNEL: boolean;
  52842. LINEARALPHAFRESNEL: boolean;
  52843. PREMULTIPLYALPHA: boolean;
  52844. EMISSIVE: boolean;
  52845. EMISSIVEDIRECTUV: number;
  52846. REFLECTIVITY: boolean;
  52847. REFLECTIVITYDIRECTUV: number;
  52848. SPECULARTERM: boolean;
  52849. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  52850. MICROSURFACEAUTOMATIC: boolean;
  52851. LODBASEDMICROSFURACE: boolean;
  52852. MICROSURFACEMAP: boolean;
  52853. MICROSURFACEMAPDIRECTUV: number;
  52854. METALLICWORKFLOW: boolean;
  52855. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  52856. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  52857. METALLNESSSTOREINMETALMAPBLUE: boolean;
  52858. AOSTOREINMETALMAPRED: boolean;
  52859. METALLICF0FACTORFROMMETALLICMAP: boolean;
  52860. ENVIRONMENTBRDF: boolean;
  52861. ENVIRONMENTBRDF_RGBD: boolean;
  52862. NORMAL: boolean;
  52863. TANGENT: boolean;
  52864. BUMP: boolean;
  52865. BUMPDIRECTUV: number;
  52866. OBJECTSPACE_NORMALMAP: boolean;
  52867. PARALLAX: boolean;
  52868. PARALLAXOCCLUSION: boolean;
  52869. NORMALXYSCALE: boolean;
  52870. LIGHTMAP: boolean;
  52871. LIGHTMAPDIRECTUV: number;
  52872. USELIGHTMAPASSHADOWMAP: boolean;
  52873. GAMMALIGHTMAP: boolean;
  52874. RGBDLIGHTMAP: boolean;
  52875. REFLECTION: boolean;
  52876. REFLECTIONMAP_3D: boolean;
  52877. REFLECTIONMAP_SPHERICAL: boolean;
  52878. REFLECTIONMAP_PLANAR: boolean;
  52879. REFLECTIONMAP_CUBIC: boolean;
  52880. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  52881. REFLECTIONMAP_PROJECTION: boolean;
  52882. REFLECTIONMAP_SKYBOX: boolean;
  52883. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  52884. REFLECTIONMAP_EXPLICIT: boolean;
  52885. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  52886. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  52887. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  52888. INVERTCUBICMAP: boolean;
  52889. USESPHERICALFROMREFLECTIONMAP: boolean;
  52890. USEIRRADIANCEMAP: boolean;
  52891. SPHERICAL_HARMONICS: boolean;
  52892. USESPHERICALINVERTEX: boolean;
  52893. REFLECTIONMAP_OPPOSITEZ: boolean;
  52894. LODINREFLECTIONALPHA: boolean;
  52895. GAMMAREFLECTION: boolean;
  52896. RGBDREFLECTION: boolean;
  52897. LINEARSPECULARREFLECTION: boolean;
  52898. RADIANCEOCCLUSION: boolean;
  52899. HORIZONOCCLUSION: boolean;
  52900. INSTANCES: boolean;
  52901. NUM_BONE_INFLUENCERS: number;
  52902. BonesPerMesh: number;
  52903. BONETEXTURE: boolean;
  52904. NONUNIFORMSCALING: boolean;
  52905. MORPHTARGETS: boolean;
  52906. MORPHTARGETS_NORMAL: boolean;
  52907. MORPHTARGETS_TANGENT: boolean;
  52908. MORPHTARGETS_UV: boolean;
  52909. NUM_MORPH_INFLUENCERS: number;
  52910. IMAGEPROCESSING: boolean;
  52911. VIGNETTE: boolean;
  52912. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52913. VIGNETTEBLENDMODEOPAQUE: boolean;
  52914. TONEMAPPING: boolean;
  52915. TONEMAPPING_ACES: boolean;
  52916. CONTRAST: boolean;
  52917. COLORCURVES: boolean;
  52918. COLORGRADING: boolean;
  52919. COLORGRADING3D: boolean;
  52920. SAMPLER3DGREENDEPTH: boolean;
  52921. SAMPLER3DBGRMAP: boolean;
  52922. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52923. EXPOSURE: boolean;
  52924. MULTIVIEW: boolean;
  52925. USEPHYSICALLIGHTFALLOFF: boolean;
  52926. USEGLTFLIGHTFALLOFF: boolean;
  52927. TWOSIDEDLIGHTING: boolean;
  52928. SHADOWFLOAT: boolean;
  52929. CLIPPLANE: boolean;
  52930. CLIPPLANE2: boolean;
  52931. CLIPPLANE3: boolean;
  52932. CLIPPLANE4: boolean;
  52933. CLIPPLANE5: boolean;
  52934. CLIPPLANE6: boolean;
  52935. POINTSIZE: boolean;
  52936. FOG: boolean;
  52937. LOGARITHMICDEPTH: boolean;
  52938. FORCENORMALFORWARD: boolean;
  52939. SPECULARAA: boolean;
  52940. CLEARCOAT: boolean;
  52941. CLEARCOAT_DEFAULTIOR: boolean;
  52942. CLEARCOAT_TEXTURE: boolean;
  52943. CLEARCOAT_TEXTUREDIRECTUV: number;
  52944. CLEARCOAT_BUMP: boolean;
  52945. CLEARCOAT_BUMPDIRECTUV: number;
  52946. CLEARCOAT_TINT: boolean;
  52947. CLEARCOAT_TINT_TEXTURE: boolean;
  52948. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52949. ANISOTROPIC: boolean;
  52950. ANISOTROPIC_TEXTURE: boolean;
  52951. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52952. BRDF_V_HEIGHT_CORRELATED: boolean;
  52953. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52954. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52955. SHEEN: boolean;
  52956. SHEEN_TEXTURE: boolean;
  52957. SHEEN_TEXTUREDIRECTUV: number;
  52958. SHEEN_LINKWITHALBEDO: boolean;
  52959. SUBSURFACE: boolean;
  52960. SS_REFRACTION: boolean;
  52961. SS_TRANSLUCENCY: boolean;
  52962. SS_SCATERRING: boolean;
  52963. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52964. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52965. SS_REFRACTIONMAP_3D: boolean;
  52966. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52967. SS_LODINREFRACTIONALPHA: boolean;
  52968. SS_GAMMAREFRACTION: boolean;
  52969. SS_RGBDREFRACTION: boolean;
  52970. SS_LINEARSPECULARREFRACTION: boolean;
  52971. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52972. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52973. UNLIT: boolean;
  52974. DEBUGMODE: number;
  52975. /**
  52976. * Initializes the PBR Material defines.
  52977. */
  52978. constructor();
  52979. /**
  52980. * Resets the PBR Material defines.
  52981. */
  52982. reset(): void;
  52983. }
  52984. /**
  52985. * The Physically based material base class of BJS.
  52986. *
  52987. * This offers the main features of a standard PBR material.
  52988. * For more information, please refer to the documentation :
  52989. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52990. */
  52991. export abstract class PBRBaseMaterial extends PushMaterial {
  52992. /**
  52993. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52994. */
  52995. static readonly PBRMATERIAL_OPAQUE: number;
  52996. /**
  52997. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52998. */
  52999. static readonly PBRMATERIAL_ALPHATEST: number;
  53000. /**
  53001. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53002. */
  53003. static readonly PBRMATERIAL_ALPHABLEND: number;
  53004. /**
  53005. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53006. * They are also discarded below the alpha cutoff threshold to improve performances.
  53007. */
  53008. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53009. /**
  53010. * Defines the default value of how much AO map is occluding the analytical lights
  53011. * (point spot...).
  53012. */
  53013. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53014. /**
  53015. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53016. */
  53017. static readonly LIGHTFALLOFF_PHYSICAL: number;
  53018. /**
  53019. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53020. * to enhance interoperability with other engines.
  53021. */
  53022. static readonly LIGHTFALLOFF_GLTF: number;
  53023. /**
  53024. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53025. * to enhance interoperability with other materials.
  53026. */
  53027. static readonly LIGHTFALLOFF_STANDARD: number;
  53028. /**
  53029. * Intensity of the direct lights e.g. the four lights available in your scene.
  53030. * This impacts both the direct diffuse and specular highlights.
  53031. */
  53032. protected _directIntensity: number;
  53033. /**
  53034. * Intensity of the emissive part of the material.
  53035. * This helps controlling the emissive effect without modifying the emissive color.
  53036. */
  53037. protected _emissiveIntensity: number;
  53038. /**
  53039. * Intensity of the environment e.g. how much the environment will light the object
  53040. * either through harmonics for rough material or through the refelction for shiny ones.
  53041. */
  53042. protected _environmentIntensity: number;
  53043. /**
  53044. * This is a special control allowing the reduction of the specular highlights coming from the
  53045. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53046. */
  53047. protected _specularIntensity: number;
  53048. /**
  53049. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  53050. */
  53051. private _lightingInfos;
  53052. /**
  53053. * Debug Control allowing disabling the bump map on this material.
  53054. */
  53055. protected _disableBumpMap: boolean;
  53056. /**
  53057. * AKA Diffuse Texture in standard nomenclature.
  53058. */
  53059. protected _albedoTexture: Nullable<BaseTexture>;
  53060. /**
  53061. * AKA Occlusion Texture in other nomenclature.
  53062. */
  53063. protected _ambientTexture: Nullable<BaseTexture>;
  53064. /**
  53065. * AKA Occlusion Texture Intensity in other nomenclature.
  53066. */
  53067. protected _ambientTextureStrength: number;
  53068. /**
  53069. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53070. * 1 means it completely occludes it
  53071. * 0 mean it has no impact
  53072. */
  53073. protected _ambientTextureImpactOnAnalyticalLights: number;
  53074. /**
  53075. * Stores the alpha values in a texture.
  53076. */
  53077. protected _opacityTexture: Nullable<BaseTexture>;
  53078. /**
  53079. * Stores the reflection values in a texture.
  53080. */
  53081. protected _reflectionTexture: Nullable<BaseTexture>;
  53082. /**
  53083. * Stores the emissive values in a texture.
  53084. */
  53085. protected _emissiveTexture: Nullable<BaseTexture>;
  53086. /**
  53087. * AKA Specular texture in other nomenclature.
  53088. */
  53089. protected _reflectivityTexture: Nullable<BaseTexture>;
  53090. /**
  53091. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53092. */
  53093. protected _metallicTexture: Nullable<BaseTexture>;
  53094. /**
  53095. * Specifies the metallic scalar of the metallic/roughness workflow.
  53096. * Can also be used to scale the metalness values of the metallic texture.
  53097. */
  53098. protected _metallic: Nullable<number>;
  53099. /**
  53100. * Specifies the roughness scalar of the metallic/roughness workflow.
  53101. * Can also be used to scale the roughness values of the metallic texture.
  53102. */
  53103. protected _roughness: Nullable<number>;
  53104. /**
  53105. * Specifies the an F0 factor to help configuring the material F0.
  53106. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53107. * to 0.5 the previously hard coded value stays the same.
  53108. * Can also be used to scale the F0 values of the metallic texture.
  53109. */
  53110. protected _metallicF0Factor: number;
  53111. /**
  53112. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53113. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53114. * your expectation as it multiplies with the texture data.
  53115. */
  53116. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  53117. /**
  53118. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53119. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53120. */
  53121. protected _microSurfaceTexture: Nullable<BaseTexture>;
  53122. /**
  53123. * Stores surface normal data used to displace a mesh in a texture.
  53124. */
  53125. protected _bumpTexture: Nullable<BaseTexture>;
  53126. /**
  53127. * Stores the pre-calculated light information of a mesh in a texture.
  53128. */
  53129. protected _lightmapTexture: Nullable<BaseTexture>;
  53130. /**
  53131. * The color of a material in ambient lighting.
  53132. */
  53133. protected _ambientColor: Color3;
  53134. /**
  53135. * AKA Diffuse Color in other nomenclature.
  53136. */
  53137. protected _albedoColor: Color3;
  53138. /**
  53139. * AKA Specular Color in other nomenclature.
  53140. */
  53141. protected _reflectivityColor: Color3;
  53142. /**
  53143. * The color applied when light is reflected from a material.
  53144. */
  53145. protected _reflectionColor: Color3;
  53146. /**
  53147. * The color applied when light is emitted from a material.
  53148. */
  53149. protected _emissiveColor: Color3;
  53150. /**
  53151. * AKA Glossiness in other nomenclature.
  53152. */
  53153. protected _microSurface: number;
  53154. /**
  53155. * Specifies that the material will use the light map as a show map.
  53156. */
  53157. protected _useLightmapAsShadowmap: boolean;
  53158. /**
  53159. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53160. * makes the reflect vector face the model (under horizon).
  53161. */
  53162. protected _useHorizonOcclusion: boolean;
  53163. /**
  53164. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53165. * too much the area relying on ambient texture to define their ambient occlusion.
  53166. */
  53167. protected _useRadianceOcclusion: boolean;
  53168. /**
  53169. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53170. */
  53171. protected _useAlphaFromAlbedoTexture: boolean;
  53172. /**
  53173. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53174. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53175. */
  53176. protected _useSpecularOverAlpha: boolean;
  53177. /**
  53178. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53179. */
  53180. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53181. /**
  53182. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53183. */
  53184. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  53185. /**
  53186. * Specifies if the metallic texture contains the roughness information in its green channel.
  53187. */
  53188. protected _useRoughnessFromMetallicTextureGreen: boolean;
  53189. /**
  53190. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53191. */
  53192. protected _useMetallnessFromMetallicTextureBlue: boolean;
  53193. /**
  53194. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53195. */
  53196. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  53197. /**
  53198. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53199. */
  53200. protected _useAmbientInGrayScale: boolean;
  53201. /**
  53202. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53203. * The material will try to infer what glossiness each pixel should be.
  53204. */
  53205. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  53206. /**
  53207. * Defines the falloff type used in this material.
  53208. * It by default is Physical.
  53209. */
  53210. protected _lightFalloff: number;
  53211. /**
  53212. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53213. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53214. */
  53215. protected _useRadianceOverAlpha: boolean;
  53216. /**
  53217. * Allows using an object space normal map (instead of tangent space).
  53218. */
  53219. protected _useObjectSpaceNormalMap: boolean;
  53220. /**
  53221. * Allows using the bump map in parallax mode.
  53222. */
  53223. protected _useParallax: boolean;
  53224. /**
  53225. * Allows using the bump map in parallax occlusion mode.
  53226. */
  53227. protected _useParallaxOcclusion: boolean;
  53228. /**
  53229. * Controls the scale bias of the parallax mode.
  53230. */
  53231. protected _parallaxScaleBias: number;
  53232. /**
  53233. * If sets to true, disables all the lights affecting the material.
  53234. */
  53235. protected _disableLighting: boolean;
  53236. /**
  53237. * Number of Simultaneous lights allowed on the material.
  53238. */
  53239. protected _maxSimultaneousLights: number;
  53240. /**
  53241. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53242. */
  53243. protected _invertNormalMapX: boolean;
  53244. /**
  53245. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53246. */
  53247. protected _invertNormalMapY: boolean;
  53248. /**
  53249. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53250. */
  53251. protected _twoSidedLighting: boolean;
  53252. /**
  53253. * Defines the alpha limits in alpha test mode.
  53254. */
  53255. protected _alphaCutOff: number;
  53256. /**
  53257. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53258. */
  53259. protected _forceAlphaTest: boolean;
  53260. /**
  53261. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53262. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53263. */
  53264. protected _useAlphaFresnel: boolean;
  53265. /**
  53266. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53267. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53268. */
  53269. protected _useLinearAlphaFresnel: boolean;
  53270. /**
  53271. * The transparency mode of the material.
  53272. */
  53273. protected _transparencyMode: Nullable<number>;
  53274. /**
  53275. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  53276. * from cos thetav and roughness:
  53277. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  53278. */
  53279. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  53280. /**
  53281. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53282. */
  53283. protected _forceIrradianceInFragment: boolean;
  53284. /**
  53285. * Force normal to face away from face.
  53286. */
  53287. protected _forceNormalForward: boolean;
  53288. /**
  53289. * Enables specular anti aliasing in the PBR shader.
  53290. * It will both interacts on the Geometry for analytical and IBL lighting.
  53291. * It also prefilter the roughness map based on the bump values.
  53292. */
  53293. protected _enableSpecularAntiAliasing: boolean;
  53294. /**
  53295. * Default configuration related to image processing available in the PBR Material.
  53296. */
  53297. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53298. /**
  53299. * Keep track of the image processing observer to allow dispose and replace.
  53300. */
  53301. private _imageProcessingObserver;
  53302. /**
  53303. * Attaches a new image processing configuration to the PBR Material.
  53304. * @param configuration
  53305. */
  53306. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53307. /**
  53308. * Stores the available render targets.
  53309. */
  53310. private _renderTargets;
  53311. /**
  53312. * Sets the global ambient color for the material used in lighting calculations.
  53313. */
  53314. private _globalAmbientColor;
  53315. /**
  53316. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  53317. */
  53318. private _useLogarithmicDepth;
  53319. /**
  53320. * If set to true, no lighting calculations will be applied.
  53321. */
  53322. private _unlit;
  53323. private _debugMode;
  53324. /**
  53325. * @hidden
  53326. * This is reserved for the inspector.
  53327. * Defines the material debug mode.
  53328. * It helps seeing only some components of the material while troubleshooting.
  53329. */
  53330. debugMode: number;
  53331. /**
  53332. * @hidden
  53333. * This is reserved for the inspector.
  53334. * Specify from where on screen the debug mode should start.
  53335. * The value goes from -1 (full screen) to 1 (not visible)
  53336. * It helps with side by side comparison against the final render
  53337. * This defaults to -1
  53338. */
  53339. private debugLimit;
  53340. /**
  53341. * @hidden
  53342. * This is reserved for the inspector.
  53343. * As the default viewing range might not be enough (if the ambient is really small for instance)
  53344. * You can use the factor to better multiply the final value.
  53345. */
  53346. private debugFactor;
  53347. /**
  53348. * Defines the clear coat layer parameters for the material.
  53349. */
  53350. readonly clearCoat: PBRClearCoatConfiguration;
  53351. /**
  53352. * Defines the anisotropic parameters for the material.
  53353. */
  53354. readonly anisotropy: PBRAnisotropicConfiguration;
  53355. /**
  53356. * Defines the BRDF parameters for the material.
  53357. */
  53358. readonly brdf: PBRBRDFConfiguration;
  53359. /**
  53360. * Defines the Sheen parameters for the material.
  53361. */
  53362. readonly sheen: PBRSheenConfiguration;
  53363. /**
  53364. * Defines the SubSurface parameters for the material.
  53365. */
  53366. readonly subSurface: PBRSubSurfaceConfiguration;
  53367. /**
  53368. * Custom callback helping to override the default shader used in the material.
  53369. */
  53370. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  53371. protected _rebuildInParallel: boolean;
  53372. /**
  53373. * Instantiates a new PBRMaterial instance.
  53374. *
  53375. * @param name The material name
  53376. * @param scene The scene the material will be use in.
  53377. */
  53378. constructor(name: string, scene: Scene);
  53379. /**
  53380. * Gets a boolean indicating that current material needs to register RTT
  53381. */
  53382. get hasRenderTargetTextures(): boolean;
  53383. /**
  53384. * Gets the name of the material class.
  53385. */
  53386. getClassName(): string;
  53387. /**
  53388. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53389. */
  53390. get useLogarithmicDepth(): boolean;
  53391. /**
  53392. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53393. */
  53394. set useLogarithmicDepth(value: boolean);
  53395. /**
  53396. * Gets the current transparency mode.
  53397. */
  53398. get transparencyMode(): Nullable<number>;
  53399. /**
  53400. * Sets the transparency mode of the material.
  53401. *
  53402. * | Value | Type | Description |
  53403. * | ----- | ----------------------------------- | ----------- |
  53404. * | 0 | OPAQUE | |
  53405. * | 1 | ALPHATEST | |
  53406. * | 2 | ALPHABLEND | |
  53407. * | 3 | ALPHATESTANDBLEND | |
  53408. *
  53409. */
  53410. set transparencyMode(value: Nullable<number>);
  53411. /**
  53412. * Returns true if alpha blending should be disabled.
  53413. */
  53414. private get _disableAlphaBlending();
  53415. /**
  53416. * Specifies whether or not this material should be rendered in alpha blend mode.
  53417. */
  53418. needAlphaBlending(): boolean;
  53419. /**
  53420. * Specifies if the mesh will require alpha blending.
  53421. * @param mesh - BJS mesh.
  53422. */
  53423. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  53424. /**
  53425. * Specifies whether or not this material should be rendered in alpha test mode.
  53426. */
  53427. needAlphaTesting(): boolean;
  53428. /**
  53429. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  53430. */
  53431. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  53432. /**
  53433. * Gets the texture used for the alpha test.
  53434. */
  53435. getAlphaTestTexture(): Nullable<BaseTexture>;
  53436. /**
  53437. * Specifies that the submesh is ready to be used.
  53438. * @param mesh - BJS mesh.
  53439. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  53440. * @param useInstances - Specifies that instances should be used.
  53441. * @returns - boolean indicating that the submesh is ready or not.
  53442. */
  53443. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53444. /**
  53445. * Specifies if the material uses metallic roughness workflow.
  53446. * @returns boolean specifiying if the material uses metallic roughness workflow.
  53447. */
  53448. isMetallicWorkflow(): boolean;
  53449. private _prepareEffect;
  53450. private _prepareDefines;
  53451. /**
  53452. * Force shader compilation
  53453. */
  53454. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  53455. /**
  53456. * Initializes the uniform buffer layout for the shader.
  53457. */
  53458. buildUniformLayout(): void;
  53459. /**
  53460. * Unbinds the material from the mesh
  53461. */
  53462. unbind(): void;
  53463. /**
  53464. * Binds the submesh data.
  53465. * @param world - The world matrix.
  53466. * @param mesh - The BJS mesh.
  53467. * @param subMesh - A submesh of the BJS mesh.
  53468. */
  53469. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53470. /**
  53471. * Returns the animatable textures.
  53472. * @returns - Array of animatable textures.
  53473. */
  53474. getAnimatables(): IAnimatable[];
  53475. /**
  53476. * Returns the texture used for reflections.
  53477. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  53478. */
  53479. private _getReflectionTexture;
  53480. /**
  53481. * Returns an array of the actively used textures.
  53482. * @returns - Array of BaseTextures
  53483. */
  53484. getActiveTextures(): BaseTexture[];
  53485. /**
  53486. * Checks to see if a texture is used in the material.
  53487. * @param texture - Base texture to use.
  53488. * @returns - Boolean specifying if a texture is used in the material.
  53489. */
  53490. hasTexture(texture: BaseTexture): boolean;
  53491. /**
  53492. * Disposes the resources of the material.
  53493. * @param forceDisposeEffect - Forces the disposal of effects.
  53494. * @param forceDisposeTextures - Forces the disposal of all textures.
  53495. */
  53496. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53497. }
  53498. }
  53499. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  53500. import { Nullable } from "babylonjs/types";
  53501. import { Scene } from "babylonjs/scene";
  53502. import { Color3 } from "babylonjs/Maths/math.color";
  53503. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  53504. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  53505. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53506. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53507. /**
  53508. * The Physically based material of BJS.
  53509. *
  53510. * This offers the main features of a standard PBR material.
  53511. * For more information, please refer to the documentation :
  53512. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53513. */
  53514. export class PBRMaterial extends PBRBaseMaterial {
  53515. /**
  53516. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53517. */
  53518. static readonly PBRMATERIAL_OPAQUE: number;
  53519. /**
  53520. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53521. */
  53522. static readonly PBRMATERIAL_ALPHATEST: number;
  53523. /**
  53524. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53525. */
  53526. static readonly PBRMATERIAL_ALPHABLEND: number;
  53527. /**
  53528. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53529. * They are also discarded below the alpha cutoff threshold to improve performances.
  53530. */
  53531. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53532. /**
  53533. * Defines the default value of how much AO map is occluding the analytical lights
  53534. * (point spot...).
  53535. */
  53536. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53537. /**
  53538. * Intensity of the direct lights e.g. the four lights available in your scene.
  53539. * This impacts both the direct diffuse and specular highlights.
  53540. */
  53541. directIntensity: number;
  53542. /**
  53543. * Intensity of the emissive part of the material.
  53544. * This helps controlling the emissive effect without modifying the emissive color.
  53545. */
  53546. emissiveIntensity: number;
  53547. /**
  53548. * Intensity of the environment e.g. how much the environment will light the object
  53549. * either through harmonics for rough material or through the refelction for shiny ones.
  53550. */
  53551. environmentIntensity: number;
  53552. /**
  53553. * This is a special control allowing the reduction of the specular highlights coming from the
  53554. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53555. */
  53556. specularIntensity: number;
  53557. /**
  53558. * Debug Control allowing disabling the bump map on this material.
  53559. */
  53560. disableBumpMap: boolean;
  53561. /**
  53562. * AKA Diffuse Texture in standard nomenclature.
  53563. */
  53564. albedoTexture: BaseTexture;
  53565. /**
  53566. * AKA Occlusion Texture in other nomenclature.
  53567. */
  53568. ambientTexture: BaseTexture;
  53569. /**
  53570. * AKA Occlusion Texture Intensity in other nomenclature.
  53571. */
  53572. ambientTextureStrength: number;
  53573. /**
  53574. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53575. * 1 means it completely occludes it
  53576. * 0 mean it has no impact
  53577. */
  53578. ambientTextureImpactOnAnalyticalLights: number;
  53579. /**
  53580. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  53581. */
  53582. opacityTexture: BaseTexture;
  53583. /**
  53584. * Stores the reflection values in a texture.
  53585. */
  53586. reflectionTexture: Nullable<BaseTexture>;
  53587. /**
  53588. * Stores the emissive values in a texture.
  53589. */
  53590. emissiveTexture: BaseTexture;
  53591. /**
  53592. * AKA Specular texture in other nomenclature.
  53593. */
  53594. reflectivityTexture: BaseTexture;
  53595. /**
  53596. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53597. */
  53598. metallicTexture: BaseTexture;
  53599. /**
  53600. * Specifies the metallic scalar of the metallic/roughness workflow.
  53601. * Can also be used to scale the metalness values of the metallic texture.
  53602. */
  53603. metallic: Nullable<number>;
  53604. /**
  53605. * Specifies the roughness scalar of the metallic/roughness workflow.
  53606. * Can also be used to scale the roughness values of the metallic texture.
  53607. */
  53608. roughness: Nullable<number>;
  53609. /**
  53610. * Specifies the an F0 factor to help configuring the material F0.
  53611. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53612. * to 0.5 the previously hard coded value stays the same.
  53613. * Can also be used to scale the F0 values of the metallic texture.
  53614. */
  53615. metallicF0Factor: number;
  53616. /**
  53617. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53618. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53619. * your expectation as it multiplies with the texture data.
  53620. */
  53621. useMetallicF0FactorFromMetallicTexture: boolean;
  53622. /**
  53623. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53624. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53625. */
  53626. microSurfaceTexture: BaseTexture;
  53627. /**
  53628. * Stores surface normal data used to displace a mesh in a texture.
  53629. */
  53630. bumpTexture: BaseTexture;
  53631. /**
  53632. * Stores the pre-calculated light information of a mesh in a texture.
  53633. */
  53634. lightmapTexture: BaseTexture;
  53635. /**
  53636. * Stores the refracted light information in a texture.
  53637. */
  53638. get refractionTexture(): Nullable<BaseTexture>;
  53639. set refractionTexture(value: Nullable<BaseTexture>);
  53640. /**
  53641. * The color of a material in ambient lighting.
  53642. */
  53643. ambientColor: Color3;
  53644. /**
  53645. * AKA Diffuse Color in other nomenclature.
  53646. */
  53647. albedoColor: Color3;
  53648. /**
  53649. * AKA Specular Color in other nomenclature.
  53650. */
  53651. reflectivityColor: Color3;
  53652. /**
  53653. * The color reflected from the material.
  53654. */
  53655. reflectionColor: Color3;
  53656. /**
  53657. * The color emitted from the material.
  53658. */
  53659. emissiveColor: Color3;
  53660. /**
  53661. * AKA Glossiness in other nomenclature.
  53662. */
  53663. microSurface: number;
  53664. /**
  53665. * source material index of refraction (IOR)' / 'destination material IOR.
  53666. */
  53667. get indexOfRefraction(): number;
  53668. set indexOfRefraction(value: number);
  53669. /**
  53670. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53671. */
  53672. get invertRefractionY(): boolean;
  53673. set invertRefractionY(value: boolean);
  53674. /**
  53675. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53676. * Materials half opaque for instance using refraction could benefit from this control.
  53677. */
  53678. get linkRefractionWithTransparency(): boolean;
  53679. set linkRefractionWithTransparency(value: boolean);
  53680. /**
  53681. * If true, the light map contains occlusion information instead of lighting info.
  53682. */
  53683. useLightmapAsShadowmap: boolean;
  53684. /**
  53685. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53686. */
  53687. useAlphaFromAlbedoTexture: boolean;
  53688. /**
  53689. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53690. */
  53691. forceAlphaTest: boolean;
  53692. /**
  53693. * Defines the alpha limits in alpha test mode.
  53694. */
  53695. alphaCutOff: number;
  53696. /**
  53697. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  53698. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53699. */
  53700. useSpecularOverAlpha: boolean;
  53701. /**
  53702. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53703. */
  53704. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53705. /**
  53706. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53707. */
  53708. useRoughnessFromMetallicTextureAlpha: boolean;
  53709. /**
  53710. * Specifies if the metallic texture contains the roughness information in its green channel.
  53711. */
  53712. useRoughnessFromMetallicTextureGreen: boolean;
  53713. /**
  53714. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53715. */
  53716. useMetallnessFromMetallicTextureBlue: boolean;
  53717. /**
  53718. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53719. */
  53720. useAmbientOcclusionFromMetallicTextureRed: boolean;
  53721. /**
  53722. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53723. */
  53724. useAmbientInGrayScale: boolean;
  53725. /**
  53726. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53727. * The material will try to infer what glossiness each pixel should be.
  53728. */
  53729. useAutoMicroSurfaceFromReflectivityMap: boolean;
  53730. /**
  53731. * BJS is using an harcoded light falloff based on a manually sets up range.
  53732. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53733. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53734. */
  53735. get usePhysicalLightFalloff(): boolean;
  53736. /**
  53737. * BJS is using an harcoded light falloff based on a manually sets up range.
  53738. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53739. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53740. */
  53741. set usePhysicalLightFalloff(value: boolean);
  53742. /**
  53743. * In order to support the falloff compatibility with gltf, a special mode has been added
  53744. * to reproduce the gltf light falloff.
  53745. */
  53746. get useGLTFLightFalloff(): boolean;
  53747. /**
  53748. * In order to support the falloff compatibility with gltf, a special mode has been added
  53749. * to reproduce the gltf light falloff.
  53750. */
  53751. set useGLTFLightFalloff(value: boolean);
  53752. /**
  53753. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53754. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53755. */
  53756. useRadianceOverAlpha: boolean;
  53757. /**
  53758. * Allows using an object space normal map (instead of tangent space).
  53759. */
  53760. useObjectSpaceNormalMap: boolean;
  53761. /**
  53762. * Allows using the bump map in parallax mode.
  53763. */
  53764. useParallax: boolean;
  53765. /**
  53766. * Allows using the bump map in parallax occlusion mode.
  53767. */
  53768. useParallaxOcclusion: boolean;
  53769. /**
  53770. * Controls the scale bias of the parallax mode.
  53771. */
  53772. parallaxScaleBias: number;
  53773. /**
  53774. * If sets to true, disables all the lights affecting the material.
  53775. */
  53776. disableLighting: boolean;
  53777. /**
  53778. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53779. */
  53780. forceIrradianceInFragment: boolean;
  53781. /**
  53782. * Number of Simultaneous lights allowed on the material.
  53783. */
  53784. maxSimultaneousLights: number;
  53785. /**
  53786. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53787. */
  53788. invertNormalMapX: boolean;
  53789. /**
  53790. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53791. */
  53792. invertNormalMapY: boolean;
  53793. /**
  53794. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53795. */
  53796. twoSidedLighting: boolean;
  53797. /**
  53798. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53799. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53800. */
  53801. useAlphaFresnel: boolean;
  53802. /**
  53803. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53804. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53805. */
  53806. useLinearAlphaFresnel: boolean;
  53807. /**
  53808. * Let user defines the brdf lookup texture used for IBL.
  53809. * A default 8bit version is embedded but you could point at :
  53810. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  53811. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  53812. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  53813. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  53814. */
  53815. environmentBRDFTexture: Nullable<BaseTexture>;
  53816. /**
  53817. * Force normal to face away from face.
  53818. */
  53819. forceNormalForward: boolean;
  53820. /**
  53821. * Enables specular anti aliasing in the PBR shader.
  53822. * It will both interacts on the Geometry for analytical and IBL lighting.
  53823. * It also prefilter the roughness map based on the bump values.
  53824. */
  53825. enableSpecularAntiAliasing: boolean;
  53826. /**
  53827. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53828. * makes the reflect vector face the model (under horizon).
  53829. */
  53830. useHorizonOcclusion: boolean;
  53831. /**
  53832. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53833. * too much the area relying on ambient texture to define their ambient occlusion.
  53834. */
  53835. useRadianceOcclusion: boolean;
  53836. /**
  53837. * If set to true, no lighting calculations will be applied.
  53838. */
  53839. unlit: boolean;
  53840. /**
  53841. * Gets the image processing configuration used either in this material.
  53842. */
  53843. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  53844. /**
  53845. * Sets the Default image processing configuration used either in the this material.
  53846. *
  53847. * If sets to null, the scene one is in use.
  53848. */
  53849. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  53850. /**
  53851. * Gets wether the color curves effect is enabled.
  53852. */
  53853. get cameraColorCurvesEnabled(): boolean;
  53854. /**
  53855. * Sets wether the color curves effect is enabled.
  53856. */
  53857. set cameraColorCurvesEnabled(value: boolean);
  53858. /**
  53859. * Gets wether the color grading effect is enabled.
  53860. */
  53861. get cameraColorGradingEnabled(): boolean;
  53862. /**
  53863. * Gets wether the color grading effect is enabled.
  53864. */
  53865. set cameraColorGradingEnabled(value: boolean);
  53866. /**
  53867. * Gets wether tonemapping is enabled or not.
  53868. */
  53869. get cameraToneMappingEnabled(): boolean;
  53870. /**
  53871. * Sets wether tonemapping is enabled or not
  53872. */
  53873. set cameraToneMappingEnabled(value: boolean);
  53874. /**
  53875. * The camera exposure used on this material.
  53876. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53877. * This corresponds to a photographic exposure.
  53878. */
  53879. get cameraExposure(): number;
  53880. /**
  53881. * The camera exposure used on this material.
  53882. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53883. * This corresponds to a photographic exposure.
  53884. */
  53885. set cameraExposure(value: number);
  53886. /**
  53887. * Gets The camera contrast used on this material.
  53888. */
  53889. get cameraContrast(): number;
  53890. /**
  53891. * Sets The camera contrast used on this material.
  53892. */
  53893. set cameraContrast(value: number);
  53894. /**
  53895. * Gets the Color Grading 2D Lookup Texture.
  53896. */
  53897. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  53898. /**
  53899. * Sets the Color Grading 2D Lookup Texture.
  53900. */
  53901. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  53902. /**
  53903. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53904. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53905. * 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;
  53906. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53907. */
  53908. get cameraColorCurves(): Nullable<ColorCurves>;
  53909. /**
  53910. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53911. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53912. * 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;
  53913. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53914. */
  53915. set cameraColorCurves(value: Nullable<ColorCurves>);
  53916. /**
  53917. * Instantiates a new PBRMaterial instance.
  53918. *
  53919. * @param name The material name
  53920. * @param scene The scene the material will be use in.
  53921. */
  53922. constructor(name: string, scene: Scene);
  53923. /**
  53924. * Returns the name of this material class.
  53925. */
  53926. getClassName(): string;
  53927. /**
  53928. * Makes a duplicate of the current material.
  53929. * @param name - name to use for the new material.
  53930. */
  53931. clone(name: string): PBRMaterial;
  53932. /**
  53933. * Serializes this PBR Material.
  53934. * @returns - An object with the serialized material.
  53935. */
  53936. serialize(): any;
  53937. /**
  53938. * Parses a PBR Material from a serialized object.
  53939. * @param source - Serialized object.
  53940. * @param scene - BJS scene instance.
  53941. * @param rootUrl - url for the scene object
  53942. * @returns - PBRMaterial
  53943. */
  53944. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  53945. }
  53946. }
  53947. declare module "babylonjs/Misc/dds" {
  53948. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53949. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53950. import { Nullable } from "babylonjs/types";
  53951. import { Scene } from "babylonjs/scene";
  53952. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  53953. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  53954. /**
  53955. * Direct draw surface info
  53956. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  53957. */
  53958. export interface DDSInfo {
  53959. /**
  53960. * Width of the texture
  53961. */
  53962. width: number;
  53963. /**
  53964. * Width of the texture
  53965. */
  53966. height: number;
  53967. /**
  53968. * Number of Mipmaps for the texture
  53969. * @see https://en.wikipedia.org/wiki/Mipmap
  53970. */
  53971. mipmapCount: number;
  53972. /**
  53973. * If the textures format is a known fourCC format
  53974. * @see https://www.fourcc.org/
  53975. */
  53976. isFourCC: boolean;
  53977. /**
  53978. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  53979. */
  53980. isRGB: boolean;
  53981. /**
  53982. * If the texture is a lumincance format
  53983. */
  53984. isLuminance: boolean;
  53985. /**
  53986. * If this is a cube texture
  53987. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  53988. */
  53989. isCube: boolean;
  53990. /**
  53991. * If the texture is a compressed format eg. FOURCC_DXT1
  53992. */
  53993. isCompressed: boolean;
  53994. /**
  53995. * The dxgiFormat of the texture
  53996. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  53997. */
  53998. dxgiFormat: number;
  53999. /**
  54000. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  54001. */
  54002. textureType: number;
  54003. /**
  54004. * Sphericle polynomial created for the dds texture
  54005. */
  54006. sphericalPolynomial?: SphericalPolynomial;
  54007. }
  54008. /**
  54009. * Class used to provide DDS decompression tools
  54010. */
  54011. export class DDSTools {
  54012. /**
  54013. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  54014. */
  54015. static StoreLODInAlphaChannel: boolean;
  54016. /**
  54017. * Gets DDS information from an array buffer
  54018. * @param data defines the array buffer view to read data from
  54019. * @returns the DDS information
  54020. */
  54021. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  54022. private static _FloatView;
  54023. private static _Int32View;
  54024. private static _ToHalfFloat;
  54025. private static _FromHalfFloat;
  54026. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  54027. private static _GetHalfFloatRGBAArrayBuffer;
  54028. private static _GetFloatRGBAArrayBuffer;
  54029. private static _GetFloatAsUIntRGBAArrayBuffer;
  54030. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  54031. private static _GetRGBAArrayBuffer;
  54032. private static _ExtractLongWordOrder;
  54033. private static _GetRGBArrayBuffer;
  54034. private static _GetLuminanceArrayBuffer;
  54035. /**
  54036. * Uploads DDS Levels to a Babylon Texture
  54037. * @hidden
  54038. */
  54039. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  54040. }
  54041. module "babylonjs/Engines/thinEngine" {
  54042. interface ThinEngine {
  54043. /**
  54044. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  54045. * @param rootUrl defines the url where the file to load is located
  54046. * @param scene defines the current scene
  54047. * @param lodScale defines scale to apply to the mip map selection
  54048. * @param lodOffset defines offset to apply to the mip map selection
  54049. * @param onLoad defines an optional callback raised when the texture is loaded
  54050. * @param onError defines an optional callback raised if there is an issue to load the texture
  54051. * @param format defines the format of the data
  54052. * @param forcedExtension defines the extension to use to pick the right loader
  54053. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  54054. * @returns the cube texture as an InternalTexture
  54055. */
  54056. 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;
  54057. }
  54058. }
  54059. }
  54060. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  54061. import { Nullable } from "babylonjs/types";
  54062. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54063. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54064. /**
  54065. * Implementation of the DDS Texture Loader.
  54066. * @hidden
  54067. */
  54068. export class _DDSTextureLoader implements IInternalTextureLoader {
  54069. /**
  54070. * Defines wether the loader supports cascade loading the different faces.
  54071. */
  54072. readonly supportCascades: boolean;
  54073. /**
  54074. * This returns if the loader support the current file information.
  54075. * @param extension defines the file extension of the file being loaded
  54076. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54077. * @param fallback defines the fallback internal texture if any
  54078. * @param isBase64 defines whether the texture is encoded as a base64
  54079. * @param isBuffer defines whether the texture data are stored as a buffer
  54080. * @returns true if the loader can load the specified file
  54081. */
  54082. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54083. /**
  54084. * Transform the url before loading if required.
  54085. * @param rootUrl the url of the texture
  54086. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54087. * @returns the transformed texture
  54088. */
  54089. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54090. /**
  54091. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54092. * @param rootUrl the url of the texture
  54093. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54094. * @returns the fallback texture
  54095. */
  54096. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54097. /**
  54098. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54099. * @param data contains the texture data
  54100. * @param texture defines the BabylonJS internal texture
  54101. * @param createPolynomials will be true if polynomials have been requested
  54102. * @param onLoad defines the callback to trigger once the texture is ready
  54103. * @param onError defines the callback to trigger in case of error
  54104. */
  54105. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54106. /**
  54107. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54108. * @param data contains the texture data
  54109. * @param texture defines the BabylonJS internal texture
  54110. * @param callback defines the method to call once ready to upload
  54111. */
  54112. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54113. }
  54114. }
  54115. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  54116. import { Nullable } from "babylonjs/types";
  54117. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54118. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54119. /**
  54120. * Implementation of the ENV Texture Loader.
  54121. * @hidden
  54122. */
  54123. export class _ENVTextureLoader implements IInternalTextureLoader {
  54124. /**
  54125. * Defines wether the loader supports cascade loading the different faces.
  54126. */
  54127. readonly supportCascades: boolean;
  54128. /**
  54129. * This returns if the loader support the current file information.
  54130. * @param extension defines the file extension of the file being loaded
  54131. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54132. * @param fallback defines the fallback internal texture if any
  54133. * @param isBase64 defines whether the texture is encoded as a base64
  54134. * @param isBuffer defines whether the texture data are stored as a buffer
  54135. * @returns true if the loader can load the specified file
  54136. */
  54137. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54138. /**
  54139. * Transform the url before loading if required.
  54140. * @param rootUrl the url of the texture
  54141. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54142. * @returns the transformed texture
  54143. */
  54144. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54145. /**
  54146. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54147. * @param rootUrl the url of the texture
  54148. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54149. * @returns the fallback texture
  54150. */
  54151. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54152. /**
  54153. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54154. * @param data contains the texture data
  54155. * @param texture defines the BabylonJS internal texture
  54156. * @param createPolynomials will be true if polynomials have been requested
  54157. * @param onLoad defines the callback to trigger once the texture is ready
  54158. * @param onError defines the callback to trigger in case of error
  54159. */
  54160. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54161. /**
  54162. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54163. * @param data contains the texture data
  54164. * @param texture defines the BabylonJS internal texture
  54165. * @param callback defines the method to call once ready to upload
  54166. */
  54167. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54168. }
  54169. }
  54170. declare module "babylonjs/Misc/khronosTextureContainer" {
  54171. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54172. /**
  54173. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54174. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54175. */
  54176. export class KhronosTextureContainer {
  54177. /** contents of the KTX container file */
  54178. data: ArrayBufferView;
  54179. private static HEADER_LEN;
  54180. private static COMPRESSED_2D;
  54181. private static COMPRESSED_3D;
  54182. private static TEX_2D;
  54183. private static TEX_3D;
  54184. /**
  54185. * Gets the openGL type
  54186. */
  54187. glType: number;
  54188. /**
  54189. * Gets the openGL type size
  54190. */
  54191. glTypeSize: number;
  54192. /**
  54193. * Gets the openGL format
  54194. */
  54195. glFormat: number;
  54196. /**
  54197. * Gets the openGL internal format
  54198. */
  54199. glInternalFormat: number;
  54200. /**
  54201. * Gets the base internal format
  54202. */
  54203. glBaseInternalFormat: number;
  54204. /**
  54205. * Gets image width in pixel
  54206. */
  54207. pixelWidth: number;
  54208. /**
  54209. * Gets image height in pixel
  54210. */
  54211. pixelHeight: number;
  54212. /**
  54213. * Gets image depth in pixels
  54214. */
  54215. pixelDepth: number;
  54216. /**
  54217. * Gets the number of array elements
  54218. */
  54219. numberOfArrayElements: number;
  54220. /**
  54221. * Gets the number of faces
  54222. */
  54223. numberOfFaces: number;
  54224. /**
  54225. * Gets the number of mipmap levels
  54226. */
  54227. numberOfMipmapLevels: number;
  54228. /**
  54229. * Gets the bytes of key value data
  54230. */
  54231. bytesOfKeyValueData: number;
  54232. /**
  54233. * Gets the load type
  54234. */
  54235. loadType: number;
  54236. /**
  54237. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  54238. */
  54239. isInvalid: boolean;
  54240. /**
  54241. * Creates a new KhronosTextureContainer
  54242. * @param data contents of the KTX container file
  54243. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  54244. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  54245. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  54246. */
  54247. constructor(
  54248. /** contents of the KTX container file */
  54249. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  54250. /**
  54251. * Uploads KTX content to a Babylon Texture.
  54252. * It is assumed that the texture has already been created & is currently bound
  54253. * @hidden
  54254. */
  54255. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  54256. private _upload2DCompressedLevels;
  54257. }
  54258. }
  54259. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  54260. import { Nullable } from "babylonjs/types";
  54261. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54262. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54263. /**
  54264. * Implementation of the KTX Texture Loader.
  54265. * @hidden
  54266. */
  54267. export class _KTXTextureLoader implements IInternalTextureLoader {
  54268. /**
  54269. * Defines wether the loader supports cascade loading the different faces.
  54270. */
  54271. readonly supportCascades: boolean;
  54272. /**
  54273. * This returns if the loader support the current file information.
  54274. * @param extension defines the file extension of the file being loaded
  54275. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54276. * @param fallback defines the fallback internal texture if any
  54277. * @param isBase64 defines whether the texture is encoded as a base64
  54278. * @param isBuffer defines whether the texture data are stored as a buffer
  54279. * @returns true if the loader can load the specified file
  54280. */
  54281. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54282. /**
  54283. * Transform the url before loading if required.
  54284. * @param rootUrl the url of the texture
  54285. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54286. * @returns the transformed texture
  54287. */
  54288. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54289. /**
  54290. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54291. * @param rootUrl the url of the texture
  54292. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54293. * @returns the fallback texture
  54294. */
  54295. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54296. /**
  54297. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54298. * @param data contains the texture data
  54299. * @param texture defines the BabylonJS internal texture
  54300. * @param createPolynomials will be true if polynomials have been requested
  54301. * @param onLoad defines the callback to trigger once the texture is ready
  54302. * @param onError defines the callback to trigger in case of error
  54303. */
  54304. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54305. /**
  54306. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54307. * @param data contains the texture data
  54308. * @param texture defines the BabylonJS internal texture
  54309. * @param callback defines the method to call once ready to upload
  54310. */
  54311. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  54312. }
  54313. }
  54314. declare module "babylonjs/Helpers/sceneHelpers" {
  54315. import { Nullable } from "babylonjs/types";
  54316. import { Mesh } from "babylonjs/Meshes/mesh";
  54317. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54318. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  54319. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  54320. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54321. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54322. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54323. import "babylonjs/Meshes/Builders/boxBuilder";
  54324. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  54325. /** @hidden */
  54326. export var _forceSceneHelpersToBundle: boolean;
  54327. module "babylonjs/scene" {
  54328. interface Scene {
  54329. /**
  54330. * Creates a default light for the scene.
  54331. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  54332. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  54333. */
  54334. createDefaultLight(replace?: boolean): void;
  54335. /**
  54336. * Creates a default camera for the scene.
  54337. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  54338. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54339. * @param replace has default false, when true replaces the active camera in the scene
  54340. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  54341. */
  54342. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54343. /**
  54344. * Creates a default camera and a default light.
  54345. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  54346. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54347. * @param replace has the default false, when true replaces the active camera/light in the scene
  54348. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  54349. */
  54350. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54351. /**
  54352. * Creates a new sky box
  54353. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  54354. * @param environmentTexture defines the texture to use as environment texture
  54355. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  54356. * @param scale defines the overall scale of the skybox
  54357. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  54358. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  54359. * @returns a new mesh holding the sky box
  54360. */
  54361. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  54362. /**
  54363. * Creates a new environment
  54364. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  54365. * @param options defines the options you can use to configure the environment
  54366. * @returns the new EnvironmentHelper
  54367. */
  54368. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  54369. /**
  54370. * Creates a new VREXperienceHelper
  54371. * @see http://doc.babylonjs.com/how_to/webvr_helper
  54372. * @param webVROptions defines the options used to create the new VREXperienceHelper
  54373. * @returns a new VREXperienceHelper
  54374. */
  54375. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  54376. /**
  54377. * Creates a new WebXRDefaultExperience
  54378. * @see http://doc.babylonjs.com/how_to/webxr
  54379. * @param options experience options
  54380. * @returns a promise for a new WebXRDefaultExperience
  54381. */
  54382. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54383. }
  54384. }
  54385. }
  54386. declare module "babylonjs/Helpers/videoDome" {
  54387. import { Scene } from "babylonjs/scene";
  54388. import { TransformNode } from "babylonjs/Meshes/transformNode";
  54389. import { Mesh } from "babylonjs/Meshes/mesh";
  54390. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  54391. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  54392. import "babylonjs/Meshes/Builders/sphereBuilder";
  54393. /**
  54394. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  54395. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  54396. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  54397. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54398. */
  54399. export class VideoDome extends TransformNode {
  54400. /**
  54401. * Define the video source as a Monoscopic panoramic 360 video.
  54402. */
  54403. static readonly MODE_MONOSCOPIC: number;
  54404. /**
  54405. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54406. */
  54407. static readonly MODE_TOPBOTTOM: number;
  54408. /**
  54409. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54410. */
  54411. static readonly MODE_SIDEBYSIDE: number;
  54412. private _halfDome;
  54413. private _useDirectMapping;
  54414. /**
  54415. * The video texture being displayed on the sphere
  54416. */
  54417. protected _videoTexture: VideoTexture;
  54418. /**
  54419. * Gets the video texture being displayed on the sphere
  54420. */
  54421. get videoTexture(): VideoTexture;
  54422. /**
  54423. * The skybox material
  54424. */
  54425. protected _material: BackgroundMaterial;
  54426. /**
  54427. * The surface used for the skybox
  54428. */
  54429. protected _mesh: Mesh;
  54430. /**
  54431. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  54432. */
  54433. private _halfDomeMask;
  54434. /**
  54435. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54436. * Also see the options.resolution property.
  54437. */
  54438. get fovMultiplier(): number;
  54439. set fovMultiplier(value: number);
  54440. private _videoMode;
  54441. /**
  54442. * Gets or set the current video mode for the video. It can be:
  54443. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  54444. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54445. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54446. */
  54447. get videoMode(): number;
  54448. set videoMode(value: number);
  54449. /**
  54450. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  54451. *
  54452. */
  54453. get halfDome(): boolean;
  54454. /**
  54455. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  54456. */
  54457. set halfDome(enabled: boolean);
  54458. /**
  54459. * Oberserver used in Stereoscopic VR Mode.
  54460. */
  54461. private _onBeforeCameraRenderObserver;
  54462. /**
  54463. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  54464. * @param name Element's name, child elements will append suffixes for their own names.
  54465. * @param urlsOrVideo defines the url(s) or the video element to use
  54466. * @param options An object containing optional or exposed sub element properties
  54467. */
  54468. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  54469. resolution?: number;
  54470. clickToPlay?: boolean;
  54471. autoPlay?: boolean;
  54472. loop?: boolean;
  54473. size?: number;
  54474. poster?: string;
  54475. faceForward?: boolean;
  54476. useDirectMapping?: boolean;
  54477. halfDomeMode?: boolean;
  54478. }, scene: Scene);
  54479. private _changeVideoMode;
  54480. /**
  54481. * Releases resources associated with this node.
  54482. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54483. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54484. */
  54485. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54486. }
  54487. }
  54488. declare module "babylonjs/Helpers/index" {
  54489. export * from "babylonjs/Helpers/environmentHelper";
  54490. export * from "babylonjs/Helpers/photoDome";
  54491. export * from "babylonjs/Helpers/sceneHelpers";
  54492. export * from "babylonjs/Helpers/videoDome";
  54493. }
  54494. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  54495. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54496. import { IDisposable } from "babylonjs/scene";
  54497. import { Engine } from "babylonjs/Engines/engine";
  54498. /**
  54499. * This class can be used to get instrumentation data from a Babylon engine
  54500. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54501. */
  54502. export class EngineInstrumentation implements IDisposable {
  54503. /**
  54504. * Define the instrumented engine.
  54505. */
  54506. engine: Engine;
  54507. private _captureGPUFrameTime;
  54508. private _gpuFrameTimeToken;
  54509. private _gpuFrameTime;
  54510. private _captureShaderCompilationTime;
  54511. private _shaderCompilationTime;
  54512. private _onBeginFrameObserver;
  54513. private _onEndFrameObserver;
  54514. private _onBeforeShaderCompilationObserver;
  54515. private _onAfterShaderCompilationObserver;
  54516. /**
  54517. * Gets the perf counter used for GPU frame time
  54518. */
  54519. get gpuFrameTimeCounter(): PerfCounter;
  54520. /**
  54521. * Gets the GPU frame time capture status
  54522. */
  54523. get captureGPUFrameTime(): boolean;
  54524. /**
  54525. * Enable or disable the GPU frame time capture
  54526. */
  54527. set captureGPUFrameTime(value: boolean);
  54528. /**
  54529. * Gets the perf counter used for shader compilation time
  54530. */
  54531. get shaderCompilationTimeCounter(): PerfCounter;
  54532. /**
  54533. * Gets the shader compilation time capture status
  54534. */
  54535. get captureShaderCompilationTime(): boolean;
  54536. /**
  54537. * Enable or disable the shader compilation time capture
  54538. */
  54539. set captureShaderCompilationTime(value: boolean);
  54540. /**
  54541. * Instantiates a new engine instrumentation.
  54542. * This class can be used to get instrumentation data from a Babylon engine
  54543. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54544. * @param engine Defines the engine to instrument
  54545. */
  54546. constructor(
  54547. /**
  54548. * Define the instrumented engine.
  54549. */
  54550. engine: Engine);
  54551. /**
  54552. * Dispose and release associated resources.
  54553. */
  54554. dispose(): void;
  54555. }
  54556. }
  54557. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  54558. import { Scene, IDisposable } from "babylonjs/scene";
  54559. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54560. /**
  54561. * This class can be used to get instrumentation data from a Babylon engine
  54562. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54563. */
  54564. export class SceneInstrumentation implements IDisposable {
  54565. /**
  54566. * Defines the scene to instrument
  54567. */
  54568. scene: Scene;
  54569. private _captureActiveMeshesEvaluationTime;
  54570. private _activeMeshesEvaluationTime;
  54571. private _captureRenderTargetsRenderTime;
  54572. private _renderTargetsRenderTime;
  54573. private _captureFrameTime;
  54574. private _frameTime;
  54575. private _captureRenderTime;
  54576. private _renderTime;
  54577. private _captureInterFrameTime;
  54578. private _interFrameTime;
  54579. private _captureParticlesRenderTime;
  54580. private _particlesRenderTime;
  54581. private _captureSpritesRenderTime;
  54582. private _spritesRenderTime;
  54583. private _capturePhysicsTime;
  54584. private _physicsTime;
  54585. private _captureAnimationsTime;
  54586. private _animationsTime;
  54587. private _captureCameraRenderTime;
  54588. private _cameraRenderTime;
  54589. private _onBeforeActiveMeshesEvaluationObserver;
  54590. private _onAfterActiveMeshesEvaluationObserver;
  54591. private _onBeforeRenderTargetsRenderObserver;
  54592. private _onAfterRenderTargetsRenderObserver;
  54593. private _onAfterRenderObserver;
  54594. private _onBeforeDrawPhaseObserver;
  54595. private _onAfterDrawPhaseObserver;
  54596. private _onBeforeAnimationsObserver;
  54597. private _onBeforeParticlesRenderingObserver;
  54598. private _onAfterParticlesRenderingObserver;
  54599. private _onBeforeSpritesRenderingObserver;
  54600. private _onAfterSpritesRenderingObserver;
  54601. private _onBeforePhysicsObserver;
  54602. private _onAfterPhysicsObserver;
  54603. private _onAfterAnimationsObserver;
  54604. private _onBeforeCameraRenderObserver;
  54605. private _onAfterCameraRenderObserver;
  54606. /**
  54607. * Gets the perf counter used for active meshes evaluation time
  54608. */
  54609. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  54610. /**
  54611. * Gets the active meshes evaluation time capture status
  54612. */
  54613. get captureActiveMeshesEvaluationTime(): boolean;
  54614. /**
  54615. * Enable or disable the active meshes evaluation time capture
  54616. */
  54617. set captureActiveMeshesEvaluationTime(value: boolean);
  54618. /**
  54619. * Gets the perf counter used for render targets render time
  54620. */
  54621. get renderTargetsRenderTimeCounter(): PerfCounter;
  54622. /**
  54623. * Gets the render targets render time capture status
  54624. */
  54625. get captureRenderTargetsRenderTime(): boolean;
  54626. /**
  54627. * Enable or disable the render targets render time capture
  54628. */
  54629. set captureRenderTargetsRenderTime(value: boolean);
  54630. /**
  54631. * Gets the perf counter used for particles render time
  54632. */
  54633. get particlesRenderTimeCounter(): PerfCounter;
  54634. /**
  54635. * Gets the particles render time capture status
  54636. */
  54637. get captureParticlesRenderTime(): boolean;
  54638. /**
  54639. * Enable or disable the particles render time capture
  54640. */
  54641. set captureParticlesRenderTime(value: boolean);
  54642. /**
  54643. * Gets the perf counter used for sprites render time
  54644. */
  54645. get spritesRenderTimeCounter(): PerfCounter;
  54646. /**
  54647. * Gets the sprites render time capture status
  54648. */
  54649. get captureSpritesRenderTime(): boolean;
  54650. /**
  54651. * Enable or disable the sprites render time capture
  54652. */
  54653. set captureSpritesRenderTime(value: boolean);
  54654. /**
  54655. * Gets the perf counter used for physics time
  54656. */
  54657. get physicsTimeCounter(): PerfCounter;
  54658. /**
  54659. * Gets the physics time capture status
  54660. */
  54661. get capturePhysicsTime(): boolean;
  54662. /**
  54663. * Enable or disable the physics time capture
  54664. */
  54665. set capturePhysicsTime(value: boolean);
  54666. /**
  54667. * Gets the perf counter used for animations time
  54668. */
  54669. get animationsTimeCounter(): PerfCounter;
  54670. /**
  54671. * Gets the animations time capture status
  54672. */
  54673. get captureAnimationsTime(): boolean;
  54674. /**
  54675. * Enable or disable the animations time capture
  54676. */
  54677. set captureAnimationsTime(value: boolean);
  54678. /**
  54679. * Gets the perf counter used for frame time capture
  54680. */
  54681. get frameTimeCounter(): PerfCounter;
  54682. /**
  54683. * Gets the frame time capture status
  54684. */
  54685. get captureFrameTime(): boolean;
  54686. /**
  54687. * Enable or disable the frame time capture
  54688. */
  54689. set captureFrameTime(value: boolean);
  54690. /**
  54691. * Gets the perf counter used for inter-frames time capture
  54692. */
  54693. get interFrameTimeCounter(): PerfCounter;
  54694. /**
  54695. * Gets the inter-frames time capture status
  54696. */
  54697. get captureInterFrameTime(): boolean;
  54698. /**
  54699. * Enable or disable the inter-frames time capture
  54700. */
  54701. set captureInterFrameTime(value: boolean);
  54702. /**
  54703. * Gets the perf counter used for render time capture
  54704. */
  54705. get renderTimeCounter(): PerfCounter;
  54706. /**
  54707. * Gets the render time capture status
  54708. */
  54709. get captureRenderTime(): boolean;
  54710. /**
  54711. * Enable or disable the render time capture
  54712. */
  54713. set captureRenderTime(value: boolean);
  54714. /**
  54715. * Gets the perf counter used for camera render time capture
  54716. */
  54717. get cameraRenderTimeCounter(): PerfCounter;
  54718. /**
  54719. * Gets the camera render time capture status
  54720. */
  54721. get captureCameraRenderTime(): boolean;
  54722. /**
  54723. * Enable or disable the camera render time capture
  54724. */
  54725. set captureCameraRenderTime(value: boolean);
  54726. /**
  54727. * Gets the perf counter used for draw calls
  54728. */
  54729. get drawCallsCounter(): PerfCounter;
  54730. /**
  54731. * Instantiates a new scene instrumentation.
  54732. * This class can be used to get instrumentation data from a Babylon engine
  54733. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54734. * @param scene Defines the scene to instrument
  54735. */
  54736. constructor(
  54737. /**
  54738. * Defines the scene to instrument
  54739. */
  54740. scene: Scene);
  54741. /**
  54742. * Dispose and release associated resources.
  54743. */
  54744. dispose(): void;
  54745. }
  54746. }
  54747. declare module "babylonjs/Instrumentation/index" {
  54748. export * from "babylonjs/Instrumentation/engineInstrumentation";
  54749. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  54750. export * from "babylonjs/Instrumentation/timeToken";
  54751. }
  54752. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  54753. /** @hidden */
  54754. export var glowMapGenerationPixelShader: {
  54755. name: string;
  54756. shader: string;
  54757. };
  54758. }
  54759. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  54760. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54761. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  54762. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  54763. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54764. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  54765. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54766. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54767. /** @hidden */
  54768. export var glowMapGenerationVertexShader: {
  54769. name: string;
  54770. shader: string;
  54771. };
  54772. }
  54773. declare module "babylonjs/Layers/effectLayer" {
  54774. import { Observable } from "babylonjs/Misc/observable";
  54775. import { Nullable } from "babylonjs/types";
  54776. import { Camera } from "babylonjs/Cameras/camera";
  54777. import { Scene } from "babylonjs/scene";
  54778. import { ISize } from "babylonjs/Maths/math.size";
  54779. import { Color4 } from "babylonjs/Maths/math.color";
  54780. import { Engine } from "babylonjs/Engines/engine";
  54781. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54782. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54783. import { Mesh } from "babylonjs/Meshes/mesh";
  54784. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54785. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54786. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54787. import { Effect } from "babylonjs/Materials/effect";
  54788. import { Material } from "babylonjs/Materials/material";
  54789. import "babylonjs/Shaders/glowMapGeneration.fragment";
  54790. import "babylonjs/Shaders/glowMapGeneration.vertex";
  54791. /**
  54792. * Effect layer options. This helps customizing the behaviour
  54793. * of the effect layer.
  54794. */
  54795. export interface IEffectLayerOptions {
  54796. /**
  54797. * Multiplication factor apply to the canvas size to compute the render target size
  54798. * used to generated the objects (the smaller the faster).
  54799. */
  54800. mainTextureRatio: number;
  54801. /**
  54802. * Enforces a fixed size texture to ensure effect stability across devices.
  54803. */
  54804. mainTextureFixedSize?: number;
  54805. /**
  54806. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  54807. */
  54808. alphaBlendingMode: number;
  54809. /**
  54810. * The camera attached to the layer.
  54811. */
  54812. camera: Nullable<Camera>;
  54813. /**
  54814. * The rendering group to draw the layer in.
  54815. */
  54816. renderingGroupId: number;
  54817. }
  54818. /**
  54819. * The effect layer Helps adding post process effect blended with the main pass.
  54820. *
  54821. * This can be for instance use to generate glow or higlight effects on the scene.
  54822. *
  54823. * The effect layer class can not be used directly and is intented to inherited from to be
  54824. * customized per effects.
  54825. */
  54826. export abstract class EffectLayer {
  54827. private _vertexBuffers;
  54828. private _indexBuffer;
  54829. private _cachedDefines;
  54830. private _effectLayerMapGenerationEffect;
  54831. private _effectLayerOptions;
  54832. private _mergeEffect;
  54833. protected _scene: Scene;
  54834. protected _engine: Engine;
  54835. protected _maxSize: number;
  54836. protected _mainTextureDesiredSize: ISize;
  54837. protected _mainTexture: RenderTargetTexture;
  54838. protected _shouldRender: boolean;
  54839. protected _postProcesses: PostProcess[];
  54840. protected _textures: BaseTexture[];
  54841. protected _emissiveTextureAndColor: {
  54842. texture: Nullable<BaseTexture>;
  54843. color: Color4;
  54844. };
  54845. /**
  54846. * The name of the layer
  54847. */
  54848. name: string;
  54849. /**
  54850. * The clear color of the texture used to generate the glow map.
  54851. */
  54852. neutralColor: Color4;
  54853. /**
  54854. * Specifies whether the highlight layer is enabled or not.
  54855. */
  54856. isEnabled: boolean;
  54857. /**
  54858. * Gets the camera attached to the layer.
  54859. */
  54860. get camera(): Nullable<Camera>;
  54861. /**
  54862. * Gets the rendering group id the layer should render in.
  54863. */
  54864. get renderingGroupId(): number;
  54865. set renderingGroupId(renderingGroupId: number);
  54866. /**
  54867. * An event triggered when the effect layer has been disposed.
  54868. */
  54869. onDisposeObservable: Observable<EffectLayer>;
  54870. /**
  54871. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  54872. */
  54873. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  54874. /**
  54875. * An event triggered when the generated texture is being merged in the scene.
  54876. */
  54877. onBeforeComposeObservable: Observable<EffectLayer>;
  54878. /**
  54879. * An event triggered when the mesh is rendered into the effect render target.
  54880. */
  54881. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  54882. /**
  54883. * An event triggered after the mesh has been rendered into the effect render target.
  54884. */
  54885. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  54886. /**
  54887. * An event triggered when the generated texture has been merged in the scene.
  54888. */
  54889. onAfterComposeObservable: Observable<EffectLayer>;
  54890. /**
  54891. * An event triggered when the efffect layer changes its size.
  54892. */
  54893. onSizeChangedObservable: Observable<EffectLayer>;
  54894. /** @hidden */
  54895. static _SceneComponentInitialization: (scene: Scene) => void;
  54896. /**
  54897. * Instantiates a new effect Layer and references it in the scene.
  54898. * @param name The name of the layer
  54899. * @param scene The scene to use the layer in
  54900. */
  54901. constructor(
  54902. /** The Friendly of the effect in the scene */
  54903. name: string, scene: Scene);
  54904. /**
  54905. * Get the effect name of the layer.
  54906. * @return The effect name
  54907. */
  54908. abstract getEffectName(): string;
  54909. /**
  54910. * Checks for the readiness of the element composing the layer.
  54911. * @param subMesh the mesh to check for
  54912. * @param useInstances specify whether or not to use instances to render the mesh
  54913. * @return true if ready otherwise, false
  54914. */
  54915. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54916. /**
  54917. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  54918. * @returns true if the effect requires stencil during the main canvas render pass.
  54919. */
  54920. abstract needStencil(): boolean;
  54921. /**
  54922. * Create the merge effect. This is the shader use to blit the information back
  54923. * to the main canvas at the end of the scene rendering.
  54924. * @returns The effect containing the shader used to merge the effect on the main canvas
  54925. */
  54926. protected abstract _createMergeEffect(): Effect;
  54927. /**
  54928. * Creates the render target textures and post processes used in the effect layer.
  54929. */
  54930. protected abstract _createTextureAndPostProcesses(): void;
  54931. /**
  54932. * Implementation specific of rendering the generating effect on the main canvas.
  54933. * @param effect The effect used to render through
  54934. */
  54935. protected abstract _internalRender(effect: Effect): void;
  54936. /**
  54937. * Sets the required values for both the emissive texture and and the main color.
  54938. */
  54939. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54940. /**
  54941. * Free any resources and references associated to a mesh.
  54942. * Internal use
  54943. * @param mesh The mesh to free.
  54944. */
  54945. abstract _disposeMesh(mesh: Mesh): void;
  54946. /**
  54947. * Serializes this layer (Glow or Highlight for example)
  54948. * @returns a serialized layer object
  54949. */
  54950. abstract serialize?(): any;
  54951. /**
  54952. * Initializes the effect layer with the required options.
  54953. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  54954. */
  54955. protected _init(options: Partial<IEffectLayerOptions>): void;
  54956. /**
  54957. * Generates the index buffer of the full screen quad blending to the main canvas.
  54958. */
  54959. private _generateIndexBuffer;
  54960. /**
  54961. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  54962. */
  54963. private _generateVertexBuffer;
  54964. /**
  54965. * Sets the main texture desired size which is the closest power of two
  54966. * of the engine canvas size.
  54967. */
  54968. private _setMainTextureSize;
  54969. /**
  54970. * Creates the main texture for the effect layer.
  54971. */
  54972. protected _createMainTexture(): void;
  54973. /**
  54974. * Adds specific effects defines.
  54975. * @param defines The defines to add specifics to.
  54976. */
  54977. protected _addCustomEffectDefines(defines: string[]): void;
  54978. /**
  54979. * Checks for the readiness of the element composing the layer.
  54980. * @param subMesh the mesh to check for
  54981. * @param useInstances specify whether or not to use instances to render the mesh
  54982. * @param emissiveTexture the associated emissive texture used to generate the glow
  54983. * @return true if ready otherwise, false
  54984. */
  54985. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  54986. /**
  54987. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  54988. */
  54989. render(): void;
  54990. /**
  54991. * Determine if a given mesh will be used in the current effect.
  54992. * @param mesh mesh to test
  54993. * @returns true if the mesh will be used
  54994. */
  54995. hasMesh(mesh: AbstractMesh): boolean;
  54996. /**
  54997. * Returns true if the layer contains information to display, otherwise false.
  54998. * @returns true if the glow layer should be rendered
  54999. */
  55000. shouldRender(): boolean;
  55001. /**
  55002. * Returns true if the mesh should render, otherwise false.
  55003. * @param mesh The mesh to render
  55004. * @returns true if it should render otherwise false
  55005. */
  55006. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  55007. /**
  55008. * Returns true if the mesh can be rendered, otherwise false.
  55009. * @param mesh The mesh to render
  55010. * @param material The material used on the mesh
  55011. * @returns true if it can be rendered otherwise false
  55012. */
  55013. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55014. /**
  55015. * Returns true if the mesh should render, otherwise false.
  55016. * @param mesh The mesh to render
  55017. * @returns true if it should render otherwise false
  55018. */
  55019. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  55020. /**
  55021. * Renders the submesh passed in parameter to the generation map.
  55022. */
  55023. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  55024. /**
  55025. * Defines whether the current material of the mesh should be use to render the effect.
  55026. * @param mesh defines the current mesh to render
  55027. */
  55028. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55029. /**
  55030. * Rebuild the required buffers.
  55031. * @hidden Internal use only.
  55032. */
  55033. _rebuild(): void;
  55034. /**
  55035. * Dispose only the render target textures and post process.
  55036. */
  55037. private _disposeTextureAndPostProcesses;
  55038. /**
  55039. * Dispose the highlight layer and free resources.
  55040. */
  55041. dispose(): void;
  55042. /**
  55043. * Gets the class name of the effect layer
  55044. * @returns the string with the class name of the effect layer
  55045. */
  55046. getClassName(): string;
  55047. /**
  55048. * Creates an effect layer from parsed effect layer data
  55049. * @param parsedEffectLayer defines effect layer data
  55050. * @param scene defines the current scene
  55051. * @param rootUrl defines the root URL containing the effect layer information
  55052. * @returns a parsed effect Layer
  55053. */
  55054. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  55055. }
  55056. }
  55057. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  55058. import { Scene } from "babylonjs/scene";
  55059. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55060. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55061. import { AbstractScene } from "babylonjs/abstractScene";
  55062. module "babylonjs/abstractScene" {
  55063. interface AbstractScene {
  55064. /**
  55065. * The list of effect layers (highlights/glow) added to the scene
  55066. * @see http://doc.babylonjs.com/how_to/highlight_layer
  55067. * @see http://doc.babylonjs.com/how_to/glow_layer
  55068. */
  55069. effectLayers: Array<EffectLayer>;
  55070. /**
  55071. * Removes the given effect layer from this scene.
  55072. * @param toRemove defines the effect layer to remove
  55073. * @returns the index of the removed effect layer
  55074. */
  55075. removeEffectLayer(toRemove: EffectLayer): number;
  55076. /**
  55077. * Adds the given effect layer to this scene
  55078. * @param newEffectLayer defines the effect layer to add
  55079. */
  55080. addEffectLayer(newEffectLayer: EffectLayer): void;
  55081. }
  55082. }
  55083. /**
  55084. * Defines the layer scene component responsible to manage any effect layers
  55085. * in a given scene.
  55086. */
  55087. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  55088. /**
  55089. * The component name helpfull to identify the component in the list of scene components.
  55090. */
  55091. readonly name: string;
  55092. /**
  55093. * The scene the component belongs to.
  55094. */
  55095. scene: Scene;
  55096. private _engine;
  55097. private _renderEffects;
  55098. private _needStencil;
  55099. private _previousStencilState;
  55100. /**
  55101. * Creates a new instance of the component for the given scene
  55102. * @param scene Defines the scene to register the component in
  55103. */
  55104. constructor(scene: Scene);
  55105. /**
  55106. * Registers the component in a given scene
  55107. */
  55108. register(): void;
  55109. /**
  55110. * Rebuilds the elements related to this component in case of
  55111. * context lost for instance.
  55112. */
  55113. rebuild(): void;
  55114. /**
  55115. * Serializes the component data to the specified json object
  55116. * @param serializationObject The object to serialize to
  55117. */
  55118. serialize(serializationObject: any): void;
  55119. /**
  55120. * Adds all the elements from the container to the scene
  55121. * @param container the container holding the elements
  55122. */
  55123. addFromContainer(container: AbstractScene): void;
  55124. /**
  55125. * Removes all the elements in the container from the scene
  55126. * @param container contains the elements to remove
  55127. * @param dispose if the removed element should be disposed (default: false)
  55128. */
  55129. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55130. /**
  55131. * Disposes the component and the associated ressources.
  55132. */
  55133. dispose(): void;
  55134. private _isReadyForMesh;
  55135. private _renderMainTexture;
  55136. private _setStencil;
  55137. private _setStencilBack;
  55138. private _draw;
  55139. private _drawCamera;
  55140. private _drawRenderingGroup;
  55141. }
  55142. }
  55143. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  55144. /** @hidden */
  55145. export var glowMapMergePixelShader: {
  55146. name: string;
  55147. shader: string;
  55148. };
  55149. }
  55150. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  55151. /** @hidden */
  55152. export var glowMapMergeVertexShader: {
  55153. name: string;
  55154. shader: string;
  55155. };
  55156. }
  55157. declare module "babylonjs/Layers/glowLayer" {
  55158. import { Nullable } from "babylonjs/types";
  55159. import { Camera } from "babylonjs/Cameras/camera";
  55160. import { Scene } from "babylonjs/scene";
  55161. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55162. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55163. import { Mesh } from "babylonjs/Meshes/mesh";
  55164. import { Texture } from "babylonjs/Materials/Textures/texture";
  55165. import { Effect } from "babylonjs/Materials/effect";
  55166. import { Material } from "babylonjs/Materials/material";
  55167. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55168. import { Color4 } from "babylonjs/Maths/math.color";
  55169. import "babylonjs/Shaders/glowMapMerge.fragment";
  55170. import "babylonjs/Shaders/glowMapMerge.vertex";
  55171. import "babylonjs/Layers/effectLayerSceneComponent";
  55172. module "babylonjs/abstractScene" {
  55173. interface AbstractScene {
  55174. /**
  55175. * Return a the first highlight layer of the scene with a given name.
  55176. * @param name The name of the highlight layer to look for.
  55177. * @return The highlight layer if found otherwise null.
  55178. */
  55179. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  55180. }
  55181. }
  55182. /**
  55183. * Glow layer options. This helps customizing the behaviour
  55184. * of the glow layer.
  55185. */
  55186. export interface IGlowLayerOptions {
  55187. /**
  55188. * Multiplication factor apply to the canvas size to compute the render target size
  55189. * used to generated the glowing objects (the smaller the faster).
  55190. */
  55191. mainTextureRatio: number;
  55192. /**
  55193. * Enforces a fixed size texture to ensure resize independant blur.
  55194. */
  55195. mainTextureFixedSize?: number;
  55196. /**
  55197. * How big is the kernel of the blur texture.
  55198. */
  55199. blurKernelSize: number;
  55200. /**
  55201. * The camera attached to the layer.
  55202. */
  55203. camera: Nullable<Camera>;
  55204. /**
  55205. * Enable MSAA by chosing the number of samples.
  55206. */
  55207. mainTextureSamples?: number;
  55208. /**
  55209. * The rendering group to draw the layer in.
  55210. */
  55211. renderingGroupId: number;
  55212. }
  55213. /**
  55214. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  55215. *
  55216. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  55217. *
  55218. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  55219. */
  55220. export class GlowLayer extends EffectLayer {
  55221. /**
  55222. * Effect Name of the layer.
  55223. */
  55224. static readonly EffectName: string;
  55225. /**
  55226. * The default blur kernel size used for the glow.
  55227. */
  55228. static DefaultBlurKernelSize: number;
  55229. /**
  55230. * The default texture size ratio used for the glow.
  55231. */
  55232. static DefaultTextureRatio: number;
  55233. /**
  55234. * Sets the kernel size of the blur.
  55235. */
  55236. set blurKernelSize(value: number);
  55237. /**
  55238. * Gets the kernel size of the blur.
  55239. */
  55240. get blurKernelSize(): number;
  55241. /**
  55242. * Sets the glow intensity.
  55243. */
  55244. set intensity(value: number);
  55245. /**
  55246. * Gets the glow intensity.
  55247. */
  55248. get intensity(): number;
  55249. private _options;
  55250. private _intensity;
  55251. private _horizontalBlurPostprocess1;
  55252. private _verticalBlurPostprocess1;
  55253. private _horizontalBlurPostprocess2;
  55254. private _verticalBlurPostprocess2;
  55255. private _blurTexture1;
  55256. private _blurTexture2;
  55257. private _postProcesses1;
  55258. private _postProcesses2;
  55259. private _includedOnlyMeshes;
  55260. private _excludedMeshes;
  55261. private _meshesUsingTheirOwnMaterials;
  55262. /**
  55263. * Callback used to let the user override the color selection on a per mesh basis
  55264. */
  55265. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  55266. /**
  55267. * Callback used to let the user override the texture selection on a per mesh basis
  55268. */
  55269. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  55270. /**
  55271. * Instantiates a new glow Layer and references it to the scene.
  55272. * @param name The name of the layer
  55273. * @param scene The scene to use the layer in
  55274. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  55275. */
  55276. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  55277. /**
  55278. * Get the effect name of the layer.
  55279. * @return The effect name
  55280. */
  55281. getEffectName(): string;
  55282. /**
  55283. * Create the merge effect. This is the shader use to blit the information back
  55284. * to the main canvas at the end of the scene rendering.
  55285. */
  55286. protected _createMergeEffect(): Effect;
  55287. /**
  55288. * Creates the render target textures and post processes used in the glow layer.
  55289. */
  55290. protected _createTextureAndPostProcesses(): void;
  55291. /**
  55292. * Checks for the readiness of the element composing the layer.
  55293. * @param subMesh the mesh to check for
  55294. * @param useInstances specify wether or not to use instances to render the mesh
  55295. * @param emissiveTexture the associated emissive texture used to generate the glow
  55296. * @return true if ready otherwise, false
  55297. */
  55298. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55299. /**
  55300. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55301. */
  55302. needStencil(): boolean;
  55303. /**
  55304. * Returns true if the mesh can be rendered, otherwise false.
  55305. * @param mesh The mesh to render
  55306. * @param material The material used on the mesh
  55307. * @returns true if it can be rendered otherwise false
  55308. */
  55309. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55310. /**
  55311. * Implementation specific of rendering the generating effect on the main canvas.
  55312. * @param effect The effect used to render through
  55313. */
  55314. protected _internalRender(effect: Effect): void;
  55315. /**
  55316. * Sets the required values for both the emissive texture and and the main color.
  55317. */
  55318. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55319. /**
  55320. * Returns true if the mesh should render, otherwise false.
  55321. * @param mesh The mesh to render
  55322. * @returns true if it should render otherwise false
  55323. */
  55324. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55325. /**
  55326. * Adds specific effects defines.
  55327. * @param defines The defines to add specifics to.
  55328. */
  55329. protected _addCustomEffectDefines(defines: string[]): void;
  55330. /**
  55331. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  55332. * @param mesh The mesh to exclude from the glow layer
  55333. */
  55334. addExcludedMesh(mesh: Mesh): void;
  55335. /**
  55336. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  55337. * @param mesh The mesh to remove
  55338. */
  55339. removeExcludedMesh(mesh: Mesh): void;
  55340. /**
  55341. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  55342. * @param mesh The mesh to include in the glow layer
  55343. */
  55344. addIncludedOnlyMesh(mesh: Mesh): void;
  55345. /**
  55346. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  55347. * @param mesh The mesh to remove
  55348. */
  55349. removeIncludedOnlyMesh(mesh: Mesh): void;
  55350. /**
  55351. * Determine if a given mesh will be used in the glow layer
  55352. * @param mesh The mesh to test
  55353. * @returns true if the mesh will be highlighted by the current glow layer
  55354. */
  55355. hasMesh(mesh: AbstractMesh): boolean;
  55356. /**
  55357. * Defines whether the current material of the mesh should be use to render the effect.
  55358. * @param mesh defines the current mesh to render
  55359. */
  55360. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55361. /**
  55362. * Add a mesh to be rendered through its own material and not with emissive only.
  55363. * @param mesh The mesh for which we need to use its material
  55364. */
  55365. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  55366. /**
  55367. * Remove a mesh from being rendered through its own material and not with emissive only.
  55368. * @param mesh The mesh for which we need to not use its material
  55369. */
  55370. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  55371. /**
  55372. * Free any resources and references associated to a mesh.
  55373. * Internal use
  55374. * @param mesh The mesh to free.
  55375. * @hidden
  55376. */
  55377. _disposeMesh(mesh: Mesh): void;
  55378. /**
  55379. * Gets the class name of the effect layer
  55380. * @returns the string with the class name of the effect layer
  55381. */
  55382. getClassName(): string;
  55383. /**
  55384. * Serializes this glow layer
  55385. * @returns a serialized glow layer object
  55386. */
  55387. serialize(): any;
  55388. /**
  55389. * Creates a Glow Layer from parsed glow layer data
  55390. * @param parsedGlowLayer defines glow layer data
  55391. * @param scene defines the current scene
  55392. * @param rootUrl defines the root URL containing the glow layer information
  55393. * @returns a parsed Glow Layer
  55394. */
  55395. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  55396. }
  55397. }
  55398. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  55399. /** @hidden */
  55400. export var glowBlurPostProcessPixelShader: {
  55401. name: string;
  55402. shader: string;
  55403. };
  55404. }
  55405. declare module "babylonjs/Layers/highlightLayer" {
  55406. import { Observable } from "babylonjs/Misc/observable";
  55407. import { Nullable } from "babylonjs/types";
  55408. import { Camera } from "babylonjs/Cameras/camera";
  55409. import { Scene } from "babylonjs/scene";
  55410. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55411. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55412. import { Mesh } from "babylonjs/Meshes/mesh";
  55413. import { Effect } from "babylonjs/Materials/effect";
  55414. import { Material } from "babylonjs/Materials/material";
  55415. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55416. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  55417. import "babylonjs/Shaders/glowMapMerge.fragment";
  55418. import "babylonjs/Shaders/glowMapMerge.vertex";
  55419. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  55420. module "babylonjs/abstractScene" {
  55421. interface AbstractScene {
  55422. /**
  55423. * Return a the first highlight layer of the scene with a given name.
  55424. * @param name The name of the highlight layer to look for.
  55425. * @return The highlight layer if found otherwise null.
  55426. */
  55427. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  55428. }
  55429. }
  55430. /**
  55431. * Highlight layer options. This helps customizing the behaviour
  55432. * of the highlight layer.
  55433. */
  55434. export interface IHighlightLayerOptions {
  55435. /**
  55436. * Multiplication factor apply to the canvas size to compute the render target size
  55437. * used to generated the glowing objects (the smaller the faster).
  55438. */
  55439. mainTextureRatio: number;
  55440. /**
  55441. * Enforces a fixed size texture to ensure resize independant blur.
  55442. */
  55443. mainTextureFixedSize?: number;
  55444. /**
  55445. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  55446. * of the picture to blur (the smaller the faster).
  55447. */
  55448. blurTextureSizeRatio: number;
  55449. /**
  55450. * How big in texel of the blur texture is the vertical blur.
  55451. */
  55452. blurVerticalSize: number;
  55453. /**
  55454. * How big in texel of the blur texture is the horizontal blur.
  55455. */
  55456. blurHorizontalSize: number;
  55457. /**
  55458. * Alpha blending mode used to apply the blur. Default is combine.
  55459. */
  55460. alphaBlendingMode: number;
  55461. /**
  55462. * The camera attached to the layer.
  55463. */
  55464. camera: Nullable<Camera>;
  55465. /**
  55466. * Should we display highlight as a solid stroke?
  55467. */
  55468. isStroke?: boolean;
  55469. /**
  55470. * The rendering group to draw the layer in.
  55471. */
  55472. renderingGroupId: number;
  55473. }
  55474. /**
  55475. * The highlight layer Helps adding a glow effect around a mesh.
  55476. *
  55477. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  55478. * glowy meshes to your scene.
  55479. *
  55480. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  55481. */
  55482. export class HighlightLayer extends EffectLayer {
  55483. name: string;
  55484. /**
  55485. * Effect Name of the highlight layer.
  55486. */
  55487. static readonly EffectName: string;
  55488. /**
  55489. * The neutral color used during the preparation of the glow effect.
  55490. * This is black by default as the blend operation is a blend operation.
  55491. */
  55492. static NeutralColor: Color4;
  55493. /**
  55494. * Stencil value used for glowing meshes.
  55495. */
  55496. static GlowingMeshStencilReference: number;
  55497. /**
  55498. * Stencil value used for the other meshes in the scene.
  55499. */
  55500. static NormalMeshStencilReference: number;
  55501. /**
  55502. * Specifies whether or not the inner glow is ACTIVE in the layer.
  55503. */
  55504. innerGlow: boolean;
  55505. /**
  55506. * Specifies whether or not the outer glow is ACTIVE in the layer.
  55507. */
  55508. outerGlow: boolean;
  55509. /**
  55510. * Specifies the horizontal size of the blur.
  55511. */
  55512. set blurHorizontalSize(value: number);
  55513. /**
  55514. * Specifies the vertical size of the blur.
  55515. */
  55516. set blurVerticalSize(value: number);
  55517. /**
  55518. * Gets the horizontal size of the blur.
  55519. */
  55520. get blurHorizontalSize(): number;
  55521. /**
  55522. * Gets the vertical size of the blur.
  55523. */
  55524. get blurVerticalSize(): number;
  55525. /**
  55526. * An event triggered when the highlight layer is being blurred.
  55527. */
  55528. onBeforeBlurObservable: Observable<HighlightLayer>;
  55529. /**
  55530. * An event triggered when the highlight layer has been blurred.
  55531. */
  55532. onAfterBlurObservable: Observable<HighlightLayer>;
  55533. private _instanceGlowingMeshStencilReference;
  55534. private _options;
  55535. private _downSamplePostprocess;
  55536. private _horizontalBlurPostprocess;
  55537. private _verticalBlurPostprocess;
  55538. private _blurTexture;
  55539. private _meshes;
  55540. private _excludedMeshes;
  55541. /**
  55542. * Instantiates a new highlight Layer and references it to the scene..
  55543. * @param name The name of the layer
  55544. * @param scene The scene to use the layer in
  55545. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  55546. */
  55547. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  55548. /**
  55549. * Get the effect name of the layer.
  55550. * @return The effect name
  55551. */
  55552. getEffectName(): string;
  55553. /**
  55554. * Create the merge effect. This is the shader use to blit the information back
  55555. * to the main canvas at the end of the scene rendering.
  55556. */
  55557. protected _createMergeEffect(): Effect;
  55558. /**
  55559. * Creates the render target textures and post processes used in the highlight layer.
  55560. */
  55561. protected _createTextureAndPostProcesses(): void;
  55562. /**
  55563. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55564. */
  55565. needStencil(): boolean;
  55566. /**
  55567. * Checks for the readiness of the element composing the layer.
  55568. * @param subMesh the mesh to check for
  55569. * @param useInstances specify wether or not to use instances to render the mesh
  55570. * @param emissiveTexture the associated emissive texture used to generate the glow
  55571. * @return true if ready otherwise, false
  55572. */
  55573. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55574. /**
  55575. * Implementation specific of rendering the generating effect on the main canvas.
  55576. * @param effect The effect used to render through
  55577. */
  55578. protected _internalRender(effect: Effect): void;
  55579. /**
  55580. * Returns true if the layer contains information to display, otherwise false.
  55581. */
  55582. shouldRender(): boolean;
  55583. /**
  55584. * Returns true if the mesh should render, otherwise false.
  55585. * @param mesh The mesh to render
  55586. * @returns true if it should render otherwise false
  55587. */
  55588. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55589. /**
  55590. * Sets the required values for both the emissive texture and and the main color.
  55591. */
  55592. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55593. /**
  55594. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  55595. * @param mesh The mesh to exclude from the highlight layer
  55596. */
  55597. addExcludedMesh(mesh: Mesh): void;
  55598. /**
  55599. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  55600. * @param mesh The mesh to highlight
  55601. */
  55602. removeExcludedMesh(mesh: Mesh): void;
  55603. /**
  55604. * Determine if a given mesh will be highlighted by the current HighlightLayer
  55605. * @param mesh mesh to test
  55606. * @returns true if the mesh will be highlighted by the current HighlightLayer
  55607. */
  55608. hasMesh(mesh: AbstractMesh): boolean;
  55609. /**
  55610. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  55611. * @param mesh The mesh to highlight
  55612. * @param color The color of the highlight
  55613. * @param glowEmissiveOnly Extract the glow from the emissive texture
  55614. */
  55615. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  55616. /**
  55617. * Remove a mesh from the highlight layer in order to make it stop glowing.
  55618. * @param mesh The mesh to highlight
  55619. */
  55620. removeMesh(mesh: Mesh): void;
  55621. /**
  55622. * Force the stencil to the normal expected value for none glowing parts
  55623. */
  55624. private _defaultStencilReference;
  55625. /**
  55626. * Free any resources and references associated to a mesh.
  55627. * Internal use
  55628. * @param mesh The mesh to free.
  55629. * @hidden
  55630. */
  55631. _disposeMesh(mesh: Mesh): void;
  55632. /**
  55633. * Dispose the highlight layer and free resources.
  55634. */
  55635. dispose(): void;
  55636. /**
  55637. * Gets the class name of the effect layer
  55638. * @returns the string with the class name of the effect layer
  55639. */
  55640. getClassName(): string;
  55641. /**
  55642. * Serializes this Highlight layer
  55643. * @returns a serialized Highlight layer object
  55644. */
  55645. serialize(): any;
  55646. /**
  55647. * Creates a Highlight layer from parsed Highlight layer data
  55648. * @param parsedHightlightLayer defines the Highlight layer data
  55649. * @param scene defines the current scene
  55650. * @param rootUrl defines the root URL containing the Highlight layer information
  55651. * @returns a parsed Highlight layer
  55652. */
  55653. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  55654. }
  55655. }
  55656. declare module "babylonjs/Layers/layerSceneComponent" {
  55657. import { Scene } from "babylonjs/scene";
  55658. import { ISceneComponent } from "babylonjs/sceneComponent";
  55659. import { Layer } from "babylonjs/Layers/layer";
  55660. import { AbstractScene } from "babylonjs/abstractScene";
  55661. module "babylonjs/abstractScene" {
  55662. interface AbstractScene {
  55663. /**
  55664. * The list of layers (background and foreground) of the scene
  55665. */
  55666. layers: Array<Layer>;
  55667. }
  55668. }
  55669. /**
  55670. * Defines the layer scene component responsible to manage any layers
  55671. * in a given scene.
  55672. */
  55673. export class LayerSceneComponent implements ISceneComponent {
  55674. /**
  55675. * The component name helpfull to identify the component in the list of scene components.
  55676. */
  55677. readonly name: string;
  55678. /**
  55679. * The scene the component belongs to.
  55680. */
  55681. scene: Scene;
  55682. private _engine;
  55683. /**
  55684. * Creates a new instance of the component for the given scene
  55685. * @param scene Defines the scene to register the component in
  55686. */
  55687. constructor(scene: Scene);
  55688. /**
  55689. * Registers the component in a given scene
  55690. */
  55691. register(): void;
  55692. /**
  55693. * Rebuilds the elements related to this component in case of
  55694. * context lost for instance.
  55695. */
  55696. rebuild(): void;
  55697. /**
  55698. * Disposes the component and the associated ressources.
  55699. */
  55700. dispose(): void;
  55701. private _draw;
  55702. private _drawCameraPredicate;
  55703. private _drawCameraBackground;
  55704. private _drawCameraForeground;
  55705. private _drawRenderTargetPredicate;
  55706. private _drawRenderTargetBackground;
  55707. private _drawRenderTargetForeground;
  55708. /**
  55709. * Adds all the elements from the container to the scene
  55710. * @param container the container holding the elements
  55711. */
  55712. addFromContainer(container: AbstractScene): void;
  55713. /**
  55714. * Removes all the elements in the container from the scene
  55715. * @param container contains the elements to remove
  55716. * @param dispose if the removed element should be disposed (default: false)
  55717. */
  55718. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55719. }
  55720. }
  55721. declare module "babylonjs/Shaders/layer.fragment" {
  55722. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55723. /** @hidden */
  55724. export var layerPixelShader: {
  55725. name: string;
  55726. shader: string;
  55727. };
  55728. }
  55729. declare module "babylonjs/Shaders/layer.vertex" {
  55730. /** @hidden */
  55731. export var layerVertexShader: {
  55732. name: string;
  55733. shader: string;
  55734. };
  55735. }
  55736. declare module "babylonjs/Layers/layer" {
  55737. import { Observable } from "babylonjs/Misc/observable";
  55738. import { Nullable } from "babylonjs/types";
  55739. import { Scene } from "babylonjs/scene";
  55740. import { Vector2 } from "babylonjs/Maths/math.vector";
  55741. import { Color4 } from "babylonjs/Maths/math.color";
  55742. import { Texture } from "babylonjs/Materials/Textures/texture";
  55743. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55744. import "babylonjs/Shaders/layer.fragment";
  55745. import "babylonjs/Shaders/layer.vertex";
  55746. /**
  55747. * This represents a full screen 2d layer.
  55748. * This can be useful to display a picture in the background of your scene for instance.
  55749. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55750. */
  55751. export class Layer {
  55752. /**
  55753. * Define the name of the layer.
  55754. */
  55755. name: string;
  55756. /**
  55757. * Define the texture the layer should display.
  55758. */
  55759. texture: Nullable<Texture>;
  55760. /**
  55761. * Is the layer in background or foreground.
  55762. */
  55763. isBackground: boolean;
  55764. /**
  55765. * Define the color of the layer (instead of texture).
  55766. */
  55767. color: Color4;
  55768. /**
  55769. * Define the scale of the layer in order to zoom in out of the texture.
  55770. */
  55771. scale: Vector2;
  55772. /**
  55773. * Define an offset for the layer in order to shift the texture.
  55774. */
  55775. offset: Vector2;
  55776. /**
  55777. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  55778. */
  55779. alphaBlendingMode: number;
  55780. /**
  55781. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  55782. * Alpha test will not mix with the background color in case of transparency.
  55783. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  55784. */
  55785. alphaTest: boolean;
  55786. /**
  55787. * Define a mask to restrict the layer to only some of the scene cameras.
  55788. */
  55789. layerMask: number;
  55790. /**
  55791. * Define the list of render target the layer is visible into.
  55792. */
  55793. renderTargetTextures: RenderTargetTexture[];
  55794. /**
  55795. * Define if the layer is only used in renderTarget or if it also
  55796. * renders in the main frame buffer of the canvas.
  55797. */
  55798. renderOnlyInRenderTargetTextures: boolean;
  55799. private _scene;
  55800. private _vertexBuffers;
  55801. private _indexBuffer;
  55802. private _effect;
  55803. private _previousDefines;
  55804. /**
  55805. * An event triggered when the layer is disposed.
  55806. */
  55807. onDisposeObservable: Observable<Layer>;
  55808. private _onDisposeObserver;
  55809. /**
  55810. * Back compatibility with callback before the onDisposeObservable existed.
  55811. * The set callback will be triggered when the layer has been disposed.
  55812. */
  55813. set onDispose(callback: () => void);
  55814. /**
  55815. * An event triggered before rendering the scene
  55816. */
  55817. onBeforeRenderObservable: Observable<Layer>;
  55818. private _onBeforeRenderObserver;
  55819. /**
  55820. * Back compatibility with callback before the onBeforeRenderObservable existed.
  55821. * The set callback will be triggered just before rendering the layer.
  55822. */
  55823. set onBeforeRender(callback: () => void);
  55824. /**
  55825. * An event triggered after rendering the scene
  55826. */
  55827. onAfterRenderObservable: Observable<Layer>;
  55828. private _onAfterRenderObserver;
  55829. /**
  55830. * Back compatibility with callback before the onAfterRenderObservable existed.
  55831. * The set callback will be triggered just after rendering the layer.
  55832. */
  55833. set onAfterRender(callback: () => void);
  55834. /**
  55835. * Instantiates a new layer.
  55836. * This represents a full screen 2d layer.
  55837. * This can be useful to display a picture in the background of your scene for instance.
  55838. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55839. * @param name Define the name of the layer in the scene
  55840. * @param imgUrl Define the url of the texture to display in the layer
  55841. * @param scene Define the scene the layer belongs to
  55842. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  55843. * @param color Defines a color for the layer
  55844. */
  55845. constructor(
  55846. /**
  55847. * Define the name of the layer.
  55848. */
  55849. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  55850. private _createIndexBuffer;
  55851. /** @hidden */
  55852. _rebuild(): void;
  55853. /**
  55854. * Renders the layer in the scene.
  55855. */
  55856. render(): void;
  55857. /**
  55858. * Disposes and releases the associated ressources.
  55859. */
  55860. dispose(): void;
  55861. }
  55862. }
  55863. declare module "babylonjs/Layers/index" {
  55864. export * from "babylonjs/Layers/effectLayer";
  55865. export * from "babylonjs/Layers/effectLayerSceneComponent";
  55866. export * from "babylonjs/Layers/glowLayer";
  55867. export * from "babylonjs/Layers/highlightLayer";
  55868. export * from "babylonjs/Layers/layer";
  55869. export * from "babylonjs/Layers/layerSceneComponent";
  55870. }
  55871. declare module "babylonjs/Shaders/lensFlare.fragment" {
  55872. /** @hidden */
  55873. export var lensFlarePixelShader: {
  55874. name: string;
  55875. shader: string;
  55876. };
  55877. }
  55878. declare module "babylonjs/Shaders/lensFlare.vertex" {
  55879. /** @hidden */
  55880. export var lensFlareVertexShader: {
  55881. name: string;
  55882. shader: string;
  55883. };
  55884. }
  55885. declare module "babylonjs/LensFlares/lensFlareSystem" {
  55886. import { Scene } from "babylonjs/scene";
  55887. import { Vector3 } from "babylonjs/Maths/math.vector";
  55888. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55889. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  55890. import "babylonjs/Shaders/lensFlare.fragment";
  55891. import "babylonjs/Shaders/lensFlare.vertex";
  55892. import { Viewport } from "babylonjs/Maths/math.viewport";
  55893. /**
  55894. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  55895. * It is usually composed of several `lensFlare`.
  55896. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55897. */
  55898. export class LensFlareSystem {
  55899. /**
  55900. * Define the name of the lens flare system
  55901. */
  55902. name: string;
  55903. /**
  55904. * List of lens flares used in this system.
  55905. */
  55906. lensFlares: LensFlare[];
  55907. /**
  55908. * Define a limit from the border the lens flare can be visible.
  55909. */
  55910. borderLimit: number;
  55911. /**
  55912. * Define a viewport border we do not want to see the lens flare in.
  55913. */
  55914. viewportBorder: number;
  55915. /**
  55916. * Define a predicate which could limit the list of meshes able to occlude the effect.
  55917. */
  55918. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  55919. /**
  55920. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  55921. */
  55922. layerMask: number;
  55923. /**
  55924. * Define the id of the lens flare system in the scene.
  55925. * (equal to name by default)
  55926. */
  55927. id: string;
  55928. private _scene;
  55929. private _emitter;
  55930. private _vertexBuffers;
  55931. private _indexBuffer;
  55932. private _effect;
  55933. private _positionX;
  55934. private _positionY;
  55935. private _isEnabled;
  55936. /** @hidden */
  55937. static _SceneComponentInitialization: (scene: Scene) => void;
  55938. /**
  55939. * Instantiates a lens flare system.
  55940. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  55941. * It is usually composed of several `lensFlare`.
  55942. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55943. * @param name Define the name of the lens flare system in the scene
  55944. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  55945. * @param scene Define the scene the lens flare system belongs to
  55946. */
  55947. constructor(
  55948. /**
  55949. * Define the name of the lens flare system
  55950. */
  55951. name: string, emitter: any, scene: Scene);
  55952. /**
  55953. * Define if the lens flare system is enabled.
  55954. */
  55955. get isEnabled(): boolean;
  55956. set isEnabled(value: boolean);
  55957. /**
  55958. * Get the scene the effects belongs to.
  55959. * @returns the scene holding the lens flare system
  55960. */
  55961. getScene(): Scene;
  55962. /**
  55963. * Get the emitter of the lens flare system.
  55964. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  55965. * @returns the emitter of the lens flare system
  55966. */
  55967. getEmitter(): any;
  55968. /**
  55969. * Set the emitter of the lens flare system.
  55970. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  55971. * @param newEmitter Define the new emitter of the system
  55972. */
  55973. setEmitter(newEmitter: any): void;
  55974. /**
  55975. * Get the lens flare system emitter position.
  55976. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  55977. * @returns the position
  55978. */
  55979. getEmitterPosition(): Vector3;
  55980. /**
  55981. * @hidden
  55982. */
  55983. computeEffectivePosition(globalViewport: Viewport): boolean;
  55984. /** @hidden */
  55985. _isVisible(): boolean;
  55986. /**
  55987. * @hidden
  55988. */
  55989. render(): boolean;
  55990. /**
  55991. * Dispose and release the lens flare with its associated resources.
  55992. */
  55993. dispose(): void;
  55994. /**
  55995. * Parse a lens flare system from a JSON repressentation
  55996. * @param parsedLensFlareSystem Define the JSON to parse
  55997. * @param scene Define the scene the parsed system should be instantiated in
  55998. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  55999. * @returns the parsed system
  56000. */
  56001. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  56002. /**
  56003. * Serialize the current Lens Flare System into a JSON representation.
  56004. * @returns the serialized JSON
  56005. */
  56006. serialize(): any;
  56007. }
  56008. }
  56009. declare module "babylonjs/LensFlares/lensFlare" {
  56010. import { Nullable } from "babylonjs/types";
  56011. import { Color3 } from "babylonjs/Maths/math.color";
  56012. import { Texture } from "babylonjs/Materials/Textures/texture";
  56013. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56014. /**
  56015. * This represents one of the lens effect in a `lensFlareSystem`.
  56016. * It controls one of the indiviual texture used in the effect.
  56017. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56018. */
  56019. export class LensFlare {
  56020. /**
  56021. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56022. */
  56023. size: number;
  56024. /**
  56025. * 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.
  56026. */
  56027. position: number;
  56028. /**
  56029. * Define the lens color.
  56030. */
  56031. color: Color3;
  56032. /**
  56033. * Define the lens texture.
  56034. */
  56035. texture: Nullable<Texture>;
  56036. /**
  56037. * Define the alpha mode to render this particular lens.
  56038. */
  56039. alphaMode: number;
  56040. private _system;
  56041. /**
  56042. * Creates a new Lens Flare.
  56043. * This represents one of the lens effect in a `lensFlareSystem`.
  56044. * It controls one of the indiviual texture used in the effect.
  56045. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56046. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  56047. * @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.
  56048. * @param color Define the lens color
  56049. * @param imgUrl Define the lens texture url
  56050. * @param system Define the `lensFlareSystem` this flare is part of
  56051. * @returns The newly created Lens Flare
  56052. */
  56053. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  56054. /**
  56055. * Instantiates a new Lens Flare.
  56056. * This represents one of the lens effect in a `lensFlareSystem`.
  56057. * It controls one of the indiviual texture used in the effect.
  56058. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56059. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  56060. * @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.
  56061. * @param color Define the lens color
  56062. * @param imgUrl Define the lens texture url
  56063. * @param system Define the `lensFlareSystem` this flare is part of
  56064. */
  56065. constructor(
  56066. /**
  56067. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56068. */
  56069. size: number,
  56070. /**
  56071. * 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.
  56072. */
  56073. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  56074. /**
  56075. * Dispose and release the lens flare with its associated resources.
  56076. */
  56077. dispose(): void;
  56078. }
  56079. }
  56080. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  56081. import { Nullable } from "babylonjs/types";
  56082. import { Scene } from "babylonjs/scene";
  56083. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56084. import { AbstractScene } from "babylonjs/abstractScene";
  56085. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56086. module "babylonjs/abstractScene" {
  56087. interface AbstractScene {
  56088. /**
  56089. * The list of lens flare system added to the scene
  56090. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56091. */
  56092. lensFlareSystems: Array<LensFlareSystem>;
  56093. /**
  56094. * Removes the given lens flare system from this scene.
  56095. * @param toRemove The lens flare system to remove
  56096. * @returns The index of the removed lens flare system
  56097. */
  56098. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  56099. /**
  56100. * Adds the given lens flare system to this scene
  56101. * @param newLensFlareSystem The lens flare system to add
  56102. */
  56103. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  56104. /**
  56105. * Gets a lens flare system using its name
  56106. * @param name defines the name to look for
  56107. * @returns the lens flare system or null if not found
  56108. */
  56109. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  56110. /**
  56111. * Gets a lens flare system using its id
  56112. * @param id defines the id to look for
  56113. * @returns the lens flare system or null if not found
  56114. */
  56115. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  56116. }
  56117. }
  56118. /**
  56119. * Defines the lens flare scene component responsible to manage any lens flares
  56120. * in a given scene.
  56121. */
  56122. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  56123. /**
  56124. * The component name helpfull to identify the component in the list of scene components.
  56125. */
  56126. readonly name: string;
  56127. /**
  56128. * The scene the component belongs to.
  56129. */
  56130. scene: Scene;
  56131. /**
  56132. * Creates a new instance of the component for the given scene
  56133. * @param scene Defines the scene to register the component in
  56134. */
  56135. constructor(scene: Scene);
  56136. /**
  56137. * Registers the component in a given scene
  56138. */
  56139. register(): void;
  56140. /**
  56141. * Rebuilds the elements related to this component in case of
  56142. * context lost for instance.
  56143. */
  56144. rebuild(): void;
  56145. /**
  56146. * Adds all the elements from the container to the scene
  56147. * @param container the container holding the elements
  56148. */
  56149. addFromContainer(container: AbstractScene): void;
  56150. /**
  56151. * Removes all the elements in the container from the scene
  56152. * @param container contains the elements to remove
  56153. * @param dispose if the removed element should be disposed (default: false)
  56154. */
  56155. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56156. /**
  56157. * Serializes the component data to the specified json object
  56158. * @param serializationObject The object to serialize to
  56159. */
  56160. serialize(serializationObject: any): void;
  56161. /**
  56162. * Disposes the component and the associated ressources.
  56163. */
  56164. dispose(): void;
  56165. private _draw;
  56166. }
  56167. }
  56168. declare module "babylonjs/LensFlares/index" {
  56169. export * from "babylonjs/LensFlares/lensFlare";
  56170. export * from "babylonjs/LensFlares/lensFlareSystem";
  56171. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  56172. }
  56173. declare module "babylonjs/Shaders/depth.fragment" {
  56174. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  56175. /** @hidden */
  56176. export var depthPixelShader: {
  56177. name: string;
  56178. shader: string;
  56179. };
  56180. }
  56181. declare module "babylonjs/Shaders/depth.vertex" {
  56182. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56183. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56184. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56185. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56186. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56187. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56188. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56189. /** @hidden */
  56190. export var depthVertexShader: {
  56191. name: string;
  56192. shader: string;
  56193. };
  56194. }
  56195. declare module "babylonjs/Rendering/depthRenderer" {
  56196. import { Nullable } from "babylonjs/types";
  56197. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56198. import { Scene } from "babylonjs/scene";
  56199. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56200. import { Camera } from "babylonjs/Cameras/camera";
  56201. import "babylonjs/Shaders/depth.fragment";
  56202. import "babylonjs/Shaders/depth.vertex";
  56203. /**
  56204. * This represents a depth renderer in Babylon.
  56205. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56206. */
  56207. export class DepthRenderer {
  56208. private _scene;
  56209. private _depthMap;
  56210. private _effect;
  56211. private readonly _storeNonLinearDepth;
  56212. private readonly _clearColor;
  56213. /** Get if the depth renderer is using packed depth or not */
  56214. readonly isPacked: boolean;
  56215. private _cachedDefines;
  56216. private _camera;
  56217. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  56218. enabled: boolean;
  56219. /**
  56220. * Specifiess that the depth renderer will only be used within
  56221. * the camera it is created for.
  56222. * This can help forcing its rendering during the camera processing.
  56223. */
  56224. useOnlyInActiveCamera: boolean;
  56225. /** @hidden */
  56226. static _SceneComponentInitialization: (scene: Scene) => void;
  56227. /**
  56228. * Instantiates a depth renderer
  56229. * @param scene The scene the renderer belongs to
  56230. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56231. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56232. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  56233. */
  56234. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  56235. /**
  56236. * Creates the depth rendering effect and checks if the effect is ready.
  56237. * @param subMesh The submesh to be used to render the depth map of
  56238. * @param useInstances If multiple world instances should be used
  56239. * @returns if the depth renderer is ready to render the depth map
  56240. */
  56241. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56242. /**
  56243. * Gets the texture which the depth map will be written to.
  56244. * @returns The depth map texture
  56245. */
  56246. getDepthMap(): RenderTargetTexture;
  56247. /**
  56248. * Disposes of the depth renderer.
  56249. */
  56250. dispose(): void;
  56251. }
  56252. }
  56253. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  56254. /** @hidden */
  56255. export var minmaxReduxPixelShader: {
  56256. name: string;
  56257. shader: string;
  56258. };
  56259. }
  56260. declare module "babylonjs/Misc/minMaxReducer" {
  56261. import { Nullable } from "babylonjs/types";
  56262. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56263. import { Camera } from "babylonjs/Cameras/camera";
  56264. import { Observer } from "babylonjs/Misc/observable";
  56265. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56266. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  56267. import { Observable } from "babylonjs/Misc/observable";
  56268. import "babylonjs/Shaders/minmaxRedux.fragment";
  56269. /**
  56270. * This class computes a min/max reduction from a texture: it means it computes the minimum
  56271. * and maximum values from all values of the texture.
  56272. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  56273. * The source values are read from the red channel of the texture.
  56274. */
  56275. export class MinMaxReducer {
  56276. /**
  56277. * Observable triggered when the computation has been performed
  56278. */
  56279. onAfterReductionPerformed: Observable<{
  56280. min: number;
  56281. max: number;
  56282. }>;
  56283. protected _camera: Camera;
  56284. protected _sourceTexture: Nullable<RenderTargetTexture>;
  56285. protected _reductionSteps: Nullable<Array<PostProcess>>;
  56286. protected _postProcessManager: PostProcessManager;
  56287. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  56288. protected _forceFullscreenViewport: boolean;
  56289. /**
  56290. * Creates a min/max reducer
  56291. * @param camera The camera to use for the post processes
  56292. */
  56293. constructor(camera: Camera);
  56294. /**
  56295. * Gets the texture used to read the values from.
  56296. */
  56297. get sourceTexture(): Nullable<RenderTargetTexture>;
  56298. /**
  56299. * Sets the source texture to read the values from.
  56300. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  56301. * because in such textures '1' value must not be taken into account to compute the maximum
  56302. * as this value is used to clear the texture.
  56303. * Note that the computation is not activated by calling this function, you must call activate() for that!
  56304. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  56305. * @param depthRedux Indicates if the texture is a depth texture or not
  56306. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  56307. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56308. */
  56309. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56310. /**
  56311. * Defines the refresh rate of the computation.
  56312. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56313. */
  56314. get refreshRate(): number;
  56315. set refreshRate(value: number);
  56316. protected _activated: boolean;
  56317. /**
  56318. * Gets the activation status of the reducer
  56319. */
  56320. get activated(): boolean;
  56321. /**
  56322. * Activates the reduction computation.
  56323. * When activated, the observers registered in onAfterReductionPerformed are
  56324. * called after the compuation is performed
  56325. */
  56326. activate(): void;
  56327. /**
  56328. * Deactivates the reduction computation.
  56329. */
  56330. deactivate(): void;
  56331. /**
  56332. * Disposes the min/max reducer
  56333. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  56334. */
  56335. dispose(disposeAll?: boolean): void;
  56336. }
  56337. }
  56338. declare module "babylonjs/Misc/depthReducer" {
  56339. import { Nullable } from "babylonjs/types";
  56340. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56341. import { Camera } from "babylonjs/Cameras/camera";
  56342. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56343. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  56344. /**
  56345. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  56346. */
  56347. export class DepthReducer extends MinMaxReducer {
  56348. private _depthRenderer;
  56349. private _depthRendererId;
  56350. /**
  56351. * Gets the depth renderer used for the computation.
  56352. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  56353. */
  56354. get depthRenderer(): Nullable<DepthRenderer>;
  56355. /**
  56356. * Creates a depth reducer
  56357. * @param camera The camera used to render the depth texture
  56358. */
  56359. constructor(camera: Camera);
  56360. /**
  56361. * Sets the depth renderer to use to generate the depth map
  56362. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  56363. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  56364. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56365. */
  56366. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  56367. /** @hidden */
  56368. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56369. /**
  56370. * Activates the reduction computation.
  56371. * When activated, the observers registered in onAfterReductionPerformed are
  56372. * called after the compuation is performed
  56373. */
  56374. activate(): void;
  56375. /**
  56376. * Deactivates the reduction computation.
  56377. */
  56378. deactivate(): void;
  56379. /**
  56380. * Disposes the depth reducer
  56381. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  56382. */
  56383. dispose(disposeAll?: boolean): void;
  56384. }
  56385. }
  56386. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  56387. import { Nullable } from "babylonjs/types";
  56388. import { Scene } from "babylonjs/scene";
  56389. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56390. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56391. import { Effect } from "babylonjs/Materials/effect";
  56392. import "babylonjs/Shaders/shadowMap.fragment";
  56393. import "babylonjs/Shaders/shadowMap.vertex";
  56394. import "babylonjs/Shaders/depthBoxBlur.fragment";
  56395. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  56396. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56397. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  56398. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56399. /**
  56400. * A CSM implementation allowing casting shadows on large scenes.
  56401. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56402. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  56403. */
  56404. export class CascadedShadowGenerator extends ShadowGenerator {
  56405. private static readonly frustumCornersNDCSpace;
  56406. /**
  56407. * Name of the CSM class
  56408. */
  56409. static CLASSNAME: string;
  56410. /**
  56411. * Defines the default number of cascades used by the CSM.
  56412. */
  56413. static readonly DEFAULT_CASCADES_COUNT: number;
  56414. /**
  56415. * Defines the minimum number of cascades used by the CSM.
  56416. */
  56417. static readonly MIN_CASCADES_COUNT: number;
  56418. /**
  56419. * Defines the maximum number of cascades used by the CSM.
  56420. */
  56421. static readonly MAX_CASCADES_COUNT: number;
  56422. protected _validateFilter(filter: number): number;
  56423. /**
  56424. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  56425. */
  56426. penumbraDarkness: number;
  56427. private _numCascades;
  56428. /**
  56429. * Gets or set the number of cascades used by the CSM.
  56430. */
  56431. get numCascades(): number;
  56432. set numCascades(value: number);
  56433. /**
  56434. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  56435. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  56436. */
  56437. stabilizeCascades: boolean;
  56438. private _freezeShadowCastersBoundingInfo;
  56439. private _freezeShadowCastersBoundingInfoObservable;
  56440. /**
  56441. * Enables or disables the shadow casters bounding info computation.
  56442. * If your shadow casters don't move, you can disable this feature.
  56443. * If it is enabled, the bounding box computation is done every frame.
  56444. */
  56445. get freezeShadowCastersBoundingInfo(): boolean;
  56446. set freezeShadowCastersBoundingInfo(freeze: boolean);
  56447. private _scbiMin;
  56448. private _scbiMax;
  56449. protected _computeShadowCastersBoundingInfo(): void;
  56450. protected _shadowCastersBoundingInfo: BoundingInfo;
  56451. /**
  56452. * Gets or sets the shadow casters bounding info.
  56453. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  56454. * so that the system won't overwrite the bounds you provide
  56455. */
  56456. get shadowCastersBoundingInfo(): BoundingInfo;
  56457. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  56458. protected _breaksAreDirty: boolean;
  56459. protected _minDistance: number;
  56460. protected _maxDistance: number;
  56461. /**
  56462. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  56463. *
  56464. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  56465. * If you don't know these values, simply leave them to their defaults and don't call this function.
  56466. * @param min minimal distance for the breaks (default to 0.)
  56467. * @param max maximal distance for the breaks (default to 1.)
  56468. */
  56469. setMinMaxDistance(min: number, max: number): void;
  56470. /** Gets the minimal distance used in the cascade break computation */
  56471. get minDistance(): number;
  56472. /** Gets the maximal distance used in the cascade break computation */
  56473. get maxDistance(): number;
  56474. /**
  56475. * Gets the class name of that object
  56476. * @returns "CascadedShadowGenerator"
  56477. */
  56478. getClassName(): string;
  56479. private _cascadeMinExtents;
  56480. private _cascadeMaxExtents;
  56481. /**
  56482. * Gets a cascade minimum extents
  56483. * @param cascadeIndex index of the cascade
  56484. * @returns the minimum cascade extents
  56485. */
  56486. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  56487. /**
  56488. * Gets a cascade maximum extents
  56489. * @param cascadeIndex index of the cascade
  56490. * @returns the maximum cascade extents
  56491. */
  56492. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  56493. private _cascades;
  56494. private _currentLayer;
  56495. private _viewSpaceFrustumsZ;
  56496. private _viewMatrices;
  56497. private _projectionMatrices;
  56498. private _transformMatrices;
  56499. private _transformMatricesAsArray;
  56500. private _frustumLengths;
  56501. private _lightSizeUVCorrection;
  56502. private _depthCorrection;
  56503. private _frustumCornersWorldSpace;
  56504. private _frustumCenter;
  56505. private _shadowCameraPos;
  56506. private _shadowMaxZ;
  56507. /**
  56508. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  56509. * It defaults to camera.maxZ
  56510. */
  56511. get shadowMaxZ(): number;
  56512. /**
  56513. * Sets the shadow max z distance.
  56514. */
  56515. set shadowMaxZ(value: number);
  56516. protected _debug: boolean;
  56517. /**
  56518. * Gets or sets the debug flag.
  56519. * When enabled, the cascades are materialized by different colors on the screen.
  56520. */
  56521. get debug(): boolean;
  56522. set debug(dbg: boolean);
  56523. private _depthClamp;
  56524. /**
  56525. * Gets or sets the depth clamping value.
  56526. *
  56527. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  56528. * to account for the shadow casters far away.
  56529. *
  56530. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  56531. */
  56532. get depthClamp(): boolean;
  56533. set depthClamp(value: boolean);
  56534. private _cascadeBlendPercentage;
  56535. /**
  56536. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  56537. * It defaults to 0.1 (10% blending).
  56538. */
  56539. get cascadeBlendPercentage(): number;
  56540. set cascadeBlendPercentage(value: number);
  56541. private _lambda;
  56542. /**
  56543. * Gets or set the lambda parameter.
  56544. * This parameter is used to split the camera frustum and create the cascades.
  56545. * It's a value between 0. and 1.: If 0, the split is a uniform split of the frustum, if 1 it is a logarithmic split.
  56546. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  56547. */
  56548. get lambda(): number;
  56549. set lambda(value: number);
  56550. /**
  56551. * Gets the view matrix corresponding to a given cascade
  56552. * @param cascadeNum cascade to retrieve the view matrix from
  56553. * @returns the cascade view matrix
  56554. */
  56555. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  56556. /**
  56557. * Gets the projection matrix corresponding to a given cascade
  56558. * @param cascadeNum cascade to retrieve the projection matrix from
  56559. * @returns the cascade projection matrix
  56560. */
  56561. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  56562. /**
  56563. * Gets the transformation matrix corresponding to a given cascade
  56564. * @param cascadeNum cascade to retrieve the transformation matrix from
  56565. * @returns the cascade transformation matrix
  56566. */
  56567. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  56568. private _depthRenderer;
  56569. /**
  56570. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  56571. *
  56572. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  56573. *
  56574. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  56575. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  56576. * @param depthRenderer The depth renderer to use when autoCalcDepthBounds is enabled. If you pass null or don't call this function at all, a depth renderer will be automatically created
  56577. */
  56578. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  56579. private _depthReducer;
  56580. private _autoCalcDepthBounds;
  56581. /**
  56582. * Gets or sets the autoCalcDepthBounds property.
  56583. *
  56584. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  56585. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  56586. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  56587. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  56588. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  56589. */
  56590. get autoCalcDepthBounds(): boolean;
  56591. set autoCalcDepthBounds(value: boolean);
  56592. /**
  56593. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  56594. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56595. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  56596. * for setting the refresh rate on the renderer yourself!
  56597. */
  56598. get autoCalcDepthBoundsRefreshRate(): number;
  56599. set autoCalcDepthBoundsRefreshRate(value: number);
  56600. /**
  56601. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  56602. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  56603. * you change the camera near/far planes!
  56604. */
  56605. splitFrustum(): void;
  56606. private _splitFrustum;
  56607. private _computeMatrices;
  56608. private _computeFrustumInWorldSpace;
  56609. private _computeCascadeFrustum;
  56610. /** @hidden */
  56611. static _SceneComponentInitialization: (scene: Scene) => void;
  56612. /**
  56613. * Creates a Cascaded Shadow Generator object.
  56614. * A ShadowGenerator is the required tool to use the shadows.
  56615. * Each directional light casting shadows needs to use its own ShadowGenerator.
  56616. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56617. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  56618. * @param light The directional light object generating the shadows.
  56619. * @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.
  56620. */
  56621. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  56622. protected _initializeGenerator(): void;
  56623. protected _createTargetRenderTexture(): void;
  56624. protected _initializeShadowMap(): void;
  56625. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  56626. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  56627. /**
  56628. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  56629. * @param defines Defines of the material we want to update
  56630. * @param lightIndex Index of the light in the enabled light list of the material
  56631. */
  56632. prepareDefines(defines: any, lightIndex: number): void;
  56633. /**
  56634. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  56635. * defined in the generator but impacting the effect).
  56636. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  56637. * @param effect The effect we are binfing the information for
  56638. */
  56639. bindShadowLight(lightIndex: string, effect: Effect): void;
  56640. /**
  56641. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  56642. * (eq to view projection * shadow projection matrices)
  56643. * @returns The transform matrix used to create the shadow map
  56644. */
  56645. getTransformMatrix(): Matrix;
  56646. /**
  56647. * Disposes the ShadowGenerator.
  56648. * Returns nothing.
  56649. */
  56650. dispose(): void;
  56651. /**
  56652. * Serializes the shadow generator setup to a json object.
  56653. * @returns The serialized JSON object
  56654. */
  56655. serialize(): any;
  56656. /**
  56657. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  56658. * @param parsedShadowGenerator The JSON object to parse
  56659. * @param scene The scene to create the shadow map for
  56660. * @returns The parsed shadow generator
  56661. */
  56662. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  56663. }
  56664. }
  56665. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  56666. import { Scene } from "babylonjs/scene";
  56667. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56668. import { AbstractScene } from "babylonjs/abstractScene";
  56669. /**
  56670. * Defines the shadow generator component responsible to manage any shadow generators
  56671. * in a given scene.
  56672. */
  56673. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  56674. /**
  56675. * The component name helpfull to identify the component in the list of scene components.
  56676. */
  56677. readonly name: string;
  56678. /**
  56679. * The scene the component belongs to.
  56680. */
  56681. scene: Scene;
  56682. /**
  56683. * Creates a new instance of the component for the given scene
  56684. * @param scene Defines the scene to register the component in
  56685. */
  56686. constructor(scene: Scene);
  56687. /**
  56688. * Registers the component in a given scene
  56689. */
  56690. register(): void;
  56691. /**
  56692. * Rebuilds the elements related to this component in case of
  56693. * context lost for instance.
  56694. */
  56695. rebuild(): void;
  56696. /**
  56697. * Serializes the component data to the specified json object
  56698. * @param serializationObject The object to serialize to
  56699. */
  56700. serialize(serializationObject: any): void;
  56701. /**
  56702. * Adds all the elements from the container to the scene
  56703. * @param container the container holding the elements
  56704. */
  56705. addFromContainer(container: AbstractScene): void;
  56706. /**
  56707. * Removes all the elements in the container from the scene
  56708. * @param container contains the elements to remove
  56709. * @param dispose if the removed element should be disposed (default: false)
  56710. */
  56711. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56712. /**
  56713. * Rebuilds the elements related to this component in case of
  56714. * context lost for instance.
  56715. */
  56716. dispose(): void;
  56717. private _gatherRenderTargets;
  56718. }
  56719. }
  56720. declare module "babylonjs/Lights/Shadows/index" {
  56721. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  56722. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  56723. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  56724. }
  56725. declare module "babylonjs/Lights/pointLight" {
  56726. import { Scene } from "babylonjs/scene";
  56727. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56728. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56729. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56730. import { Effect } from "babylonjs/Materials/effect";
  56731. /**
  56732. * A point light is a light defined by an unique point in world space.
  56733. * The light is emitted in every direction from this point.
  56734. * A good example of a point light is a standard light bulb.
  56735. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56736. */
  56737. export class PointLight extends ShadowLight {
  56738. private _shadowAngle;
  56739. /**
  56740. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56741. * This specifies what angle the shadow will use to be created.
  56742. *
  56743. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56744. */
  56745. get shadowAngle(): number;
  56746. /**
  56747. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56748. * This specifies what angle the shadow will use to be created.
  56749. *
  56750. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56751. */
  56752. set shadowAngle(value: number);
  56753. /**
  56754. * Gets the direction if it has been set.
  56755. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56756. */
  56757. get direction(): Vector3;
  56758. /**
  56759. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56760. */
  56761. set direction(value: Vector3);
  56762. /**
  56763. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  56764. * A PointLight emits the light in every direction.
  56765. * It can cast shadows.
  56766. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  56767. * ```javascript
  56768. * var pointLight = new PointLight("pl", camera.position, scene);
  56769. * ```
  56770. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56771. * @param name The light friendly name
  56772. * @param position The position of the point light in the scene
  56773. * @param scene The scene the lights belongs to
  56774. */
  56775. constructor(name: string, position: Vector3, scene: Scene);
  56776. /**
  56777. * Returns the string "PointLight"
  56778. * @returns the class name
  56779. */
  56780. getClassName(): string;
  56781. /**
  56782. * Returns the integer 0.
  56783. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56784. */
  56785. getTypeID(): number;
  56786. /**
  56787. * Specifies wether or not the shadowmap should be a cube texture.
  56788. * @returns true if the shadowmap needs to be a cube texture.
  56789. */
  56790. needCube(): boolean;
  56791. /**
  56792. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  56793. * @param faceIndex The index of the face we are computed the direction to generate shadow
  56794. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  56795. */
  56796. getShadowDirection(faceIndex?: number): Vector3;
  56797. /**
  56798. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  56799. * - fov = PI / 2
  56800. * - aspect ratio : 1.0
  56801. * - z-near and far equal to the active camera minZ and maxZ.
  56802. * Returns the PointLight.
  56803. */
  56804. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56805. protected _buildUniformLayout(): void;
  56806. /**
  56807. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  56808. * @param effect The effect to update
  56809. * @param lightIndex The index of the light in the effect to update
  56810. * @returns The point light
  56811. */
  56812. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  56813. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56814. /**
  56815. * Prepares the list of defines specific to the light type.
  56816. * @param defines the list of defines
  56817. * @param lightIndex defines the index of the light for the effect
  56818. */
  56819. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56820. }
  56821. }
  56822. declare module "babylonjs/Lights/index" {
  56823. export * from "babylonjs/Lights/light";
  56824. export * from "babylonjs/Lights/shadowLight";
  56825. export * from "babylonjs/Lights/Shadows/index";
  56826. export * from "babylonjs/Lights/directionalLight";
  56827. export * from "babylonjs/Lights/hemisphericLight";
  56828. export * from "babylonjs/Lights/pointLight";
  56829. export * from "babylonjs/Lights/spotLight";
  56830. }
  56831. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  56832. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  56833. /**
  56834. * Header information of HDR texture files.
  56835. */
  56836. export interface HDRInfo {
  56837. /**
  56838. * The height of the texture in pixels.
  56839. */
  56840. height: number;
  56841. /**
  56842. * The width of the texture in pixels.
  56843. */
  56844. width: number;
  56845. /**
  56846. * The index of the beginning of the data in the binary file.
  56847. */
  56848. dataPosition: number;
  56849. }
  56850. /**
  56851. * This groups tools to convert HDR texture to native colors array.
  56852. */
  56853. export class HDRTools {
  56854. private static Ldexp;
  56855. private static Rgbe2float;
  56856. private static readStringLine;
  56857. /**
  56858. * Reads header information from an RGBE texture stored in a native array.
  56859. * More information on this format are available here:
  56860. * https://en.wikipedia.org/wiki/RGBE_image_format
  56861. *
  56862. * @param uint8array The binary file stored in native array.
  56863. * @return The header information.
  56864. */
  56865. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  56866. /**
  56867. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  56868. * This RGBE texture needs to store the information as a panorama.
  56869. *
  56870. * More information on this format are available here:
  56871. * https://en.wikipedia.org/wiki/RGBE_image_format
  56872. *
  56873. * @param buffer The binary file stored in an array buffer.
  56874. * @param size The expected size of the extracted cubemap.
  56875. * @return The Cube Map information.
  56876. */
  56877. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  56878. /**
  56879. * Returns the pixels data extracted from an RGBE texture.
  56880. * This pixels will be stored left to right up to down in the R G B order in one array.
  56881. *
  56882. * More information on this format are available here:
  56883. * https://en.wikipedia.org/wiki/RGBE_image_format
  56884. *
  56885. * @param uint8array The binary file stored in an array buffer.
  56886. * @param hdrInfo The header information of the file.
  56887. * @return The pixels data in RGB right to left up to down order.
  56888. */
  56889. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  56890. private static RGBE_ReadPixels_RLE;
  56891. }
  56892. }
  56893. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  56894. import { Nullable } from "babylonjs/types";
  56895. import { Scene } from "babylonjs/scene";
  56896. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56897. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56898. import "babylonjs/Engines/Extensions/engine.rawTexture";
  56899. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  56900. /**
  56901. * This represents a texture coming from an HDR input.
  56902. *
  56903. * The only supported format is currently panorama picture stored in RGBE format.
  56904. * Example of such files can be found on HDRLib: http://hdrlib.com/
  56905. */
  56906. export class HDRCubeTexture extends BaseTexture {
  56907. private static _facesMapping;
  56908. private _generateHarmonics;
  56909. private _noMipmap;
  56910. private _textureMatrix;
  56911. private _size;
  56912. private _onLoad;
  56913. private _onError;
  56914. /**
  56915. * The texture URL.
  56916. */
  56917. url: string;
  56918. /**
  56919. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  56920. */
  56921. coordinatesMode: number;
  56922. protected _isBlocking: boolean;
  56923. /**
  56924. * Sets wether or not the texture is blocking during loading.
  56925. */
  56926. set isBlocking(value: boolean);
  56927. /**
  56928. * Gets wether or not the texture is blocking during loading.
  56929. */
  56930. get isBlocking(): boolean;
  56931. protected _rotationY: number;
  56932. /**
  56933. * Sets texture matrix rotation angle around Y axis in radians.
  56934. */
  56935. set rotationY(value: number);
  56936. /**
  56937. * Gets texture matrix rotation angle around Y axis radians.
  56938. */
  56939. get rotationY(): number;
  56940. /**
  56941. * Gets or sets the center of the bounding box associated with the cube texture
  56942. * It must define where the camera used to render the texture was set
  56943. */
  56944. boundingBoxPosition: Vector3;
  56945. private _boundingBoxSize;
  56946. /**
  56947. * Gets or sets the size of the bounding box associated with the cube texture
  56948. * When defined, the cubemap will switch to local mode
  56949. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  56950. * @example https://www.babylonjs-playground.com/#RNASML
  56951. */
  56952. set boundingBoxSize(value: Vector3);
  56953. get boundingBoxSize(): Vector3;
  56954. /**
  56955. * Instantiates an HDRTexture from the following parameters.
  56956. *
  56957. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  56958. * @param scene The scene the texture will be used in
  56959. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56960. * @param noMipmap Forces to not generate the mipmap if true
  56961. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  56962. * @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)
  56963. * @param reserved Reserved flag for internal use.
  56964. */
  56965. 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>);
  56966. /**
  56967. * Get the current class name of the texture useful for serialization or dynamic coding.
  56968. * @returns "HDRCubeTexture"
  56969. */
  56970. getClassName(): string;
  56971. /**
  56972. * Occurs when the file is raw .hdr file.
  56973. */
  56974. private loadTexture;
  56975. clone(): HDRCubeTexture;
  56976. delayLoad(): void;
  56977. /**
  56978. * Get the texture reflection matrix used to rotate/transform the reflection.
  56979. * @returns the reflection matrix
  56980. */
  56981. getReflectionTextureMatrix(): Matrix;
  56982. /**
  56983. * Set the texture reflection matrix used to rotate/transform the reflection.
  56984. * @param value Define the reflection matrix to set
  56985. */
  56986. setReflectionTextureMatrix(value: Matrix): void;
  56987. /**
  56988. * Parses a JSON representation of an HDR Texture in order to create the texture
  56989. * @param parsedTexture Define the JSON representation
  56990. * @param scene Define the scene the texture should be created in
  56991. * @param rootUrl Define the root url in case we need to load relative dependencies
  56992. * @returns the newly created texture after parsing
  56993. */
  56994. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  56995. serialize(): any;
  56996. }
  56997. }
  56998. declare module "babylonjs/Physics/physicsEngine" {
  56999. import { Nullable } from "babylonjs/types";
  57000. import { Vector3 } from "babylonjs/Maths/math.vector";
  57001. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57002. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  57003. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  57004. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57005. /**
  57006. * Class used to control physics engine
  57007. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57008. */
  57009. export class PhysicsEngine implements IPhysicsEngine {
  57010. private _physicsPlugin;
  57011. /**
  57012. * Global value used to control the smallest number supported by the simulation
  57013. */
  57014. static Epsilon: number;
  57015. private _impostors;
  57016. private _joints;
  57017. private _subTimeStep;
  57018. /**
  57019. * Gets the gravity vector used by the simulation
  57020. */
  57021. gravity: Vector3;
  57022. /**
  57023. * Factory used to create the default physics plugin.
  57024. * @returns The default physics plugin
  57025. */
  57026. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  57027. /**
  57028. * Creates a new Physics Engine
  57029. * @param gravity defines the gravity vector used by the simulation
  57030. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  57031. */
  57032. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  57033. /**
  57034. * Sets the gravity vector used by the simulation
  57035. * @param gravity defines the gravity vector to use
  57036. */
  57037. setGravity(gravity: Vector3): void;
  57038. /**
  57039. * Set the time step of the physics engine.
  57040. * Default is 1/60.
  57041. * To slow it down, enter 1/600 for example.
  57042. * To speed it up, 1/30
  57043. * @param newTimeStep defines the new timestep to apply to this world.
  57044. */
  57045. setTimeStep(newTimeStep?: number): void;
  57046. /**
  57047. * Get the time step of the physics engine.
  57048. * @returns the current time step
  57049. */
  57050. getTimeStep(): number;
  57051. /**
  57052. * Set the sub time step of the physics engine.
  57053. * Default is 0 meaning there is no sub steps
  57054. * To increase physics resolution precision, set a small value (like 1 ms)
  57055. * @param subTimeStep defines the new sub timestep used for physics resolution.
  57056. */
  57057. setSubTimeStep(subTimeStep?: number): void;
  57058. /**
  57059. * Get the sub time step of the physics engine.
  57060. * @returns the current sub time step
  57061. */
  57062. getSubTimeStep(): number;
  57063. /**
  57064. * Release all resources
  57065. */
  57066. dispose(): void;
  57067. /**
  57068. * Gets the name of the current physics plugin
  57069. * @returns the name of the plugin
  57070. */
  57071. getPhysicsPluginName(): string;
  57072. /**
  57073. * Adding a new impostor for the impostor tracking.
  57074. * This will be done by the impostor itself.
  57075. * @param impostor the impostor to add
  57076. */
  57077. addImpostor(impostor: PhysicsImpostor): void;
  57078. /**
  57079. * Remove an impostor from the engine.
  57080. * This impostor and its mesh will not longer be updated by the physics engine.
  57081. * @param impostor the impostor to remove
  57082. */
  57083. removeImpostor(impostor: PhysicsImpostor): void;
  57084. /**
  57085. * Add a joint to the physics engine
  57086. * @param mainImpostor defines the main impostor to which the joint is added.
  57087. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  57088. * @param joint defines the joint that will connect both impostors.
  57089. */
  57090. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57091. /**
  57092. * Removes a joint from the simulation
  57093. * @param mainImpostor defines the impostor used with the joint
  57094. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  57095. * @param joint defines the joint to remove
  57096. */
  57097. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57098. /**
  57099. * Called by the scene. No need to call it.
  57100. * @param delta defines the timespam between frames
  57101. */
  57102. _step(delta: number): void;
  57103. /**
  57104. * Gets the current plugin used to run the simulation
  57105. * @returns current plugin
  57106. */
  57107. getPhysicsPlugin(): IPhysicsEnginePlugin;
  57108. /**
  57109. * Gets the list of physic impostors
  57110. * @returns an array of PhysicsImpostor
  57111. */
  57112. getImpostors(): Array<PhysicsImpostor>;
  57113. /**
  57114. * Gets the impostor for a physics enabled object
  57115. * @param object defines the object impersonated by the impostor
  57116. * @returns the PhysicsImpostor or null if not found
  57117. */
  57118. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  57119. /**
  57120. * Gets the impostor for a physics body object
  57121. * @param body defines physics body used by the impostor
  57122. * @returns the PhysicsImpostor or null if not found
  57123. */
  57124. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  57125. /**
  57126. * Does a raycast in the physics world
  57127. * @param from when should the ray start?
  57128. * @param to when should the ray end?
  57129. * @returns PhysicsRaycastResult
  57130. */
  57131. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57132. }
  57133. }
  57134. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  57135. import { Nullable } from "babylonjs/types";
  57136. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57137. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57138. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57139. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57140. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57141. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57142. /** @hidden */
  57143. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  57144. private _useDeltaForWorldStep;
  57145. world: any;
  57146. name: string;
  57147. private _physicsMaterials;
  57148. private _fixedTimeStep;
  57149. private _cannonRaycastResult;
  57150. private _raycastResult;
  57151. private _physicsBodysToRemoveAfterStep;
  57152. BJSCANNON: any;
  57153. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  57154. setGravity(gravity: Vector3): void;
  57155. setTimeStep(timeStep: number): void;
  57156. getTimeStep(): number;
  57157. executeStep(delta: number): void;
  57158. private _removeMarkedPhysicsBodiesFromWorld;
  57159. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57160. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57161. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57162. private _processChildMeshes;
  57163. removePhysicsBody(impostor: PhysicsImpostor): void;
  57164. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57165. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57166. private _addMaterial;
  57167. private _checkWithEpsilon;
  57168. private _createShape;
  57169. private _createHeightmap;
  57170. private _minus90X;
  57171. private _plus90X;
  57172. private _tmpPosition;
  57173. private _tmpDeltaPosition;
  57174. private _tmpUnityRotation;
  57175. private _updatePhysicsBodyTransformation;
  57176. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57177. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57178. isSupported(): boolean;
  57179. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57180. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57181. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57182. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57183. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57184. getBodyMass(impostor: PhysicsImpostor): number;
  57185. getBodyFriction(impostor: PhysicsImpostor): number;
  57186. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57187. getBodyRestitution(impostor: PhysicsImpostor): number;
  57188. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57189. sleepBody(impostor: PhysicsImpostor): void;
  57190. wakeUpBody(impostor: PhysicsImpostor): void;
  57191. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  57192. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57193. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57194. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57195. getRadius(impostor: PhysicsImpostor): number;
  57196. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57197. dispose(): void;
  57198. private _extendNamespace;
  57199. /**
  57200. * Does a raycast in the physics world
  57201. * @param from when should the ray start?
  57202. * @param to when should the ray end?
  57203. * @returns PhysicsRaycastResult
  57204. */
  57205. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57206. }
  57207. }
  57208. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  57209. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57210. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57211. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57213. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57214. import { Nullable } from "babylonjs/types";
  57215. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57216. /** @hidden */
  57217. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  57218. world: any;
  57219. name: string;
  57220. BJSOIMO: any;
  57221. private _raycastResult;
  57222. constructor(iterations?: number, oimoInjection?: any);
  57223. setGravity(gravity: Vector3): void;
  57224. setTimeStep(timeStep: number): void;
  57225. getTimeStep(): number;
  57226. private _tmpImpostorsArray;
  57227. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57228. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57229. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57230. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57231. private _tmpPositionVector;
  57232. removePhysicsBody(impostor: PhysicsImpostor): void;
  57233. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57234. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57235. isSupported(): boolean;
  57236. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57237. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57238. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57239. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57240. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57241. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57242. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57243. getBodyMass(impostor: PhysicsImpostor): number;
  57244. getBodyFriction(impostor: PhysicsImpostor): number;
  57245. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57246. getBodyRestitution(impostor: PhysicsImpostor): number;
  57247. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57248. sleepBody(impostor: PhysicsImpostor): void;
  57249. wakeUpBody(impostor: PhysicsImpostor): void;
  57250. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57251. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  57252. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  57253. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57254. getRadius(impostor: PhysicsImpostor): number;
  57255. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57256. dispose(): void;
  57257. /**
  57258. * Does a raycast in the physics world
  57259. * @param from when should the ray start?
  57260. * @param to when should the ray end?
  57261. * @returns PhysicsRaycastResult
  57262. */
  57263. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57264. }
  57265. }
  57266. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  57267. import { Nullable } from "babylonjs/types";
  57268. import { Scene } from "babylonjs/scene";
  57269. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  57270. import { Color4 } from "babylonjs/Maths/math.color";
  57271. import { Mesh } from "babylonjs/Meshes/mesh";
  57272. /**
  57273. * Class containing static functions to help procedurally build meshes
  57274. */
  57275. export class RibbonBuilder {
  57276. /**
  57277. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57278. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57279. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57280. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57281. * * 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
  57282. * * 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
  57283. * * 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
  57284. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57285. * * 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
  57286. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57287. * * 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
  57288. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57289. * * 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
  57290. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57292. * @param name defines the name of the mesh
  57293. * @param options defines the options used to create the mesh
  57294. * @param scene defines the hosting scene
  57295. * @returns the ribbon mesh
  57296. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57297. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57298. */
  57299. static CreateRibbon(name: string, options: {
  57300. pathArray: Vector3[][];
  57301. closeArray?: boolean;
  57302. closePath?: boolean;
  57303. offset?: number;
  57304. updatable?: boolean;
  57305. sideOrientation?: number;
  57306. frontUVs?: Vector4;
  57307. backUVs?: Vector4;
  57308. instance?: Mesh;
  57309. invertUV?: boolean;
  57310. uvs?: Vector2[];
  57311. colors?: Color4[];
  57312. }, scene?: Nullable<Scene>): Mesh;
  57313. }
  57314. }
  57315. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  57316. import { Nullable } from "babylonjs/types";
  57317. import { Scene } from "babylonjs/scene";
  57318. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57319. import { Mesh } from "babylonjs/Meshes/mesh";
  57320. /**
  57321. * Class containing static functions to help procedurally build meshes
  57322. */
  57323. export class ShapeBuilder {
  57324. /**
  57325. * 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.
  57326. * * 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.
  57327. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57328. * * 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.
  57329. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57330. * * 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
  57331. * * 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
  57332. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57333. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57334. * * 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
  57335. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57337. * @param name defines the name of the mesh
  57338. * @param options defines the options used to create the mesh
  57339. * @param scene defines the hosting scene
  57340. * @returns the extruded shape mesh
  57341. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57342. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57343. */
  57344. static ExtrudeShape(name: string, options: {
  57345. shape: Vector3[];
  57346. path: Vector3[];
  57347. scale?: number;
  57348. rotation?: number;
  57349. cap?: number;
  57350. updatable?: boolean;
  57351. sideOrientation?: number;
  57352. frontUVs?: Vector4;
  57353. backUVs?: Vector4;
  57354. instance?: Mesh;
  57355. invertUV?: boolean;
  57356. }, scene?: Nullable<Scene>): Mesh;
  57357. /**
  57358. * Creates an custom extruded shape mesh.
  57359. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57360. * * 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.
  57361. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57362. * * 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
  57363. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57364. * * 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
  57365. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57366. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57367. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57368. * * 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
  57369. * * 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
  57370. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57371. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57372. * * 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
  57373. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57375. * @param name defines the name of the mesh
  57376. * @param options defines the options used to create the mesh
  57377. * @param scene defines the hosting scene
  57378. * @returns the custom extruded shape mesh
  57379. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57380. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57381. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57382. */
  57383. static ExtrudeShapeCustom(name: string, options: {
  57384. shape: Vector3[];
  57385. path: Vector3[];
  57386. scaleFunction?: any;
  57387. rotationFunction?: any;
  57388. ribbonCloseArray?: boolean;
  57389. ribbonClosePath?: boolean;
  57390. cap?: number;
  57391. updatable?: boolean;
  57392. sideOrientation?: number;
  57393. frontUVs?: Vector4;
  57394. backUVs?: Vector4;
  57395. instance?: Mesh;
  57396. invertUV?: boolean;
  57397. }, scene?: Nullable<Scene>): Mesh;
  57398. private static _ExtrudeShapeGeneric;
  57399. }
  57400. }
  57401. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  57402. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  57403. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57404. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57405. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57406. import { Nullable } from "babylonjs/types";
  57407. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57408. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57409. /**
  57410. * AmmoJS Physics plugin
  57411. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  57412. * @see https://github.com/kripken/ammo.js/
  57413. */
  57414. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  57415. private _useDeltaForWorldStep;
  57416. /**
  57417. * Reference to the Ammo library
  57418. */
  57419. bjsAMMO: any;
  57420. /**
  57421. * Created ammoJS world which physics bodies are added to
  57422. */
  57423. world: any;
  57424. /**
  57425. * Name of the plugin
  57426. */
  57427. name: string;
  57428. private _timeStep;
  57429. private _fixedTimeStep;
  57430. private _maxSteps;
  57431. private _tmpQuaternion;
  57432. private _tmpAmmoTransform;
  57433. private _tmpAmmoQuaternion;
  57434. private _tmpAmmoConcreteContactResultCallback;
  57435. private _collisionConfiguration;
  57436. private _dispatcher;
  57437. private _overlappingPairCache;
  57438. private _solver;
  57439. private _softBodySolver;
  57440. private _tmpAmmoVectorA;
  57441. private _tmpAmmoVectorB;
  57442. private _tmpAmmoVectorC;
  57443. private _tmpAmmoVectorD;
  57444. private _tmpContactCallbackResult;
  57445. private _tmpAmmoVectorRCA;
  57446. private _tmpAmmoVectorRCB;
  57447. private _raycastResult;
  57448. private static readonly DISABLE_COLLISION_FLAG;
  57449. private static readonly KINEMATIC_FLAG;
  57450. private static readonly DISABLE_DEACTIVATION_FLAG;
  57451. /**
  57452. * Initializes the ammoJS plugin
  57453. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  57454. * @param ammoInjection can be used to inject your own ammo reference
  57455. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  57456. */
  57457. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  57458. /**
  57459. * Sets the gravity of the physics world (m/(s^2))
  57460. * @param gravity Gravity to set
  57461. */
  57462. setGravity(gravity: Vector3): void;
  57463. /**
  57464. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  57465. * @param timeStep timestep to use in seconds
  57466. */
  57467. setTimeStep(timeStep: number): void;
  57468. /**
  57469. * 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)
  57470. * @param fixedTimeStep fixedTimeStep to use in seconds
  57471. */
  57472. setFixedTimeStep(fixedTimeStep: number): void;
  57473. /**
  57474. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  57475. * @param maxSteps the maximum number of steps by the physics engine per frame
  57476. */
  57477. setMaxSteps(maxSteps: number): void;
  57478. /**
  57479. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  57480. * @returns the current timestep in seconds
  57481. */
  57482. getTimeStep(): number;
  57483. /**
  57484. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  57485. */
  57486. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  57487. private _isImpostorInContact;
  57488. private _isImpostorPairInContact;
  57489. private _stepSimulation;
  57490. /**
  57491. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  57492. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  57493. * After the step the babylon meshes are set to the position of the physics imposters
  57494. * @param delta amount of time to step forward
  57495. * @param impostors array of imposters to update before/after the step
  57496. */
  57497. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57498. /**
  57499. * Update babylon mesh to match physics world object
  57500. * @param impostor imposter to match
  57501. */
  57502. private _afterSoftStep;
  57503. /**
  57504. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57505. * @param impostor imposter to match
  57506. */
  57507. private _ropeStep;
  57508. /**
  57509. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57510. * @param impostor imposter to match
  57511. */
  57512. private _softbodyOrClothStep;
  57513. private _tmpVector;
  57514. private _tmpMatrix;
  57515. /**
  57516. * Applies an impulse on the imposter
  57517. * @param impostor imposter to apply impulse to
  57518. * @param force amount of force to be applied to the imposter
  57519. * @param contactPoint the location to apply the impulse on the imposter
  57520. */
  57521. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57522. /**
  57523. * Applies a force on the imposter
  57524. * @param impostor imposter to apply force
  57525. * @param force amount of force to be applied to the imposter
  57526. * @param contactPoint the location to apply the force on the imposter
  57527. */
  57528. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57529. /**
  57530. * Creates a physics body using the plugin
  57531. * @param impostor the imposter to create the physics body on
  57532. */
  57533. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57534. /**
  57535. * Removes the physics body from the imposter and disposes of the body's memory
  57536. * @param impostor imposter to remove the physics body from
  57537. */
  57538. removePhysicsBody(impostor: PhysicsImpostor): void;
  57539. /**
  57540. * Generates a joint
  57541. * @param impostorJoint the imposter joint to create the joint with
  57542. */
  57543. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57544. /**
  57545. * Removes a joint
  57546. * @param impostorJoint the imposter joint to remove the joint from
  57547. */
  57548. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57549. private _addMeshVerts;
  57550. /**
  57551. * Initialise the soft body vertices to match its object's (mesh) vertices
  57552. * Softbody vertices (nodes) are in world space and to match this
  57553. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  57554. * @param impostor to create the softbody for
  57555. */
  57556. private _softVertexData;
  57557. /**
  57558. * Create an impostor's soft body
  57559. * @param impostor to create the softbody for
  57560. */
  57561. private _createSoftbody;
  57562. /**
  57563. * Create cloth for an impostor
  57564. * @param impostor to create the softbody for
  57565. */
  57566. private _createCloth;
  57567. /**
  57568. * Create rope for an impostor
  57569. * @param impostor to create the softbody for
  57570. */
  57571. private _createRope;
  57572. /**
  57573. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  57574. * @param impostor to create the custom physics shape for
  57575. */
  57576. private _createCustom;
  57577. private _addHullVerts;
  57578. private _createShape;
  57579. /**
  57580. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  57581. * @param impostor imposter containing the physics body and babylon object
  57582. */
  57583. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57584. /**
  57585. * Sets the babylon object's position/rotation from the physics body's position/rotation
  57586. * @param impostor imposter containing the physics body and babylon object
  57587. * @param newPosition new position
  57588. * @param newRotation new rotation
  57589. */
  57590. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57591. /**
  57592. * If this plugin is supported
  57593. * @returns true if its supported
  57594. */
  57595. isSupported(): boolean;
  57596. /**
  57597. * Sets the linear velocity of the physics body
  57598. * @param impostor imposter to set the velocity on
  57599. * @param velocity velocity to set
  57600. */
  57601. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57602. /**
  57603. * Sets the angular velocity of the physics body
  57604. * @param impostor imposter to set the velocity on
  57605. * @param velocity velocity to set
  57606. */
  57607. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57608. /**
  57609. * gets the linear velocity
  57610. * @param impostor imposter to get linear velocity from
  57611. * @returns linear velocity
  57612. */
  57613. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57614. /**
  57615. * gets the angular velocity
  57616. * @param impostor imposter to get angular velocity from
  57617. * @returns angular velocity
  57618. */
  57619. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57620. /**
  57621. * Sets the mass of physics body
  57622. * @param impostor imposter to set the mass on
  57623. * @param mass mass to set
  57624. */
  57625. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57626. /**
  57627. * Gets the mass of the physics body
  57628. * @param impostor imposter to get the mass from
  57629. * @returns mass
  57630. */
  57631. getBodyMass(impostor: PhysicsImpostor): number;
  57632. /**
  57633. * Gets friction of the impostor
  57634. * @param impostor impostor to get friction from
  57635. * @returns friction value
  57636. */
  57637. getBodyFriction(impostor: PhysicsImpostor): number;
  57638. /**
  57639. * Sets friction of the impostor
  57640. * @param impostor impostor to set friction on
  57641. * @param friction friction value
  57642. */
  57643. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57644. /**
  57645. * Gets restitution of the impostor
  57646. * @param impostor impostor to get restitution from
  57647. * @returns restitution value
  57648. */
  57649. getBodyRestitution(impostor: PhysicsImpostor): number;
  57650. /**
  57651. * Sets resitution of the impostor
  57652. * @param impostor impostor to set resitution on
  57653. * @param restitution resitution value
  57654. */
  57655. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57656. /**
  57657. * Gets pressure inside the impostor
  57658. * @param impostor impostor to get pressure from
  57659. * @returns pressure value
  57660. */
  57661. getBodyPressure(impostor: PhysicsImpostor): number;
  57662. /**
  57663. * Sets pressure inside a soft body impostor
  57664. * Cloth and rope must remain 0 pressure
  57665. * @param impostor impostor to set pressure on
  57666. * @param pressure pressure value
  57667. */
  57668. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  57669. /**
  57670. * Gets stiffness of the impostor
  57671. * @param impostor impostor to get stiffness from
  57672. * @returns pressure value
  57673. */
  57674. getBodyStiffness(impostor: PhysicsImpostor): number;
  57675. /**
  57676. * Sets stiffness of the impostor
  57677. * @param impostor impostor to set stiffness on
  57678. * @param stiffness stiffness value from 0 to 1
  57679. */
  57680. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  57681. /**
  57682. * Gets velocityIterations of the impostor
  57683. * @param impostor impostor to get velocity iterations from
  57684. * @returns velocityIterations value
  57685. */
  57686. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  57687. /**
  57688. * Sets velocityIterations of the impostor
  57689. * @param impostor impostor to set velocity iterations on
  57690. * @param velocityIterations velocityIterations value
  57691. */
  57692. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  57693. /**
  57694. * Gets positionIterations of the impostor
  57695. * @param impostor impostor to get position iterations from
  57696. * @returns positionIterations value
  57697. */
  57698. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  57699. /**
  57700. * Sets positionIterations of the impostor
  57701. * @param impostor impostor to set position on
  57702. * @param positionIterations positionIterations value
  57703. */
  57704. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  57705. /**
  57706. * Append an anchor to a cloth object
  57707. * @param impostor is the cloth impostor to add anchor to
  57708. * @param otherImpostor is the rigid impostor to anchor to
  57709. * @param width ratio across width from 0 to 1
  57710. * @param height ratio up height from 0 to 1
  57711. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  57712. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57713. */
  57714. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57715. /**
  57716. * Append an hook to a rope object
  57717. * @param impostor is the rope impostor to add hook to
  57718. * @param otherImpostor is the rigid impostor to hook to
  57719. * @param length ratio along the rope from 0 to 1
  57720. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  57721. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57722. */
  57723. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57724. /**
  57725. * Sleeps the physics body and stops it from being active
  57726. * @param impostor impostor to sleep
  57727. */
  57728. sleepBody(impostor: PhysicsImpostor): void;
  57729. /**
  57730. * Activates the physics body
  57731. * @param impostor impostor to activate
  57732. */
  57733. wakeUpBody(impostor: PhysicsImpostor): void;
  57734. /**
  57735. * Updates the distance parameters of the joint
  57736. * @param joint joint to update
  57737. * @param maxDistance maximum distance of the joint
  57738. * @param minDistance minimum distance of the joint
  57739. */
  57740. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57741. /**
  57742. * Sets a motor on the joint
  57743. * @param joint joint to set motor on
  57744. * @param speed speed of the motor
  57745. * @param maxForce maximum force of the motor
  57746. * @param motorIndex index of the motor
  57747. */
  57748. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57749. /**
  57750. * Sets the motors limit
  57751. * @param joint joint to set limit on
  57752. * @param upperLimit upper limit
  57753. * @param lowerLimit lower limit
  57754. */
  57755. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57756. /**
  57757. * Syncs the position and rotation of a mesh with the impostor
  57758. * @param mesh mesh to sync
  57759. * @param impostor impostor to update the mesh with
  57760. */
  57761. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57762. /**
  57763. * Gets the radius of the impostor
  57764. * @param impostor impostor to get radius from
  57765. * @returns the radius
  57766. */
  57767. getRadius(impostor: PhysicsImpostor): number;
  57768. /**
  57769. * Gets the box size of the impostor
  57770. * @param impostor impostor to get box size from
  57771. * @param result the resulting box size
  57772. */
  57773. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57774. /**
  57775. * Disposes of the impostor
  57776. */
  57777. dispose(): void;
  57778. /**
  57779. * Does a raycast in the physics world
  57780. * @param from when should the ray start?
  57781. * @param to when should the ray end?
  57782. * @returns PhysicsRaycastResult
  57783. */
  57784. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57785. }
  57786. }
  57787. declare module "babylonjs/Probes/reflectionProbe" {
  57788. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57789. import { Vector3 } from "babylonjs/Maths/math.vector";
  57790. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57791. import { Nullable } from "babylonjs/types";
  57792. import { Scene } from "babylonjs/scene";
  57793. module "babylonjs/abstractScene" {
  57794. interface AbstractScene {
  57795. /**
  57796. * The list of reflection probes added to the scene
  57797. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57798. */
  57799. reflectionProbes: Array<ReflectionProbe>;
  57800. /**
  57801. * Removes the given reflection probe from this scene.
  57802. * @param toRemove The reflection probe to remove
  57803. * @returns The index of the removed reflection probe
  57804. */
  57805. removeReflectionProbe(toRemove: ReflectionProbe): number;
  57806. /**
  57807. * Adds the given reflection probe to this scene.
  57808. * @param newReflectionProbe The reflection probe to add
  57809. */
  57810. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  57811. }
  57812. }
  57813. /**
  57814. * Class used to generate realtime reflection / refraction cube textures
  57815. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57816. */
  57817. export class ReflectionProbe {
  57818. /** defines the name of the probe */
  57819. name: string;
  57820. private _scene;
  57821. private _renderTargetTexture;
  57822. private _projectionMatrix;
  57823. private _viewMatrix;
  57824. private _target;
  57825. private _add;
  57826. private _attachedMesh;
  57827. private _invertYAxis;
  57828. /** Gets or sets probe position (center of the cube map) */
  57829. position: Vector3;
  57830. /**
  57831. * Creates a new reflection probe
  57832. * @param name defines the name of the probe
  57833. * @param size defines the texture resolution (for each face)
  57834. * @param scene defines the hosting scene
  57835. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  57836. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  57837. */
  57838. constructor(
  57839. /** defines the name of the probe */
  57840. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  57841. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  57842. get samples(): number;
  57843. set samples(value: number);
  57844. /** Gets or sets the refresh rate to use (on every frame by default) */
  57845. get refreshRate(): number;
  57846. set refreshRate(value: number);
  57847. /**
  57848. * Gets the hosting scene
  57849. * @returns a Scene
  57850. */
  57851. getScene(): Scene;
  57852. /** Gets the internal CubeTexture used to render to */
  57853. get cubeTexture(): RenderTargetTexture;
  57854. /** Gets the list of meshes to render */
  57855. get renderList(): Nullable<AbstractMesh[]>;
  57856. /**
  57857. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  57858. * @param mesh defines the mesh to attach to
  57859. */
  57860. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  57861. /**
  57862. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  57863. * @param renderingGroupId The rendering group id corresponding to its index
  57864. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  57865. */
  57866. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  57867. /**
  57868. * Clean all associated resources
  57869. */
  57870. dispose(): void;
  57871. /**
  57872. * Converts the reflection probe information to a readable string for debug purpose.
  57873. * @param fullDetails Supports for multiple levels of logging within scene loading
  57874. * @returns the human readable reflection probe info
  57875. */
  57876. toString(fullDetails?: boolean): string;
  57877. /**
  57878. * Get the class name of the relfection probe.
  57879. * @returns "ReflectionProbe"
  57880. */
  57881. getClassName(): string;
  57882. /**
  57883. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  57884. * @returns The JSON representation of the texture
  57885. */
  57886. serialize(): any;
  57887. /**
  57888. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  57889. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  57890. * @param scene Define the scene the parsed reflection probe should be instantiated in
  57891. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  57892. * @returns The parsed reflection probe if successful
  57893. */
  57894. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  57895. }
  57896. }
  57897. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  57898. /** @hidden */
  57899. export var _BabylonLoaderRegistered: boolean;
  57900. /**
  57901. * Helps setting up some configuration for the babylon file loader.
  57902. */
  57903. export class BabylonFileLoaderConfiguration {
  57904. /**
  57905. * The loader does not allow injecting custom physix engine into the plugins.
  57906. * Unfortunately in ES6, we need to manually inject them into the plugin.
  57907. * So you could set this variable to your engine import to make it work.
  57908. */
  57909. static LoaderInjectedPhysicsEngine: any;
  57910. }
  57911. }
  57912. declare module "babylonjs/Loading/Plugins/index" {
  57913. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  57914. }
  57915. declare module "babylonjs/Loading/index" {
  57916. export * from "babylonjs/Loading/loadingScreen";
  57917. export * from "babylonjs/Loading/Plugins/index";
  57918. export * from "babylonjs/Loading/sceneLoader";
  57919. export * from "babylonjs/Loading/sceneLoaderFlags";
  57920. }
  57921. declare module "babylonjs/Materials/Background/index" {
  57922. export * from "babylonjs/Materials/Background/backgroundMaterial";
  57923. }
  57924. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  57925. import { Scene } from "babylonjs/scene";
  57926. import { Color3 } from "babylonjs/Maths/math.color";
  57927. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  57928. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57929. /**
  57930. * The Physically based simple base material of BJS.
  57931. *
  57932. * This enables better naming and convention enforcements on top of the pbrMaterial.
  57933. * It is used as the base class for both the specGloss and metalRough conventions.
  57934. */
  57935. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  57936. /**
  57937. * Number of Simultaneous lights allowed on the material.
  57938. */
  57939. maxSimultaneousLights: number;
  57940. /**
  57941. * If sets to true, disables all the lights affecting the material.
  57942. */
  57943. disableLighting: boolean;
  57944. /**
  57945. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  57946. */
  57947. environmentTexture: BaseTexture;
  57948. /**
  57949. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  57950. */
  57951. invertNormalMapX: boolean;
  57952. /**
  57953. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  57954. */
  57955. invertNormalMapY: boolean;
  57956. /**
  57957. * Normal map used in the model.
  57958. */
  57959. normalTexture: BaseTexture;
  57960. /**
  57961. * Emissivie color used to self-illuminate the model.
  57962. */
  57963. emissiveColor: Color3;
  57964. /**
  57965. * Emissivie texture used to self-illuminate the model.
  57966. */
  57967. emissiveTexture: BaseTexture;
  57968. /**
  57969. * Occlusion Channel Strenght.
  57970. */
  57971. occlusionStrength: number;
  57972. /**
  57973. * Occlusion Texture of the material (adding extra occlusion effects).
  57974. */
  57975. occlusionTexture: BaseTexture;
  57976. /**
  57977. * Defines the alpha limits in alpha test mode.
  57978. */
  57979. alphaCutOff: number;
  57980. /**
  57981. * Gets the current double sided mode.
  57982. */
  57983. get doubleSided(): boolean;
  57984. /**
  57985. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57986. */
  57987. set doubleSided(value: boolean);
  57988. /**
  57989. * Stores the pre-calculated light information of a mesh in a texture.
  57990. */
  57991. lightmapTexture: BaseTexture;
  57992. /**
  57993. * If true, the light map contains occlusion information instead of lighting info.
  57994. */
  57995. useLightmapAsShadowmap: boolean;
  57996. /**
  57997. * Instantiates a new PBRMaterial instance.
  57998. *
  57999. * @param name The material name
  58000. * @param scene The scene the material will be use in.
  58001. */
  58002. constructor(name: string, scene: Scene);
  58003. getClassName(): string;
  58004. }
  58005. }
  58006. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  58007. import { Scene } from "babylonjs/scene";
  58008. import { Color3 } from "babylonjs/Maths/math.color";
  58009. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58010. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58011. /**
  58012. * The PBR material of BJS following the metal roughness convention.
  58013. *
  58014. * This fits to the PBR convention in the GLTF definition:
  58015. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  58016. */
  58017. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  58018. /**
  58019. * The base color has two different interpretations depending on the value of metalness.
  58020. * When the material is a metal, the base color is the specific measured reflectance value
  58021. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  58022. * of the material.
  58023. */
  58024. baseColor: Color3;
  58025. /**
  58026. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  58027. * well as opacity information in the alpha channel.
  58028. */
  58029. baseTexture: BaseTexture;
  58030. /**
  58031. * Specifies the metallic scalar value of the material.
  58032. * Can also be used to scale the metalness values of the metallic texture.
  58033. */
  58034. metallic: number;
  58035. /**
  58036. * Specifies the roughness scalar value of the material.
  58037. * Can also be used to scale the roughness values of the metallic texture.
  58038. */
  58039. roughness: number;
  58040. /**
  58041. * Texture containing both the metallic value in the B channel and the
  58042. * roughness value in the G channel to keep better precision.
  58043. */
  58044. metallicRoughnessTexture: BaseTexture;
  58045. /**
  58046. * Instantiates a new PBRMetalRoughnessMaterial instance.
  58047. *
  58048. * @param name The material name
  58049. * @param scene The scene the material will be use in.
  58050. */
  58051. constructor(name: string, scene: Scene);
  58052. /**
  58053. * Return the currrent class name of the material.
  58054. */
  58055. getClassName(): string;
  58056. /**
  58057. * Makes a duplicate of the current material.
  58058. * @param name - name to use for the new material.
  58059. */
  58060. clone(name: string): PBRMetallicRoughnessMaterial;
  58061. /**
  58062. * Serialize the material to a parsable JSON object.
  58063. */
  58064. serialize(): any;
  58065. /**
  58066. * Parses a JSON object correponding to the serialize function.
  58067. */
  58068. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  58069. }
  58070. }
  58071. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  58072. import { Scene } from "babylonjs/scene";
  58073. import { Color3 } from "babylonjs/Maths/math.color";
  58074. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58075. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58076. /**
  58077. * The PBR material of BJS following the specular glossiness convention.
  58078. *
  58079. * This fits to the PBR convention in the GLTF definition:
  58080. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  58081. */
  58082. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  58083. /**
  58084. * Specifies the diffuse color of the material.
  58085. */
  58086. diffuseColor: Color3;
  58087. /**
  58088. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  58089. * channel.
  58090. */
  58091. diffuseTexture: BaseTexture;
  58092. /**
  58093. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  58094. */
  58095. specularColor: Color3;
  58096. /**
  58097. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  58098. */
  58099. glossiness: number;
  58100. /**
  58101. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  58102. */
  58103. specularGlossinessTexture: BaseTexture;
  58104. /**
  58105. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  58106. *
  58107. * @param name The material name
  58108. * @param scene The scene the material will be use in.
  58109. */
  58110. constructor(name: string, scene: Scene);
  58111. /**
  58112. * Return the currrent class name of the material.
  58113. */
  58114. getClassName(): string;
  58115. /**
  58116. * Makes a duplicate of the current material.
  58117. * @param name - name to use for the new material.
  58118. */
  58119. clone(name: string): PBRSpecularGlossinessMaterial;
  58120. /**
  58121. * Serialize the material to a parsable JSON object.
  58122. */
  58123. serialize(): any;
  58124. /**
  58125. * Parses a JSON object correponding to the serialize function.
  58126. */
  58127. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  58128. }
  58129. }
  58130. declare module "babylonjs/Materials/PBR/index" {
  58131. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58132. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58133. export * from "babylonjs/Materials/PBR/pbrMaterial";
  58134. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  58135. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  58136. }
  58137. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  58138. import { Nullable } from "babylonjs/types";
  58139. import { Scene } from "babylonjs/scene";
  58140. import { Matrix } from "babylonjs/Maths/math.vector";
  58141. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58142. /**
  58143. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  58144. * It can help converting any input color in a desired output one. This can then be used to create effects
  58145. * from sepia, black and white to sixties or futuristic rendering...
  58146. *
  58147. * The only supported format is currently 3dl.
  58148. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  58149. */
  58150. export class ColorGradingTexture extends BaseTexture {
  58151. /**
  58152. * The current texture matrix. (will always be identity in color grading texture)
  58153. */
  58154. private _textureMatrix;
  58155. /**
  58156. * The texture URL.
  58157. */
  58158. url: string;
  58159. /**
  58160. * Empty line regex stored for GC.
  58161. */
  58162. private static _noneEmptyLineRegex;
  58163. private _engine;
  58164. /**
  58165. * Instantiates a ColorGradingTexture from the following parameters.
  58166. *
  58167. * @param url The location of the color gradind data (currently only supporting 3dl)
  58168. * @param scene The scene the texture will be used in
  58169. */
  58170. constructor(url: string, scene: Scene);
  58171. /**
  58172. * Returns the texture matrix used in most of the material.
  58173. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  58174. */
  58175. getTextureMatrix(): Matrix;
  58176. /**
  58177. * Occurs when the file being loaded is a .3dl LUT file.
  58178. */
  58179. private load3dlTexture;
  58180. /**
  58181. * Starts the loading process of the texture.
  58182. */
  58183. private loadTexture;
  58184. /**
  58185. * Clones the color gradind texture.
  58186. */
  58187. clone(): ColorGradingTexture;
  58188. /**
  58189. * Called during delayed load for textures.
  58190. */
  58191. delayLoad(): void;
  58192. /**
  58193. * Parses a color grading texture serialized by Babylon.
  58194. * @param parsedTexture The texture information being parsedTexture
  58195. * @param scene The scene to load the texture in
  58196. * @param rootUrl The root url of the data assets to load
  58197. * @return A color gradind texture
  58198. */
  58199. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  58200. /**
  58201. * Serializes the LUT texture to json format.
  58202. */
  58203. serialize(): any;
  58204. }
  58205. }
  58206. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  58207. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58208. import { Scene } from "babylonjs/scene";
  58209. import { Nullable } from "babylonjs/types";
  58210. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58211. /**
  58212. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58213. */
  58214. export class EquiRectangularCubeTexture extends BaseTexture {
  58215. /** The six faces of the cube. */
  58216. private static _FacesMapping;
  58217. private _noMipmap;
  58218. private _onLoad;
  58219. private _onError;
  58220. /** The size of the cubemap. */
  58221. private _size;
  58222. /** The buffer of the image. */
  58223. private _buffer;
  58224. /** The width of the input image. */
  58225. private _width;
  58226. /** The height of the input image. */
  58227. private _height;
  58228. /** The URL to the image. */
  58229. url: string;
  58230. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  58231. coordinatesMode: number;
  58232. /**
  58233. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  58234. * @param url The location of the image
  58235. * @param scene The scene the texture will be used in
  58236. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58237. * @param noMipmap Forces to not generate the mipmap if true
  58238. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58239. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58240. * @param onLoad — defines a callback called when texture is loaded
  58241. * @param onError — defines a callback called if there is an error
  58242. */
  58243. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58244. /**
  58245. * Load the image data, by putting the image on a canvas and extracting its buffer.
  58246. */
  58247. private loadImage;
  58248. /**
  58249. * Convert the image buffer into a cubemap and create a CubeTexture.
  58250. */
  58251. private loadTexture;
  58252. /**
  58253. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  58254. * @param buffer The ArrayBuffer that should be converted.
  58255. * @returns The buffer as Float32Array.
  58256. */
  58257. private getFloat32ArrayFromArrayBuffer;
  58258. /**
  58259. * Get the current class name of the texture useful for serialization or dynamic coding.
  58260. * @returns "EquiRectangularCubeTexture"
  58261. */
  58262. getClassName(): string;
  58263. /**
  58264. * Create a clone of the current EquiRectangularCubeTexture and return it.
  58265. * @returns A clone of the current EquiRectangularCubeTexture.
  58266. */
  58267. clone(): EquiRectangularCubeTexture;
  58268. }
  58269. }
  58270. declare module "babylonjs/Misc/tga" {
  58271. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58272. /**
  58273. * Based on jsTGALoader - Javascript loader for TGA file
  58274. * By Vincent Thibault
  58275. * @see http://blog.robrowser.com/javascript-tga-loader.html
  58276. */
  58277. export class TGATools {
  58278. private static _TYPE_INDEXED;
  58279. private static _TYPE_RGB;
  58280. private static _TYPE_GREY;
  58281. private static _TYPE_RLE_INDEXED;
  58282. private static _TYPE_RLE_RGB;
  58283. private static _TYPE_RLE_GREY;
  58284. private static _ORIGIN_MASK;
  58285. private static _ORIGIN_SHIFT;
  58286. private static _ORIGIN_BL;
  58287. private static _ORIGIN_BR;
  58288. private static _ORIGIN_UL;
  58289. private static _ORIGIN_UR;
  58290. /**
  58291. * Gets the header of a TGA file
  58292. * @param data defines the TGA data
  58293. * @returns the header
  58294. */
  58295. static GetTGAHeader(data: Uint8Array): any;
  58296. /**
  58297. * Uploads TGA content to a Babylon Texture
  58298. * @hidden
  58299. */
  58300. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  58301. /** @hidden */
  58302. 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;
  58303. /** @hidden */
  58304. 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;
  58305. /** @hidden */
  58306. 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;
  58307. /** @hidden */
  58308. 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;
  58309. /** @hidden */
  58310. 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;
  58311. /** @hidden */
  58312. 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;
  58313. }
  58314. }
  58315. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  58316. import { Nullable } from "babylonjs/types";
  58317. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58318. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58319. /**
  58320. * Implementation of the TGA Texture Loader.
  58321. * @hidden
  58322. */
  58323. export class _TGATextureLoader implements IInternalTextureLoader {
  58324. /**
  58325. * Defines wether the loader supports cascade loading the different faces.
  58326. */
  58327. readonly supportCascades: boolean;
  58328. /**
  58329. * This returns if the loader support the current file information.
  58330. * @param extension defines the file extension of the file being loaded
  58331. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58332. * @param fallback defines the fallback internal texture if any
  58333. * @param isBase64 defines whether the texture is encoded as a base64
  58334. * @param isBuffer defines whether the texture data are stored as a buffer
  58335. * @returns true if the loader can load the specified file
  58336. */
  58337. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  58338. /**
  58339. * Transform the url before loading if required.
  58340. * @param rootUrl the url of the texture
  58341. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58342. * @returns the transformed texture
  58343. */
  58344. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  58345. /**
  58346. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  58347. * @param rootUrl the url of the texture
  58348. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58349. * @returns the fallback texture
  58350. */
  58351. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  58352. /**
  58353. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  58354. * @param data contains the texture data
  58355. * @param texture defines the BabylonJS internal texture
  58356. * @param createPolynomials will be true if polynomials have been requested
  58357. * @param onLoad defines the callback to trigger once the texture is ready
  58358. * @param onError defines the callback to trigger in case of error
  58359. */
  58360. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58361. /**
  58362. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  58363. * @param data contains the texture data
  58364. * @param texture defines the BabylonJS internal texture
  58365. * @param callback defines the method to call once ready to upload
  58366. */
  58367. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58368. }
  58369. }
  58370. declare module "babylonjs/Misc/basis" {
  58371. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58372. /**
  58373. * Info about the .basis files
  58374. */
  58375. class BasisFileInfo {
  58376. /**
  58377. * If the file has alpha
  58378. */
  58379. hasAlpha: boolean;
  58380. /**
  58381. * Info about each image of the basis file
  58382. */
  58383. images: Array<{
  58384. levels: Array<{
  58385. width: number;
  58386. height: number;
  58387. transcodedPixels: ArrayBufferView;
  58388. }>;
  58389. }>;
  58390. }
  58391. /**
  58392. * Result of transcoding a basis file
  58393. */
  58394. class TranscodeResult {
  58395. /**
  58396. * Info about the .basis file
  58397. */
  58398. fileInfo: BasisFileInfo;
  58399. /**
  58400. * Format to use when loading the file
  58401. */
  58402. format: number;
  58403. }
  58404. /**
  58405. * Configuration options for the Basis transcoder
  58406. */
  58407. export class BasisTranscodeConfiguration {
  58408. /**
  58409. * Supported compression formats used to determine the supported output format of the transcoder
  58410. */
  58411. supportedCompressionFormats?: {
  58412. /**
  58413. * etc1 compression format
  58414. */
  58415. etc1?: boolean;
  58416. /**
  58417. * s3tc compression format
  58418. */
  58419. s3tc?: boolean;
  58420. /**
  58421. * pvrtc compression format
  58422. */
  58423. pvrtc?: boolean;
  58424. /**
  58425. * etc2 compression format
  58426. */
  58427. etc2?: boolean;
  58428. };
  58429. /**
  58430. * If mipmap levels should be loaded for transcoded images (Default: true)
  58431. */
  58432. loadMipmapLevels?: boolean;
  58433. /**
  58434. * Index of a single image to load (Default: all images)
  58435. */
  58436. loadSingleImage?: number;
  58437. }
  58438. /**
  58439. * Used to load .Basis files
  58440. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  58441. */
  58442. export class BasisTools {
  58443. private static _IgnoreSupportedFormats;
  58444. /**
  58445. * URL to use when loading the basis transcoder
  58446. */
  58447. static JSModuleURL: string;
  58448. /**
  58449. * URL to use when loading the wasm module for the transcoder
  58450. */
  58451. static WasmModuleURL: string;
  58452. /**
  58453. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  58454. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  58455. * @returns internal format corresponding to the Basis format
  58456. */
  58457. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  58458. private static _WorkerPromise;
  58459. private static _Worker;
  58460. private static _actionId;
  58461. private static _CreateWorkerAsync;
  58462. /**
  58463. * Transcodes a loaded image file to compressed pixel data
  58464. * @param data image data to transcode
  58465. * @param config configuration options for the transcoding
  58466. * @returns a promise resulting in the transcoded image
  58467. */
  58468. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  58469. /**
  58470. * Loads a texture from the transcode result
  58471. * @param texture texture load to
  58472. * @param transcodeResult the result of transcoding the basis file to load from
  58473. */
  58474. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  58475. }
  58476. }
  58477. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  58478. import { Nullable } from "babylonjs/types";
  58479. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58480. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58481. /**
  58482. * Loader for .basis file format
  58483. */
  58484. export class _BasisTextureLoader implements IInternalTextureLoader {
  58485. /**
  58486. * Defines whether the loader supports cascade loading the different faces.
  58487. */
  58488. readonly supportCascades: boolean;
  58489. /**
  58490. * This returns if the loader support the current file information.
  58491. * @param extension defines the file extension of the file being loaded
  58492. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58493. * @param fallback defines the fallback internal texture if any
  58494. * @param isBase64 defines whether the texture is encoded as a base64
  58495. * @param isBuffer defines whether the texture data are stored as a buffer
  58496. * @returns true if the loader can load the specified file
  58497. */
  58498. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  58499. /**
  58500. * Transform the url before loading if required.
  58501. * @param rootUrl the url of the texture
  58502. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58503. * @returns the transformed texture
  58504. */
  58505. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  58506. /**
  58507. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  58508. * @param rootUrl the url of the texture
  58509. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58510. * @returns the fallback texture
  58511. */
  58512. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  58513. /**
  58514. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  58515. * @param data contains the texture data
  58516. * @param texture defines the BabylonJS internal texture
  58517. * @param createPolynomials will be true if polynomials have been requested
  58518. * @param onLoad defines the callback to trigger once the texture is ready
  58519. * @param onError defines the callback to trigger in case of error
  58520. */
  58521. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58522. /**
  58523. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  58524. * @param data contains the texture data
  58525. * @param texture defines the BabylonJS internal texture
  58526. * @param callback defines the method to call once ready to upload
  58527. */
  58528. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58529. }
  58530. }
  58531. declare module "babylonjs/Materials/Textures/Loaders/index" {
  58532. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  58533. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  58534. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  58535. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  58536. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  58537. }
  58538. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  58539. import { Scene } from "babylonjs/scene";
  58540. import { Texture } from "babylonjs/Materials/Textures/texture";
  58541. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58542. /**
  58543. * 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.
  58544. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58545. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58546. */
  58547. export class CustomProceduralTexture extends ProceduralTexture {
  58548. private _animate;
  58549. private _time;
  58550. private _config;
  58551. private _texturePath;
  58552. /**
  58553. * Instantiates a new Custom Procedural Texture.
  58554. * 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.
  58555. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58556. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58557. * @param name Define the name of the texture
  58558. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  58559. * @param size Define the size of the texture to create
  58560. * @param scene Define the scene the texture belongs to
  58561. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  58562. * @param generateMipMaps Define if the texture should creates mip maps or not
  58563. */
  58564. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58565. private _loadJson;
  58566. /**
  58567. * Is the texture ready to be used ? (rendered at least once)
  58568. * @returns true if ready, otherwise, false.
  58569. */
  58570. isReady(): boolean;
  58571. /**
  58572. * Render the texture to its associated render target.
  58573. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  58574. */
  58575. render(useCameraPostProcess?: boolean): void;
  58576. /**
  58577. * Update the list of dependant textures samplers in the shader.
  58578. */
  58579. updateTextures(): void;
  58580. /**
  58581. * Update the uniform values of the procedural texture in the shader.
  58582. */
  58583. updateShaderUniforms(): void;
  58584. /**
  58585. * Define if the texture animates or not.
  58586. */
  58587. get animate(): boolean;
  58588. set animate(value: boolean);
  58589. }
  58590. }
  58591. declare module "babylonjs/Shaders/noise.fragment" {
  58592. /** @hidden */
  58593. export var noisePixelShader: {
  58594. name: string;
  58595. shader: string;
  58596. };
  58597. }
  58598. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  58599. import { Nullable } from "babylonjs/types";
  58600. import { Scene } from "babylonjs/scene";
  58601. import { Texture } from "babylonjs/Materials/Textures/texture";
  58602. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58603. import "babylonjs/Shaders/noise.fragment";
  58604. /**
  58605. * Class used to generate noise procedural textures
  58606. */
  58607. export class NoiseProceduralTexture extends ProceduralTexture {
  58608. private _time;
  58609. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  58610. brightness: number;
  58611. /** Defines the number of octaves to process */
  58612. octaves: number;
  58613. /** Defines the level of persistence (0.8 by default) */
  58614. persistence: number;
  58615. /** Gets or sets animation speed factor (default is 1) */
  58616. animationSpeedFactor: number;
  58617. /**
  58618. * Creates a new NoiseProceduralTexture
  58619. * @param name defines the name fo the texture
  58620. * @param size defines the size of the texture (default is 256)
  58621. * @param scene defines the hosting scene
  58622. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  58623. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  58624. */
  58625. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58626. private _updateShaderUniforms;
  58627. protected _getDefines(): string;
  58628. /** Generate the current state of the procedural texture */
  58629. render(useCameraPostProcess?: boolean): void;
  58630. /**
  58631. * Serializes this noise procedural texture
  58632. * @returns a serialized noise procedural texture object
  58633. */
  58634. serialize(): any;
  58635. /**
  58636. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  58637. * @param parsedTexture defines parsed texture data
  58638. * @param scene defines the current scene
  58639. * @param rootUrl defines the root URL containing noise procedural texture information
  58640. * @returns a parsed NoiseProceduralTexture
  58641. */
  58642. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  58643. }
  58644. }
  58645. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  58646. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  58647. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  58648. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58649. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  58650. }
  58651. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  58652. import { Nullable } from "babylonjs/types";
  58653. import { Scene } from "babylonjs/scene";
  58654. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58655. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58656. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  58657. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58658. /**
  58659. * Raw cube texture where the raw buffers are passed in
  58660. */
  58661. export class RawCubeTexture extends CubeTexture {
  58662. /**
  58663. * Creates a cube texture where the raw buffers are passed in.
  58664. * @param scene defines the scene the texture is attached to
  58665. * @param data defines the array of data to use to create each face
  58666. * @param size defines the size of the textures
  58667. * @param format defines the format of the data
  58668. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  58669. * @param generateMipMaps defines if the engine should generate the mip levels
  58670. * @param invertY defines if data must be stored with Y axis inverted
  58671. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  58672. * @param compression defines the compression used (null by default)
  58673. */
  58674. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  58675. /**
  58676. * Updates the raw cube texture.
  58677. * @param data defines the data to store
  58678. * @param format defines the data format
  58679. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  58680. * @param invertY defines if data must be stored with Y axis inverted
  58681. * @param compression defines the compression used (null by default)
  58682. * @param level defines which level of the texture to update
  58683. */
  58684. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  58685. /**
  58686. * Updates a raw cube texture with RGBD encoded data.
  58687. * @param data defines the array of data [mipmap][face] to use to create each face
  58688. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  58689. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58690. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58691. * @returns a promsie that resolves when the operation is complete
  58692. */
  58693. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  58694. /**
  58695. * Clones the raw cube texture.
  58696. * @return a new cube texture
  58697. */
  58698. clone(): CubeTexture;
  58699. /** @hidden */
  58700. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  58701. }
  58702. }
  58703. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  58704. import { Scene } from "babylonjs/scene";
  58705. import { Texture } from "babylonjs/Materials/Textures/texture";
  58706. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58707. /**
  58708. * Class used to store 3D textures containing user data
  58709. */
  58710. export class RawTexture3D extends Texture {
  58711. /** Gets or sets the texture format to use */
  58712. format: number;
  58713. private _engine;
  58714. /**
  58715. * Create a new RawTexture3D
  58716. * @param data defines the data of the texture
  58717. * @param width defines the width of the texture
  58718. * @param height defines the height of the texture
  58719. * @param depth defines the depth of the texture
  58720. * @param format defines the texture format to use
  58721. * @param scene defines the hosting scene
  58722. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58723. * @param invertY defines if texture must be stored with Y axis inverted
  58724. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58725. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58726. */
  58727. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58728. /** Gets or sets the texture format to use */
  58729. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58730. /**
  58731. * Update the texture with new data
  58732. * @param data defines the data to store in the texture
  58733. */
  58734. update(data: ArrayBufferView): void;
  58735. }
  58736. }
  58737. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  58738. import { Scene } from "babylonjs/scene";
  58739. import { Texture } from "babylonjs/Materials/Textures/texture";
  58740. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58741. /**
  58742. * Class used to store 2D array textures containing user data
  58743. */
  58744. export class RawTexture2DArray extends Texture {
  58745. /** Gets or sets the texture format to use */
  58746. format: number;
  58747. private _engine;
  58748. /**
  58749. * Create a new RawTexture2DArray
  58750. * @param data defines the data of the texture
  58751. * @param width defines the width of the texture
  58752. * @param height defines the height of the texture
  58753. * @param depth defines the number of layers of the texture
  58754. * @param format defines the texture format to use
  58755. * @param scene defines the hosting scene
  58756. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58757. * @param invertY defines if texture must be stored with Y axis inverted
  58758. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58759. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58760. */
  58761. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58762. /** Gets or sets the texture format to use */
  58763. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58764. /**
  58765. * Update the texture with new data
  58766. * @param data defines the data to store in the texture
  58767. */
  58768. update(data: ArrayBufferView): void;
  58769. }
  58770. }
  58771. declare module "babylonjs/Materials/Textures/refractionTexture" {
  58772. import { Scene } from "babylonjs/scene";
  58773. import { Plane } from "babylonjs/Maths/math.plane";
  58774. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58775. /**
  58776. * Creates a refraction texture used by refraction channel of the standard material.
  58777. * It is like a mirror but to see through a material.
  58778. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58779. */
  58780. export class RefractionTexture extends RenderTargetTexture {
  58781. /**
  58782. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  58783. * 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.
  58784. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58785. */
  58786. refractionPlane: Plane;
  58787. /**
  58788. * Define how deep under the surface we should see.
  58789. */
  58790. depth: number;
  58791. /**
  58792. * Creates a refraction texture used by refraction channel of the standard material.
  58793. * It is like a mirror but to see through a material.
  58794. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58795. * @param name Define the texture name
  58796. * @param size Define the size of the underlying texture
  58797. * @param scene Define the scene the refraction belongs to
  58798. * @param generateMipMaps Define if we need to generate mips level for the refraction
  58799. */
  58800. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  58801. /**
  58802. * Clone the refraction texture.
  58803. * @returns the cloned texture
  58804. */
  58805. clone(): RefractionTexture;
  58806. /**
  58807. * Serialize the texture to a JSON representation you could use in Parse later on
  58808. * @returns the serialized JSON representation
  58809. */
  58810. serialize(): any;
  58811. }
  58812. }
  58813. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  58814. import { Nullable } from "babylonjs/types";
  58815. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58816. import { Matrix } from "babylonjs/Maths/math.vector";
  58817. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  58818. import "babylonjs/Engines/Extensions/engine.videoTexture";
  58819. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58820. import { Scene } from "babylonjs/scene";
  58821. /**
  58822. * Defines the options related to the creation of an HtmlElementTexture
  58823. */
  58824. export interface IHtmlElementTextureOptions {
  58825. /**
  58826. * Defines wether mip maps should be created or not.
  58827. */
  58828. generateMipMaps?: boolean;
  58829. /**
  58830. * Defines the sampling mode of the texture.
  58831. */
  58832. samplingMode?: number;
  58833. /**
  58834. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  58835. */
  58836. engine: Nullable<ThinEngine>;
  58837. /**
  58838. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  58839. */
  58840. scene: Nullable<Scene>;
  58841. }
  58842. /**
  58843. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  58844. * To be as efficient as possible depending on your constraints nothing aside the first upload
  58845. * is automatically managed.
  58846. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  58847. * in your application.
  58848. *
  58849. * As the update is not automatic, you need to call them manually.
  58850. */
  58851. export class HtmlElementTexture extends BaseTexture {
  58852. /**
  58853. * The texture URL.
  58854. */
  58855. element: HTMLVideoElement | HTMLCanvasElement;
  58856. private static readonly DefaultOptions;
  58857. private _textureMatrix;
  58858. private _engine;
  58859. private _isVideo;
  58860. private _generateMipMaps;
  58861. private _samplingMode;
  58862. /**
  58863. * Instantiates a HtmlElementTexture from the following parameters.
  58864. *
  58865. * @param name Defines the name of the texture
  58866. * @param element Defines the video or canvas the texture is filled with
  58867. * @param options Defines the other none mandatory texture creation options
  58868. */
  58869. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  58870. private _createInternalTexture;
  58871. /**
  58872. * Returns the texture matrix used in most of the material.
  58873. */
  58874. getTextureMatrix(): Matrix;
  58875. /**
  58876. * Updates the content of the texture.
  58877. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  58878. */
  58879. update(invertY?: Nullable<boolean>): void;
  58880. }
  58881. }
  58882. declare module "babylonjs/Materials/Textures/index" {
  58883. export * from "babylonjs/Materials/Textures/baseTexture";
  58884. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  58885. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  58886. export * from "babylonjs/Materials/Textures/cubeTexture";
  58887. export * from "babylonjs/Materials/Textures/dynamicTexture";
  58888. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  58889. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  58890. export * from "babylonjs/Materials/Textures/internalTexture";
  58891. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  58892. export * from "babylonjs/Materials/Textures/Loaders/index";
  58893. export * from "babylonjs/Materials/Textures/mirrorTexture";
  58894. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  58895. export * from "babylonjs/Materials/Textures/Procedurals/index";
  58896. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  58897. export * from "babylonjs/Materials/Textures/rawTexture";
  58898. export * from "babylonjs/Materials/Textures/rawTexture3D";
  58899. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  58900. export * from "babylonjs/Materials/Textures/refractionTexture";
  58901. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  58902. export * from "babylonjs/Materials/Textures/texture";
  58903. export * from "babylonjs/Materials/Textures/videoTexture";
  58904. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  58905. }
  58906. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  58907. /**
  58908. * Enum used to define the target of a block
  58909. */
  58910. export enum NodeMaterialBlockTargets {
  58911. /** Vertex shader */
  58912. Vertex = 1,
  58913. /** Fragment shader */
  58914. Fragment = 2,
  58915. /** Neutral */
  58916. Neutral = 4,
  58917. /** Vertex and Fragment */
  58918. VertexAndFragment = 3
  58919. }
  58920. }
  58921. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  58922. /**
  58923. * Defines the kind of connection point for node based material
  58924. */
  58925. export enum NodeMaterialBlockConnectionPointTypes {
  58926. /** Float */
  58927. Float = 1,
  58928. /** Int */
  58929. Int = 2,
  58930. /** Vector2 */
  58931. Vector2 = 4,
  58932. /** Vector3 */
  58933. Vector3 = 8,
  58934. /** Vector4 */
  58935. Vector4 = 16,
  58936. /** Color3 */
  58937. Color3 = 32,
  58938. /** Color4 */
  58939. Color4 = 64,
  58940. /** Matrix */
  58941. Matrix = 128,
  58942. /** Detect type based on connection */
  58943. AutoDetect = 1024,
  58944. /** Output type that will be defined by input type */
  58945. BasedOnInput = 2048
  58946. }
  58947. }
  58948. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  58949. /**
  58950. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  58951. */
  58952. export enum NodeMaterialBlockConnectionPointMode {
  58953. /** Value is an uniform */
  58954. Uniform = 0,
  58955. /** Value is a mesh attribute */
  58956. Attribute = 1,
  58957. /** Value is a varying between vertex and fragment shaders */
  58958. Varying = 2,
  58959. /** Mode is undefined */
  58960. Undefined = 3
  58961. }
  58962. }
  58963. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  58964. /**
  58965. * Enum used to define system values e.g. values automatically provided by the system
  58966. */
  58967. export enum NodeMaterialSystemValues {
  58968. /** World */
  58969. World = 1,
  58970. /** View */
  58971. View = 2,
  58972. /** Projection */
  58973. Projection = 3,
  58974. /** ViewProjection */
  58975. ViewProjection = 4,
  58976. /** WorldView */
  58977. WorldView = 5,
  58978. /** WorldViewProjection */
  58979. WorldViewProjection = 6,
  58980. /** CameraPosition */
  58981. CameraPosition = 7,
  58982. /** Fog Color */
  58983. FogColor = 8,
  58984. /** Delta time */
  58985. DeltaTime = 9
  58986. }
  58987. }
  58988. declare module "babylonjs/Materials/Node/Enums/index" {
  58989. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58990. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58991. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  58992. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  58993. }
  58994. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  58995. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58996. /**
  58997. * Root class for all node material optimizers
  58998. */
  58999. export class NodeMaterialOptimizer {
  59000. /**
  59001. * Function used to optimize a NodeMaterial graph
  59002. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  59003. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  59004. */
  59005. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  59006. }
  59007. }
  59008. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  59009. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59010. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59011. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59012. import { Scene } from "babylonjs/scene";
  59013. /**
  59014. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  59015. */
  59016. export class TransformBlock extends NodeMaterialBlock {
  59017. /**
  59018. * Defines the value to use to complement W value to transform it to a Vector4
  59019. */
  59020. complementW: number;
  59021. /**
  59022. * Defines the value to use to complement z value to transform it to a Vector4
  59023. */
  59024. complementZ: number;
  59025. /**
  59026. * Creates a new TransformBlock
  59027. * @param name defines the block name
  59028. */
  59029. constructor(name: string);
  59030. /**
  59031. * Gets the current class name
  59032. * @returns the class name
  59033. */
  59034. getClassName(): string;
  59035. /**
  59036. * Gets the vector input
  59037. */
  59038. get vector(): NodeMaterialConnectionPoint;
  59039. /**
  59040. * Gets the output component
  59041. */
  59042. get output(): NodeMaterialConnectionPoint;
  59043. /**
  59044. * Gets the matrix transform input
  59045. */
  59046. get transform(): NodeMaterialConnectionPoint;
  59047. protected _buildBlock(state: NodeMaterialBuildState): this;
  59048. serialize(): any;
  59049. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59050. protected _dumpPropertiesCode(): string;
  59051. }
  59052. }
  59053. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  59054. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59055. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59056. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59057. /**
  59058. * Block used to output the vertex position
  59059. */
  59060. export class VertexOutputBlock extends NodeMaterialBlock {
  59061. /**
  59062. * Creates a new VertexOutputBlock
  59063. * @param name defines the block name
  59064. */
  59065. constructor(name: string);
  59066. /**
  59067. * Gets the current class name
  59068. * @returns the class name
  59069. */
  59070. getClassName(): string;
  59071. /**
  59072. * Gets the vector input component
  59073. */
  59074. get vector(): NodeMaterialConnectionPoint;
  59075. protected _buildBlock(state: NodeMaterialBuildState): this;
  59076. }
  59077. }
  59078. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  59079. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59080. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59081. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59082. /**
  59083. * Block used to output the final color
  59084. */
  59085. export class FragmentOutputBlock extends NodeMaterialBlock {
  59086. /**
  59087. * Create a new FragmentOutputBlock
  59088. * @param name defines the block name
  59089. */
  59090. constructor(name: string);
  59091. /**
  59092. * Gets the current class name
  59093. * @returns the class name
  59094. */
  59095. getClassName(): string;
  59096. /**
  59097. * Gets the rgba input component
  59098. */
  59099. get rgba(): NodeMaterialConnectionPoint;
  59100. /**
  59101. * Gets the rgb input component
  59102. */
  59103. get rgb(): NodeMaterialConnectionPoint;
  59104. /**
  59105. * Gets the a input component
  59106. */
  59107. get a(): NodeMaterialConnectionPoint;
  59108. protected _buildBlock(state: NodeMaterialBuildState): this;
  59109. }
  59110. }
  59111. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  59112. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59113. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59114. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59115. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59116. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59117. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59118. import { Effect } from "babylonjs/Materials/effect";
  59119. import { Mesh } from "babylonjs/Meshes/mesh";
  59120. import { Nullable } from "babylonjs/types";
  59121. import { Scene } from "babylonjs/scene";
  59122. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59123. /**
  59124. * Block used to read a reflection texture from a sampler
  59125. */
  59126. export class ReflectionTextureBlock extends NodeMaterialBlock {
  59127. private _define3DName;
  59128. private _defineCubicName;
  59129. private _defineExplicitName;
  59130. private _defineProjectionName;
  59131. private _defineLocalCubicName;
  59132. private _defineSphericalName;
  59133. private _definePlanarName;
  59134. private _defineEquirectangularName;
  59135. private _defineMirroredEquirectangularFixedName;
  59136. private _defineEquirectangularFixedName;
  59137. private _defineSkyboxName;
  59138. private _cubeSamplerName;
  59139. private _2DSamplerName;
  59140. private _positionUVWName;
  59141. private _directionWName;
  59142. private _reflectionCoordsName;
  59143. private _reflection2DCoordsName;
  59144. private _reflectionColorName;
  59145. private _reflectionMatrixName;
  59146. /**
  59147. * Gets or sets the texture associated with the node
  59148. */
  59149. texture: Nullable<BaseTexture>;
  59150. /**
  59151. * Create a new TextureBlock
  59152. * @param name defines the block name
  59153. */
  59154. constructor(name: string);
  59155. /**
  59156. * Gets the current class name
  59157. * @returns the class name
  59158. */
  59159. getClassName(): string;
  59160. /**
  59161. * Gets the world position input component
  59162. */
  59163. get position(): NodeMaterialConnectionPoint;
  59164. /**
  59165. * Gets the world position input component
  59166. */
  59167. get worldPosition(): NodeMaterialConnectionPoint;
  59168. /**
  59169. * Gets the world normal input component
  59170. */
  59171. get worldNormal(): NodeMaterialConnectionPoint;
  59172. /**
  59173. * Gets the world input component
  59174. */
  59175. get world(): NodeMaterialConnectionPoint;
  59176. /**
  59177. * Gets the camera (or eye) position component
  59178. */
  59179. get cameraPosition(): NodeMaterialConnectionPoint;
  59180. /**
  59181. * Gets the view input component
  59182. */
  59183. get view(): NodeMaterialConnectionPoint;
  59184. /**
  59185. * Gets the rgb output component
  59186. */
  59187. get rgb(): NodeMaterialConnectionPoint;
  59188. /**
  59189. * Gets the r output component
  59190. */
  59191. get r(): NodeMaterialConnectionPoint;
  59192. /**
  59193. * Gets the g output component
  59194. */
  59195. get g(): NodeMaterialConnectionPoint;
  59196. /**
  59197. * Gets the b output component
  59198. */
  59199. get b(): NodeMaterialConnectionPoint;
  59200. autoConfigure(material: NodeMaterial): void;
  59201. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59202. isReady(): boolean;
  59203. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59204. private _injectVertexCode;
  59205. private _writeOutput;
  59206. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59207. protected _dumpPropertiesCode(): string;
  59208. serialize(): any;
  59209. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59210. }
  59211. }
  59212. declare module "babylonjs/Materials/Node/nodeMaterial" {
  59213. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59214. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59215. import { Scene } from "babylonjs/scene";
  59216. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59217. import { Matrix } from "babylonjs/Maths/math.vector";
  59218. import { Mesh } from "babylonjs/Meshes/mesh";
  59219. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59220. import { Observable } from "babylonjs/Misc/observable";
  59221. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59222. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59223. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59224. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59225. import { Nullable } from "babylonjs/types";
  59226. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59227. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59228. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59229. /**
  59230. * Interface used to configure the node material editor
  59231. */
  59232. export interface INodeMaterialEditorOptions {
  59233. /** Define the URl to load node editor script */
  59234. editorURL?: string;
  59235. }
  59236. /** @hidden */
  59237. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  59238. NORMAL: boolean;
  59239. TANGENT: boolean;
  59240. UV1: boolean;
  59241. /** BONES */
  59242. NUM_BONE_INFLUENCERS: number;
  59243. BonesPerMesh: number;
  59244. BONETEXTURE: boolean;
  59245. /** MORPH TARGETS */
  59246. MORPHTARGETS: boolean;
  59247. MORPHTARGETS_NORMAL: boolean;
  59248. MORPHTARGETS_TANGENT: boolean;
  59249. MORPHTARGETS_UV: boolean;
  59250. NUM_MORPH_INFLUENCERS: number;
  59251. /** IMAGE PROCESSING */
  59252. IMAGEPROCESSING: boolean;
  59253. VIGNETTE: boolean;
  59254. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59255. VIGNETTEBLENDMODEOPAQUE: boolean;
  59256. TONEMAPPING: boolean;
  59257. TONEMAPPING_ACES: boolean;
  59258. CONTRAST: boolean;
  59259. EXPOSURE: boolean;
  59260. COLORCURVES: boolean;
  59261. COLORGRADING: boolean;
  59262. COLORGRADING3D: boolean;
  59263. SAMPLER3DGREENDEPTH: boolean;
  59264. SAMPLER3DBGRMAP: boolean;
  59265. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59266. /** MISC. */
  59267. BUMPDIRECTUV: number;
  59268. constructor();
  59269. setValue(name: string, value: boolean): void;
  59270. }
  59271. /**
  59272. * Class used to configure NodeMaterial
  59273. */
  59274. export interface INodeMaterialOptions {
  59275. /**
  59276. * Defines if blocks should emit comments
  59277. */
  59278. emitComments: boolean;
  59279. }
  59280. /**
  59281. * Class used to create a node based material built by assembling shader blocks
  59282. */
  59283. export class NodeMaterial extends PushMaterial {
  59284. private static _BuildIdGenerator;
  59285. private _options;
  59286. private _vertexCompilationState;
  59287. private _fragmentCompilationState;
  59288. private _sharedData;
  59289. private _buildId;
  59290. private _buildWasSuccessful;
  59291. private _cachedWorldViewMatrix;
  59292. private _cachedWorldViewProjectionMatrix;
  59293. private _optimizers;
  59294. private _animationFrame;
  59295. /** Define the Url to load node editor script */
  59296. static EditorURL: string;
  59297. /** Define the Url to load snippets */
  59298. static SnippetUrl: string;
  59299. private BJSNODEMATERIALEDITOR;
  59300. /** Get the inspector from bundle or global */
  59301. private _getGlobalNodeMaterialEditor;
  59302. /**
  59303. * Gets or sets data used by visual editor
  59304. * @see https://nme.babylonjs.com
  59305. */
  59306. editorData: any;
  59307. /**
  59308. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  59309. */
  59310. ignoreAlpha: boolean;
  59311. /**
  59312. * Defines the maximum number of lights that can be used in the material
  59313. */
  59314. maxSimultaneousLights: number;
  59315. /**
  59316. * Observable raised when the material is built
  59317. */
  59318. onBuildObservable: Observable<NodeMaterial>;
  59319. /**
  59320. * Gets or sets the root nodes of the material vertex shader
  59321. */
  59322. _vertexOutputNodes: NodeMaterialBlock[];
  59323. /**
  59324. * Gets or sets the root nodes of the material fragment (pixel) shader
  59325. */
  59326. _fragmentOutputNodes: NodeMaterialBlock[];
  59327. /** Gets or sets options to control the node material overall behavior */
  59328. get options(): INodeMaterialOptions;
  59329. set options(options: INodeMaterialOptions);
  59330. /**
  59331. * Default configuration related to image processing available in the standard Material.
  59332. */
  59333. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59334. /**
  59335. * Gets the image processing configuration used either in this material.
  59336. */
  59337. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59338. /**
  59339. * Sets the Default image processing configuration used either in the this material.
  59340. *
  59341. * If sets to null, the scene one is in use.
  59342. */
  59343. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59344. /**
  59345. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  59346. */
  59347. attachedBlocks: NodeMaterialBlock[];
  59348. /**
  59349. * Create a new node based material
  59350. * @param name defines the material name
  59351. * @param scene defines the hosting scene
  59352. * @param options defines creation option
  59353. */
  59354. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  59355. /**
  59356. * Gets the current class name of the material e.g. "NodeMaterial"
  59357. * @returns the class name
  59358. */
  59359. getClassName(): string;
  59360. /**
  59361. * Keep track of the image processing observer to allow dispose and replace.
  59362. */
  59363. private _imageProcessingObserver;
  59364. /**
  59365. * Attaches a new image processing configuration to the Standard Material.
  59366. * @param configuration
  59367. */
  59368. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59369. /**
  59370. * Get a block by its name
  59371. * @param name defines the name of the block to retrieve
  59372. * @returns the required block or null if not found
  59373. */
  59374. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  59375. /**
  59376. * Get a block by its name
  59377. * @param predicate defines the predicate used to find the good candidate
  59378. * @returns the required block or null if not found
  59379. */
  59380. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  59381. /**
  59382. * Get an input block by its name
  59383. * @param predicate defines the predicate used to find the good candidate
  59384. * @returns the required input block or null if not found
  59385. */
  59386. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  59387. /**
  59388. * Gets the list of input blocks attached to this material
  59389. * @returns an array of InputBlocks
  59390. */
  59391. getInputBlocks(): InputBlock[];
  59392. /**
  59393. * Adds a new optimizer to the list of optimizers
  59394. * @param optimizer defines the optimizers to add
  59395. * @returns the current material
  59396. */
  59397. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59398. /**
  59399. * Remove an optimizer from the list of optimizers
  59400. * @param optimizer defines the optimizers to remove
  59401. * @returns the current material
  59402. */
  59403. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59404. /**
  59405. * Add a new block to the list of output nodes
  59406. * @param node defines the node to add
  59407. * @returns the current material
  59408. */
  59409. addOutputNode(node: NodeMaterialBlock): this;
  59410. /**
  59411. * Remove a block from the list of root nodes
  59412. * @param node defines the node to remove
  59413. * @returns the current material
  59414. */
  59415. removeOutputNode(node: NodeMaterialBlock): this;
  59416. private _addVertexOutputNode;
  59417. private _removeVertexOutputNode;
  59418. private _addFragmentOutputNode;
  59419. private _removeFragmentOutputNode;
  59420. /**
  59421. * Specifies if the material will require alpha blending
  59422. * @returns a boolean specifying if alpha blending is needed
  59423. */
  59424. needAlphaBlending(): boolean;
  59425. /**
  59426. * Specifies if this material should be rendered in alpha test mode
  59427. * @returns a boolean specifying if an alpha test is needed.
  59428. */
  59429. needAlphaTesting(): boolean;
  59430. private _initializeBlock;
  59431. private _resetDualBlocks;
  59432. /**
  59433. * Remove a block from the current node material
  59434. * @param block defines the block to remove
  59435. */
  59436. removeBlock(block: NodeMaterialBlock): void;
  59437. /**
  59438. * Build the material and generates the inner effect
  59439. * @param verbose defines if the build should log activity
  59440. */
  59441. build(verbose?: boolean): void;
  59442. /**
  59443. * Runs an otpimization phase to try to improve the shader code
  59444. */
  59445. optimize(): void;
  59446. private _prepareDefinesForAttributes;
  59447. /**
  59448. * Get if the submesh is ready to be used and all its information available.
  59449. * Child classes can use it to update shaders
  59450. * @param mesh defines the mesh to check
  59451. * @param subMesh defines which submesh to check
  59452. * @param useInstances specifies that instances should be used
  59453. * @returns a boolean indicating that the submesh is ready or not
  59454. */
  59455. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59456. /**
  59457. * Get a string representing the shaders built by the current node graph
  59458. */
  59459. get compiledShaders(): string;
  59460. /**
  59461. * Binds the world matrix to the material
  59462. * @param world defines the world transformation matrix
  59463. */
  59464. bindOnlyWorldMatrix(world: Matrix): void;
  59465. /**
  59466. * Binds the submesh to this material by preparing the effect and shader to draw
  59467. * @param world defines the world transformation matrix
  59468. * @param mesh defines the mesh containing the submesh
  59469. * @param subMesh defines the submesh to bind the material to
  59470. */
  59471. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59472. /**
  59473. * Gets the active textures from the material
  59474. * @returns an array of textures
  59475. */
  59476. getActiveTextures(): BaseTexture[];
  59477. /**
  59478. * Gets the list of texture blocks
  59479. * @returns an array of texture blocks
  59480. */
  59481. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  59482. /**
  59483. * Specifies if the material uses a texture
  59484. * @param texture defines the texture to check against the material
  59485. * @returns a boolean specifying if the material uses the texture
  59486. */
  59487. hasTexture(texture: BaseTexture): boolean;
  59488. /**
  59489. * Disposes the material
  59490. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  59491. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  59492. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  59493. */
  59494. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  59495. /** Creates the node editor window. */
  59496. private _createNodeEditor;
  59497. /**
  59498. * Launch the node material editor
  59499. * @param config Define the configuration of the editor
  59500. * @return a promise fulfilled when the node editor is visible
  59501. */
  59502. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  59503. /**
  59504. * Clear the current material
  59505. */
  59506. clear(): void;
  59507. /**
  59508. * Clear the current material and set it to a default state
  59509. */
  59510. setToDefault(): void;
  59511. /**
  59512. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  59513. * @param url defines the url to load from
  59514. * @returns a promise that will fullfil when the material is fully loaded
  59515. */
  59516. loadAsync(url: string): Promise<void>;
  59517. private _gatherBlocks;
  59518. /**
  59519. * Generate a string containing the code declaration required to create an equivalent of this material
  59520. * @returns a string
  59521. */
  59522. generateCode(): string;
  59523. /**
  59524. * Serializes this material in a JSON representation
  59525. * @returns the serialized material object
  59526. */
  59527. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  59528. private _restoreConnections;
  59529. /**
  59530. * Clear the current graph and load a new one from a serialization object
  59531. * @param source defines the JSON representation of the material
  59532. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59533. */
  59534. loadFromSerialization(source: any, rootUrl?: string): void;
  59535. /**
  59536. * Creates a node material from parsed material data
  59537. * @param source defines the JSON representation of the material
  59538. * @param scene defines the hosting scene
  59539. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59540. * @returns a new node material
  59541. */
  59542. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  59543. /**
  59544. * Creates a node material from a snippet saved by the node material editor
  59545. * @param snippetId defines the snippet to load
  59546. * @param scene defines the hosting scene
  59547. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59548. * @returns a promise that will resolve to the new node material
  59549. */
  59550. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  59551. /**
  59552. * Creates a new node material set to default basic configuration
  59553. * @param name defines the name of the material
  59554. * @param scene defines the hosting scene
  59555. * @returns a new NodeMaterial
  59556. */
  59557. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  59558. }
  59559. }
  59560. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  59561. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59562. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59563. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59564. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59565. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59566. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59567. import { Effect } from "babylonjs/Materials/effect";
  59568. import { Mesh } from "babylonjs/Meshes/mesh";
  59569. import { Nullable } from "babylonjs/types";
  59570. import { Texture } from "babylonjs/Materials/Textures/texture";
  59571. import { Scene } from "babylonjs/scene";
  59572. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59573. /**
  59574. * Block used to read a texture from a sampler
  59575. */
  59576. export class TextureBlock extends NodeMaterialBlock {
  59577. private _defineName;
  59578. private _linearDefineName;
  59579. private _tempTextureRead;
  59580. private _samplerName;
  59581. private _transformedUVName;
  59582. private _textureTransformName;
  59583. private _textureInfoName;
  59584. private _mainUVName;
  59585. private _mainUVDefineName;
  59586. /**
  59587. * Gets or sets the texture associated with the node
  59588. */
  59589. texture: Nullable<Texture>;
  59590. /**
  59591. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  59592. */
  59593. convertToGammaSpace: boolean;
  59594. /**
  59595. * Create a new TextureBlock
  59596. * @param name defines the block name
  59597. */
  59598. constructor(name: string);
  59599. /**
  59600. * Gets the current class name
  59601. * @returns the class name
  59602. */
  59603. getClassName(): string;
  59604. /**
  59605. * Gets the uv input component
  59606. */
  59607. get uv(): NodeMaterialConnectionPoint;
  59608. /**
  59609. * Gets the rgba output component
  59610. */
  59611. get rgba(): NodeMaterialConnectionPoint;
  59612. /**
  59613. * Gets the rgb output component
  59614. */
  59615. get rgb(): NodeMaterialConnectionPoint;
  59616. /**
  59617. * Gets the r output component
  59618. */
  59619. get r(): NodeMaterialConnectionPoint;
  59620. /**
  59621. * Gets the g output component
  59622. */
  59623. get g(): NodeMaterialConnectionPoint;
  59624. /**
  59625. * Gets the b output component
  59626. */
  59627. get b(): NodeMaterialConnectionPoint;
  59628. /**
  59629. * Gets the a output component
  59630. */
  59631. get a(): NodeMaterialConnectionPoint;
  59632. get target(): NodeMaterialBlockTargets;
  59633. autoConfigure(material: NodeMaterial): void;
  59634. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59635. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59636. isReady(): boolean;
  59637. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59638. private get _isMixed();
  59639. private _injectVertexCode;
  59640. private _writeTextureRead;
  59641. private _writeOutput;
  59642. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59643. protected _dumpPropertiesCode(): string;
  59644. serialize(): any;
  59645. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59646. }
  59647. }
  59648. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  59649. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59650. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59651. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59652. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59653. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59654. import { Scene } from "babylonjs/scene";
  59655. /**
  59656. * Class used to store shared data between 2 NodeMaterialBuildState
  59657. */
  59658. export class NodeMaterialBuildStateSharedData {
  59659. /**
  59660. * Gets the list of emitted varyings
  59661. */
  59662. temps: string[];
  59663. /**
  59664. * Gets the list of emitted varyings
  59665. */
  59666. varyings: string[];
  59667. /**
  59668. * Gets the varying declaration string
  59669. */
  59670. varyingDeclaration: string;
  59671. /**
  59672. * Input blocks
  59673. */
  59674. inputBlocks: InputBlock[];
  59675. /**
  59676. * Input blocks
  59677. */
  59678. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  59679. /**
  59680. * Bindable blocks (Blocks that need to set data to the effect)
  59681. */
  59682. bindableBlocks: NodeMaterialBlock[];
  59683. /**
  59684. * List of blocks that can provide a compilation fallback
  59685. */
  59686. blocksWithFallbacks: NodeMaterialBlock[];
  59687. /**
  59688. * List of blocks that can provide a define update
  59689. */
  59690. blocksWithDefines: NodeMaterialBlock[];
  59691. /**
  59692. * List of blocks that can provide a repeatable content
  59693. */
  59694. repeatableContentBlocks: NodeMaterialBlock[];
  59695. /**
  59696. * List of blocks that can provide a dynamic list of uniforms
  59697. */
  59698. dynamicUniformBlocks: NodeMaterialBlock[];
  59699. /**
  59700. * List of blocks that can block the isReady function for the material
  59701. */
  59702. blockingBlocks: NodeMaterialBlock[];
  59703. /**
  59704. * Gets the list of animated inputs
  59705. */
  59706. animatedInputs: InputBlock[];
  59707. /**
  59708. * Build Id used to avoid multiple recompilations
  59709. */
  59710. buildId: number;
  59711. /** List of emitted variables */
  59712. variableNames: {
  59713. [key: string]: number;
  59714. };
  59715. /** List of emitted defines */
  59716. defineNames: {
  59717. [key: string]: number;
  59718. };
  59719. /** Should emit comments? */
  59720. emitComments: boolean;
  59721. /** Emit build activity */
  59722. verbose: boolean;
  59723. /** Gets or sets the hosting scene */
  59724. scene: Scene;
  59725. /**
  59726. * Gets the compilation hints emitted at compilation time
  59727. */
  59728. hints: {
  59729. needWorldViewMatrix: boolean;
  59730. needWorldViewProjectionMatrix: boolean;
  59731. needAlphaBlending: boolean;
  59732. needAlphaTesting: boolean;
  59733. };
  59734. /**
  59735. * List of compilation checks
  59736. */
  59737. checks: {
  59738. emitVertex: boolean;
  59739. emitFragment: boolean;
  59740. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  59741. };
  59742. /** Creates a new shared data */
  59743. constructor();
  59744. /**
  59745. * Emits console errors and exceptions if there is a failing check
  59746. */
  59747. emitErrors(): void;
  59748. }
  59749. }
  59750. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  59751. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59752. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59753. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  59754. /**
  59755. * Class used to store node based material build state
  59756. */
  59757. export class NodeMaterialBuildState {
  59758. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  59759. supportUniformBuffers: boolean;
  59760. /**
  59761. * Gets the list of emitted attributes
  59762. */
  59763. attributes: string[];
  59764. /**
  59765. * Gets the list of emitted uniforms
  59766. */
  59767. uniforms: string[];
  59768. /**
  59769. * Gets the list of emitted constants
  59770. */
  59771. constants: string[];
  59772. /**
  59773. * Gets the list of emitted samplers
  59774. */
  59775. samplers: string[];
  59776. /**
  59777. * Gets the list of emitted functions
  59778. */
  59779. functions: {
  59780. [key: string]: string;
  59781. };
  59782. /**
  59783. * Gets the list of emitted extensions
  59784. */
  59785. extensions: {
  59786. [key: string]: string;
  59787. };
  59788. /**
  59789. * Gets the target of the compilation state
  59790. */
  59791. target: NodeMaterialBlockTargets;
  59792. /**
  59793. * Gets the list of emitted counters
  59794. */
  59795. counters: {
  59796. [key: string]: number;
  59797. };
  59798. /**
  59799. * Shared data between multiple NodeMaterialBuildState instances
  59800. */
  59801. sharedData: NodeMaterialBuildStateSharedData;
  59802. /** @hidden */
  59803. _vertexState: NodeMaterialBuildState;
  59804. /** @hidden */
  59805. _attributeDeclaration: string;
  59806. /** @hidden */
  59807. _uniformDeclaration: string;
  59808. /** @hidden */
  59809. _constantDeclaration: string;
  59810. /** @hidden */
  59811. _samplerDeclaration: string;
  59812. /** @hidden */
  59813. _varyingTransfer: string;
  59814. private _repeatableContentAnchorIndex;
  59815. /** @hidden */
  59816. _builtCompilationString: string;
  59817. /**
  59818. * Gets the emitted compilation strings
  59819. */
  59820. compilationString: string;
  59821. /**
  59822. * Finalize the compilation strings
  59823. * @param state defines the current compilation state
  59824. */
  59825. finalize(state: NodeMaterialBuildState): void;
  59826. /** @hidden */
  59827. get _repeatableContentAnchor(): string;
  59828. /** @hidden */
  59829. _getFreeVariableName(prefix: string): string;
  59830. /** @hidden */
  59831. _getFreeDefineName(prefix: string): string;
  59832. /** @hidden */
  59833. _excludeVariableName(name: string): void;
  59834. /** @hidden */
  59835. _emit2DSampler(name: string): void;
  59836. /** @hidden */
  59837. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  59838. /** @hidden */
  59839. _emitExtension(name: string, extension: string): void;
  59840. /** @hidden */
  59841. _emitFunction(name: string, code: string, comments: string): void;
  59842. /** @hidden */
  59843. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  59844. replaceStrings?: {
  59845. search: RegExp;
  59846. replace: string;
  59847. }[];
  59848. repeatKey?: string;
  59849. }): string;
  59850. /** @hidden */
  59851. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  59852. repeatKey?: string;
  59853. removeAttributes?: boolean;
  59854. removeUniforms?: boolean;
  59855. removeVaryings?: boolean;
  59856. removeIfDef?: boolean;
  59857. replaceStrings?: {
  59858. search: RegExp;
  59859. replace: string;
  59860. }[];
  59861. }, storeKey?: string): void;
  59862. /** @hidden */
  59863. _registerTempVariable(name: string): boolean;
  59864. /** @hidden */
  59865. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  59866. /** @hidden */
  59867. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  59868. /** @hidden */
  59869. _emitFloat(value: number): string;
  59870. }
  59871. }
  59872. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  59873. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59874. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59875. import { Nullable } from "babylonjs/types";
  59876. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59877. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59878. import { Effect } from "babylonjs/Materials/effect";
  59879. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59880. import { Mesh } from "babylonjs/Meshes/mesh";
  59881. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59882. import { Scene } from "babylonjs/scene";
  59883. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  59884. /**
  59885. * Defines a block that can be used inside a node based material
  59886. */
  59887. export class NodeMaterialBlock {
  59888. private _buildId;
  59889. private _buildTarget;
  59890. private _target;
  59891. private _isFinalMerger;
  59892. private _isInput;
  59893. protected _isUnique: boolean;
  59894. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  59895. inputsAreExclusive: boolean;
  59896. /** @hidden */
  59897. _codeVariableName: string;
  59898. /** @hidden */
  59899. _inputs: NodeMaterialConnectionPoint[];
  59900. /** @hidden */
  59901. _outputs: NodeMaterialConnectionPoint[];
  59902. /** @hidden */
  59903. _preparationId: number;
  59904. /**
  59905. * Gets or sets the name of the block
  59906. */
  59907. name: string;
  59908. /**
  59909. * Gets or sets the unique id of the node
  59910. */
  59911. uniqueId: number;
  59912. /**
  59913. * Gets or sets the comments associated with this block
  59914. */
  59915. comments: string;
  59916. /**
  59917. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  59918. */
  59919. get isUnique(): boolean;
  59920. /**
  59921. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  59922. */
  59923. get isFinalMerger(): boolean;
  59924. /**
  59925. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  59926. */
  59927. get isInput(): boolean;
  59928. /**
  59929. * Gets or sets the build Id
  59930. */
  59931. get buildId(): number;
  59932. set buildId(value: number);
  59933. /**
  59934. * Gets or sets the target of the block
  59935. */
  59936. get target(): NodeMaterialBlockTargets;
  59937. set target(value: NodeMaterialBlockTargets);
  59938. /**
  59939. * Gets the list of input points
  59940. */
  59941. get inputs(): NodeMaterialConnectionPoint[];
  59942. /** Gets the list of output points */
  59943. get outputs(): NodeMaterialConnectionPoint[];
  59944. /**
  59945. * Find an input by its name
  59946. * @param name defines the name of the input to look for
  59947. * @returns the input or null if not found
  59948. */
  59949. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  59950. /**
  59951. * Find an output by its name
  59952. * @param name defines the name of the outputto look for
  59953. * @returns the output or null if not found
  59954. */
  59955. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  59956. /**
  59957. * Creates a new NodeMaterialBlock
  59958. * @param name defines the block name
  59959. * @param target defines the target of that block (Vertex by default)
  59960. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  59961. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  59962. */
  59963. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  59964. /**
  59965. * Initialize the block and prepare the context for build
  59966. * @param state defines the state that will be used for the build
  59967. */
  59968. initialize(state: NodeMaterialBuildState): void;
  59969. /**
  59970. * Bind data to effect. Will only be called for blocks with isBindable === true
  59971. * @param effect defines the effect to bind data to
  59972. * @param nodeMaterial defines the hosting NodeMaterial
  59973. * @param mesh defines the mesh that will be rendered
  59974. */
  59975. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59976. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  59977. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  59978. protected _writeFloat(value: number): string;
  59979. /**
  59980. * Gets the current class name e.g. "NodeMaterialBlock"
  59981. * @returns the class name
  59982. */
  59983. getClassName(): string;
  59984. /**
  59985. * Register a new input. Must be called inside a block constructor
  59986. * @param name defines the connection point name
  59987. * @param type defines the connection point type
  59988. * @param isOptional defines a boolean indicating that this input can be omitted
  59989. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  59990. * @returns the current block
  59991. */
  59992. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  59993. /**
  59994. * Register a new output. Must be called inside a block constructor
  59995. * @param name defines the connection point name
  59996. * @param type defines the connection point type
  59997. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  59998. * @returns the current block
  59999. */
  60000. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  60001. /**
  60002. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  60003. * @param forOutput defines an optional connection point to check compatibility with
  60004. * @returns the first available input or null
  60005. */
  60006. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  60007. /**
  60008. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  60009. * @param forBlock defines an optional block to check compatibility with
  60010. * @returns the first available input or null
  60011. */
  60012. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  60013. /**
  60014. * Gets the sibling of the given output
  60015. * @param current defines the current output
  60016. * @returns the next output in the list or null
  60017. */
  60018. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  60019. /**
  60020. * Connect current block with another block
  60021. * @param other defines the block to connect with
  60022. * @param options define the various options to help pick the right connections
  60023. * @returns the current block
  60024. */
  60025. connectTo(other: NodeMaterialBlock, options?: {
  60026. input?: string;
  60027. output?: string;
  60028. outputSwizzle?: string;
  60029. }): this | undefined;
  60030. protected _buildBlock(state: NodeMaterialBuildState): void;
  60031. /**
  60032. * Add uniforms, samplers and uniform buffers at compilation time
  60033. * @param state defines the state to update
  60034. * @param nodeMaterial defines the node material requesting the update
  60035. * @param defines defines the material defines to update
  60036. * @param uniformBuffers defines the list of uniform buffer names
  60037. */
  60038. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  60039. /**
  60040. * Add potential fallbacks if shader compilation fails
  60041. * @param mesh defines the mesh to be rendered
  60042. * @param fallbacks defines the current prioritized list of fallbacks
  60043. */
  60044. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60045. /**
  60046. * Initialize defines for shader compilation
  60047. * @param mesh defines the mesh to be rendered
  60048. * @param nodeMaterial defines the node material requesting the update
  60049. * @param defines defines the material defines to update
  60050. * @param useInstances specifies that instances should be used
  60051. */
  60052. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60053. /**
  60054. * Update defines for shader compilation
  60055. * @param mesh defines the mesh to be rendered
  60056. * @param nodeMaterial defines the node material requesting the update
  60057. * @param defines defines the material defines to update
  60058. * @param useInstances specifies that instances should be used
  60059. */
  60060. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60061. /**
  60062. * Lets the block try to connect some inputs automatically
  60063. * @param material defines the hosting NodeMaterial
  60064. */
  60065. autoConfigure(material: NodeMaterial): void;
  60066. /**
  60067. * Function called when a block is declared as repeatable content generator
  60068. * @param vertexShaderState defines the current compilation state for the vertex shader
  60069. * @param fragmentShaderState defines the current compilation state for the fragment shader
  60070. * @param mesh defines the mesh to be rendered
  60071. * @param defines defines the material defines to update
  60072. */
  60073. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60074. /**
  60075. * Checks if the block is ready
  60076. * @param mesh defines the mesh to be rendered
  60077. * @param nodeMaterial defines the node material requesting the update
  60078. * @param defines defines the material defines to update
  60079. * @param useInstances specifies that instances should be used
  60080. * @returns true if the block is ready
  60081. */
  60082. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  60083. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  60084. private _processBuild;
  60085. /**
  60086. * Compile the current node and generate the shader code
  60087. * @param state defines the current compilation state (uniforms, samplers, current string)
  60088. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  60089. * @returns true if already built
  60090. */
  60091. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  60092. protected _inputRename(name: string): string;
  60093. protected _outputRename(name: string): string;
  60094. protected _dumpPropertiesCode(): string;
  60095. /** @hidden */
  60096. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  60097. /** @hidden */
  60098. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  60099. /**
  60100. * Clone the current block to a new identical block
  60101. * @param scene defines the hosting scene
  60102. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60103. * @returns a copy of the current block
  60104. */
  60105. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  60106. /**
  60107. * Serializes this block in a JSON representation
  60108. * @returns the serialized block object
  60109. */
  60110. serialize(): any;
  60111. /** @hidden */
  60112. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60113. /**
  60114. * Release resources
  60115. */
  60116. dispose(): void;
  60117. }
  60118. }
  60119. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  60120. /**
  60121. * Enum defining the type of animations supported by InputBlock
  60122. */
  60123. export enum AnimatedInputBlockTypes {
  60124. /** No animation */
  60125. None = 0,
  60126. /** Time based animation. Will only work for floats */
  60127. Time = 1
  60128. }
  60129. }
  60130. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  60131. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60132. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60133. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  60134. import { Nullable } from "babylonjs/types";
  60135. import { Effect } from "babylonjs/Materials/effect";
  60136. import { Matrix } from "babylonjs/Maths/math.vector";
  60137. import { Scene } from "babylonjs/scene";
  60138. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60139. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60140. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60141. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  60142. /**
  60143. * Block used to expose an input value
  60144. */
  60145. export class InputBlock extends NodeMaterialBlock {
  60146. private _mode;
  60147. private _associatedVariableName;
  60148. private _storedValue;
  60149. private _valueCallback;
  60150. private _type;
  60151. private _animationType;
  60152. /** Gets or set a value used to limit the range of float values */
  60153. min: number;
  60154. /** Gets or set a value used to limit the range of float values */
  60155. max: number;
  60156. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  60157. isBoolean: boolean;
  60158. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  60159. matrixMode: number;
  60160. /** @hidden */
  60161. _systemValue: Nullable<NodeMaterialSystemValues>;
  60162. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  60163. visibleInInspector: boolean;
  60164. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  60165. isConstant: boolean;
  60166. /** Gets or sets the group to use to display this block in the Inspector */
  60167. groupInInspector: string;
  60168. /**
  60169. * Gets or sets the connection point type (default is float)
  60170. */
  60171. get type(): NodeMaterialBlockConnectionPointTypes;
  60172. /**
  60173. * Creates a new InputBlock
  60174. * @param name defines the block name
  60175. * @param target defines the target of that block (Vertex by default)
  60176. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  60177. */
  60178. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  60179. /**
  60180. * Gets the output component
  60181. */
  60182. get output(): NodeMaterialConnectionPoint;
  60183. /**
  60184. * Set the source of this connection point to a vertex attribute
  60185. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  60186. * @returns the current connection point
  60187. */
  60188. setAsAttribute(attributeName?: string): InputBlock;
  60189. /**
  60190. * Set the source of this connection point to a system value
  60191. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  60192. * @returns the current connection point
  60193. */
  60194. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  60195. /**
  60196. * Gets or sets the value of that point.
  60197. * Please note that this value will be ignored if valueCallback is defined
  60198. */
  60199. get value(): any;
  60200. set value(value: any);
  60201. /**
  60202. * Gets or sets a callback used to get the value of that point.
  60203. * Please note that setting this value will force the connection point to ignore the value property
  60204. */
  60205. get valueCallback(): () => any;
  60206. set valueCallback(value: () => any);
  60207. /**
  60208. * Gets or sets the associated variable name in the shader
  60209. */
  60210. get associatedVariableName(): string;
  60211. set associatedVariableName(value: string);
  60212. /** Gets or sets the type of animation applied to the input */
  60213. get animationType(): AnimatedInputBlockTypes;
  60214. set animationType(value: AnimatedInputBlockTypes);
  60215. /**
  60216. * Gets a boolean indicating that this connection point not defined yet
  60217. */
  60218. get isUndefined(): boolean;
  60219. /**
  60220. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  60221. * In this case the connection point name must be the name of the uniform to use.
  60222. * Can only be set on inputs
  60223. */
  60224. get isUniform(): boolean;
  60225. set isUniform(value: boolean);
  60226. /**
  60227. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  60228. * In this case the connection point name must be the name of the attribute to use
  60229. * Can only be set on inputs
  60230. */
  60231. get isAttribute(): boolean;
  60232. set isAttribute(value: boolean);
  60233. /**
  60234. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  60235. * Can only be set on exit points
  60236. */
  60237. get isVarying(): boolean;
  60238. set isVarying(value: boolean);
  60239. /**
  60240. * Gets a boolean indicating that the current connection point is a system value
  60241. */
  60242. get isSystemValue(): boolean;
  60243. /**
  60244. * Gets or sets the current well known value or null if not defined as a system value
  60245. */
  60246. get systemValue(): Nullable<NodeMaterialSystemValues>;
  60247. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  60248. /**
  60249. * Gets the current class name
  60250. * @returns the class name
  60251. */
  60252. getClassName(): string;
  60253. /**
  60254. * Animate the input if animationType !== None
  60255. * @param scene defines the rendering scene
  60256. */
  60257. animate(scene: Scene): void;
  60258. private _emitDefine;
  60259. initialize(state: NodeMaterialBuildState): void;
  60260. /**
  60261. * Set the input block to its default value (based on its type)
  60262. */
  60263. setDefaultValue(): void;
  60264. private _emitConstant;
  60265. private _emit;
  60266. /** @hidden */
  60267. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  60268. /** @hidden */
  60269. _transmit(effect: Effect, scene: Scene): void;
  60270. protected _buildBlock(state: NodeMaterialBuildState): void;
  60271. protected _dumpPropertiesCode(): string;
  60272. serialize(): any;
  60273. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60274. }
  60275. }
  60276. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  60277. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60278. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60279. import { Nullable } from "babylonjs/types";
  60280. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60281. import { Observable } from "babylonjs/Misc/observable";
  60282. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60283. /**
  60284. * Enum used to define the compatibility state between two connection points
  60285. */
  60286. export enum NodeMaterialConnectionPointCompatibilityStates {
  60287. /** Points are compatibles */
  60288. Compatible = 0,
  60289. /** Points are incompatible because of their types */
  60290. TypeIncompatible = 1,
  60291. /** Points are incompatible because of their targets (vertex vs fragment) */
  60292. TargetIncompatible = 2
  60293. }
  60294. /**
  60295. * Defines the direction of a connection point
  60296. */
  60297. export enum NodeMaterialConnectionPointDirection {
  60298. /** Input */
  60299. Input = 0,
  60300. /** Output */
  60301. Output = 1
  60302. }
  60303. /**
  60304. * Defines a connection point for a block
  60305. */
  60306. export class NodeMaterialConnectionPoint {
  60307. /** @hidden */
  60308. _ownerBlock: NodeMaterialBlock;
  60309. /** @hidden */
  60310. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  60311. private _endpoints;
  60312. private _associatedVariableName;
  60313. private _direction;
  60314. /** @hidden */
  60315. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60316. /** @hidden */
  60317. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60318. private _type;
  60319. /** @hidden */
  60320. _enforceAssociatedVariableName: boolean;
  60321. /** Gets the direction of the point */
  60322. get direction(): NodeMaterialConnectionPointDirection;
  60323. /**
  60324. * Gets or sets the additional types supported by this connection point
  60325. */
  60326. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60327. /**
  60328. * Gets or sets the additional types excluded by this connection point
  60329. */
  60330. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60331. /**
  60332. * Observable triggered when this point is connected
  60333. */
  60334. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  60335. /**
  60336. * Gets or sets the associated variable name in the shader
  60337. */
  60338. get associatedVariableName(): string;
  60339. set associatedVariableName(value: string);
  60340. /** Get the inner type (ie AutoDetect for isntance instead of the inferred one) */
  60341. get innerType(): NodeMaterialBlockConnectionPointTypes;
  60342. /**
  60343. * Gets or sets the connection point type (default is float)
  60344. */
  60345. get type(): NodeMaterialBlockConnectionPointTypes;
  60346. set type(value: NodeMaterialBlockConnectionPointTypes);
  60347. /**
  60348. * Gets or sets the connection point name
  60349. */
  60350. name: string;
  60351. /**
  60352. * Gets or sets a boolean indicating that this connection point can be omitted
  60353. */
  60354. isOptional: boolean;
  60355. /**
  60356. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  60357. */
  60358. define: string;
  60359. /** @hidden */
  60360. _prioritizeVertex: boolean;
  60361. private _target;
  60362. /** Gets or sets the target of that connection point */
  60363. get target(): NodeMaterialBlockTargets;
  60364. set target(value: NodeMaterialBlockTargets);
  60365. /**
  60366. * Gets a boolean indicating that the current point is connected
  60367. */
  60368. get isConnected(): boolean;
  60369. /**
  60370. * Gets a boolean indicating that the current point is connected to an input block
  60371. */
  60372. get isConnectedToInputBlock(): boolean;
  60373. /**
  60374. * Gets a the connected input block (if any)
  60375. */
  60376. get connectInputBlock(): Nullable<InputBlock>;
  60377. /** Get the other side of the connection (if any) */
  60378. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  60379. /** Get the block that owns this connection point */
  60380. get ownerBlock(): NodeMaterialBlock;
  60381. /** Get the block connected on the other side of this connection (if any) */
  60382. get sourceBlock(): Nullable<NodeMaterialBlock>;
  60383. /** Get the block connected on the endpoints of this connection (if any) */
  60384. get connectedBlocks(): Array<NodeMaterialBlock>;
  60385. /** Gets the list of connected endpoints */
  60386. get endpoints(): NodeMaterialConnectionPoint[];
  60387. /** Gets a boolean indicating if that output point is connected to at least one input */
  60388. get hasEndpoints(): boolean;
  60389. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  60390. get isConnectedInVertexShader(): boolean;
  60391. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  60392. get isConnectedInFragmentShader(): boolean;
  60393. /**
  60394. * Creates a new connection point
  60395. * @param name defines the connection point name
  60396. * @param ownerBlock defines the block hosting this connection point
  60397. * @param direction defines the direction of the connection point
  60398. */
  60399. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  60400. /**
  60401. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  60402. * @returns the class name
  60403. */
  60404. getClassName(): string;
  60405. /**
  60406. * Gets a boolean indicating if the current point can be connected to another point
  60407. * @param connectionPoint defines the other connection point
  60408. * @returns a boolean
  60409. */
  60410. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  60411. /**
  60412. * Gets a number indicating if the current point can be connected to another point
  60413. * @param connectionPoint defines the other connection point
  60414. * @returns a number defining the compatibility state
  60415. */
  60416. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  60417. /**
  60418. * Connect this point to another connection point
  60419. * @param connectionPoint defines the other connection point
  60420. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  60421. * @returns the current connection point
  60422. */
  60423. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  60424. /**
  60425. * Disconnect this point from one of his endpoint
  60426. * @param endpoint defines the other connection point
  60427. * @returns the current connection point
  60428. */
  60429. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  60430. /**
  60431. * Serializes this point in a JSON representation
  60432. * @returns the serialized point object
  60433. */
  60434. serialize(): any;
  60435. /**
  60436. * Release resources
  60437. */
  60438. dispose(): void;
  60439. }
  60440. }
  60441. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  60442. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60443. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60444. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60445. import { Mesh } from "babylonjs/Meshes/mesh";
  60446. import { Effect } from "babylonjs/Materials/effect";
  60447. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60448. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60449. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60450. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60451. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60452. /**
  60453. * Block used to add support for vertex skinning (bones)
  60454. */
  60455. export class BonesBlock extends NodeMaterialBlock {
  60456. /**
  60457. * Creates a new BonesBlock
  60458. * @param name defines the block name
  60459. */
  60460. constructor(name: string);
  60461. /**
  60462. * Initialize the block and prepare the context for build
  60463. * @param state defines the state that will be used for the build
  60464. */
  60465. initialize(state: NodeMaterialBuildState): void;
  60466. /**
  60467. * Gets the current class name
  60468. * @returns the class name
  60469. */
  60470. getClassName(): string;
  60471. /**
  60472. * Gets the matrix indices input component
  60473. */
  60474. get matricesIndices(): NodeMaterialConnectionPoint;
  60475. /**
  60476. * Gets the matrix weights input component
  60477. */
  60478. get matricesWeights(): NodeMaterialConnectionPoint;
  60479. /**
  60480. * Gets the extra matrix indices input component
  60481. */
  60482. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60483. /**
  60484. * Gets the extra matrix weights input component
  60485. */
  60486. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60487. /**
  60488. * Gets the world input component
  60489. */
  60490. get world(): NodeMaterialConnectionPoint;
  60491. /**
  60492. * Gets the output component
  60493. */
  60494. get output(): NodeMaterialConnectionPoint;
  60495. autoConfigure(material: NodeMaterial): void;
  60496. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60497. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60498. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60499. protected _buildBlock(state: NodeMaterialBuildState): this;
  60500. }
  60501. }
  60502. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  60503. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60504. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60505. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60506. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60507. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60508. /**
  60509. * Block used to add support for instances
  60510. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60511. */
  60512. export class InstancesBlock extends NodeMaterialBlock {
  60513. /**
  60514. * Creates a new InstancesBlock
  60515. * @param name defines the block name
  60516. */
  60517. constructor(name: string);
  60518. /**
  60519. * Gets the current class name
  60520. * @returns the class name
  60521. */
  60522. getClassName(): string;
  60523. /**
  60524. * Gets the first world row input component
  60525. */
  60526. get world0(): NodeMaterialConnectionPoint;
  60527. /**
  60528. * Gets the second world row input component
  60529. */
  60530. get world1(): NodeMaterialConnectionPoint;
  60531. /**
  60532. * Gets the third world row input component
  60533. */
  60534. get world2(): NodeMaterialConnectionPoint;
  60535. /**
  60536. * Gets the forth world row input component
  60537. */
  60538. get world3(): NodeMaterialConnectionPoint;
  60539. /**
  60540. * Gets the world input component
  60541. */
  60542. get world(): NodeMaterialConnectionPoint;
  60543. /**
  60544. * Gets the output component
  60545. */
  60546. get output(): NodeMaterialConnectionPoint;
  60547. /**
  60548. * Gets the isntanceID component
  60549. */
  60550. get instanceID(): NodeMaterialConnectionPoint;
  60551. autoConfigure(material: NodeMaterial): void;
  60552. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60553. protected _buildBlock(state: NodeMaterialBuildState): this;
  60554. }
  60555. }
  60556. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  60557. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60558. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60559. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60560. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60561. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60562. import { Effect } from "babylonjs/Materials/effect";
  60563. import { Mesh } from "babylonjs/Meshes/mesh";
  60564. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60565. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60566. /**
  60567. * Block used to add morph targets support to vertex shader
  60568. */
  60569. export class MorphTargetsBlock extends NodeMaterialBlock {
  60570. private _repeatableContentAnchor;
  60571. /**
  60572. * Create a new MorphTargetsBlock
  60573. * @param name defines the block name
  60574. */
  60575. constructor(name: string);
  60576. /**
  60577. * Gets the current class name
  60578. * @returns the class name
  60579. */
  60580. getClassName(): string;
  60581. /**
  60582. * Gets the position input component
  60583. */
  60584. get position(): NodeMaterialConnectionPoint;
  60585. /**
  60586. * Gets the normal input component
  60587. */
  60588. get normal(): NodeMaterialConnectionPoint;
  60589. /**
  60590. * Gets the tangent input component
  60591. */
  60592. get tangent(): NodeMaterialConnectionPoint;
  60593. /**
  60594. * Gets the tangent input component
  60595. */
  60596. get uv(): NodeMaterialConnectionPoint;
  60597. /**
  60598. * Gets the position output component
  60599. */
  60600. get positionOutput(): NodeMaterialConnectionPoint;
  60601. /**
  60602. * Gets the normal output component
  60603. */
  60604. get normalOutput(): NodeMaterialConnectionPoint;
  60605. /**
  60606. * Gets the tangent output component
  60607. */
  60608. get tangentOutput(): NodeMaterialConnectionPoint;
  60609. /**
  60610. * Gets the tangent output component
  60611. */
  60612. get uvOutput(): NodeMaterialConnectionPoint;
  60613. initialize(state: NodeMaterialBuildState): void;
  60614. autoConfigure(material: NodeMaterial): void;
  60615. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60616. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60617. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60618. protected _buildBlock(state: NodeMaterialBuildState): this;
  60619. }
  60620. }
  60621. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  60622. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60623. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60624. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60625. import { Nullable } from "babylonjs/types";
  60626. import { Scene } from "babylonjs/scene";
  60627. import { Effect } from "babylonjs/Materials/effect";
  60628. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60629. import { Mesh } from "babylonjs/Meshes/mesh";
  60630. import { Light } from "babylonjs/Lights/light";
  60631. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60632. /**
  60633. * Block used to get data information from a light
  60634. */
  60635. export class LightInformationBlock extends NodeMaterialBlock {
  60636. private _lightDataUniformName;
  60637. private _lightColorUniformName;
  60638. private _lightTypeDefineName;
  60639. /**
  60640. * Gets or sets the light associated with this block
  60641. */
  60642. light: Nullable<Light>;
  60643. /**
  60644. * Creates a new LightInformationBlock
  60645. * @param name defines the block name
  60646. */
  60647. constructor(name: string);
  60648. /**
  60649. * Gets the current class name
  60650. * @returns the class name
  60651. */
  60652. getClassName(): string;
  60653. /**
  60654. * Gets the world position input component
  60655. */
  60656. get worldPosition(): NodeMaterialConnectionPoint;
  60657. /**
  60658. * Gets the direction output component
  60659. */
  60660. get direction(): NodeMaterialConnectionPoint;
  60661. /**
  60662. * Gets the direction output component
  60663. */
  60664. get color(): NodeMaterialConnectionPoint;
  60665. /**
  60666. * Gets the direction output component
  60667. */
  60668. get intensity(): NodeMaterialConnectionPoint;
  60669. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60670. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60671. protected _buildBlock(state: NodeMaterialBuildState): this;
  60672. serialize(): any;
  60673. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60674. }
  60675. }
  60676. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  60677. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  60678. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  60679. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  60680. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  60681. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  60682. }
  60683. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  60684. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60685. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60686. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60687. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60688. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60689. import { Effect } from "babylonjs/Materials/effect";
  60690. import { Mesh } from "babylonjs/Meshes/mesh";
  60691. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60692. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  60693. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  60694. /**
  60695. * Block used to add image processing support to fragment shader
  60696. */
  60697. export class ImageProcessingBlock extends NodeMaterialBlock {
  60698. /**
  60699. * Create a new ImageProcessingBlock
  60700. * @param name defines the block name
  60701. */
  60702. constructor(name: string);
  60703. /**
  60704. * Gets the current class name
  60705. * @returns the class name
  60706. */
  60707. getClassName(): string;
  60708. /**
  60709. * Gets the color input component
  60710. */
  60711. get color(): NodeMaterialConnectionPoint;
  60712. /**
  60713. * Gets the output component
  60714. */
  60715. get output(): NodeMaterialConnectionPoint;
  60716. /**
  60717. * Initialize the block and prepare the context for build
  60718. * @param state defines the state that will be used for the build
  60719. */
  60720. initialize(state: NodeMaterialBuildState): void;
  60721. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  60722. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60723. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60724. protected _buildBlock(state: NodeMaterialBuildState): this;
  60725. }
  60726. }
  60727. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  60728. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60729. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60730. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60731. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60732. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60733. import { Effect } from "babylonjs/Materials/effect";
  60734. import { Mesh } from "babylonjs/Meshes/mesh";
  60735. import { Scene } from "babylonjs/scene";
  60736. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  60737. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  60738. /**
  60739. * Block used to pertub normals based on a normal map
  60740. */
  60741. export class PerturbNormalBlock extends NodeMaterialBlock {
  60742. private _tangentSpaceParameterName;
  60743. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60744. invertX: boolean;
  60745. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  60746. invertY: boolean;
  60747. /**
  60748. * Create a new PerturbNormalBlock
  60749. * @param name defines the block name
  60750. */
  60751. constructor(name: string);
  60752. /**
  60753. * Gets the current class name
  60754. * @returns the class name
  60755. */
  60756. getClassName(): string;
  60757. /**
  60758. * Gets the world position input component
  60759. */
  60760. get worldPosition(): NodeMaterialConnectionPoint;
  60761. /**
  60762. * Gets the world normal input component
  60763. */
  60764. get worldNormal(): NodeMaterialConnectionPoint;
  60765. /**
  60766. * Gets the world tangent input component
  60767. */
  60768. get worldTangent(): NodeMaterialConnectionPoint;
  60769. /**
  60770. * Gets the uv input component
  60771. */
  60772. get uv(): NodeMaterialConnectionPoint;
  60773. /**
  60774. * Gets the normal map color input component
  60775. */
  60776. get normalMapColor(): NodeMaterialConnectionPoint;
  60777. /**
  60778. * Gets the strength input component
  60779. */
  60780. get strength(): NodeMaterialConnectionPoint;
  60781. /**
  60782. * Gets the output component
  60783. */
  60784. get output(): NodeMaterialConnectionPoint;
  60785. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60786. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60787. autoConfigure(material: NodeMaterial): void;
  60788. protected _buildBlock(state: NodeMaterialBuildState): this;
  60789. protected _dumpPropertiesCode(): string;
  60790. serialize(): any;
  60791. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60792. }
  60793. }
  60794. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  60795. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60796. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60797. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60798. /**
  60799. * Block used to discard a pixel if a value is smaller than a cutoff
  60800. */
  60801. export class DiscardBlock extends NodeMaterialBlock {
  60802. /**
  60803. * Create a new DiscardBlock
  60804. * @param name defines the block name
  60805. */
  60806. constructor(name: string);
  60807. /**
  60808. * Gets the current class name
  60809. * @returns the class name
  60810. */
  60811. getClassName(): string;
  60812. /**
  60813. * Gets the color input component
  60814. */
  60815. get value(): NodeMaterialConnectionPoint;
  60816. /**
  60817. * Gets the cutoff input component
  60818. */
  60819. get cutoff(): NodeMaterialConnectionPoint;
  60820. protected _buildBlock(state: NodeMaterialBuildState): this;
  60821. }
  60822. }
  60823. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  60824. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60825. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60826. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60827. /**
  60828. * Block used to test if the fragment shader is front facing
  60829. */
  60830. export class FrontFacingBlock extends NodeMaterialBlock {
  60831. /**
  60832. * Creates a new FrontFacingBlock
  60833. * @param name defines the block name
  60834. */
  60835. constructor(name: string);
  60836. /**
  60837. * Gets the current class name
  60838. * @returns the class name
  60839. */
  60840. getClassName(): string;
  60841. /**
  60842. * Gets the output component
  60843. */
  60844. get output(): NodeMaterialConnectionPoint;
  60845. protected _buildBlock(state: NodeMaterialBuildState): this;
  60846. }
  60847. }
  60848. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  60849. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60850. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60851. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60852. /**
  60853. * Block used to get the derivative value on x and y of a given input
  60854. */
  60855. export class DerivativeBlock extends NodeMaterialBlock {
  60856. /**
  60857. * Create a new DerivativeBlock
  60858. * @param name defines the block name
  60859. */
  60860. constructor(name: string);
  60861. /**
  60862. * Gets the current class name
  60863. * @returns the class name
  60864. */
  60865. getClassName(): string;
  60866. /**
  60867. * Gets the input component
  60868. */
  60869. get input(): NodeMaterialConnectionPoint;
  60870. /**
  60871. * Gets the derivative output on x
  60872. */
  60873. get dx(): NodeMaterialConnectionPoint;
  60874. /**
  60875. * Gets the derivative output on y
  60876. */
  60877. get dy(): NodeMaterialConnectionPoint;
  60878. protected _buildBlock(state: NodeMaterialBuildState): this;
  60879. }
  60880. }
  60881. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  60882. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  60883. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  60884. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  60885. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  60886. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  60887. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  60888. }
  60889. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  60890. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60891. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60892. import { Mesh } from "babylonjs/Meshes/mesh";
  60893. import { Effect } from "babylonjs/Materials/effect";
  60894. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60895. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60896. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60897. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  60898. /**
  60899. * Block used to add support for scene fog
  60900. */
  60901. export class FogBlock extends NodeMaterialBlock {
  60902. private _fogDistanceName;
  60903. private _fogParameters;
  60904. /**
  60905. * Create a new FogBlock
  60906. * @param name defines the block name
  60907. */
  60908. constructor(name: string);
  60909. /**
  60910. * Gets the current class name
  60911. * @returns the class name
  60912. */
  60913. getClassName(): string;
  60914. /**
  60915. * Gets the world position input component
  60916. */
  60917. get worldPosition(): NodeMaterialConnectionPoint;
  60918. /**
  60919. * Gets the view input component
  60920. */
  60921. get view(): NodeMaterialConnectionPoint;
  60922. /**
  60923. * Gets the color input component
  60924. */
  60925. get input(): NodeMaterialConnectionPoint;
  60926. /**
  60927. * Gets the fog color input component
  60928. */
  60929. get fogColor(): NodeMaterialConnectionPoint;
  60930. /**
  60931. * Gets the output component
  60932. */
  60933. get output(): NodeMaterialConnectionPoint;
  60934. autoConfigure(material: NodeMaterial): void;
  60935. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60936. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60937. protected _buildBlock(state: NodeMaterialBuildState): this;
  60938. }
  60939. }
  60940. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  60941. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60942. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60943. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60944. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60945. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60946. import { Effect } from "babylonjs/Materials/effect";
  60947. import { Mesh } from "babylonjs/Meshes/mesh";
  60948. import { Light } from "babylonjs/Lights/light";
  60949. import { Nullable } from "babylonjs/types";
  60950. import { Scene } from "babylonjs/scene";
  60951. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  60952. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  60953. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  60954. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60955. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  60956. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  60957. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  60958. /**
  60959. * Block used to add light in the fragment shader
  60960. */
  60961. export class LightBlock extends NodeMaterialBlock {
  60962. private _lightId;
  60963. /**
  60964. * Gets or sets the light associated with this block
  60965. */
  60966. light: Nullable<Light>;
  60967. /**
  60968. * Create a new LightBlock
  60969. * @param name defines the block name
  60970. */
  60971. constructor(name: string);
  60972. /**
  60973. * Gets the current class name
  60974. * @returns the class name
  60975. */
  60976. getClassName(): string;
  60977. /**
  60978. * Gets the world position input component
  60979. */
  60980. get worldPosition(): NodeMaterialConnectionPoint;
  60981. /**
  60982. * Gets the world normal input component
  60983. */
  60984. get worldNormal(): NodeMaterialConnectionPoint;
  60985. /**
  60986. * Gets the camera (or eye) position component
  60987. */
  60988. get cameraPosition(): NodeMaterialConnectionPoint;
  60989. /**
  60990. * Gets the glossiness component
  60991. */
  60992. get glossiness(): NodeMaterialConnectionPoint;
  60993. /**
  60994. * Gets the glossinness power component
  60995. */
  60996. get glossPower(): NodeMaterialConnectionPoint;
  60997. /**
  60998. * Gets the diffuse color component
  60999. */
  61000. get diffuseColor(): NodeMaterialConnectionPoint;
  61001. /**
  61002. * Gets the specular color component
  61003. */
  61004. get specularColor(): NodeMaterialConnectionPoint;
  61005. /**
  61006. * Gets the diffuse output component
  61007. */
  61008. get diffuseOutput(): NodeMaterialConnectionPoint;
  61009. /**
  61010. * Gets the specular output component
  61011. */
  61012. get specularOutput(): NodeMaterialConnectionPoint;
  61013. /**
  61014. * Gets the shadow output component
  61015. */
  61016. get shadow(): NodeMaterialConnectionPoint;
  61017. autoConfigure(material: NodeMaterial): void;
  61018. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61019. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61020. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61021. private _injectVertexCode;
  61022. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61023. serialize(): any;
  61024. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61025. }
  61026. }
  61027. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  61028. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  61029. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  61030. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61031. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  61032. }
  61033. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  61034. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61035. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61036. }
  61037. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  61038. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61039. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61040. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61041. /**
  61042. * Block used to multiply 2 values
  61043. */
  61044. export class MultiplyBlock extends NodeMaterialBlock {
  61045. /**
  61046. * Creates a new MultiplyBlock
  61047. * @param name defines the block name
  61048. */
  61049. constructor(name: string);
  61050. /**
  61051. * Gets the current class name
  61052. * @returns the class name
  61053. */
  61054. getClassName(): string;
  61055. /**
  61056. * Gets the left operand input component
  61057. */
  61058. get left(): NodeMaterialConnectionPoint;
  61059. /**
  61060. * Gets the right operand input component
  61061. */
  61062. get right(): NodeMaterialConnectionPoint;
  61063. /**
  61064. * Gets the output component
  61065. */
  61066. get output(): NodeMaterialConnectionPoint;
  61067. protected _buildBlock(state: NodeMaterialBuildState): this;
  61068. }
  61069. }
  61070. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  61071. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61072. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61073. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61074. /**
  61075. * Block used to add 2 vectors
  61076. */
  61077. export class AddBlock extends NodeMaterialBlock {
  61078. /**
  61079. * Creates a new AddBlock
  61080. * @param name defines the block name
  61081. */
  61082. constructor(name: string);
  61083. /**
  61084. * Gets the current class name
  61085. * @returns the class name
  61086. */
  61087. getClassName(): string;
  61088. /**
  61089. * Gets the left operand input component
  61090. */
  61091. get left(): NodeMaterialConnectionPoint;
  61092. /**
  61093. * Gets the right operand input component
  61094. */
  61095. get right(): NodeMaterialConnectionPoint;
  61096. /**
  61097. * Gets the output component
  61098. */
  61099. get output(): NodeMaterialConnectionPoint;
  61100. protected _buildBlock(state: NodeMaterialBuildState): this;
  61101. }
  61102. }
  61103. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  61104. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61105. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61106. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61107. /**
  61108. * Block used to scale a vector by a float
  61109. */
  61110. export class ScaleBlock extends NodeMaterialBlock {
  61111. /**
  61112. * Creates a new ScaleBlock
  61113. * @param name defines the block name
  61114. */
  61115. constructor(name: string);
  61116. /**
  61117. * Gets the current class name
  61118. * @returns the class name
  61119. */
  61120. getClassName(): string;
  61121. /**
  61122. * Gets the input component
  61123. */
  61124. get input(): NodeMaterialConnectionPoint;
  61125. /**
  61126. * Gets the factor input component
  61127. */
  61128. get factor(): NodeMaterialConnectionPoint;
  61129. /**
  61130. * Gets the output component
  61131. */
  61132. get output(): NodeMaterialConnectionPoint;
  61133. protected _buildBlock(state: NodeMaterialBuildState): this;
  61134. }
  61135. }
  61136. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  61137. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61138. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61139. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61140. import { Scene } from "babylonjs/scene";
  61141. /**
  61142. * Block used to clamp a float
  61143. */
  61144. export class ClampBlock extends NodeMaterialBlock {
  61145. /** Gets or sets the minimum range */
  61146. minimum: number;
  61147. /** Gets or sets the maximum range */
  61148. maximum: number;
  61149. /**
  61150. * Creates a new ClampBlock
  61151. * @param name defines the block name
  61152. */
  61153. constructor(name: string);
  61154. /**
  61155. * Gets the current class name
  61156. * @returns the class name
  61157. */
  61158. getClassName(): string;
  61159. /**
  61160. * Gets the value input component
  61161. */
  61162. get value(): NodeMaterialConnectionPoint;
  61163. /**
  61164. * Gets the output component
  61165. */
  61166. get output(): NodeMaterialConnectionPoint;
  61167. protected _buildBlock(state: NodeMaterialBuildState): this;
  61168. protected _dumpPropertiesCode(): string;
  61169. serialize(): any;
  61170. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61171. }
  61172. }
  61173. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  61174. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61175. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61176. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61177. /**
  61178. * Block used to apply a cross product between 2 vectors
  61179. */
  61180. export class CrossBlock extends NodeMaterialBlock {
  61181. /**
  61182. * Creates a new CrossBlock
  61183. * @param name defines the block name
  61184. */
  61185. constructor(name: string);
  61186. /**
  61187. * Gets the current class name
  61188. * @returns the class name
  61189. */
  61190. getClassName(): string;
  61191. /**
  61192. * Gets the left operand input component
  61193. */
  61194. get left(): NodeMaterialConnectionPoint;
  61195. /**
  61196. * Gets the right operand input component
  61197. */
  61198. get right(): NodeMaterialConnectionPoint;
  61199. /**
  61200. * Gets the output component
  61201. */
  61202. get output(): NodeMaterialConnectionPoint;
  61203. protected _buildBlock(state: NodeMaterialBuildState): this;
  61204. }
  61205. }
  61206. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  61207. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61208. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61209. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61210. /**
  61211. * Block used to apply a dot product between 2 vectors
  61212. */
  61213. export class DotBlock extends NodeMaterialBlock {
  61214. /**
  61215. * Creates a new DotBlock
  61216. * @param name defines the block name
  61217. */
  61218. constructor(name: string);
  61219. /**
  61220. * Gets the current class name
  61221. * @returns the class name
  61222. */
  61223. getClassName(): string;
  61224. /**
  61225. * Gets the left operand input component
  61226. */
  61227. get left(): NodeMaterialConnectionPoint;
  61228. /**
  61229. * Gets the right operand input component
  61230. */
  61231. get right(): NodeMaterialConnectionPoint;
  61232. /**
  61233. * Gets the output component
  61234. */
  61235. get output(): NodeMaterialConnectionPoint;
  61236. protected _buildBlock(state: NodeMaterialBuildState): this;
  61237. }
  61238. }
  61239. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  61240. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61241. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61242. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61243. import { Vector2 } from "babylonjs/Maths/math.vector";
  61244. import { Scene } from "babylonjs/scene";
  61245. /**
  61246. * Block used to remap a float from a range to a new one
  61247. */
  61248. export class RemapBlock extends NodeMaterialBlock {
  61249. /**
  61250. * Gets or sets the source range
  61251. */
  61252. sourceRange: Vector2;
  61253. /**
  61254. * Gets or sets the target range
  61255. */
  61256. targetRange: Vector2;
  61257. /**
  61258. * Creates a new RemapBlock
  61259. * @param name defines the block name
  61260. */
  61261. constructor(name: string);
  61262. /**
  61263. * Gets the current class name
  61264. * @returns the class name
  61265. */
  61266. getClassName(): string;
  61267. /**
  61268. * Gets the input component
  61269. */
  61270. get input(): NodeMaterialConnectionPoint;
  61271. /**
  61272. * Gets the source min input component
  61273. */
  61274. get sourceMin(): NodeMaterialConnectionPoint;
  61275. /**
  61276. * Gets the source max input component
  61277. */
  61278. get sourceMax(): NodeMaterialConnectionPoint;
  61279. /**
  61280. * Gets the target min input component
  61281. */
  61282. get targetMin(): NodeMaterialConnectionPoint;
  61283. /**
  61284. * Gets the target max input component
  61285. */
  61286. get targetMax(): NodeMaterialConnectionPoint;
  61287. /**
  61288. * Gets the output component
  61289. */
  61290. get output(): NodeMaterialConnectionPoint;
  61291. protected _buildBlock(state: NodeMaterialBuildState): this;
  61292. protected _dumpPropertiesCode(): string;
  61293. serialize(): any;
  61294. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61295. }
  61296. }
  61297. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  61298. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61299. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61300. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61301. /**
  61302. * Block used to normalize a vector
  61303. */
  61304. export class NormalizeBlock extends NodeMaterialBlock {
  61305. /**
  61306. * Creates a new NormalizeBlock
  61307. * @param name defines the block name
  61308. */
  61309. constructor(name: string);
  61310. /**
  61311. * Gets the current class name
  61312. * @returns the class name
  61313. */
  61314. getClassName(): string;
  61315. /**
  61316. * Gets the input component
  61317. */
  61318. get input(): NodeMaterialConnectionPoint;
  61319. /**
  61320. * Gets the output component
  61321. */
  61322. get output(): NodeMaterialConnectionPoint;
  61323. protected _buildBlock(state: NodeMaterialBuildState): this;
  61324. }
  61325. }
  61326. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  61327. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61328. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61329. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61330. import { Scene } from "babylonjs/scene";
  61331. /**
  61332. * Operations supported by the Trigonometry block
  61333. */
  61334. export enum TrigonometryBlockOperations {
  61335. /** Cos */
  61336. Cos = 0,
  61337. /** Sin */
  61338. Sin = 1,
  61339. /** Abs */
  61340. Abs = 2,
  61341. /** Exp */
  61342. Exp = 3,
  61343. /** Exp2 */
  61344. Exp2 = 4,
  61345. /** Round */
  61346. Round = 5,
  61347. /** Floor */
  61348. Floor = 6,
  61349. /** Ceiling */
  61350. Ceiling = 7,
  61351. /** Square root */
  61352. Sqrt = 8,
  61353. /** Log */
  61354. Log = 9,
  61355. /** Tangent */
  61356. Tan = 10,
  61357. /** Arc tangent */
  61358. ArcTan = 11,
  61359. /** Arc cosinus */
  61360. ArcCos = 12,
  61361. /** Arc sinus */
  61362. ArcSin = 13,
  61363. /** Fraction */
  61364. Fract = 14,
  61365. /** Sign */
  61366. Sign = 15,
  61367. /** To radians (from degrees) */
  61368. Radians = 16,
  61369. /** To degrees (from radians) */
  61370. Degrees = 17
  61371. }
  61372. /**
  61373. * Block used to apply trigonometry operation to floats
  61374. */
  61375. export class TrigonometryBlock extends NodeMaterialBlock {
  61376. /**
  61377. * Gets or sets the operation applied by the block
  61378. */
  61379. operation: TrigonometryBlockOperations;
  61380. /**
  61381. * Creates a new TrigonometryBlock
  61382. * @param name defines the block name
  61383. */
  61384. constructor(name: string);
  61385. /**
  61386. * Gets the current class name
  61387. * @returns the class name
  61388. */
  61389. getClassName(): string;
  61390. /**
  61391. * Gets the input component
  61392. */
  61393. get input(): NodeMaterialConnectionPoint;
  61394. /**
  61395. * Gets the output component
  61396. */
  61397. get output(): NodeMaterialConnectionPoint;
  61398. protected _buildBlock(state: NodeMaterialBuildState): this;
  61399. serialize(): any;
  61400. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61401. protected _dumpPropertiesCode(): string;
  61402. }
  61403. }
  61404. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  61405. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61406. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61407. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61408. /**
  61409. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61410. */
  61411. export class ColorMergerBlock extends NodeMaterialBlock {
  61412. /**
  61413. * Create a new ColorMergerBlock
  61414. * @param name defines the block name
  61415. */
  61416. constructor(name: string);
  61417. /**
  61418. * Gets the current class name
  61419. * @returns the class name
  61420. */
  61421. getClassName(): string;
  61422. /**
  61423. * Gets the rgb component (input)
  61424. */
  61425. get rgbIn(): NodeMaterialConnectionPoint;
  61426. /**
  61427. * Gets the r component (input)
  61428. */
  61429. get r(): NodeMaterialConnectionPoint;
  61430. /**
  61431. * Gets the g component (input)
  61432. */
  61433. get g(): NodeMaterialConnectionPoint;
  61434. /**
  61435. * Gets the b component (input)
  61436. */
  61437. get b(): NodeMaterialConnectionPoint;
  61438. /**
  61439. * Gets the a component (input)
  61440. */
  61441. get a(): NodeMaterialConnectionPoint;
  61442. /**
  61443. * Gets the rgba component (output)
  61444. */
  61445. get rgba(): NodeMaterialConnectionPoint;
  61446. /**
  61447. * Gets the rgb component (output)
  61448. */
  61449. get rgbOut(): NodeMaterialConnectionPoint;
  61450. /**
  61451. * Gets the rgb component (output)
  61452. * @deprecated Please use rgbOut instead.
  61453. */
  61454. get rgb(): NodeMaterialConnectionPoint;
  61455. protected _buildBlock(state: NodeMaterialBuildState): this;
  61456. }
  61457. }
  61458. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  61459. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61460. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61461. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61462. /**
  61463. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  61464. */
  61465. export class VectorMergerBlock extends NodeMaterialBlock {
  61466. /**
  61467. * Create a new VectorMergerBlock
  61468. * @param name defines the block name
  61469. */
  61470. constructor(name: string);
  61471. /**
  61472. * Gets the current class name
  61473. * @returns the class name
  61474. */
  61475. getClassName(): string;
  61476. /**
  61477. * Gets the xyz component (input)
  61478. */
  61479. get xyzIn(): NodeMaterialConnectionPoint;
  61480. /**
  61481. * Gets the xy component (input)
  61482. */
  61483. get xyIn(): NodeMaterialConnectionPoint;
  61484. /**
  61485. * Gets the x component (input)
  61486. */
  61487. get x(): NodeMaterialConnectionPoint;
  61488. /**
  61489. * Gets the y component (input)
  61490. */
  61491. get y(): NodeMaterialConnectionPoint;
  61492. /**
  61493. * Gets the z component (input)
  61494. */
  61495. get z(): NodeMaterialConnectionPoint;
  61496. /**
  61497. * Gets the w component (input)
  61498. */
  61499. get w(): NodeMaterialConnectionPoint;
  61500. /**
  61501. * Gets the xyzw component (output)
  61502. */
  61503. get xyzw(): NodeMaterialConnectionPoint;
  61504. /**
  61505. * Gets the xyz component (output)
  61506. */
  61507. get xyzOut(): NodeMaterialConnectionPoint;
  61508. /**
  61509. * Gets the xy component (output)
  61510. */
  61511. get xyOut(): NodeMaterialConnectionPoint;
  61512. /**
  61513. * Gets the xy component (output)
  61514. * @deprecated Please use xyOut instead.
  61515. */
  61516. get xy(): NodeMaterialConnectionPoint;
  61517. /**
  61518. * Gets the xyz component (output)
  61519. * @deprecated Please use xyzOut instead.
  61520. */
  61521. get xyz(): NodeMaterialConnectionPoint;
  61522. protected _buildBlock(state: NodeMaterialBuildState): this;
  61523. }
  61524. }
  61525. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  61526. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61527. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61528. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61529. /**
  61530. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  61531. */
  61532. export class ColorSplitterBlock extends NodeMaterialBlock {
  61533. /**
  61534. * Create a new ColorSplitterBlock
  61535. * @param name defines the block name
  61536. */
  61537. constructor(name: string);
  61538. /**
  61539. * Gets the current class name
  61540. * @returns the class name
  61541. */
  61542. getClassName(): string;
  61543. /**
  61544. * Gets the rgba component (input)
  61545. */
  61546. get rgba(): NodeMaterialConnectionPoint;
  61547. /**
  61548. * Gets the rgb component (input)
  61549. */
  61550. get rgbIn(): NodeMaterialConnectionPoint;
  61551. /**
  61552. * Gets the rgb component (output)
  61553. */
  61554. get rgbOut(): NodeMaterialConnectionPoint;
  61555. /**
  61556. * Gets the r component (output)
  61557. */
  61558. get r(): NodeMaterialConnectionPoint;
  61559. /**
  61560. * Gets the g component (output)
  61561. */
  61562. get g(): NodeMaterialConnectionPoint;
  61563. /**
  61564. * Gets the b component (output)
  61565. */
  61566. get b(): NodeMaterialConnectionPoint;
  61567. /**
  61568. * Gets the a component (output)
  61569. */
  61570. get a(): NodeMaterialConnectionPoint;
  61571. protected _inputRename(name: string): string;
  61572. protected _outputRename(name: string): string;
  61573. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61574. }
  61575. }
  61576. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  61577. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61578. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61579. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61580. /**
  61581. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61582. */
  61583. export class VectorSplitterBlock extends NodeMaterialBlock {
  61584. /**
  61585. * Create a new VectorSplitterBlock
  61586. * @param name defines the block name
  61587. */
  61588. constructor(name: string);
  61589. /**
  61590. * Gets the current class name
  61591. * @returns the class name
  61592. */
  61593. getClassName(): string;
  61594. /**
  61595. * Gets the xyzw component (input)
  61596. */
  61597. get xyzw(): NodeMaterialConnectionPoint;
  61598. /**
  61599. * Gets the xyz component (input)
  61600. */
  61601. get xyzIn(): NodeMaterialConnectionPoint;
  61602. /**
  61603. * Gets the xy component (input)
  61604. */
  61605. get xyIn(): NodeMaterialConnectionPoint;
  61606. /**
  61607. * Gets the xyz component (output)
  61608. */
  61609. get xyzOut(): NodeMaterialConnectionPoint;
  61610. /**
  61611. * Gets the xy component (output)
  61612. */
  61613. get xyOut(): NodeMaterialConnectionPoint;
  61614. /**
  61615. * Gets the x component (output)
  61616. */
  61617. get x(): NodeMaterialConnectionPoint;
  61618. /**
  61619. * Gets the y component (output)
  61620. */
  61621. get y(): NodeMaterialConnectionPoint;
  61622. /**
  61623. * Gets the z component (output)
  61624. */
  61625. get z(): NodeMaterialConnectionPoint;
  61626. /**
  61627. * Gets the w component (output)
  61628. */
  61629. get w(): NodeMaterialConnectionPoint;
  61630. protected _inputRename(name: string): string;
  61631. protected _outputRename(name: string): string;
  61632. protected _buildBlock(state: NodeMaterialBuildState): this;
  61633. }
  61634. }
  61635. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  61636. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61637. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61638. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61639. /**
  61640. * Block used to lerp between 2 values
  61641. */
  61642. export class LerpBlock extends NodeMaterialBlock {
  61643. /**
  61644. * Creates a new LerpBlock
  61645. * @param name defines the block name
  61646. */
  61647. constructor(name: string);
  61648. /**
  61649. * Gets the current class name
  61650. * @returns the class name
  61651. */
  61652. getClassName(): string;
  61653. /**
  61654. * Gets the left operand input component
  61655. */
  61656. get left(): NodeMaterialConnectionPoint;
  61657. /**
  61658. * Gets the right operand input component
  61659. */
  61660. get right(): NodeMaterialConnectionPoint;
  61661. /**
  61662. * Gets the gradient operand input component
  61663. */
  61664. get gradient(): NodeMaterialConnectionPoint;
  61665. /**
  61666. * Gets the output component
  61667. */
  61668. get output(): NodeMaterialConnectionPoint;
  61669. protected _buildBlock(state: NodeMaterialBuildState): this;
  61670. }
  61671. }
  61672. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  61673. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61674. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61675. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61676. /**
  61677. * Block used to divide 2 vectors
  61678. */
  61679. export class DivideBlock extends NodeMaterialBlock {
  61680. /**
  61681. * Creates a new DivideBlock
  61682. * @param name defines the block name
  61683. */
  61684. constructor(name: string);
  61685. /**
  61686. * Gets the current class name
  61687. * @returns the class name
  61688. */
  61689. getClassName(): string;
  61690. /**
  61691. * Gets the left operand input component
  61692. */
  61693. get left(): NodeMaterialConnectionPoint;
  61694. /**
  61695. * Gets the right operand input component
  61696. */
  61697. get right(): NodeMaterialConnectionPoint;
  61698. /**
  61699. * Gets the output component
  61700. */
  61701. get output(): NodeMaterialConnectionPoint;
  61702. protected _buildBlock(state: NodeMaterialBuildState): this;
  61703. }
  61704. }
  61705. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  61706. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61707. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61708. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61709. /**
  61710. * Block used to subtract 2 vectors
  61711. */
  61712. export class SubtractBlock extends NodeMaterialBlock {
  61713. /**
  61714. * Creates a new SubtractBlock
  61715. * @param name defines the block name
  61716. */
  61717. constructor(name: string);
  61718. /**
  61719. * Gets the current class name
  61720. * @returns the class name
  61721. */
  61722. getClassName(): string;
  61723. /**
  61724. * Gets the left operand input component
  61725. */
  61726. get left(): NodeMaterialConnectionPoint;
  61727. /**
  61728. * Gets the right operand input component
  61729. */
  61730. get right(): NodeMaterialConnectionPoint;
  61731. /**
  61732. * Gets the output component
  61733. */
  61734. get output(): NodeMaterialConnectionPoint;
  61735. protected _buildBlock(state: NodeMaterialBuildState): this;
  61736. }
  61737. }
  61738. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  61739. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61740. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61741. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61742. /**
  61743. * Block used to step a value
  61744. */
  61745. export class StepBlock extends NodeMaterialBlock {
  61746. /**
  61747. * Creates a new StepBlock
  61748. * @param name defines the block name
  61749. */
  61750. constructor(name: string);
  61751. /**
  61752. * Gets the current class name
  61753. * @returns the class name
  61754. */
  61755. getClassName(): string;
  61756. /**
  61757. * Gets the value operand input component
  61758. */
  61759. get value(): NodeMaterialConnectionPoint;
  61760. /**
  61761. * Gets the edge operand input component
  61762. */
  61763. get edge(): NodeMaterialConnectionPoint;
  61764. /**
  61765. * Gets the output component
  61766. */
  61767. get output(): NodeMaterialConnectionPoint;
  61768. protected _buildBlock(state: NodeMaterialBuildState): this;
  61769. }
  61770. }
  61771. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  61772. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61773. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61774. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61775. /**
  61776. * Block used to get the opposite (1 - x) of a value
  61777. */
  61778. export class OneMinusBlock extends NodeMaterialBlock {
  61779. /**
  61780. * Creates a new OneMinusBlock
  61781. * @param name defines the block name
  61782. */
  61783. constructor(name: string);
  61784. /**
  61785. * Gets the current class name
  61786. * @returns the class name
  61787. */
  61788. getClassName(): string;
  61789. /**
  61790. * Gets the input component
  61791. */
  61792. get input(): NodeMaterialConnectionPoint;
  61793. /**
  61794. * Gets the output component
  61795. */
  61796. get output(): NodeMaterialConnectionPoint;
  61797. protected _buildBlock(state: NodeMaterialBuildState): this;
  61798. }
  61799. }
  61800. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  61801. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61802. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61803. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61804. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  61805. /**
  61806. * Block used to get the view direction
  61807. */
  61808. export class ViewDirectionBlock extends NodeMaterialBlock {
  61809. /**
  61810. * Creates a new ViewDirectionBlock
  61811. * @param name defines the block name
  61812. */
  61813. constructor(name: string);
  61814. /**
  61815. * Gets the current class name
  61816. * @returns the class name
  61817. */
  61818. getClassName(): string;
  61819. /**
  61820. * Gets the world position component
  61821. */
  61822. get worldPosition(): NodeMaterialConnectionPoint;
  61823. /**
  61824. * Gets the camera position component
  61825. */
  61826. get cameraPosition(): NodeMaterialConnectionPoint;
  61827. /**
  61828. * Gets the output component
  61829. */
  61830. get output(): NodeMaterialConnectionPoint;
  61831. autoConfigure(material: NodeMaterial): void;
  61832. protected _buildBlock(state: NodeMaterialBuildState): this;
  61833. }
  61834. }
  61835. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  61836. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61837. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61838. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61839. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  61840. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  61841. /**
  61842. * Block used to compute fresnel value
  61843. */
  61844. export class FresnelBlock extends NodeMaterialBlock {
  61845. /**
  61846. * Create a new FresnelBlock
  61847. * @param name defines the block name
  61848. */
  61849. constructor(name: string);
  61850. /**
  61851. * Gets the current class name
  61852. * @returns the class name
  61853. */
  61854. getClassName(): string;
  61855. /**
  61856. * Gets the world normal input component
  61857. */
  61858. get worldNormal(): NodeMaterialConnectionPoint;
  61859. /**
  61860. * Gets the view direction input component
  61861. */
  61862. get viewDirection(): NodeMaterialConnectionPoint;
  61863. /**
  61864. * Gets the bias input component
  61865. */
  61866. get bias(): NodeMaterialConnectionPoint;
  61867. /**
  61868. * Gets the camera (or eye) position component
  61869. */
  61870. get power(): NodeMaterialConnectionPoint;
  61871. /**
  61872. * Gets the fresnel output component
  61873. */
  61874. get fresnel(): NodeMaterialConnectionPoint;
  61875. autoConfigure(material: NodeMaterial): void;
  61876. protected _buildBlock(state: NodeMaterialBuildState): this;
  61877. }
  61878. }
  61879. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  61880. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61881. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61882. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61883. /**
  61884. * Block used to get the max of 2 values
  61885. */
  61886. export class MaxBlock extends NodeMaterialBlock {
  61887. /**
  61888. * Creates a new MaxBlock
  61889. * @param name defines the block name
  61890. */
  61891. constructor(name: string);
  61892. /**
  61893. * Gets the current class name
  61894. * @returns the class name
  61895. */
  61896. getClassName(): string;
  61897. /**
  61898. * Gets the left operand input component
  61899. */
  61900. get left(): NodeMaterialConnectionPoint;
  61901. /**
  61902. * Gets the right operand input component
  61903. */
  61904. get right(): NodeMaterialConnectionPoint;
  61905. /**
  61906. * Gets the output component
  61907. */
  61908. get output(): NodeMaterialConnectionPoint;
  61909. protected _buildBlock(state: NodeMaterialBuildState): this;
  61910. }
  61911. }
  61912. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  61913. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61914. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61915. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61916. /**
  61917. * Block used to get the min of 2 values
  61918. */
  61919. export class MinBlock extends NodeMaterialBlock {
  61920. /**
  61921. * Creates a new MinBlock
  61922. * @param name defines the block name
  61923. */
  61924. constructor(name: string);
  61925. /**
  61926. * Gets the current class name
  61927. * @returns the class name
  61928. */
  61929. getClassName(): string;
  61930. /**
  61931. * Gets the left operand input component
  61932. */
  61933. get left(): NodeMaterialConnectionPoint;
  61934. /**
  61935. * Gets the right operand input component
  61936. */
  61937. get right(): NodeMaterialConnectionPoint;
  61938. /**
  61939. * Gets the output component
  61940. */
  61941. get output(): NodeMaterialConnectionPoint;
  61942. protected _buildBlock(state: NodeMaterialBuildState): this;
  61943. }
  61944. }
  61945. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  61946. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61947. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61948. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61949. /**
  61950. * Block used to get the distance between 2 values
  61951. */
  61952. export class DistanceBlock extends NodeMaterialBlock {
  61953. /**
  61954. * Creates a new DistanceBlock
  61955. * @param name defines the block name
  61956. */
  61957. constructor(name: string);
  61958. /**
  61959. * Gets the current class name
  61960. * @returns the class name
  61961. */
  61962. getClassName(): string;
  61963. /**
  61964. * Gets the left operand input component
  61965. */
  61966. get left(): NodeMaterialConnectionPoint;
  61967. /**
  61968. * Gets the right operand input component
  61969. */
  61970. get right(): NodeMaterialConnectionPoint;
  61971. /**
  61972. * Gets the output component
  61973. */
  61974. get output(): NodeMaterialConnectionPoint;
  61975. protected _buildBlock(state: NodeMaterialBuildState): this;
  61976. }
  61977. }
  61978. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  61979. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61980. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61981. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61982. /**
  61983. * Block used to get the length of a vector
  61984. */
  61985. export class LengthBlock extends NodeMaterialBlock {
  61986. /**
  61987. * Creates a new LengthBlock
  61988. * @param name defines the block name
  61989. */
  61990. constructor(name: string);
  61991. /**
  61992. * Gets the current class name
  61993. * @returns the class name
  61994. */
  61995. getClassName(): string;
  61996. /**
  61997. * Gets the value input component
  61998. */
  61999. get value(): NodeMaterialConnectionPoint;
  62000. /**
  62001. * Gets the output component
  62002. */
  62003. get output(): NodeMaterialConnectionPoint;
  62004. protected _buildBlock(state: NodeMaterialBuildState): this;
  62005. }
  62006. }
  62007. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  62008. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62009. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62010. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62011. /**
  62012. * Block used to get negative version of a value (i.e. x * -1)
  62013. */
  62014. export class NegateBlock extends NodeMaterialBlock {
  62015. /**
  62016. * Creates a new NegateBlock
  62017. * @param name defines the block name
  62018. */
  62019. constructor(name: string);
  62020. /**
  62021. * Gets the current class name
  62022. * @returns the class name
  62023. */
  62024. getClassName(): string;
  62025. /**
  62026. * Gets the value input component
  62027. */
  62028. get value(): NodeMaterialConnectionPoint;
  62029. /**
  62030. * Gets the output component
  62031. */
  62032. get output(): NodeMaterialConnectionPoint;
  62033. protected _buildBlock(state: NodeMaterialBuildState): this;
  62034. }
  62035. }
  62036. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  62037. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62038. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62039. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62040. /**
  62041. * Block used to get the value of the first parameter raised to the power of the second
  62042. */
  62043. export class PowBlock extends NodeMaterialBlock {
  62044. /**
  62045. * Creates a new PowBlock
  62046. * @param name defines the block name
  62047. */
  62048. constructor(name: string);
  62049. /**
  62050. * Gets the current class name
  62051. * @returns the class name
  62052. */
  62053. getClassName(): string;
  62054. /**
  62055. * Gets the value operand input component
  62056. */
  62057. get value(): NodeMaterialConnectionPoint;
  62058. /**
  62059. * Gets the power operand input component
  62060. */
  62061. get power(): NodeMaterialConnectionPoint;
  62062. /**
  62063. * Gets the output component
  62064. */
  62065. get output(): NodeMaterialConnectionPoint;
  62066. protected _buildBlock(state: NodeMaterialBuildState): this;
  62067. }
  62068. }
  62069. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  62070. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62071. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62072. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62073. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62074. /**
  62075. * Block used to get a random number
  62076. */
  62077. export class RandomNumberBlock extends NodeMaterialBlock {
  62078. /**
  62079. * Creates a new RandomNumberBlock
  62080. * @param name defines the block name
  62081. */
  62082. constructor(name: string);
  62083. /**
  62084. * Gets the current class name
  62085. * @returns the class name
  62086. */
  62087. getClassName(): string;
  62088. /**
  62089. * Gets the seed input component
  62090. */
  62091. get seed(): NodeMaterialConnectionPoint;
  62092. /**
  62093. * Gets the output component
  62094. */
  62095. get output(): NodeMaterialConnectionPoint;
  62096. protected _buildBlock(state: NodeMaterialBuildState): this;
  62097. }
  62098. }
  62099. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  62100. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62101. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62102. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62103. /**
  62104. * Block used to compute arc tangent of 2 values
  62105. */
  62106. export class ArcTan2Block extends NodeMaterialBlock {
  62107. /**
  62108. * Creates a new ArcTan2Block
  62109. * @param name defines the block name
  62110. */
  62111. constructor(name: string);
  62112. /**
  62113. * Gets the current class name
  62114. * @returns the class name
  62115. */
  62116. getClassName(): string;
  62117. /**
  62118. * Gets the x operand input component
  62119. */
  62120. get x(): NodeMaterialConnectionPoint;
  62121. /**
  62122. * Gets the y operand input component
  62123. */
  62124. get y(): NodeMaterialConnectionPoint;
  62125. /**
  62126. * Gets the output component
  62127. */
  62128. get output(): NodeMaterialConnectionPoint;
  62129. protected _buildBlock(state: NodeMaterialBuildState): this;
  62130. }
  62131. }
  62132. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  62133. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62134. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62135. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62136. /**
  62137. * Block used to smooth step a value
  62138. */
  62139. export class SmoothStepBlock extends NodeMaterialBlock {
  62140. /**
  62141. * Creates a new SmoothStepBlock
  62142. * @param name defines the block name
  62143. */
  62144. constructor(name: string);
  62145. /**
  62146. * Gets the current class name
  62147. * @returns the class name
  62148. */
  62149. getClassName(): string;
  62150. /**
  62151. * Gets the value operand input component
  62152. */
  62153. get value(): NodeMaterialConnectionPoint;
  62154. /**
  62155. * Gets the first edge operand input component
  62156. */
  62157. get edge0(): NodeMaterialConnectionPoint;
  62158. /**
  62159. * Gets the second edge operand input component
  62160. */
  62161. get edge1(): NodeMaterialConnectionPoint;
  62162. /**
  62163. * Gets the output component
  62164. */
  62165. get output(): NodeMaterialConnectionPoint;
  62166. protected _buildBlock(state: NodeMaterialBuildState): this;
  62167. }
  62168. }
  62169. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  62170. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62171. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62172. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62173. /**
  62174. * Block used to get the reciprocal (1 / x) of a value
  62175. */
  62176. export class ReciprocalBlock extends NodeMaterialBlock {
  62177. /**
  62178. * Creates a new ReciprocalBlock
  62179. * @param name defines the block name
  62180. */
  62181. constructor(name: string);
  62182. /**
  62183. * Gets the current class name
  62184. * @returns the class name
  62185. */
  62186. getClassName(): string;
  62187. /**
  62188. * Gets the input component
  62189. */
  62190. get input(): NodeMaterialConnectionPoint;
  62191. /**
  62192. * Gets the output component
  62193. */
  62194. get output(): NodeMaterialConnectionPoint;
  62195. protected _buildBlock(state: NodeMaterialBuildState): this;
  62196. }
  62197. }
  62198. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  62199. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62200. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62201. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62202. /**
  62203. * Block used to replace a color by another one
  62204. */
  62205. export class ReplaceColorBlock extends NodeMaterialBlock {
  62206. /**
  62207. * Creates a new ReplaceColorBlock
  62208. * @param name defines the block name
  62209. */
  62210. constructor(name: string);
  62211. /**
  62212. * Gets the current class name
  62213. * @returns the class name
  62214. */
  62215. getClassName(): string;
  62216. /**
  62217. * Gets the value input component
  62218. */
  62219. get value(): NodeMaterialConnectionPoint;
  62220. /**
  62221. * Gets the reference input component
  62222. */
  62223. get reference(): NodeMaterialConnectionPoint;
  62224. /**
  62225. * Gets the distance input component
  62226. */
  62227. get distance(): NodeMaterialConnectionPoint;
  62228. /**
  62229. * Gets the replacement input component
  62230. */
  62231. get replacement(): NodeMaterialConnectionPoint;
  62232. /**
  62233. * Gets the output component
  62234. */
  62235. get output(): NodeMaterialConnectionPoint;
  62236. protected _buildBlock(state: NodeMaterialBuildState): this;
  62237. }
  62238. }
  62239. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  62240. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62241. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62242. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62243. /**
  62244. * Block used to posterize a value
  62245. * @see https://en.wikipedia.org/wiki/Posterization
  62246. */
  62247. export class PosterizeBlock extends NodeMaterialBlock {
  62248. /**
  62249. * Creates a new PosterizeBlock
  62250. * @param name defines the block name
  62251. */
  62252. constructor(name: string);
  62253. /**
  62254. * Gets the current class name
  62255. * @returns the class name
  62256. */
  62257. getClassName(): string;
  62258. /**
  62259. * Gets the value input component
  62260. */
  62261. get value(): NodeMaterialConnectionPoint;
  62262. /**
  62263. * Gets the steps input component
  62264. */
  62265. get steps(): NodeMaterialConnectionPoint;
  62266. /**
  62267. * Gets the output component
  62268. */
  62269. get output(): NodeMaterialConnectionPoint;
  62270. protected _buildBlock(state: NodeMaterialBuildState): this;
  62271. }
  62272. }
  62273. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  62274. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62275. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62276. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62277. import { Scene } from "babylonjs/scene";
  62278. /**
  62279. * Operations supported by the Wave block
  62280. */
  62281. export enum WaveBlockKind {
  62282. /** SawTooth */
  62283. SawTooth = 0,
  62284. /** Square */
  62285. Square = 1,
  62286. /** Triangle */
  62287. Triangle = 2
  62288. }
  62289. /**
  62290. * Block used to apply wave operation to floats
  62291. */
  62292. export class WaveBlock extends NodeMaterialBlock {
  62293. /**
  62294. * Gets or sets the kibnd of wave to be applied by the block
  62295. */
  62296. kind: WaveBlockKind;
  62297. /**
  62298. * Creates a new WaveBlock
  62299. * @param name defines the block name
  62300. */
  62301. constructor(name: string);
  62302. /**
  62303. * Gets the current class name
  62304. * @returns the class name
  62305. */
  62306. getClassName(): string;
  62307. /**
  62308. * Gets the input component
  62309. */
  62310. get input(): NodeMaterialConnectionPoint;
  62311. /**
  62312. * Gets the output component
  62313. */
  62314. get output(): NodeMaterialConnectionPoint;
  62315. protected _buildBlock(state: NodeMaterialBuildState): this;
  62316. serialize(): any;
  62317. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62318. }
  62319. }
  62320. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  62321. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62322. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62323. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62324. import { Color3 } from "babylonjs/Maths/math.color";
  62325. import { Scene } from "babylonjs/scene";
  62326. /**
  62327. * Class used to store a color step for the GradientBlock
  62328. */
  62329. export class GradientBlockColorStep {
  62330. /**
  62331. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62332. */
  62333. step: number;
  62334. /**
  62335. * Gets or sets the color associated with this step
  62336. */
  62337. color: Color3;
  62338. /**
  62339. * Creates a new GradientBlockColorStep
  62340. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62341. * @param color defines the color associated with this step
  62342. */
  62343. constructor(
  62344. /**
  62345. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62346. */
  62347. step: number,
  62348. /**
  62349. * Gets or sets the color associated with this step
  62350. */
  62351. color: Color3);
  62352. }
  62353. /**
  62354. * Block used to return a color from a gradient based on an input value between 0 and 1
  62355. */
  62356. export class GradientBlock extends NodeMaterialBlock {
  62357. /**
  62358. * Gets or sets the list of color steps
  62359. */
  62360. colorSteps: GradientBlockColorStep[];
  62361. /**
  62362. * Creates a new GradientBlock
  62363. * @param name defines the block name
  62364. */
  62365. constructor(name: string);
  62366. /**
  62367. * Gets the current class name
  62368. * @returns the class name
  62369. */
  62370. getClassName(): string;
  62371. /**
  62372. * Gets the gradient input component
  62373. */
  62374. get gradient(): NodeMaterialConnectionPoint;
  62375. /**
  62376. * Gets the output component
  62377. */
  62378. get output(): NodeMaterialConnectionPoint;
  62379. private _writeColorConstant;
  62380. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62381. serialize(): any;
  62382. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62383. protected _dumpPropertiesCode(): string;
  62384. }
  62385. }
  62386. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  62387. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62388. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62389. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62390. /**
  62391. * Block used to normalize lerp between 2 values
  62392. */
  62393. export class NLerpBlock extends NodeMaterialBlock {
  62394. /**
  62395. * Creates a new NLerpBlock
  62396. * @param name defines the block name
  62397. */
  62398. constructor(name: string);
  62399. /**
  62400. * Gets the current class name
  62401. * @returns the class name
  62402. */
  62403. getClassName(): string;
  62404. /**
  62405. * Gets the left operand input component
  62406. */
  62407. get left(): NodeMaterialConnectionPoint;
  62408. /**
  62409. * Gets the right operand input component
  62410. */
  62411. get right(): NodeMaterialConnectionPoint;
  62412. /**
  62413. * Gets the gradient operand input component
  62414. */
  62415. get gradient(): NodeMaterialConnectionPoint;
  62416. /**
  62417. * Gets the output component
  62418. */
  62419. get output(): NodeMaterialConnectionPoint;
  62420. protected _buildBlock(state: NodeMaterialBuildState): this;
  62421. }
  62422. }
  62423. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  62424. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62425. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62426. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62427. import { Scene } from "babylonjs/scene";
  62428. /**
  62429. * block used to Generate a Worley Noise 3D Noise Pattern
  62430. */
  62431. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62432. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62433. manhattanDistance: boolean;
  62434. /**
  62435. * Creates a new WorleyNoise3DBlock
  62436. * @param name defines the block name
  62437. */
  62438. constructor(name: string);
  62439. /**
  62440. * Gets the current class name
  62441. * @returns the class name
  62442. */
  62443. getClassName(): string;
  62444. /**
  62445. * Gets the seed input component
  62446. */
  62447. get seed(): NodeMaterialConnectionPoint;
  62448. /**
  62449. * Gets the jitter input component
  62450. */
  62451. get jitter(): NodeMaterialConnectionPoint;
  62452. /**
  62453. * Gets the output component
  62454. */
  62455. get output(): NodeMaterialConnectionPoint;
  62456. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62457. /**
  62458. * Exposes the properties to the UI?
  62459. */
  62460. protected _dumpPropertiesCode(): string;
  62461. /**
  62462. * Exposes the properties to the Seralize?
  62463. */
  62464. serialize(): any;
  62465. /**
  62466. * Exposes the properties to the deseralize?
  62467. */
  62468. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62469. }
  62470. }
  62471. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  62472. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62473. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62474. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62475. /**
  62476. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62477. */
  62478. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62479. /**
  62480. * Creates a new SimplexPerlin3DBlock
  62481. * @param name defines the block name
  62482. */
  62483. constructor(name: string);
  62484. /**
  62485. * Gets the current class name
  62486. * @returns the class name
  62487. */
  62488. getClassName(): string;
  62489. /**
  62490. * Gets the seed operand input component
  62491. */
  62492. get seed(): NodeMaterialConnectionPoint;
  62493. /**
  62494. * Gets the output component
  62495. */
  62496. get output(): NodeMaterialConnectionPoint;
  62497. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62498. }
  62499. }
  62500. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  62501. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62502. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62503. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62504. /**
  62505. * Block used to blend normals
  62506. */
  62507. export class NormalBlendBlock extends NodeMaterialBlock {
  62508. /**
  62509. * Creates a new NormalBlendBlock
  62510. * @param name defines the block name
  62511. */
  62512. constructor(name: string);
  62513. /**
  62514. * Gets the current class name
  62515. * @returns the class name
  62516. */
  62517. getClassName(): string;
  62518. /**
  62519. * Gets the first input component
  62520. */
  62521. get normalMap0(): NodeMaterialConnectionPoint;
  62522. /**
  62523. * Gets the second input component
  62524. */
  62525. get normalMap1(): NodeMaterialConnectionPoint;
  62526. /**
  62527. * Gets the output component
  62528. */
  62529. get output(): NodeMaterialConnectionPoint;
  62530. protected _buildBlock(state: NodeMaterialBuildState): this;
  62531. }
  62532. }
  62533. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  62534. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62535. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62536. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62537. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62538. /**
  62539. * Block used to rotate a 2d vector by a given angle
  62540. */
  62541. export class Rotate2dBlock extends NodeMaterialBlock {
  62542. /**
  62543. * Creates a new Rotate2dBlock
  62544. * @param name defines the block name
  62545. */
  62546. constructor(name: string);
  62547. /**
  62548. * Gets the current class name
  62549. * @returns the class name
  62550. */
  62551. getClassName(): string;
  62552. /**
  62553. * Gets the input vector
  62554. */
  62555. get input(): NodeMaterialConnectionPoint;
  62556. /**
  62557. * Gets the input angle
  62558. */
  62559. get angle(): NodeMaterialConnectionPoint;
  62560. /**
  62561. * Gets the output component
  62562. */
  62563. get output(): NodeMaterialConnectionPoint;
  62564. autoConfigure(material: NodeMaterial): void;
  62565. protected _buildBlock(state: NodeMaterialBuildState): this;
  62566. }
  62567. }
  62568. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  62569. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62570. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62571. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62572. /**
  62573. * Block used to get the reflected vector from a direction and a normal
  62574. */
  62575. export class ReflectBlock extends NodeMaterialBlock {
  62576. /**
  62577. * Creates a new ReflectBlock
  62578. * @param name defines the block name
  62579. */
  62580. constructor(name: string);
  62581. /**
  62582. * Gets the current class name
  62583. * @returns the class name
  62584. */
  62585. getClassName(): string;
  62586. /**
  62587. * Gets the incident component
  62588. */
  62589. get incident(): NodeMaterialConnectionPoint;
  62590. /**
  62591. * Gets the normal component
  62592. */
  62593. get normal(): NodeMaterialConnectionPoint;
  62594. /**
  62595. * Gets the output component
  62596. */
  62597. get output(): NodeMaterialConnectionPoint;
  62598. protected _buildBlock(state: NodeMaterialBuildState): this;
  62599. }
  62600. }
  62601. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  62602. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62603. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62604. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62605. /**
  62606. * Block used to get the refracted vector from a direction and a normal
  62607. */
  62608. export class RefractBlock extends NodeMaterialBlock {
  62609. /**
  62610. * Creates a new RefractBlock
  62611. * @param name defines the block name
  62612. */
  62613. constructor(name: string);
  62614. /**
  62615. * Gets the current class name
  62616. * @returns the class name
  62617. */
  62618. getClassName(): string;
  62619. /**
  62620. * Gets the incident component
  62621. */
  62622. get incident(): NodeMaterialConnectionPoint;
  62623. /**
  62624. * Gets the normal component
  62625. */
  62626. get normal(): NodeMaterialConnectionPoint;
  62627. /**
  62628. * Gets the index of refraction component
  62629. */
  62630. get ior(): NodeMaterialConnectionPoint;
  62631. /**
  62632. * Gets the output component
  62633. */
  62634. get output(): NodeMaterialConnectionPoint;
  62635. protected _buildBlock(state: NodeMaterialBuildState): this;
  62636. }
  62637. }
  62638. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  62639. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62640. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62641. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62642. /**
  62643. * Block used to desaturate a color
  62644. */
  62645. export class DesaturateBlock extends NodeMaterialBlock {
  62646. /**
  62647. * Creates a new DesaturateBlock
  62648. * @param name defines the block name
  62649. */
  62650. constructor(name: string);
  62651. /**
  62652. * Gets the current class name
  62653. * @returns the class name
  62654. */
  62655. getClassName(): string;
  62656. /**
  62657. * Gets the color operand input component
  62658. */
  62659. get color(): NodeMaterialConnectionPoint;
  62660. /**
  62661. * Gets the level operand input component
  62662. */
  62663. get level(): NodeMaterialConnectionPoint;
  62664. /**
  62665. * Gets the output component
  62666. */
  62667. get output(): NodeMaterialConnectionPoint;
  62668. protected _buildBlock(state: NodeMaterialBuildState): this;
  62669. }
  62670. }
  62671. declare module "babylonjs/Materials/Node/Blocks/index" {
  62672. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  62673. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  62674. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  62675. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  62676. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  62677. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  62678. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  62679. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  62680. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  62681. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  62682. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  62683. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  62684. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  62685. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  62686. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  62687. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  62688. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  62689. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  62690. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  62691. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  62692. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  62693. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  62694. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  62695. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  62696. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  62697. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  62698. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  62699. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  62700. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  62701. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  62702. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  62703. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  62704. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  62705. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  62706. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  62707. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  62708. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  62709. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  62710. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  62711. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  62712. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  62713. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  62714. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  62715. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  62716. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  62717. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  62718. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  62719. }
  62720. declare module "babylonjs/Materials/Node/Optimizers/index" {
  62721. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  62722. }
  62723. declare module "babylonjs/Materials/Node/index" {
  62724. export * from "babylonjs/Materials/Node/Enums/index";
  62725. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62726. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  62727. export * from "babylonjs/Materials/Node/nodeMaterial";
  62728. export * from "babylonjs/Materials/Node/Blocks/index";
  62729. export * from "babylonjs/Materials/Node/Optimizers/index";
  62730. }
  62731. declare module "babylonjs/Materials/effectRenderer" {
  62732. import { Nullable } from "babylonjs/types";
  62733. import { Texture } from "babylonjs/Materials/Textures/texture";
  62734. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62735. import { Viewport } from "babylonjs/Maths/math.viewport";
  62736. import { Observable } from "babylonjs/Misc/observable";
  62737. import { Effect } from "babylonjs/Materials/effect";
  62738. import "babylonjs/Engines/Extensions/engine.renderTarget";
  62739. import "babylonjs/Shaders/postprocess.vertex";
  62740. /**
  62741. * Effect Render Options
  62742. */
  62743. export interface IEffectRendererOptions {
  62744. /**
  62745. * Defines the vertices positions.
  62746. */
  62747. positions?: number[];
  62748. /**
  62749. * Defines the indices.
  62750. */
  62751. indices?: number[];
  62752. }
  62753. /**
  62754. * Helper class to render one or more effects
  62755. */
  62756. export class EffectRenderer {
  62757. private engine;
  62758. private static _DefaultOptions;
  62759. private _vertexBuffers;
  62760. private _indexBuffer;
  62761. private _ringBufferIndex;
  62762. private _ringScreenBuffer;
  62763. private _fullscreenViewport;
  62764. private _getNextFrameBuffer;
  62765. /**
  62766. * Creates an effect renderer
  62767. * @param engine the engine to use for rendering
  62768. * @param options defines the options of the effect renderer
  62769. */
  62770. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  62771. /**
  62772. * Sets the current viewport in normalized coordinates 0-1
  62773. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  62774. */
  62775. setViewport(viewport?: Viewport): void;
  62776. /**
  62777. * Binds the embedded attributes buffer to the effect.
  62778. * @param effect Defines the effect to bind the attributes for
  62779. */
  62780. bindBuffers(effect: Effect): void;
  62781. /**
  62782. * Sets the current effect wrapper to use during draw.
  62783. * The effect needs to be ready before calling this api.
  62784. * This also sets the default full screen position attribute.
  62785. * @param effectWrapper Defines the effect to draw with
  62786. */
  62787. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  62788. /**
  62789. * Draws a full screen quad.
  62790. */
  62791. draw(): void;
  62792. /**
  62793. * renders one or more effects to a specified texture
  62794. * @param effectWrappers list of effects to renderer
  62795. * @param outputTexture texture to draw to, if null it will render to the screen
  62796. */
  62797. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  62798. /**
  62799. * Disposes of the effect renderer
  62800. */
  62801. dispose(): void;
  62802. }
  62803. /**
  62804. * Options to create an EffectWrapper
  62805. */
  62806. interface EffectWrapperCreationOptions {
  62807. /**
  62808. * Engine to use to create the effect
  62809. */
  62810. engine: ThinEngine;
  62811. /**
  62812. * Fragment shader for the effect
  62813. */
  62814. fragmentShader: string;
  62815. /**
  62816. * Vertex shader for the effect
  62817. */
  62818. vertexShader?: string;
  62819. /**
  62820. * Attributes to use in the shader
  62821. */
  62822. attributeNames?: Array<string>;
  62823. /**
  62824. * Uniforms to use in the shader
  62825. */
  62826. uniformNames?: Array<string>;
  62827. /**
  62828. * Texture sampler names to use in the shader
  62829. */
  62830. samplerNames?: Array<string>;
  62831. /**
  62832. * The friendly name of the effect displayed in Spector.
  62833. */
  62834. name?: string;
  62835. }
  62836. /**
  62837. * Wraps an effect to be used for rendering
  62838. */
  62839. export class EffectWrapper {
  62840. /**
  62841. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  62842. */
  62843. onApplyObservable: Observable<{}>;
  62844. /**
  62845. * The underlying effect
  62846. */
  62847. effect: Effect;
  62848. /**
  62849. * Creates an effect to be renderer
  62850. * @param creationOptions options to create the effect
  62851. */
  62852. constructor(creationOptions: EffectWrapperCreationOptions);
  62853. /**
  62854. * Disposes of the effect wrapper
  62855. */
  62856. dispose(): void;
  62857. }
  62858. }
  62859. declare module "babylonjs/Materials/index" {
  62860. export * from "babylonjs/Materials/Background/index";
  62861. export * from "babylonjs/Materials/colorCurves";
  62862. export * from "babylonjs/Materials/iEffectFallbacks";
  62863. export * from "babylonjs/Materials/effectFallbacks";
  62864. export * from "babylonjs/Materials/effect";
  62865. export * from "babylonjs/Materials/fresnelParameters";
  62866. export * from "babylonjs/Materials/imageProcessingConfiguration";
  62867. export * from "babylonjs/Materials/material";
  62868. export * from "babylonjs/Materials/materialDefines";
  62869. export * from "babylonjs/Materials/materialHelper";
  62870. export * from "babylonjs/Materials/multiMaterial";
  62871. export * from "babylonjs/Materials/PBR/index";
  62872. export * from "babylonjs/Materials/pushMaterial";
  62873. export * from "babylonjs/Materials/shaderMaterial";
  62874. export * from "babylonjs/Materials/standardMaterial";
  62875. export * from "babylonjs/Materials/Textures/index";
  62876. export * from "babylonjs/Materials/uniformBuffer";
  62877. export * from "babylonjs/Materials/materialFlags";
  62878. export * from "babylonjs/Materials/Node/index";
  62879. export * from "babylonjs/Materials/effectRenderer";
  62880. }
  62881. declare module "babylonjs/Maths/index" {
  62882. export * from "babylonjs/Maths/math.scalar";
  62883. export * from "babylonjs/Maths/math";
  62884. export * from "babylonjs/Maths/sphericalPolynomial";
  62885. }
  62886. declare module "babylonjs/Misc/workerPool" {
  62887. import { IDisposable } from "babylonjs/scene";
  62888. /**
  62889. * Helper class to push actions to a pool of workers.
  62890. */
  62891. export class WorkerPool implements IDisposable {
  62892. private _workerInfos;
  62893. private _pendingActions;
  62894. /**
  62895. * Constructor
  62896. * @param workers Array of workers to use for actions
  62897. */
  62898. constructor(workers: Array<Worker>);
  62899. /**
  62900. * Terminates all workers and clears any pending actions.
  62901. */
  62902. dispose(): void;
  62903. /**
  62904. * Pushes an action to the worker pool. If all the workers are active, the action will be
  62905. * pended until a worker has completed its action.
  62906. * @param action The action to perform. Call onComplete when the action is complete.
  62907. */
  62908. push(action: (worker: Worker, onComplete: () => void) => void): void;
  62909. private _execute;
  62910. }
  62911. }
  62912. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  62913. import { IDisposable } from "babylonjs/scene";
  62914. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  62915. /**
  62916. * Configuration for Draco compression
  62917. */
  62918. export interface IDracoCompressionConfiguration {
  62919. /**
  62920. * Configuration for the decoder.
  62921. */
  62922. decoder: {
  62923. /**
  62924. * The url to the WebAssembly module.
  62925. */
  62926. wasmUrl?: string;
  62927. /**
  62928. * The url to the WebAssembly binary.
  62929. */
  62930. wasmBinaryUrl?: string;
  62931. /**
  62932. * The url to the fallback JavaScript module.
  62933. */
  62934. fallbackUrl?: string;
  62935. };
  62936. }
  62937. /**
  62938. * Draco compression (https://google.github.io/draco/)
  62939. *
  62940. * This class wraps the Draco module.
  62941. *
  62942. * **Encoder**
  62943. *
  62944. * The encoder is not currently implemented.
  62945. *
  62946. * **Decoder**
  62947. *
  62948. * 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.
  62949. *
  62950. * To update the configuration, use the following code:
  62951. * ```javascript
  62952. * DracoCompression.Configuration = {
  62953. * decoder: {
  62954. * wasmUrl: "<url to the WebAssembly library>",
  62955. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  62956. * fallbackUrl: "<url to the fallback JavaScript library>",
  62957. * }
  62958. * };
  62959. * ```
  62960. *
  62961. * 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.
  62962. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  62963. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  62964. *
  62965. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  62966. * ```javascript
  62967. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  62968. * ```
  62969. *
  62970. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  62971. */
  62972. export class DracoCompression implements IDisposable {
  62973. private _workerPoolPromise?;
  62974. private _decoderModulePromise?;
  62975. /**
  62976. * The configuration. Defaults to the following urls:
  62977. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  62978. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  62979. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  62980. */
  62981. static Configuration: IDracoCompressionConfiguration;
  62982. /**
  62983. * Returns true if the decoder configuration is available.
  62984. */
  62985. static get DecoderAvailable(): boolean;
  62986. /**
  62987. * Default number of workers to create when creating the draco compression object.
  62988. */
  62989. static DefaultNumWorkers: number;
  62990. private static GetDefaultNumWorkers;
  62991. private static _Default;
  62992. /**
  62993. * Default instance for the draco compression object.
  62994. */
  62995. static get Default(): DracoCompression;
  62996. /**
  62997. * Constructor
  62998. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  62999. */
  63000. constructor(numWorkers?: number);
  63001. /**
  63002. * Stop all async operations and release resources.
  63003. */
  63004. dispose(): void;
  63005. /**
  63006. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63007. * @returns a promise that resolves when ready
  63008. */
  63009. whenReadyAsync(): Promise<void>;
  63010. /**
  63011. * Decode Draco compressed mesh data to vertex data.
  63012. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63013. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63014. * @returns A promise that resolves with the decoded vertex data
  63015. */
  63016. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63017. [kind: string]: number;
  63018. }): Promise<VertexData>;
  63019. }
  63020. }
  63021. declare module "babylonjs/Meshes/Compression/index" {
  63022. export * from "babylonjs/Meshes/Compression/dracoCompression";
  63023. }
  63024. declare module "babylonjs/Meshes/csg" {
  63025. import { Nullable } from "babylonjs/types";
  63026. import { Scene } from "babylonjs/scene";
  63027. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63028. import { Mesh } from "babylonjs/Meshes/mesh";
  63029. import { Material } from "babylonjs/Materials/material";
  63030. /**
  63031. * Class for building Constructive Solid Geometry
  63032. */
  63033. export class CSG {
  63034. private polygons;
  63035. /**
  63036. * The world matrix
  63037. */
  63038. matrix: Matrix;
  63039. /**
  63040. * Stores the position
  63041. */
  63042. position: Vector3;
  63043. /**
  63044. * Stores the rotation
  63045. */
  63046. rotation: Vector3;
  63047. /**
  63048. * Stores the rotation quaternion
  63049. */
  63050. rotationQuaternion: Nullable<Quaternion>;
  63051. /**
  63052. * Stores the scaling vector
  63053. */
  63054. scaling: Vector3;
  63055. /**
  63056. * Convert the Mesh to CSG
  63057. * @param mesh The Mesh to convert to CSG
  63058. * @returns A new CSG from the Mesh
  63059. */
  63060. static FromMesh(mesh: Mesh): CSG;
  63061. /**
  63062. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63063. * @param polygons Polygons used to construct a CSG solid
  63064. */
  63065. private static FromPolygons;
  63066. /**
  63067. * Clones, or makes a deep copy, of the CSG
  63068. * @returns A new CSG
  63069. */
  63070. clone(): CSG;
  63071. /**
  63072. * Unions this CSG with another CSG
  63073. * @param csg The CSG to union against this CSG
  63074. * @returns The unioned CSG
  63075. */
  63076. union(csg: CSG): CSG;
  63077. /**
  63078. * Unions this CSG with another CSG in place
  63079. * @param csg The CSG to union against this CSG
  63080. */
  63081. unionInPlace(csg: CSG): void;
  63082. /**
  63083. * Subtracts this CSG with another CSG
  63084. * @param csg The CSG to subtract against this CSG
  63085. * @returns A new CSG
  63086. */
  63087. subtract(csg: CSG): CSG;
  63088. /**
  63089. * Subtracts this CSG with another CSG in place
  63090. * @param csg The CSG to subtact against this CSG
  63091. */
  63092. subtractInPlace(csg: CSG): void;
  63093. /**
  63094. * Intersect this CSG with another CSG
  63095. * @param csg The CSG to intersect against this CSG
  63096. * @returns A new CSG
  63097. */
  63098. intersect(csg: CSG): CSG;
  63099. /**
  63100. * Intersects this CSG with another CSG in place
  63101. * @param csg The CSG to intersect against this CSG
  63102. */
  63103. intersectInPlace(csg: CSG): void;
  63104. /**
  63105. * Return a new CSG solid with solid and empty space switched. This solid is
  63106. * not modified.
  63107. * @returns A new CSG solid with solid and empty space switched
  63108. */
  63109. inverse(): CSG;
  63110. /**
  63111. * Inverses the CSG in place
  63112. */
  63113. inverseInPlace(): void;
  63114. /**
  63115. * This is used to keep meshes transformations so they can be restored
  63116. * when we build back a Babylon Mesh
  63117. * NB : All CSG operations are performed in world coordinates
  63118. * @param csg The CSG to copy the transform attributes from
  63119. * @returns This CSG
  63120. */
  63121. copyTransformAttributes(csg: CSG): CSG;
  63122. /**
  63123. * Build Raw mesh from CSG
  63124. * Coordinates here are in world space
  63125. * @param name The name of the mesh geometry
  63126. * @param scene The Scene
  63127. * @param keepSubMeshes Specifies if the submeshes should be kept
  63128. * @returns A new Mesh
  63129. */
  63130. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63131. /**
  63132. * Build Mesh from CSG taking material and transforms into account
  63133. * @param name The name of the Mesh
  63134. * @param material The material of the Mesh
  63135. * @param scene The Scene
  63136. * @param keepSubMeshes Specifies if submeshes should be kept
  63137. * @returns The new Mesh
  63138. */
  63139. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63140. }
  63141. }
  63142. declare module "babylonjs/Meshes/trailMesh" {
  63143. import { Mesh } from "babylonjs/Meshes/mesh";
  63144. import { Scene } from "babylonjs/scene";
  63145. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63146. /**
  63147. * Class used to create a trail following a mesh
  63148. */
  63149. export class TrailMesh extends Mesh {
  63150. private _generator;
  63151. private _autoStart;
  63152. private _running;
  63153. private _diameter;
  63154. private _length;
  63155. private _sectionPolygonPointsCount;
  63156. private _sectionVectors;
  63157. private _sectionNormalVectors;
  63158. private _beforeRenderObserver;
  63159. /**
  63160. * @constructor
  63161. * @param name The value used by scene.getMeshByName() to do a lookup.
  63162. * @param generator The mesh or transform node to generate a trail.
  63163. * @param scene The scene to add this mesh to.
  63164. * @param diameter Diameter of trailing mesh. Default is 1.
  63165. * @param length Length of trailing mesh. Default is 60.
  63166. * @param autoStart Automatically start trailing mesh. Default true.
  63167. */
  63168. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63169. /**
  63170. * "TrailMesh"
  63171. * @returns "TrailMesh"
  63172. */
  63173. getClassName(): string;
  63174. private _createMesh;
  63175. /**
  63176. * Start trailing mesh.
  63177. */
  63178. start(): void;
  63179. /**
  63180. * Stop trailing mesh.
  63181. */
  63182. stop(): void;
  63183. /**
  63184. * Update trailing mesh geometry.
  63185. */
  63186. update(): void;
  63187. /**
  63188. * Returns a new TrailMesh object.
  63189. * @param name is a string, the name given to the new mesh
  63190. * @param newGenerator use new generator object for cloned trail mesh
  63191. * @returns a new mesh
  63192. */
  63193. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63194. /**
  63195. * Serializes this trail mesh
  63196. * @param serializationObject object to write serialization to
  63197. */
  63198. serialize(serializationObject: any): void;
  63199. /**
  63200. * Parses a serialized trail mesh
  63201. * @param parsedMesh the serialized mesh
  63202. * @param scene the scene to create the trail mesh in
  63203. * @returns the created trail mesh
  63204. */
  63205. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63206. }
  63207. }
  63208. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  63209. import { Nullable } from "babylonjs/types";
  63210. import { Scene } from "babylonjs/scene";
  63211. import { Vector4 } from "babylonjs/Maths/math.vector";
  63212. import { Color4 } from "babylonjs/Maths/math.color";
  63213. import { Mesh } from "babylonjs/Meshes/mesh";
  63214. /**
  63215. * Class containing static functions to help procedurally build meshes
  63216. */
  63217. export class TiledBoxBuilder {
  63218. /**
  63219. * Creates a box mesh
  63220. * 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)
  63221. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63222. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63223. * * 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
  63224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63225. * @param name defines the name of the mesh
  63226. * @param options defines the options used to create the mesh
  63227. * @param scene defines the hosting scene
  63228. * @returns the box mesh
  63229. */
  63230. static CreateTiledBox(name: string, options: {
  63231. pattern?: number;
  63232. width?: number;
  63233. height?: number;
  63234. depth?: number;
  63235. tileSize?: number;
  63236. tileWidth?: number;
  63237. tileHeight?: number;
  63238. alignHorizontal?: number;
  63239. alignVertical?: number;
  63240. faceUV?: Vector4[];
  63241. faceColors?: Color4[];
  63242. sideOrientation?: number;
  63243. updatable?: boolean;
  63244. }, scene?: Nullable<Scene>): Mesh;
  63245. }
  63246. }
  63247. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  63248. import { Vector4 } from "babylonjs/Maths/math.vector";
  63249. import { Mesh } from "babylonjs/Meshes/mesh";
  63250. /**
  63251. * Class containing static functions to help procedurally build meshes
  63252. */
  63253. export class TorusKnotBuilder {
  63254. /**
  63255. * Creates a torus knot mesh
  63256. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63257. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63258. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63259. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63260. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63261. * * 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
  63262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63263. * @param name defines the name of the mesh
  63264. * @param options defines the options used to create the mesh
  63265. * @param scene defines the hosting scene
  63266. * @returns the torus knot mesh
  63267. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63268. */
  63269. static CreateTorusKnot(name: string, options: {
  63270. radius?: number;
  63271. tube?: number;
  63272. radialSegments?: number;
  63273. tubularSegments?: number;
  63274. p?: number;
  63275. q?: number;
  63276. updatable?: boolean;
  63277. sideOrientation?: number;
  63278. frontUVs?: Vector4;
  63279. backUVs?: Vector4;
  63280. }, scene: any): Mesh;
  63281. }
  63282. }
  63283. declare module "babylonjs/Meshes/polygonMesh" {
  63284. import { Scene } from "babylonjs/scene";
  63285. import { Vector2 } from "babylonjs/Maths/math.vector";
  63286. import { Mesh } from "babylonjs/Meshes/mesh";
  63287. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63288. import { Path2 } from "babylonjs/Maths/math.path";
  63289. /**
  63290. * Polygon
  63291. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63292. */
  63293. export class Polygon {
  63294. /**
  63295. * Creates a rectangle
  63296. * @param xmin bottom X coord
  63297. * @param ymin bottom Y coord
  63298. * @param xmax top X coord
  63299. * @param ymax top Y coord
  63300. * @returns points that make the resulting rectation
  63301. */
  63302. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63303. /**
  63304. * Creates a circle
  63305. * @param radius radius of circle
  63306. * @param cx scale in x
  63307. * @param cy scale in y
  63308. * @param numberOfSides number of sides that make up the circle
  63309. * @returns points that make the resulting circle
  63310. */
  63311. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63312. /**
  63313. * Creates a polygon from input string
  63314. * @param input Input polygon data
  63315. * @returns the parsed points
  63316. */
  63317. static Parse(input: string): Vector2[];
  63318. /**
  63319. * Starts building a polygon from x and y coordinates
  63320. * @param x x coordinate
  63321. * @param y y coordinate
  63322. * @returns the started path2
  63323. */
  63324. static StartingAt(x: number, y: number): Path2;
  63325. }
  63326. /**
  63327. * Builds a polygon
  63328. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63329. */
  63330. export class PolygonMeshBuilder {
  63331. private _points;
  63332. private _outlinepoints;
  63333. private _holes;
  63334. private _name;
  63335. private _scene;
  63336. private _epoints;
  63337. private _eholes;
  63338. private _addToepoint;
  63339. /**
  63340. * Babylon reference to the earcut plugin.
  63341. */
  63342. bjsEarcut: any;
  63343. /**
  63344. * Creates a PolygonMeshBuilder
  63345. * @param name name of the builder
  63346. * @param contours Path of the polygon
  63347. * @param scene scene to add to when creating the mesh
  63348. * @param earcutInjection can be used to inject your own earcut reference
  63349. */
  63350. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63351. /**
  63352. * Adds a whole within the polygon
  63353. * @param hole Array of points defining the hole
  63354. * @returns this
  63355. */
  63356. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63357. /**
  63358. * Creates the polygon
  63359. * @param updatable If the mesh should be updatable
  63360. * @param depth The depth of the mesh created
  63361. * @returns the created mesh
  63362. */
  63363. build(updatable?: boolean, depth?: number): Mesh;
  63364. /**
  63365. * Creates the polygon
  63366. * @param depth The depth of the mesh created
  63367. * @returns the created VertexData
  63368. */
  63369. buildVertexData(depth?: number): VertexData;
  63370. /**
  63371. * Adds a side to the polygon
  63372. * @param positions points that make the polygon
  63373. * @param normals normals of the polygon
  63374. * @param uvs uvs of the polygon
  63375. * @param indices indices of the polygon
  63376. * @param bounds bounds of the polygon
  63377. * @param points points of the polygon
  63378. * @param depth depth of the polygon
  63379. * @param flip flip of the polygon
  63380. */
  63381. private addSide;
  63382. }
  63383. }
  63384. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  63385. import { Scene } from "babylonjs/scene";
  63386. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63387. import { Color4 } from "babylonjs/Maths/math.color";
  63388. import { Mesh } from "babylonjs/Meshes/mesh";
  63389. import { Nullable } from "babylonjs/types";
  63390. /**
  63391. * Class containing static functions to help procedurally build meshes
  63392. */
  63393. export class PolygonBuilder {
  63394. /**
  63395. * Creates a polygon mesh
  63396. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63397. * * 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
  63398. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63400. * * 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)
  63401. * * Remember you can only change the shape positions, not their number when updating a polygon
  63402. * @param name defines the name of the mesh
  63403. * @param options defines the options used to create the mesh
  63404. * @param scene defines the hosting scene
  63405. * @param earcutInjection can be used to inject your own earcut reference
  63406. * @returns the polygon mesh
  63407. */
  63408. static CreatePolygon(name: string, options: {
  63409. shape: Vector3[];
  63410. holes?: Vector3[][];
  63411. depth?: number;
  63412. faceUV?: Vector4[];
  63413. faceColors?: Color4[];
  63414. updatable?: boolean;
  63415. sideOrientation?: number;
  63416. frontUVs?: Vector4;
  63417. backUVs?: Vector4;
  63418. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63419. /**
  63420. * Creates an extruded polygon mesh, with depth in the Y direction.
  63421. * * 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)
  63422. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63423. * @param name defines the name of the mesh
  63424. * @param options defines the options used to create the mesh
  63425. * @param scene defines the hosting scene
  63426. * @param earcutInjection can be used to inject your own earcut reference
  63427. * @returns the polygon mesh
  63428. */
  63429. static ExtrudePolygon(name: string, options: {
  63430. shape: Vector3[];
  63431. holes?: Vector3[][];
  63432. depth?: number;
  63433. faceUV?: Vector4[];
  63434. faceColors?: Color4[];
  63435. updatable?: boolean;
  63436. sideOrientation?: number;
  63437. frontUVs?: Vector4;
  63438. backUVs?: Vector4;
  63439. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63440. }
  63441. }
  63442. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  63443. import { Scene } from "babylonjs/scene";
  63444. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63445. import { Mesh } from "babylonjs/Meshes/mesh";
  63446. import { Nullable } from "babylonjs/types";
  63447. /**
  63448. * Class containing static functions to help procedurally build meshes
  63449. */
  63450. export class LatheBuilder {
  63451. /**
  63452. * Creates lathe mesh.
  63453. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63454. * * 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
  63455. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63456. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63457. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63458. * * 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
  63459. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63460. * * 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
  63461. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63462. * * 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
  63463. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63464. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63465. * @param name defines the name of the mesh
  63466. * @param options defines the options used to create the mesh
  63467. * @param scene defines the hosting scene
  63468. * @returns the lathe mesh
  63469. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63470. */
  63471. static CreateLathe(name: string, options: {
  63472. shape: Vector3[];
  63473. radius?: number;
  63474. tessellation?: number;
  63475. clip?: number;
  63476. arc?: number;
  63477. closed?: boolean;
  63478. updatable?: boolean;
  63479. sideOrientation?: number;
  63480. frontUVs?: Vector4;
  63481. backUVs?: Vector4;
  63482. cap?: number;
  63483. invertUV?: boolean;
  63484. }, scene?: Nullable<Scene>): Mesh;
  63485. }
  63486. }
  63487. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  63488. import { Nullable } from "babylonjs/types";
  63489. import { Scene } from "babylonjs/scene";
  63490. import { Vector4 } from "babylonjs/Maths/math.vector";
  63491. import { Mesh } from "babylonjs/Meshes/mesh";
  63492. /**
  63493. * Class containing static functions to help procedurally build meshes
  63494. */
  63495. export class TiledPlaneBuilder {
  63496. /**
  63497. * Creates a tiled plane mesh
  63498. * * The parameter `pattern` will, depending on value, do nothing or
  63499. * * * flip (reflect about central vertical) alternate tiles across and up
  63500. * * * flip every tile on alternate rows
  63501. * * * rotate (180 degs) alternate tiles across and up
  63502. * * * rotate every tile on alternate rows
  63503. * * * flip and rotate alternate tiles across and up
  63504. * * * flip and rotate every tile on alternate rows
  63505. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  63506. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  63507. * * 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
  63508. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63509. * * 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)
  63510. * * 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)
  63511. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63512. * @param name defines the name of the mesh
  63513. * @param options defines the options used to create the mesh
  63514. * @param scene defines the hosting scene
  63515. * @returns the box mesh
  63516. */
  63517. static CreateTiledPlane(name: string, options: {
  63518. pattern?: number;
  63519. tileSize?: number;
  63520. tileWidth?: number;
  63521. tileHeight?: number;
  63522. size?: number;
  63523. width?: number;
  63524. height?: number;
  63525. alignHorizontal?: number;
  63526. alignVertical?: number;
  63527. sideOrientation?: number;
  63528. frontUVs?: Vector4;
  63529. backUVs?: Vector4;
  63530. updatable?: boolean;
  63531. }, scene?: Nullable<Scene>): Mesh;
  63532. }
  63533. }
  63534. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  63535. import { Nullable } from "babylonjs/types";
  63536. import { Scene } from "babylonjs/scene";
  63537. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63538. import { Mesh } from "babylonjs/Meshes/mesh";
  63539. /**
  63540. * Class containing static functions to help procedurally build meshes
  63541. */
  63542. export class TubeBuilder {
  63543. /**
  63544. * Creates a tube mesh.
  63545. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63546. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63547. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63548. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63549. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63550. * * 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)
  63551. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63552. * * 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
  63553. * * 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
  63554. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63555. * * 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
  63556. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63558. * @param name defines the name of the mesh
  63559. * @param options defines the options used to create the mesh
  63560. * @param scene defines the hosting scene
  63561. * @returns the tube mesh
  63562. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63563. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63564. */
  63565. static CreateTube(name: string, options: {
  63566. path: Vector3[];
  63567. radius?: number;
  63568. tessellation?: number;
  63569. radiusFunction?: {
  63570. (i: number, distance: number): number;
  63571. };
  63572. cap?: number;
  63573. arc?: number;
  63574. updatable?: boolean;
  63575. sideOrientation?: number;
  63576. frontUVs?: Vector4;
  63577. backUVs?: Vector4;
  63578. instance?: Mesh;
  63579. invertUV?: boolean;
  63580. }, scene?: Nullable<Scene>): Mesh;
  63581. }
  63582. }
  63583. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  63584. import { Scene } from "babylonjs/scene";
  63585. import { Vector4 } from "babylonjs/Maths/math.vector";
  63586. import { Mesh } from "babylonjs/Meshes/mesh";
  63587. import { Nullable } from "babylonjs/types";
  63588. /**
  63589. * Class containing static functions to help procedurally build meshes
  63590. */
  63591. export class IcoSphereBuilder {
  63592. /**
  63593. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63594. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63595. * * 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`)
  63596. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63597. * * 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
  63598. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63599. * * 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
  63600. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63601. * @param name defines the name of the mesh
  63602. * @param options defines the options used to create the mesh
  63603. * @param scene defines the hosting scene
  63604. * @returns the icosahedron mesh
  63605. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63606. */
  63607. static CreateIcoSphere(name: string, options: {
  63608. radius?: number;
  63609. radiusX?: number;
  63610. radiusY?: number;
  63611. radiusZ?: number;
  63612. flat?: boolean;
  63613. subdivisions?: number;
  63614. sideOrientation?: number;
  63615. frontUVs?: Vector4;
  63616. backUVs?: Vector4;
  63617. updatable?: boolean;
  63618. }, scene?: Nullable<Scene>): Mesh;
  63619. }
  63620. }
  63621. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  63622. import { Vector3 } from "babylonjs/Maths/math.vector";
  63623. import { Mesh } from "babylonjs/Meshes/mesh";
  63624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63625. /**
  63626. * Class containing static functions to help procedurally build meshes
  63627. */
  63628. export class DecalBuilder {
  63629. /**
  63630. * Creates a decal mesh.
  63631. * 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
  63632. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  63633. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  63634. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  63635. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  63636. * @param name defines the name of the mesh
  63637. * @param sourceMesh defines the mesh where the decal must be applied
  63638. * @param options defines the options used to create the mesh
  63639. * @param scene defines the hosting scene
  63640. * @returns the decal mesh
  63641. * @see https://doc.babylonjs.com/how_to/decals
  63642. */
  63643. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  63644. position?: Vector3;
  63645. normal?: Vector3;
  63646. size?: Vector3;
  63647. angle?: number;
  63648. }): Mesh;
  63649. }
  63650. }
  63651. declare module "babylonjs/Meshes/meshBuilder" {
  63652. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  63653. import { Nullable } from "babylonjs/types";
  63654. import { Scene } from "babylonjs/scene";
  63655. import { Mesh } from "babylonjs/Meshes/mesh";
  63656. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  63657. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  63658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63659. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  63660. import { Plane } from "babylonjs/Maths/math.plane";
  63661. /**
  63662. * Class containing static functions to help procedurally build meshes
  63663. */
  63664. export class MeshBuilder {
  63665. /**
  63666. * Creates a box mesh
  63667. * * The parameter `size` sets the size (float) of each box side (default 1)
  63668. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  63669. * * 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)
  63670. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63671. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63672. * * 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
  63673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63674. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63675. * @param name defines the name of the mesh
  63676. * @param options defines the options used to create the mesh
  63677. * @param scene defines the hosting scene
  63678. * @returns the box mesh
  63679. */
  63680. static CreateBox(name: string, options: {
  63681. size?: number;
  63682. width?: number;
  63683. height?: number;
  63684. depth?: number;
  63685. faceUV?: Vector4[];
  63686. faceColors?: Color4[];
  63687. sideOrientation?: number;
  63688. frontUVs?: Vector4;
  63689. backUVs?: Vector4;
  63690. updatable?: boolean;
  63691. }, scene?: Nullable<Scene>): Mesh;
  63692. /**
  63693. * Creates a tiled box mesh
  63694. * * faceTiles sets the pattern, tile size and number of tiles for a face
  63695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63696. * @param name defines the name of the mesh
  63697. * @param options defines the options used to create the mesh
  63698. * @param scene defines the hosting scene
  63699. * @returns the tiled box mesh
  63700. */
  63701. static CreateTiledBox(name: string, options: {
  63702. pattern?: number;
  63703. size?: number;
  63704. width?: number;
  63705. height?: number;
  63706. depth: number;
  63707. tileSize?: number;
  63708. tileWidth?: number;
  63709. tileHeight?: number;
  63710. faceUV?: Vector4[];
  63711. faceColors?: Color4[];
  63712. alignHorizontal?: number;
  63713. alignVertical?: number;
  63714. sideOrientation?: number;
  63715. updatable?: boolean;
  63716. }, scene?: Nullable<Scene>): Mesh;
  63717. /**
  63718. * Creates a sphere mesh
  63719. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  63720. * * 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`)
  63721. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  63722. * * 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
  63723. * * 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)
  63724. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63725. * * 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
  63726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63727. * @param name defines the name of the mesh
  63728. * @param options defines the options used to create the mesh
  63729. * @param scene defines the hosting scene
  63730. * @returns the sphere mesh
  63731. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  63732. */
  63733. static CreateSphere(name: string, options: {
  63734. segments?: number;
  63735. diameter?: number;
  63736. diameterX?: number;
  63737. diameterY?: number;
  63738. diameterZ?: number;
  63739. arc?: number;
  63740. slice?: number;
  63741. sideOrientation?: number;
  63742. frontUVs?: Vector4;
  63743. backUVs?: Vector4;
  63744. updatable?: boolean;
  63745. }, scene?: Nullable<Scene>): Mesh;
  63746. /**
  63747. * Creates a plane polygonal mesh. By default, this is a disc
  63748. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  63749. * * 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
  63750. * * 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
  63751. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63752. * * 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
  63753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63754. * @param name defines the name of the mesh
  63755. * @param options defines the options used to create the mesh
  63756. * @param scene defines the hosting scene
  63757. * @returns the plane polygonal mesh
  63758. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  63759. */
  63760. static CreateDisc(name: string, options: {
  63761. radius?: number;
  63762. tessellation?: number;
  63763. arc?: number;
  63764. updatable?: boolean;
  63765. sideOrientation?: number;
  63766. frontUVs?: Vector4;
  63767. backUVs?: Vector4;
  63768. }, scene?: Nullable<Scene>): Mesh;
  63769. /**
  63770. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63771. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63772. * * 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`)
  63773. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63774. * * 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
  63775. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63776. * * 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
  63777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63778. * @param name defines the name of the mesh
  63779. * @param options defines the options used to create the mesh
  63780. * @param scene defines the hosting scene
  63781. * @returns the icosahedron mesh
  63782. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63783. */
  63784. static CreateIcoSphere(name: string, options: {
  63785. radius?: number;
  63786. radiusX?: number;
  63787. radiusY?: number;
  63788. radiusZ?: number;
  63789. flat?: boolean;
  63790. subdivisions?: number;
  63791. sideOrientation?: number;
  63792. frontUVs?: Vector4;
  63793. backUVs?: Vector4;
  63794. updatable?: boolean;
  63795. }, scene?: Nullable<Scene>): Mesh;
  63796. /**
  63797. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63798. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  63799. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  63800. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  63801. * * 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
  63802. * * 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
  63803. * * 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
  63804. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63805. * * 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
  63806. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63807. * * 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
  63808. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  63809. * * 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
  63810. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  63811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63812. * @param name defines the name of the mesh
  63813. * @param options defines the options used to create the mesh
  63814. * @param scene defines the hosting scene
  63815. * @returns the ribbon mesh
  63816. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  63817. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63818. */
  63819. static CreateRibbon(name: string, options: {
  63820. pathArray: Vector3[][];
  63821. closeArray?: boolean;
  63822. closePath?: boolean;
  63823. offset?: number;
  63824. updatable?: boolean;
  63825. sideOrientation?: number;
  63826. frontUVs?: Vector4;
  63827. backUVs?: Vector4;
  63828. instance?: Mesh;
  63829. invertUV?: boolean;
  63830. uvs?: Vector2[];
  63831. colors?: Color4[];
  63832. }, scene?: Nullable<Scene>): Mesh;
  63833. /**
  63834. * Creates a cylinder or a cone mesh
  63835. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  63836. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  63837. * * 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.
  63838. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  63839. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  63840. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  63841. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  63842. * * 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).
  63843. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  63844. * * 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).
  63845. * * 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
  63846. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  63847. * * 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
  63848. * * 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.
  63849. * * If `enclose` is false, a ring surface is one element.
  63850. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  63851. * * 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
  63852. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63853. * * 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
  63854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63855. * @param name defines the name of the mesh
  63856. * @param options defines the options used to create the mesh
  63857. * @param scene defines the hosting scene
  63858. * @returns the cylinder mesh
  63859. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  63860. */
  63861. static CreateCylinder(name: string, options: {
  63862. height?: number;
  63863. diameterTop?: number;
  63864. diameterBottom?: number;
  63865. diameter?: number;
  63866. tessellation?: number;
  63867. subdivisions?: number;
  63868. arc?: number;
  63869. faceColors?: Color4[];
  63870. faceUV?: Vector4[];
  63871. updatable?: boolean;
  63872. hasRings?: boolean;
  63873. enclose?: boolean;
  63874. cap?: number;
  63875. sideOrientation?: number;
  63876. frontUVs?: Vector4;
  63877. backUVs?: Vector4;
  63878. }, scene?: Nullable<Scene>): Mesh;
  63879. /**
  63880. * Creates a torus mesh
  63881. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  63882. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  63883. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  63884. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63885. * * 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
  63886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63887. * @param name defines the name of the mesh
  63888. * @param options defines the options used to create the mesh
  63889. * @param scene defines the hosting scene
  63890. * @returns the torus mesh
  63891. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  63892. */
  63893. static CreateTorus(name: string, options: {
  63894. diameter?: number;
  63895. thickness?: number;
  63896. tessellation?: number;
  63897. updatable?: boolean;
  63898. sideOrientation?: number;
  63899. frontUVs?: Vector4;
  63900. backUVs?: Vector4;
  63901. }, scene?: Nullable<Scene>): Mesh;
  63902. /**
  63903. * Creates a torus knot mesh
  63904. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63905. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63906. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63907. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63908. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63909. * * 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
  63910. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63911. * @param name defines the name of the mesh
  63912. * @param options defines the options used to create the mesh
  63913. * @param scene defines the hosting scene
  63914. * @returns the torus knot mesh
  63915. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63916. */
  63917. static CreateTorusKnot(name: string, options: {
  63918. radius?: number;
  63919. tube?: number;
  63920. radialSegments?: number;
  63921. tubularSegments?: number;
  63922. p?: number;
  63923. q?: number;
  63924. updatable?: boolean;
  63925. sideOrientation?: number;
  63926. frontUVs?: Vector4;
  63927. backUVs?: Vector4;
  63928. }, scene?: Nullable<Scene>): Mesh;
  63929. /**
  63930. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  63931. * * 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
  63932. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  63933. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  63934. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  63935. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  63936. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  63937. * * 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
  63938. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  63939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63940. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  63941. * @param name defines the name of the new line system
  63942. * @param options defines the options used to create the line system
  63943. * @param scene defines the hosting scene
  63944. * @returns a new line system mesh
  63945. */
  63946. static CreateLineSystem(name: string, options: {
  63947. lines: Vector3[][];
  63948. updatable?: boolean;
  63949. instance?: Nullable<LinesMesh>;
  63950. colors?: Nullable<Color4[][]>;
  63951. useVertexAlpha?: boolean;
  63952. }, scene: Nullable<Scene>): LinesMesh;
  63953. /**
  63954. * Creates a line mesh
  63955. * 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
  63956. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  63957. * * The parameter `points` is an array successive Vector3
  63958. * * 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
  63959. * * The optional parameter `colors` is an array of successive Color4, one per line point
  63960. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  63961. * * When updating an instance, remember that only point positions can change, not the number of points
  63962. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63963. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  63964. * @param name defines the name of the new line system
  63965. * @param options defines the options used to create the line system
  63966. * @param scene defines the hosting scene
  63967. * @returns a new line mesh
  63968. */
  63969. static CreateLines(name: string, options: {
  63970. points: Vector3[];
  63971. updatable?: boolean;
  63972. instance?: Nullable<LinesMesh>;
  63973. colors?: Color4[];
  63974. useVertexAlpha?: boolean;
  63975. }, scene?: Nullable<Scene>): LinesMesh;
  63976. /**
  63977. * Creates a dashed line mesh
  63978. * * 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
  63979. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  63980. * * The parameter `points` is an array successive Vector3
  63981. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  63982. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  63983. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  63984. * * 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
  63985. * * When updating an instance, remember that only point positions can change, not the number of points
  63986. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63987. * @param name defines the name of the mesh
  63988. * @param options defines the options used to create the mesh
  63989. * @param scene defines the hosting scene
  63990. * @returns the dashed line mesh
  63991. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  63992. */
  63993. static CreateDashedLines(name: string, options: {
  63994. points: Vector3[];
  63995. dashSize?: number;
  63996. gapSize?: number;
  63997. dashNb?: number;
  63998. updatable?: boolean;
  63999. instance?: LinesMesh;
  64000. }, scene?: Nullable<Scene>): LinesMesh;
  64001. /**
  64002. * 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.
  64003. * * 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.
  64004. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64005. * * 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.
  64006. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64007. * * 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
  64008. * * 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
  64009. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64010. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64011. * * 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
  64012. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64014. * @param name defines the name of the mesh
  64015. * @param options defines the options used to create the mesh
  64016. * @param scene defines the hosting scene
  64017. * @returns the extruded shape mesh
  64018. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64019. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64020. */
  64021. static ExtrudeShape(name: string, options: {
  64022. shape: Vector3[];
  64023. path: Vector3[];
  64024. scale?: number;
  64025. rotation?: number;
  64026. cap?: number;
  64027. updatable?: boolean;
  64028. sideOrientation?: number;
  64029. frontUVs?: Vector4;
  64030. backUVs?: Vector4;
  64031. instance?: Mesh;
  64032. invertUV?: boolean;
  64033. }, scene?: Nullable<Scene>): Mesh;
  64034. /**
  64035. * Creates an custom extruded shape mesh.
  64036. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64037. * * 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.
  64038. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64039. * * 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
  64040. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64041. * * 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
  64042. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64043. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64044. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64045. * * 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
  64046. * * 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
  64047. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64048. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64049. * * 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
  64050. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64051. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64052. * @param name defines the name of the mesh
  64053. * @param options defines the options used to create the mesh
  64054. * @param scene defines the hosting scene
  64055. * @returns the custom extruded shape mesh
  64056. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64057. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64058. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64059. */
  64060. static ExtrudeShapeCustom(name: string, options: {
  64061. shape: Vector3[];
  64062. path: Vector3[];
  64063. scaleFunction?: any;
  64064. rotationFunction?: any;
  64065. ribbonCloseArray?: boolean;
  64066. ribbonClosePath?: boolean;
  64067. cap?: number;
  64068. updatable?: boolean;
  64069. sideOrientation?: number;
  64070. frontUVs?: Vector4;
  64071. backUVs?: Vector4;
  64072. instance?: Mesh;
  64073. invertUV?: boolean;
  64074. }, scene?: Nullable<Scene>): Mesh;
  64075. /**
  64076. * Creates lathe mesh.
  64077. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64078. * * 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
  64079. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64080. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64081. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64082. * * 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
  64083. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64084. * * 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
  64085. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64086. * * 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
  64087. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64088. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64089. * @param name defines the name of the mesh
  64090. * @param options defines the options used to create the mesh
  64091. * @param scene defines the hosting scene
  64092. * @returns the lathe mesh
  64093. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64094. */
  64095. static CreateLathe(name: string, options: {
  64096. shape: Vector3[];
  64097. radius?: number;
  64098. tessellation?: number;
  64099. clip?: number;
  64100. arc?: number;
  64101. closed?: boolean;
  64102. updatable?: boolean;
  64103. sideOrientation?: number;
  64104. frontUVs?: Vector4;
  64105. backUVs?: Vector4;
  64106. cap?: number;
  64107. invertUV?: boolean;
  64108. }, scene?: Nullable<Scene>): Mesh;
  64109. /**
  64110. * Creates a tiled plane mesh
  64111. * * You can set a limited pattern arrangement with the tiles
  64112. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64113. * * 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
  64114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64115. * @param name defines the name of the mesh
  64116. * @param options defines the options used to create the mesh
  64117. * @param scene defines the hosting scene
  64118. * @returns the plane mesh
  64119. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64120. */
  64121. static CreateTiledPlane(name: string, options: {
  64122. pattern?: number;
  64123. tileSize?: number;
  64124. tileWidth?: number;
  64125. tileHeight?: number;
  64126. size?: number;
  64127. width?: number;
  64128. height?: number;
  64129. alignHorizontal?: number;
  64130. alignVertical?: number;
  64131. sideOrientation?: number;
  64132. frontUVs?: Vector4;
  64133. backUVs?: Vector4;
  64134. updatable?: boolean;
  64135. }, scene?: Nullable<Scene>): Mesh;
  64136. /**
  64137. * Creates a plane mesh
  64138. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64139. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64140. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64141. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64142. * * 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
  64143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64144. * @param name defines the name of the mesh
  64145. * @param options defines the options used to create the mesh
  64146. * @param scene defines the hosting scene
  64147. * @returns the plane mesh
  64148. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64149. */
  64150. static CreatePlane(name: string, options: {
  64151. size?: number;
  64152. width?: number;
  64153. height?: number;
  64154. sideOrientation?: number;
  64155. frontUVs?: Vector4;
  64156. backUVs?: Vector4;
  64157. updatable?: boolean;
  64158. sourcePlane?: Plane;
  64159. }, scene?: Nullable<Scene>): Mesh;
  64160. /**
  64161. * Creates a ground mesh
  64162. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64163. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64165. * @param name defines the name of the mesh
  64166. * @param options defines the options used to create the mesh
  64167. * @param scene defines the hosting scene
  64168. * @returns the ground mesh
  64169. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64170. */
  64171. static CreateGround(name: string, options: {
  64172. width?: number;
  64173. height?: number;
  64174. subdivisions?: number;
  64175. subdivisionsX?: number;
  64176. subdivisionsY?: number;
  64177. updatable?: boolean;
  64178. }, scene?: Nullable<Scene>): Mesh;
  64179. /**
  64180. * Creates a tiled ground mesh
  64181. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64182. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64183. * * 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
  64184. * * 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
  64185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64186. * @param name defines the name of the mesh
  64187. * @param options defines the options used to create the mesh
  64188. * @param scene defines the hosting scene
  64189. * @returns the tiled ground mesh
  64190. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64191. */
  64192. static CreateTiledGround(name: string, options: {
  64193. xmin: number;
  64194. zmin: number;
  64195. xmax: number;
  64196. zmax: number;
  64197. subdivisions?: {
  64198. w: number;
  64199. h: number;
  64200. };
  64201. precision?: {
  64202. w: number;
  64203. h: number;
  64204. };
  64205. updatable?: boolean;
  64206. }, scene?: Nullable<Scene>): Mesh;
  64207. /**
  64208. * Creates a ground mesh from a height map
  64209. * * The parameter `url` sets the URL of the height map image resource.
  64210. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64211. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64212. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64213. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64214. * * 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.
  64215. * * 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).
  64216. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64217. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64218. * @param name defines the name of the mesh
  64219. * @param url defines the url to the height map
  64220. * @param options defines the options used to create the mesh
  64221. * @param scene defines the hosting scene
  64222. * @returns the ground mesh
  64223. * @see https://doc.babylonjs.com/babylon101/height_map
  64224. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64225. */
  64226. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64227. width?: number;
  64228. height?: number;
  64229. subdivisions?: number;
  64230. minHeight?: number;
  64231. maxHeight?: number;
  64232. colorFilter?: Color3;
  64233. alphaFilter?: number;
  64234. updatable?: boolean;
  64235. onReady?: (mesh: GroundMesh) => void;
  64236. }, scene?: Nullable<Scene>): GroundMesh;
  64237. /**
  64238. * Creates a polygon mesh
  64239. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64240. * * 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
  64241. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64243. * * 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)
  64244. * * Remember you can only change the shape positions, not their number when updating a polygon
  64245. * @param name defines the name of the mesh
  64246. * @param options defines the options used to create the mesh
  64247. * @param scene defines the hosting scene
  64248. * @param earcutInjection can be used to inject your own earcut reference
  64249. * @returns the polygon mesh
  64250. */
  64251. static CreatePolygon(name: string, options: {
  64252. shape: Vector3[];
  64253. holes?: Vector3[][];
  64254. depth?: number;
  64255. faceUV?: Vector4[];
  64256. faceColors?: Color4[];
  64257. updatable?: boolean;
  64258. sideOrientation?: number;
  64259. frontUVs?: Vector4;
  64260. backUVs?: Vector4;
  64261. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64262. /**
  64263. * Creates an extruded polygon mesh, with depth in the Y direction.
  64264. * * 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)
  64265. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64266. * @param name defines the name of the mesh
  64267. * @param options defines the options used to create the mesh
  64268. * @param scene defines the hosting scene
  64269. * @param earcutInjection can be used to inject your own earcut reference
  64270. * @returns the polygon mesh
  64271. */
  64272. static ExtrudePolygon(name: string, options: {
  64273. shape: Vector3[];
  64274. holes?: Vector3[][];
  64275. depth?: number;
  64276. faceUV?: Vector4[];
  64277. faceColors?: Color4[];
  64278. updatable?: boolean;
  64279. sideOrientation?: number;
  64280. frontUVs?: Vector4;
  64281. backUVs?: Vector4;
  64282. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64283. /**
  64284. * Creates a tube mesh.
  64285. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64286. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64287. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64288. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64289. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64290. * * 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)
  64291. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64292. * * 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
  64293. * * 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
  64294. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64295. * * 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
  64296. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64298. * @param name defines the name of the mesh
  64299. * @param options defines the options used to create the mesh
  64300. * @param scene defines the hosting scene
  64301. * @returns the tube mesh
  64302. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64303. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64304. */
  64305. static CreateTube(name: string, options: {
  64306. path: Vector3[];
  64307. radius?: number;
  64308. tessellation?: number;
  64309. radiusFunction?: {
  64310. (i: number, distance: number): number;
  64311. };
  64312. cap?: number;
  64313. arc?: number;
  64314. updatable?: boolean;
  64315. sideOrientation?: number;
  64316. frontUVs?: Vector4;
  64317. backUVs?: Vector4;
  64318. instance?: Mesh;
  64319. invertUV?: boolean;
  64320. }, scene?: Nullable<Scene>): Mesh;
  64321. /**
  64322. * Creates a polyhedron mesh
  64323. * * 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
  64324. * * The parameter `size` (positive float, default 1) sets the polygon size
  64325. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64326. * * 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`
  64327. * * 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
  64328. * * 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)`)
  64329. * * 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
  64330. * * 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
  64331. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64332. * * 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
  64333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64334. * @param name defines the name of the mesh
  64335. * @param options defines the options used to create the mesh
  64336. * @param scene defines the hosting scene
  64337. * @returns the polyhedron mesh
  64338. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64339. */
  64340. static CreatePolyhedron(name: string, options: {
  64341. type?: number;
  64342. size?: number;
  64343. sizeX?: number;
  64344. sizeY?: number;
  64345. sizeZ?: number;
  64346. custom?: any;
  64347. faceUV?: Vector4[];
  64348. faceColors?: Color4[];
  64349. flat?: boolean;
  64350. updatable?: boolean;
  64351. sideOrientation?: number;
  64352. frontUVs?: Vector4;
  64353. backUVs?: Vector4;
  64354. }, scene?: Nullable<Scene>): Mesh;
  64355. /**
  64356. * Creates a decal mesh.
  64357. * 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
  64358. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64359. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64360. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64361. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64362. * @param name defines the name of the mesh
  64363. * @param sourceMesh defines the mesh where the decal must be applied
  64364. * @param options defines the options used to create the mesh
  64365. * @param scene defines the hosting scene
  64366. * @returns the decal mesh
  64367. * @see https://doc.babylonjs.com/how_to/decals
  64368. */
  64369. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64370. position?: Vector3;
  64371. normal?: Vector3;
  64372. size?: Vector3;
  64373. angle?: number;
  64374. }): Mesh;
  64375. }
  64376. }
  64377. declare module "babylonjs/Meshes/meshSimplification" {
  64378. import { Mesh } from "babylonjs/Meshes/mesh";
  64379. /**
  64380. * A simplifier interface for future simplification implementations
  64381. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64382. */
  64383. export interface ISimplifier {
  64384. /**
  64385. * Simplification of a given mesh according to the given settings.
  64386. * Since this requires computation, it is assumed that the function runs async.
  64387. * @param settings The settings of the simplification, including quality and distance
  64388. * @param successCallback A callback that will be called after the mesh was simplified.
  64389. * @param errorCallback in case of an error, this callback will be called. optional.
  64390. */
  64391. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64392. }
  64393. /**
  64394. * Expected simplification settings.
  64395. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64396. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64397. */
  64398. export interface ISimplificationSettings {
  64399. /**
  64400. * Gets or sets the expected quality
  64401. */
  64402. quality: number;
  64403. /**
  64404. * Gets or sets the distance when this optimized version should be used
  64405. */
  64406. distance: number;
  64407. /**
  64408. * Gets an already optimized mesh
  64409. */
  64410. optimizeMesh?: boolean;
  64411. }
  64412. /**
  64413. * Class used to specify simplification options
  64414. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64415. */
  64416. export class SimplificationSettings implements ISimplificationSettings {
  64417. /** expected quality */
  64418. quality: number;
  64419. /** distance when this optimized version should be used */
  64420. distance: number;
  64421. /** already optimized mesh */
  64422. optimizeMesh?: boolean | undefined;
  64423. /**
  64424. * Creates a SimplificationSettings
  64425. * @param quality expected quality
  64426. * @param distance distance when this optimized version should be used
  64427. * @param optimizeMesh already optimized mesh
  64428. */
  64429. constructor(
  64430. /** expected quality */
  64431. quality: number,
  64432. /** distance when this optimized version should be used */
  64433. distance: number,
  64434. /** already optimized mesh */
  64435. optimizeMesh?: boolean | undefined);
  64436. }
  64437. /**
  64438. * Interface used to define a simplification task
  64439. */
  64440. export interface ISimplificationTask {
  64441. /**
  64442. * Array of settings
  64443. */
  64444. settings: Array<ISimplificationSettings>;
  64445. /**
  64446. * Simplification type
  64447. */
  64448. simplificationType: SimplificationType;
  64449. /**
  64450. * Mesh to simplify
  64451. */
  64452. mesh: Mesh;
  64453. /**
  64454. * Callback called on success
  64455. */
  64456. successCallback?: () => void;
  64457. /**
  64458. * Defines if parallel processing can be used
  64459. */
  64460. parallelProcessing: boolean;
  64461. }
  64462. /**
  64463. * Queue used to order the simplification tasks
  64464. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64465. */
  64466. export class SimplificationQueue {
  64467. private _simplificationArray;
  64468. /**
  64469. * Gets a boolean indicating that the process is still running
  64470. */
  64471. running: boolean;
  64472. /**
  64473. * Creates a new queue
  64474. */
  64475. constructor();
  64476. /**
  64477. * Adds a new simplification task
  64478. * @param task defines a task to add
  64479. */
  64480. addTask(task: ISimplificationTask): void;
  64481. /**
  64482. * Execute next task
  64483. */
  64484. executeNext(): void;
  64485. /**
  64486. * Execute a simplification task
  64487. * @param task defines the task to run
  64488. */
  64489. runSimplification(task: ISimplificationTask): void;
  64490. private getSimplifier;
  64491. }
  64492. /**
  64493. * The implemented types of simplification
  64494. * At the moment only Quadratic Error Decimation is implemented
  64495. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64496. */
  64497. export enum SimplificationType {
  64498. /** Quadratic error decimation */
  64499. QUADRATIC = 0
  64500. }
  64501. }
  64502. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  64503. import { Scene } from "babylonjs/scene";
  64504. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  64505. import { ISceneComponent } from "babylonjs/sceneComponent";
  64506. module "babylonjs/scene" {
  64507. interface Scene {
  64508. /** @hidden (Backing field) */
  64509. _simplificationQueue: SimplificationQueue;
  64510. /**
  64511. * Gets or sets the simplification queue attached to the scene
  64512. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64513. */
  64514. simplificationQueue: SimplificationQueue;
  64515. }
  64516. }
  64517. module "babylonjs/Meshes/mesh" {
  64518. interface Mesh {
  64519. /**
  64520. * Simplify the mesh according to the given array of settings.
  64521. * Function will return immediately and will simplify async
  64522. * @param settings a collection of simplification settings
  64523. * @param parallelProcessing should all levels calculate parallel or one after the other
  64524. * @param simplificationType the type of simplification to run
  64525. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  64526. * @returns the current mesh
  64527. */
  64528. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  64529. }
  64530. }
  64531. /**
  64532. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  64533. * created in a scene
  64534. */
  64535. export class SimplicationQueueSceneComponent implements ISceneComponent {
  64536. /**
  64537. * The component name helpfull to identify the component in the list of scene components.
  64538. */
  64539. readonly name: string;
  64540. /**
  64541. * The scene the component belongs to.
  64542. */
  64543. scene: Scene;
  64544. /**
  64545. * Creates a new instance of the component for the given scene
  64546. * @param scene Defines the scene to register the component in
  64547. */
  64548. constructor(scene: Scene);
  64549. /**
  64550. * Registers the component in a given scene
  64551. */
  64552. register(): void;
  64553. /**
  64554. * Rebuilds the elements related to this component in case of
  64555. * context lost for instance.
  64556. */
  64557. rebuild(): void;
  64558. /**
  64559. * Disposes the component and the associated ressources
  64560. */
  64561. dispose(): void;
  64562. private _beforeCameraUpdate;
  64563. }
  64564. }
  64565. declare module "babylonjs/Meshes/Builders/index" {
  64566. export * from "babylonjs/Meshes/Builders/boxBuilder";
  64567. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  64568. export * from "babylonjs/Meshes/Builders/discBuilder";
  64569. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  64570. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  64571. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  64572. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  64573. export * from "babylonjs/Meshes/Builders/torusBuilder";
  64574. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  64575. export * from "babylonjs/Meshes/Builders/linesBuilder";
  64576. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  64577. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  64578. export * from "babylonjs/Meshes/Builders/latheBuilder";
  64579. export * from "babylonjs/Meshes/Builders/planeBuilder";
  64580. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  64581. export * from "babylonjs/Meshes/Builders/groundBuilder";
  64582. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  64583. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  64584. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  64585. export * from "babylonjs/Meshes/Builders/decalBuilder";
  64586. }
  64587. declare module "babylonjs/Meshes/index" {
  64588. export * from "babylonjs/Meshes/abstractMesh";
  64589. export * from "babylonjs/Meshes/buffer";
  64590. export * from "babylonjs/Meshes/Compression/index";
  64591. export * from "babylonjs/Meshes/csg";
  64592. export * from "babylonjs/Meshes/geometry";
  64593. export * from "babylonjs/Meshes/groundMesh";
  64594. export * from "babylonjs/Meshes/trailMesh";
  64595. export * from "babylonjs/Meshes/instancedMesh";
  64596. export * from "babylonjs/Meshes/linesMesh";
  64597. export * from "babylonjs/Meshes/mesh";
  64598. export * from "babylonjs/Meshes/mesh.vertexData";
  64599. export * from "babylonjs/Meshes/meshBuilder";
  64600. export * from "babylonjs/Meshes/meshSimplification";
  64601. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  64602. export * from "babylonjs/Meshes/polygonMesh";
  64603. export * from "babylonjs/Meshes/subMesh";
  64604. export * from "babylonjs/Meshes/meshLODLevel";
  64605. export * from "babylonjs/Meshes/transformNode";
  64606. export * from "babylonjs/Meshes/Builders/index";
  64607. export * from "babylonjs/Meshes/dataBuffer";
  64608. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  64609. }
  64610. declare module "babylonjs/Morph/index" {
  64611. export * from "babylonjs/Morph/morphTarget";
  64612. export * from "babylonjs/Morph/morphTargetManager";
  64613. }
  64614. declare module "babylonjs/Navigation/INavigationEngine" {
  64615. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64616. import { Vector3 } from "babylonjs/Maths/math";
  64617. import { Mesh } from "babylonjs/Meshes/mesh";
  64618. import { Scene } from "babylonjs/scene";
  64619. /**
  64620. * Navigation plugin interface to add navigation constrained by a navigation mesh
  64621. */
  64622. export interface INavigationEnginePlugin {
  64623. /**
  64624. * plugin name
  64625. */
  64626. name: string;
  64627. /**
  64628. * Creates a navigation mesh
  64629. * @param meshes array of all the geometry used to compute the navigatio mesh
  64630. * @param parameters bunch of parameters used to filter geometry
  64631. */
  64632. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  64633. /**
  64634. * Create a navigation mesh debug mesh
  64635. * @param scene is where the mesh will be added
  64636. * @returns debug display mesh
  64637. */
  64638. createDebugNavMesh(scene: Scene): Mesh;
  64639. /**
  64640. * Get a navigation mesh constrained position, closest to the parameter position
  64641. * @param position world position
  64642. * @returns the closest point to position constrained by the navigation mesh
  64643. */
  64644. getClosestPoint(position: Vector3): Vector3;
  64645. /**
  64646. * Get a navigation mesh constrained position, within a particular radius
  64647. * @param position world position
  64648. * @param maxRadius the maximum distance to the constrained world position
  64649. * @returns the closest point to position constrained by the navigation mesh
  64650. */
  64651. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  64652. /**
  64653. * Compute the final position from a segment made of destination-position
  64654. * @param position world position
  64655. * @param destination world position
  64656. * @returns the resulting point along the navmesh
  64657. */
  64658. moveAlong(position: Vector3, destination: Vector3): Vector3;
  64659. /**
  64660. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  64661. * @param start world position
  64662. * @param end world position
  64663. * @returns array containing world position composing the path
  64664. */
  64665. computePath(start: Vector3, end: Vector3): Vector3[];
  64666. /**
  64667. * If this plugin is supported
  64668. * @returns true if plugin is supported
  64669. */
  64670. isSupported(): boolean;
  64671. /**
  64672. * Create a new Crowd so you can add agents
  64673. * @param maxAgents the maximum agent count in the crowd
  64674. * @param maxAgentRadius the maximum radius an agent can have
  64675. * @param scene to attach the crowd to
  64676. * @returns the crowd you can add agents to
  64677. */
  64678. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  64679. /**
  64680. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64681. * The queries will try to find a solution within those bounds
  64682. * default is (1,1,1)
  64683. * @param extent x,y,z value that define the extent around the queries point of reference
  64684. */
  64685. setDefaultQueryExtent(extent: Vector3): void;
  64686. /**
  64687. * Get the Bounding box extent specified by setDefaultQueryExtent
  64688. * @returns the box extent values
  64689. */
  64690. getDefaultQueryExtent(): Vector3;
  64691. /**
  64692. * Release all resources
  64693. */
  64694. dispose(): void;
  64695. }
  64696. /**
  64697. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  64698. */
  64699. export interface ICrowd {
  64700. /**
  64701. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  64702. * You can attach anything to that node. The node position is updated in the scene update tick.
  64703. * @param pos world position that will be constrained by the navigation mesh
  64704. * @param parameters agent parameters
  64705. * @param transform hooked to the agent that will be update by the scene
  64706. * @returns agent index
  64707. */
  64708. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  64709. /**
  64710. * Returns the agent position in world space
  64711. * @param index agent index returned by addAgent
  64712. * @returns world space position
  64713. */
  64714. getAgentPosition(index: number): Vector3;
  64715. /**
  64716. * Gets the agent velocity in world space
  64717. * @param index agent index returned by addAgent
  64718. * @returns world space velocity
  64719. */
  64720. getAgentVelocity(index: number): Vector3;
  64721. /**
  64722. * remove a particular agent previously created
  64723. * @param index agent index returned by addAgent
  64724. */
  64725. removeAgent(index: number): void;
  64726. /**
  64727. * get the list of all agents attached to this crowd
  64728. * @returns list of agent indices
  64729. */
  64730. getAgents(): number[];
  64731. /**
  64732. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  64733. * @param deltaTime in seconds
  64734. */
  64735. update(deltaTime: number): void;
  64736. /**
  64737. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  64738. * @param index agent index returned by addAgent
  64739. * @param destination targeted world position
  64740. */
  64741. agentGoto(index: number, destination: Vector3): void;
  64742. /**
  64743. * Teleport the agent to a new position
  64744. * @param index agent index returned by addAgent
  64745. * @param destination targeted world position
  64746. */
  64747. agentTeleport(index: number, destination: Vector3): void;
  64748. /**
  64749. * Update agent parameters
  64750. * @param index agent index returned by addAgent
  64751. * @param parameters agent parameters
  64752. */
  64753. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  64754. /**
  64755. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64756. * The queries will try to find a solution within those bounds
  64757. * default is (1,1,1)
  64758. * @param extent x,y,z value that define the extent around the queries point of reference
  64759. */
  64760. setDefaultQueryExtent(extent: Vector3): void;
  64761. /**
  64762. * Get the Bounding box extent specified by setDefaultQueryExtent
  64763. * @returns the box extent values
  64764. */
  64765. getDefaultQueryExtent(): Vector3;
  64766. /**
  64767. * Release all resources
  64768. */
  64769. dispose(): void;
  64770. }
  64771. /**
  64772. * Configures an agent
  64773. */
  64774. export interface IAgentParameters {
  64775. /**
  64776. * Agent radius. [Limit: >= 0]
  64777. */
  64778. radius: number;
  64779. /**
  64780. * Agent height. [Limit: > 0]
  64781. */
  64782. height: number;
  64783. /**
  64784. * Maximum allowed acceleration. [Limit: >= 0]
  64785. */
  64786. maxAcceleration: number;
  64787. /**
  64788. * Maximum allowed speed. [Limit: >= 0]
  64789. */
  64790. maxSpeed: number;
  64791. /**
  64792. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  64793. */
  64794. collisionQueryRange: number;
  64795. /**
  64796. * The path visibility optimization range. [Limit: > 0]
  64797. */
  64798. pathOptimizationRange: number;
  64799. /**
  64800. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  64801. */
  64802. separationWeight: number;
  64803. }
  64804. /**
  64805. * Configures the navigation mesh creation
  64806. */
  64807. export interface INavMeshParameters {
  64808. /**
  64809. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  64810. */
  64811. cs: number;
  64812. /**
  64813. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  64814. */
  64815. ch: number;
  64816. /**
  64817. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  64818. */
  64819. walkableSlopeAngle: number;
  64820. /**
  64821. * Minimum floor to 'ceiling' height that will still allow the floor area to
  64822. * be considered walkable. [Limit: >= 3] [Units: vx]
  64823. */
  64824. walkableHeight: number;
  64825. /**
  64826. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  64827. */
  64828. walkableClimb: number;
  64829. /**
  64830. * The distance to erode/shrink the walkable area of the heightfield away from
  64831. * obstructions. [Limit: >=0] [Units: vx]
  64832. */
  64833. walkableRadius: number;
  64834. /**
  64835. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  64836. */
  64837. maxEdgeLen: number;
  64838. /**
  64839. * The maximum distance a simplfied contour's border edges should deviate
  64840. * the original raw contour. [Limit: >=0] [Units: vx]
  64841. */
  64842. maxSimplificationError: number;
  64843. /**
  64844. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  64845. */
  64846. minRegionArea: number;
  64847. /**
  64848. * Any regions with a span count smaller than this value will, if possible,
  64849. * be merged with larger regions. [Limit: >=0] [Units: vx]
  64850. */
  64851. mergeRegionArea: number;
  64852. /**
  64853. * The maximum number of vertices allowed for polygons generated during the
  64854. * contour to polygon conversion process. [Limit: >= 3]
  64855. */
  64856. maxVertsPerPoly: number;
  64857. /**
  64858. * Sets the sampling distance to use when generating the detail mesh.
  64859. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  64860. */
  64861. detailSampleDist: number;
  64862. /**
  64863. * The maximum distance the detail mesh surface should deviate from heightfield
  64864. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  64865. */
  64866. detailSampleMaxError: number;
  64867. }
  64868. }
  64869. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  64870. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  64871. import { Mesh } from "babylonjs/Meshes/mesh";
  64872. import { Scene } from "babylonjs/scene";
  64873. import { Vector3 } from "babylonjs/Maths/math";
  64874. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64875. /**
  64876. * RecastJS navigation plugin
  64877. */
  64878. export class RecastJSPlugin implements INavigationEnginePlugin {
  64879. /**
  64880. * Reference to the Recast library
  64881. */
  64882. bjsRECAST: any;
  64883. /**
  64884. * plugin name
  64885. */
  64886. name: string;
  64887. /**
  64888. * the first navmesh created. We might extend this to support multiple navmeshes
  64889. */
  64890. navMesh: any;
  64891. /**
  64892. * Initializes the recastJS plugin
  64893. * @param recastInjection can be used to inject your own recast reference
  64894. */
  64895. constructor(recastInjection?: any);
  64896. /**
  64897. * Creates a navigation mesh
  64898. * @param meshes array of all the geometry used to compute the navigatio mesh
  64899. * @param parameters bunch of parameters used to filter geometry
  64900. */
  64901. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  64902. /**
  64903. * Create a navigation mesh debug mesh
  64904. * @param scene is where the mesh will be added
  64905. * @returns debug display mesh
  64906. */
  64907. createDebugNavMesh(scene: Scene): Mesh;
  64908. /**
  64909. * Get a navigation mesh constrained position, closest to the parameter position
  64910. * @param position world position
  64911. * @returns the closest point to position constrained by the navigation mesh
  64912. */
  64913. getClosestPoint(position: Vector3): Vector3;
  64914. /**
  64915. * Get a navigation mesh constrained position, within a particular radius
  64916. * @param position world position
  64917. * @param maxRadius the maximum distance to the constrained world position
  64918. * @returns the closest point to position constrained by the navigation mesh
  64919. */
  64920. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  64921. /**
  64922. * Compute the final position from a segment made of destination-position
  64923. * @param position world position
  64924. * @param destination world position
  64925. * @returns the resulting point along the navmesh
  64926. */
  64927. moveAlong(position: Vector3, destination: Vector3): Vector3;
  64928. /**
  64929. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  64930. * @param start world position
  64931. * @param end world position
  64932. * @returns array containing world position composing the path
  64933. */
  64934. computePath(start: Vector3, end: Vector3): Vector3[];
  64935. /**
  64936. * Create a new Crowd so you can add agents
  64937. * @param maxAgents the maximum agent count in the crowd
  64938. * @param maxAgentRadius the maximum radius an agent can have
  64939. * @param scene to attach the crowd to
  64940. * @returns the crowd you can add agents to
  64941. */
  64942. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  64943. /**
  64944. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64945. * The queries will try to find a solution within those bounds
  64946. * default is (1,1,1)
  64947. * @param extent x,y,z value that define the extent around the queries point of reference
  64948. */
  64949. setDefaultQueryExtent(extent: Vector3): void;
  64950. /**
  64951. * Get the Bounding box extent specified by setDefaultQueryExtent
  64952. * @returns the box extent values
  64953. */
  64954. getDefaultQueryExtent(): Vector3;
  64955. /**
  64956. * Disposes
  64957. */
  64958. dispose(): void;
  64959. /**
  64960. * If this plugin is supported
  64961. * @returns true if plugin is supported
  64962. */
  64963. isSupported(): boolean;
  64964. }
  64965. /**
  64966. * Recast detour crowd implementation
  64967. */
  64968. export class RecastJSCrowd implements ICrowd {
  64969. /**
  64970. * Recast/detour plugin
  64971. */
  64972. bjsRECASTPlugin: RecastJSPlugin;
  64973. /**
  64974. * Link to the detour crowd
  64975. */
  64976. recastCrowd: any;
  64977. /**
  64978. * One transform per agent
  64979. */
  64980. transforms: TransformNode[];
  64981. /**
  64982. * All agents created
  64983. */
  64984. agents: number[];
  64985. /**
  64986. * Link to the scene is kept to unregister the crowd from the scene
  64987. */
  64988. private _scene;
  64989. /**
  64990. * Observer for crowd updates
  64991. */
  64992. private _onBeforeAnimationsObserver;
  64993. /**
  64994. * Constructor
  64995. * @param plugin recastJS plugin
  64996. * @param maxAgents the maximum agent count in the crowd
  64997. * @param maxAgentRadius the maximum radius an agent can have
  64998. * @param scene to attach the crowd to
  64999. * @returns the crowd you can add agents to
  65000. */
  65001. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65002. /**
  65003. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65004. * You can attach anything to that node. The node position is updated in the scene update tick.
  65005. * @param pos world position that will be constrained by the navigation mesh
  65006. * @param parameters agent parameters
  65007. * @param transform hooked to the agent that will be update by the scene
  65008. * @returns agent index
  65009. */
  65010. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65011. /**
  65012. * Returns the agent position in world space
  65013. * @param index agent index returned by addAgent
  65014. * @returns world space position
  65015. */
  65016. getAgentPosition(index: number): Vector3;
  65017. /**
  65018. * Returns the agent velocity in world space
  65019. * @param index agent index returned by addAgent
  65020. * @returns world space velocity
  65021. */
  65022. getAgentVelocity(index: number): Vector3;
  65023. /**
  65024. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65025. * @param index agent index returned by addAgent
  65026. * @param destination targeted world position
  65027. */
  65028. agentGoto(index: number, destination: Vector3): void;
  65029. /**
  65030. * Teleport the agent to a new position
  65031. * @param index agent index returned by addAgent
  65032. * @param destination targeted world position
  65033. */
  65034. agentTeleport(index: number, destination: Vector3): void;
  65035. /**
  65036. * Update agent parameters
  65037. * @param index agent index returned by addAgent
  65038. * @param parameters agent parameters
  65039. */
  65040. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65041. /**
  65042. * remove a particular agent previously created
  65043. * @param index agent index returned by addAgent
  65044. */
  65045. removeAgent(index: number): void;
  65046. /**
  65047. * get the list of all agents attached to this crowd
  65048. * @returns list of agent indices
  65049. */
  65050. getAgents(): number[];
  65051. /**
  65052. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65053. * @param deltaTime in seconds
  65054. */
  65055. update(deltaTime: number): void;
  65056. /**
  65057. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65058. * The queries will try to find a solution within those bounds
  65059. * default is (1,1,1)
  65060. * @param extent x,y,z value that define the extent around the queries point of reference
  65061. */
  65062. setDefaultQueryExtent(extent: Vector3): void;
  65063. /**
  65064. * Get the Bounding box extent specified by setDefaultQueryExtent
  65065. * @returns the box extent values
  65066. */
  65067. getDefaultQueryExtent(): Vector3;
  65068. /**
  65069. * Release all resources
  65070. */
  65071. dispose(): void;
  65072. }
  65073. }
  65074. declare module "babylonjs/Navigation/Plugins/index" {
  65075. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  65076. }
  65077. declare module "babylonjs/Navigation/index" {
  65078. export * from "babylonjs/Navigation/INavigationEngine";
  65079. export * from "babylonjs/Navigation/Plugins/index";
  65080. }
  65081. declare module "babylonjs/Offline/database" {
  65082. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  65083. /**
  65084. * Class used to enable access to IndexedDB
  65085. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65086. */
  65087. export class Database implements IOfflineProvider {
  65088. private _callbackManifestChecked;
  65089. private _currentSceneUrl;
  65090. private _db;
  65091. private _enableSceneOffline;
  65092. private _enableTexturesOffline;
  65093. private _manifestVersionFound;
  65094. private _mustUpdateRessources;
  65095. private _hasReachedQuota;
  65096. private _isSupported;
  65097. private _idbFactory;
  65098. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65099. private static IsUASupportingBlobStorage;
  65100. /**
  65101. * Gets a boolean indicating if Database storate is enabled (off by default)
  65102. */
  65103. static IDBStorageEnabled: boolean;
  65104. /**
  65105. * Gets a boolean indicating if scene must be saved in the database
  65106. */
  65107. get enableSceneOffline(): boolean;
  65108. /**
  65109. * Gets a boolean indicating if textures must be saved in the database
  65110. */
  65111. get enableTexturesOffline(): boolean;
  65112. /**
  65113. * Creates a new Database
  65114. * @param urlToScene defines the url to load the scene
  65115. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65116. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65117. */
  65118. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65119. private static _ParseURL;
  65120. private static _ReturnFullUrlLocation;
  65121. private _checkManifestFile;
  65122. /**
  65123. * Open the database and make it available
  65124. * @param successCallback defines the callback to call on success
  65125. * @param errorCallback defines the callback to call on error
  65126. */
  65127. open(successCallback: () => void, errorCallback: () => void): void;
  65128. /**
  65129. * Loads an image from the database
  65130. * @param url defines the url to load from
  65131. * @param image defines the target DOM image
  65132. */
  65133. loadImage(url: string, image: HTMLImageElement): void;
  65134. private _loadImageFromDBAsync;
  65135. private _saveImageIntoDBAsync;
  65136. private _checkVersionFromDB;
  65137. private _loadVersionFromDBAsync;
  65138. private _saveVersionIntoDBAsync;
  65139. /**
  65140. * Loads a file from database
  65141. * @param url defines the URL to load from
  65142. * @param sceneLoaded defines a callback to call on success
  65143. * @param progressCallBack defines a callback to call when progress changed
  65144. * @param errorCallback defines a callback to call on error
  65145. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65146. */
  65147. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65148. private _loadFileAsync;
  65149. private _saveFileAsync;
  65150. /**
  65151. * Validates if xhr data is correct
  65152. * @param xhr defines the request to validate
  65153. * @param dataType defines the expected data type
  65154. * @returns true if data is correct
  65155. */
  65156. private static _ValidateXHRData;
  65157. }
  65158. }
  65159. declare module "babylonjs/Offline/index" {
  65160. export * from "babylonjs/Offline/database";
  65161. export * from "babylonjs/Offline/IOfflineProvider";
  65162. }
  65163. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  65164. /** @hidden */
  65165. export var gpuUpdateParticlesPixelShader: {
  65166. name: string;
  65167. shader: string;
  65168. };
  65169. }
  65170. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  65171. /** @hidden */
  65172. export var gpuUpdateParticlesVertexShader: {
  65173. name: string;
  65174. shader: string;
  65175. };
  65176. }
  65177. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  65178. /** @hidden */
  65179. export var clipPlaneFragmentDeclaration2: {
  65180. name: string;
  65181. shader: string;
  65182. };
  65183. }
  65184. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  65185. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  65186. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65187. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65188. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65189. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  65190. /** @hidden */
  65191. export var gpuRenderParticlesPixelShader: {
  65192. name: string;
  65193. shader: string;
  65194. };
  65195. }
  65196. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  65197. /** @hidden */
  65198. export var clipPlaneVertexDeclaration2: {
  65199. name: string;
  65200. shader: string;
  65201. };
  65202. }
  65203. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  65204. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  65205. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  65206. /** @hidden */
  65207. export var gpuRenderParticlesVertexShader: {
  65208. name: string;
  65209. shader: string;
  65210. };
  65211. }
  65212. declare module "babylonjs/Particles/gpuParticleSystem" {
  65213. import { Nullable } from "babylonjs/types";
  65214. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  65215. import { Observable } from "babylonjs/Misc/observable";
  65216. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  65217. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65218. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  65219. import { Scene, IDisposable } from "babylonjs/scene";
  65220. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  65221. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65222. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  65223. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  65224. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  65225. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  65226. /**
  65227. * This represents a GPU particle system in Babylon
  65228. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65229. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65230. */
  65231. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65232. /**
  65233. * The layer mask we are rendering the particles through.
  65234. */
  65235. layerMask: number;
  65236. private _capacity;
  65237. private _activeCount;
  65238. private _currentActiveCount;
  65239. private _accumulatedCount;
  65240. private _renderEffect;
  65241. private _updateEffect;
  65242. private _buffer0;
  65243. private _buffer1;
  65244. private _spriteBuffer;
  65245. private _updateVAO;
  65246. private _renderVAO;
  65247. private _targetIndex;
  65248. private _sourceBuffer;
  65249. private _targetBuffer;
  65250. private _engine;
  65251. private _currentRenderId;
  65252. private _started;
  65253. private _stopped;
  65254. private _timeDelta;
  65255. private _randomTexture;
  65256. private _randomTexture2;
  65257. private _attributesStrideSize;
  65258. private _updateEffectOptions;
  65259. private _randomTextureSize;
  65260. private _actualFrame;
  65261. private readonly _rawTextureWidth;
  65262. /**
  65263. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65264. */
  65265. static get IsSupported(): boolean;
  65266. /**
  65267. * An event triggered when the system is disposed.
  65268. */
  65269. onDisposeObservable: Observable<GPUParticleSystem>;
  65270. /**
  65271. * Gets the maximum number of particles active at the same time.
  65272. * @returns The max number of active particles.
  65273. */
  65274. getCapacity(): number;
  65275. /**
  65276. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65277. * to override the particles.
  65278. */
  65279. forceDepthWrite: boolean;
  65280. /**
  65281. * Gets or set the number of active particles
  65282. */
  65283. get activeParticleCount(): number;
  65284. set activeParticleCount(value: number);
  65285. private _preWarmDone;
  65286. /**
  65287. * Is this system ready to be used/rendered
  65288. * @return true if the system is ready
  65289. */
  65290. isReady(): boolean;
  65291. /**
  65292. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65293. * @returns True if it has been started, otherwise false.
  65294. */
  65295. isStarted(): boolean;
  65296. /**
  65297. * Starts the particle system and begins to emit
  65298. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65299. */
  65300. start(delay?: number): void;
  65301. /**
  65302. * Stops the particle system.
  65303. */
  65304. stop(): void;
  65305. /**
  65306. * Remove all active particles
  65307. */
  65308. reset(): void;
  65309. /**
  65310. * Returns the string "GPUParticleSystem"
  65311. * @returns a string containing the class name
  65312. */
  65313. getClassName(): string;
  65314. private _colorGradientsTexture;
  65315. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65316. /**
  65317. * Adds a new color gradient
  65318. * @param gradient defines the gradient to use (between 0 and 1)
  65319. * @param color1 defines the color to affect to the specified gradient
  65320. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65321. * @returns the current particle system
  65322. */
  65323. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65324. /**
  65325. * Remove a specific color gradient
  65326. * @param gradient defines the gradient to remove
  65327. * @returns the current particle system
  65328. */
  65329. removeColorGradient(gradient: number): GPUParticleSystem;
  65330. private _angularSpeedGradientsTexture;
  65331. private _sizeGradientsTexture;
  65332. private _velocityGradientsTexture;
  65333. private _limitVelocityGradientsTexture;
  65334. private _dragGradientsTexture;
  65335. private _addFactorGradient;
  65336. /**
  65337. * Adds a new size gradient
  65338. * @param gradient defines the gradient to use (between 0 and 1)
  65339. * @param factor defines the size factor to affect to the specified gradient
  65340. * @returns the current particle system
  65341. */
  65342. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65343. /**
  65344. * Remove a specific size gradient
  65345. * @param gradient defines the gradient to remove
  65346. * @returns the current particle system
  65347. */
  65348. removeSizeGradient(gradient: number): GPUParticleSystem;
  65349. /**
  65350. * Adds a new angular speed gradient
  65351. * @param gradient defines the gradient to use (between 0 and 1)
  65352. * @param factor defines the angular speed to affect to the specified gradient
  65353. * @returns the current particle system
  65354. */
  65355. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65356. /**
  65357. * Remove a specific angular speed gradient
  65358. * @param gradient defines the gradient to remove
  65359. * @returns the current particle system
  65360. */
  65361. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  65362. /**
  65363. * Adds a new velocity gradient
  65364. * @param gradient defines the gradient to use (between 0 and 1)
  65365. * @param factor defines the velocity to affect to the specified gradient
  65366. * @returns the current particle system
  65367. */
  65368. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65369. /**
  65370. * Remove a specific velocity gradient
  65371. * @param gradient defines the gradient to remove
  65372. * @returns the current particle system
  65373. */
  65374. removeVelocityGradient(gradient: number): GPUParticleSystem;
  65375. /**
  65376. * Adds a new limit velocity gradient
  65377. * @param gradient defines the gradient to use (between 0 and 1)
  65378. * @param factor defines the limit velocity value to affect to the specified gradient
  65379. * @returns the current particle system
  65380. */
  65381. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65382. /**
  65383. * Remove a specific limit velocity gradient
  65384. * @param gradient defines the gradient to remove
  65385. * @returns the current particle system
  65386. */
  65387. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  65388. /**
  65389. * Adds a new drag gradient
  65390. * @param gradient defines the gradient to use (between 0 and 1)
  65391. * @param factor defines the drag value to affect to the specified gradient
  65392. * @returns the current particle system
  65393. */
  65394. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  65395. /**
  65396. * Remove a specific drag gradient
  65397. * @param gradient defines the gradient to remove
  65398. * @returns the current particle system
  65399. */
  65400. removeDragGradient(gradient: number): GPUParticleSystem;
  65401. /**
  65402. * Not supported by GPUParticleSystem
  65403. * @param gradient defines the gradient to use (between 0 and 1)
  65404. * @param factor defines the emit rate value to affect to the specified gradient
  65405. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65406. * @returns the current particle system
  65407. */
  65408. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65409. /**
  65410. * Not supported by GPUParticleSystem
  65411. * @param gradient defines the gradient to remove
  65412. * @returns the current particle system
  65413. */
  65414. removeEmitRateGradient(gradient: number): IParticleSystem;
  65415. /**
  65416. * Not supported by GPUParticleSystem
  65417. * @param gradient defines the gradient to use (between 0 and 1)
  65418. * @param factor defines the start size value to affect to the specified gradient
  65419. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65420. * @returns the current particle system
  65421. */
  65422. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65423. /**
  65424. * Not supported by GPUParticleSystem
  65425. * @param gradient defines the gradient to remove
  65426. * @returns the current particle system
  65427. */
  65428. removeStartSizeGradient(gradient: number): IParticleSystem;
  65429. /**
  65430. * Not supported by GPUParticleSystem
  65431. * @param gradient defines the gradient to use (between 0 and 1)
  65432. * @param min defines the color remap minimal range
  65433. * @param max defines the color remap maximal range
  65434. * @returns the current particle system
  65435. */
  65436. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65437. /**
  65438. * Not supported by GPUParticleSystem
  65439. * @param gradient defines the gradient to remove
  65440. * @returns the current particle system
  65441. */
  65442. removeColorRemapGradient(): IParticleSystem;
  65443. /**
  65444. * Not supported by GPUParticleSystem
  65445. * @param gradient defines the gradient to use (between 0 and 1)
  65446. * @param min defines the alpha remap minimal range
  65447. * @param max defines the alpha remap maximal range
  65448. * @returns the current particle system
  65449. */
  65450. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65451. /**
  65452. * Not supported by GPUParticleSystem
  65453. * @param gradient defines the gradient to remove
  65454. * @returns the current particle system
  65455. */
  65456. removeAlphaRemapGradient(): IParticleSystem;
  65457. /**
  65458. * Not supported by GPUParticleSystem
  65459. * @param gradient defines the gradient to use (between 0 and 1)
  65460. * @param color defines the color to affect to the specified gradient
  65461. * @returns the current particle system
  65462. */
  65463. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  65464. /**
  65465. * Not supported by GPUParticleSystem
  65466. * @param gradient defines the gradient to remove
  65467. * @returns the current particle system
  65468. */
  65469. removeRampGradient(): IParticleSystem;
  65470. /**
  65471. * Not supported by GPUParticleSystem
  65472. * @returns the list of ramp gradients
  65473. */
  65474. getRampGradients(): Nullable<Array<Color3Gradient>>;
  65475. /**
  65476. * Not supported by GPUParticleSystem
  65477. * Gets or sets a boolean indicating that ramp gradients must be used
  65478. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  65479. */
  65480. get useRampGradients(): boolean;
  65481. set useRampGradients(value: boolean);
  65482. /**
  65483. * Not supported by GPUParticleSystem
  65484. * @param gradient defines the gradient to use (between 0 and 1)
  65485. * @param factor defines the life time factor to affect to the specified gradient
  65486. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65487. * @returns the current particle system
  65488. */
  65489. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65490. /**
  65491. * Not supported by GPUParticleSystem
  65492. * @param gradient defines the gradient to remove
  65493. * @returns the current particle system
  65494. */
  65495. removeLifeTimeGradient(gradient: number): IParticleSystem;
  65496. /**
  65497. * Instantiates a GPU particle system.
  65498. * 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.
  65499. * @param name The name of the particle system
  65500. * @param options The options used to create the system
  65501. * @param scene The scene the particle system belongs to
  65502. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  65503. */
  65504. constructor(name: string, options: Partial<{
  65505. capacity: number;
  65506. randomTextureSize: number;
  65507. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  65508. protected _reset(): void;
  65509. private _createUpdateVAO;
  65510. private _createRenderVAO;
  65511. private _initialize;
  65512. /** @hidden */
  65513. _recreateUpdateEffect(): void;
  65514. /** @hidden */
  65515. _recreateRenderEffect(): void;
  65516. /**
  65517. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  65518. * @param preWarm defines if we are in the pre-warmimg phase
  65519. */
  65520. animate(preWarm?: boolean): void;
  65521. private _createFactorGradientTexture;
  65522. private _createSizeGradientTexture;
  65523. private _createAngularSpeedGradientTexture;
  65524. private _createVelocityGradientTexture;
  65525. private _createLimitVelocityGradientTexture;
  65526. private _createDragGradientTexture;
  65527. private _createColorGradientTexture;
  65528. /**
  65529. * Renders the particle system in its current state
  65530. * @param preWarm defines if the system should only update the particles but not render them
  65531. * @returns the current number of particles
  65532. */
  65533. render(preWarm?: boolean): number;
  65534. /**
  65535. * Rebuilds the particle system
  65536. */
  65537. rebuild(): void;
  65538. private _releaseBuffers;
  65539. private _releaseVAOs;
  65540. /**
  65541. * Disposes the particle system and free the associated resources
  65542. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  65543. */
  65544. dispose(disposeTexture?: boolean): void;
  65545. /**
  65546. * Clones the particle system.
  65547. * @param name The name of the cloned object
  65548. * @param newEmitter The new emitter to use
  65549. * @returns the cloned particle system
  65550. */
  65551. clone(name: string, newEmitter: any): GPUParticleSystem;
  65552. /**
  65553. * Serializes the particle system to a JSON object.
  65554. * @returns the JSON object
  65555. */
  65556. serialize(): any;
  65557. /**
  65558. * Parses a JSON object to create a GPU particle system.
  65559. * @param parsedParticleSystem The JSON object to parse
  65560. * @param scene The scene to create the particle system in
  65561. * @param rootUrl The root url to use to load external dependencies like texture
  65562. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  65563. * @returns the parsed GPU particle system
  65564. */
  65565. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  65566. }
  65567. }
  65568. declare module "babylonjs/Particles/particleSystemSet" {
  65569. import { Nullable } from "babylonjs/types";
  65570. import { Color3 } from "babylonjs/Maths/math.color";
  65571. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65572. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65573. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65574. import { Scene, IDisposable } from "babylonjs/scene";
  65575. /**
  65576. * Represents a set of particle systems working together to create a specific effect
  65577. */
  65578. export class ParticleSystemSet implements IDisposable {
  65579. /**
  65580. * Gets or sets base Assets URL
  65581. */
  65582. static BaseAssetsUrl: string;
  65583. private _emitterCreationOptions;
  65584. private _emitterNode;
  65585. /**
  65586. * Gets the particle system list
  65587. */
  65588. systems: IParticleSystem[];
  65589. /**
  65590. * Gets the emitter node used with this set
  65591. */
  65592. get emitterNode(): Nullable<TransformNode>;
  65593. /**
  65594. * Creates a new emitter mesh as a sphere
  65595. * @param options defines the options used to create the sphere
  65596. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  65597. * @param scene defines the hosting scene
  65598. */
  65599. setEmitterAsSphere(options: {
  65600. diameter: number;
  65601. segments: number;
  65602. color: Color3;
  65603. }, renderingGroupId: number, scene: Scene): void;
  65604. /**
  65605. * Starts all particle systems of the set
  65606. * @param emitter defines an optional mesh to use as emitter for the particle systems
  65607. */
  65608. start(emitter?: AbstractMesh): void;
  65609. /**
  65610. * Release all associated resources
  65611. */
  65612. dispose(): void;
  65613. /**
  65614. * Serialize the set into a JSON compatible object
  65615. * @returns a JSON compatible representation of the set
  65616. */
  65617. serialize(): any;
  65618. /**
  65619. * Parse a new ParticleSystemSet from a serialized source
  65620. * @param data defines a JSON compatible representation of the set
  65621. * @param scene defines the hosting scene
  65622. * @param gpu defines if we want GPU particles or CPU particles
  65623. * @returns a new ParticleSystemSet
  65624. */
  65625. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  65626. }
  65627. }
  65628. declare module "babylonjs/Particles/particleHelper" {
  65629. import { Nullable } from "babylonjs/types";
  65630. import { Scene } from "babylonjs/scene";
  65631. import { Vector3 } from "babylonjs/Maths/math.vector";
  65632. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65633. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65634. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  65635. /**
  65636. * This class is made for on one-liner static method to help creating particle system set.
  65637. */
  65638. export class ParticleHelper {
  65639. /**
  65640. * Gets or sets base Assets URL
  65641. */
  65642. static BaseAssetsUrl: string;
  65643. /**
  65644. * Create a default particle system that you can tweak
  65645. * @param emitter defines the emitter to use
  65646. * @param capacity defines the system capacity (default is 500 particles)
  65647. * @param scene defines the hosting scene
  65648. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  65649. * @returns the new Particle system
  65650. */
  65651. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  65652. /**
  65653. * This is the main static method (one-liner) of this helper to create different particle systems
  65654. * @param type This string represents the type to the particle system to create
  65655. * @param scene The scene where the particle system should live
  65656. * @param gpu If the system will use gpu
  65657. * @returns the ParticleSystemSet created
  65658. */
  65659. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  65660. /**
  65661. * Static function used to export a particle system to a ParticleSystemSet variable.
  65662. * Please note that the emitter shape is not exported
  65663. * @param systems defines the particle systems to export
  65664. * @returns the created particle system set
  65665. */
  65666. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  65667. }
  65668. }
  65669. declare module "babylonjs/Particles/particleSystemComponent" {
  65670. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65671. import { Effect } from "babylonjs/Materials/effect";
  65672. import "babylonjs/Shaders/particles.vertex";
  65673. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  65674. module "babylonjs/Engines/engine" {
  65675. interface Engine {
  65676. /**
  65677. * Create an effect to use with particle systems.
  65678. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  65679. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  65680. * @param uniformsNames defines a list of attribute names
  65681. * @param samplers defines an array of string used to represent textures
  65682. * @param defines defines the string containing the defines to use to compile the shaders
  65683. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  65684. * @param onCompiled defines a function to call when the effect creation is successful
  65685. * @param onError defines a function to call when the effect creation has failed
  65686. * @returns the new Effect
  65687. */
  65688. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  65689. }
  65690. }
  65691. module "babylonjs/Meshes/mesh" {
  65692. interface Mesh {
  65693. /**
  65694. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  65695. * @returns an array of IParticleSystem
  65696. */
  65697. getEmittedParticleSystems(): IParticleSystem[];
  65698. /**
  65699. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  65700. * @returns an array of IParticleSystem
  65701. */
  65702. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  65703. }
  65704. }
  65705. /**
  65706. * @hidden
  65707. */
  65708. export var _IDoNeedToBeInTheBuild: number;
  65709. }
  65710. declare module "babylonjs/Particles/pointsCloudSystem" {
  65711. import { Color4 } from "babylonjs/Maths/math";
  65712. import { Mesh } from "babylonjs/Meshes/mesh";
  65713. import { Scene, IDisposable } from "babylonjs/scene";
  65714. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  65715. /** Defines the 4 color options */
  65716. export enum PointColor {
  65717. /** color value */
  65718. Color = 2,
  65719. /** uv value */
  65720. UV = 1,
  65721. /** random value */
  65722. Random = 0,
  65723. /** stated value */
  65724. Stated = 3
  65725. }
  65726. /**
  65727. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  65728. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  65729. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  65730. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  65731. *
  65732. * Full documentation here : TO BE ENTERED
  65733. */
  65734. export class PointsCloudSystem implements IDisposable {
  65735. /**
  65736. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  65737. * Example : var p = SPS.particles[i];
  65738. */
  65739. particles: CloudPoint[];
  65740. /**
  65741. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  65742. */
  65743. nbParticles: number;
  65744. /**
  65745. * This a counter for your own usage. It's not set by any SPS functions.
  65746. */
  65747. counter: number;
  65748. /**
  65749. * The PCS name. This name is also given to the underlying mesh.
  65750. */
  65751. name: string;
  65752. /**
  65753. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  65754. */
  65755. mesh: Mesh;
  65756. /**
  65757. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  65758. * Please read :
  65759. */
  65760. vars: any;
  65761. /**
  65762. * @hidden
  65763. */
  65764. _size: number;
  65765. private _scene;
  65766. private _promises;
  65767. private _positions;
  65768. private _indices;
  65769. private _normals;
  65770. private _colors;
  65771. private _uvs;
  65772. private _indices32;
  65773. private _positions32;
  65774. private _colors32;
  65775. private _uvs32;
  65776. private _updatable;
  65777. private _isVisibilityBoxLocked;
  65778. private _alwaysVisible;
  65779. private _groups;
  65780. private _groupCounter;
  65781. private _computeParticleColor;
  65782. private _computeParticleTexture;
  65783. private _computeParticleRotation;
  65784. private _computeBoundingBox;
  65785. private _isReady;
  65786. /**
  65787. * Creates a PCS (Points Cloud System) object
  65788. * @param name (String) is the PCS name, this will be the underlying mesh name
  65789. * @param pointSize (number) is the size for each point
  65790. * @param scene (Scene) is the scene in which the PCS is added
  65791. * @param options defines the options of the PCS e.g.
  65792. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  65793. */
  65794. constructor(name: string, pointSize: number, scene: Scene, options?: {
  65795. updatable?: boolean;
  65796. });
  65797. /**
  65798. * Builds the PCS underlying mesh. Returns a standard Mesh.
  65799. * If no points were added to the PCS, the returned mesh is just a single point.
  65800. * @returns a promise for the created mesh
  65801. */
  65802. buildMeshAsync(): Promise<Mesh>;
  65803. /**
  65804. * @hidden
  65805. */
  65806. private _buildMesh;
  65807. private _addParticle;
  65808. private _randomUnitVector;
  65809. private _getColorIndicesForCoord;
  65810. private _setPointsColorOrUV;
  65811. private _colorFromTexture;
  65812. private _calculateDensity;
  65813. /**
  65814. * Adds points to the PCS in random positions within a unit sphere
  65815. * @param nb (positive integer) the number of particles to be created from this model
  65816. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  65817. * @returns the number of groups in the system
  65818. */
  65819. addPoints(nb: number, pointFunction?: any): number;
  65820. /**
  65821. * Adds points to the PCS from the surface of the model shape
  65822. * @param mesh is any Mesh object that will be used as a surface model for the points
  65823. * @param nb (positive integer) the number of particles to be created from this model
  65824. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  65825. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  65826. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  65827. * @returns the number of groups in the system
  65828. */
  65829. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  65830. /**
  65831. * Adds points to the PCS inside the model shape
  65832. * @param mesh is any Mesh object that will be used as a surface model for the points
  65833. * @param nb (positive integer) the number of particles to be created from this model
  65834. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  65835. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  65836. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  65837. * @returns the number of groups in the system
  65838. */
  65839. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  65840. /**
  65841. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  65842. * This method calls `updateParticle()` for each particle of the SPS.
  65843. * For an animated SPS, it is usually called within the render loop.
  65844. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  65845. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  65846. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  65847. * @returns the PCS.
  65848. */
  65849. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  65850. /**
  65851. * Disposes the PCS.
  65852. */
  65853. dispose(): void;
  65854. /**
  65855. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  65856. * doc :
  65857. * @returns the PCS.
  65858. */
  65859. refreshVisibleSize(): PointsCloudSystem;
  65860. /**
  65861. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  65862. * @param size the size (float) of the visibility box
  65863. * note : this doesn't lock the PCS mesh bounding box.
  65864. * doc :
  65865. */
  65866. setVisibilityBox(size: number): void;
  65867. /**
  65868. * Gets whether the PCS is always visible or not
  65869. * doc :
  65870. */
  65871. get isAlwaysVisible(): boolean;
  65872. /**
  65873. * Sets the PCS as always visible or not
  65874. * doc :
  65875. */
  65876. set isAlwaysVisible(val: boolean);
  65877. /**
  65878. * Tells to `setParticles()` to compute the particle rotations or not
  65879. * Default value : false. The PCS is faster when it's set to false
  65880. * Note : particle rotations are only applied to parent particles
  65881. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  65882. */
  65883. set computeParticleRotation(val: boolean);
  65884. /**
  65885. * Tells to `setParticles()` to compute the particle colors or not.
  65886. * Default value : true. The PCS is faster when it's set to false.
  65887. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  65888. */
  65889. set computeParticleColor(val: boolean);
  65890. set computeParticleTexture(val: boolean);
  65891. /**
  65892. * Gets if `setParticles()` computes the particle colors or not.
  65893. * Default value : false. The PCS is faster when it's set to false.
  65894. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  65895. */
  65896. get computeParticleColor(): boolean;
  65897. /**
  65898. * Gets if `setParticles()` computes the particle textures or not.
  65899. * Default value : false. The PCS is faster when it's set to false.
  65900. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  65901. */
  65902. get computeParticleTexture(): boolean;
  65903. /**
  65904. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  65905. */
  65906. set computeBoundingBox(val: boolean);
  65907. /**
  65908. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  65909. */
  65910. get computeBoundingBox(): boolean;
  65911. /**
  65912. * This function does nothing. It may be overwritten to set all the particle first values.
  65913. * The PCS doesn't call this function, you may have to call it by your own.
  65914. * doc :
  65915. */
  65916. initParticles(): void;
  65917. /**
  65918. * This function does nothing. It may be overwritten to recycle a particle
  65919. * The PCS doesn't call this function, you can to call it
  65920. * doc :
  65921. * @param particle The particle to recycle
  65922. * @returns the recycled particle
  65923. */
  65924. recycleParticle(particle: CloudPoint): CloudPoint;
  65925. /**
  65926. * Updates a particle : this function should be overwritten by the user.
  65927. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  65928. * doc :
  65929. * @example : just set a particle position or velocity and recycle conditions
  65930. * @param particle The particle to update
  65931. * @returns the updated particle
  65932. */
  65933. updateParticle(particle: CloudPoint): CloudPoint;
  65934. /**
  65935. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  65936. * This does nothing and may be overwritten by the user.
  65937. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  65938. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  65939. * @param update the boolean update value actually passed to setParticles()
  65940. */
  65941. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  65942. /**
  65943. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  65944. * This will be passed three parameters.
  65945. * This does nothing and may be overwritten by the user.
  65946. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  65947. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  65948. * @param update the boolean update value actually passed to setParticles()
  65949. */
  65950. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  65951. }
  65952. }
  65953. declare module "babylonjs/Particles/cloudPoint" {
  65954. import { Nullable } from "babylonjs/types";
  65955. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  65956. import { Mesh } from "babylonjs/Meshes/mesh";
  65957. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  65958. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  65959. /**
  65960. * Represents one particle of a points cloud system.
  65961. */
  65962. export class CloudPoint {
  65963. /**
  65964. * particle global index
  65965. */
  65966. idx: number;
  65967. /**
  65968. * The color of the particle
  65969. */
  65970. color: Nullable<Color4>;
  65971. /**
  65972. * The world space position of the particle.
  65973. */
  65974. position: Vector3;
  65975. /**
  65976. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  65977. */
  65978. rotation: Vector3;
  65979. /**
  65980. * The world space rotation quaternion of the particle.
  65981. */
  65982. rotationQuaternion: Nullable<Quaternion>;
  65983. /**
  65984. * The uv of the particle.
  65985. */
  65986. uv: Nullable<Vector2>;
  65987. /**
  65988. * The current speed of the particle.
  65989. */
  65990. velocity: Vector3;
  65991. /**
  65992. * The pivot point in the particle local space.
  65993. */
  65994. pivot: Vector3;
  65995. /**
  65996. * Must the particle be translated from its pivot point in its local space ?
  65997. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  65998. * Default : false
  65999. */
  66000. translateFromPivot: boolean;
  66001. /**
  66002. * Index of this particle in the global "positions" array (Internal use)
  66003. * @hidden
  66004. */
  66005. _pos: number;
  66006. /**
  66007. * @hidden Index of this particle in the global "indices" array (Internal use)
  66008. */
  66009. _ind: number;
  66010. /**
  66011. * Group this particle belongs to
  66012. */
  66013. _group: PointsGroup;
  66014. /**
  66015. * Group id of this particle
  66016. */
  66017. groupId: number;
  66018. /**
  66019. * Index of the particle in its group id (Internal use)
  66020. */
  66021. idxInGroup: number;
  66022. /**
  66023. * @hidden Particle BoundingInfo object (Internal use)
  66024. */
  66025. _boundingInfo: BoundingInfo;
  66026. /**
  66027. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66028. */
  66029. _pcs: PointsCloudSystem;
  66030. /**
  66031. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66032. */
  66033. _stillInvisible: boolean;
  66034. /**
  66035. * @hidden Last computed particle rotation matrix
  66036. */
  66037. _rotationMatrix: number[];
  66038. /**
  66039. * Parent particle Id, if any.
  66040. * Default null.
  66041. */
  66042. parentId: Nullable<number>;
  66043. /**
  66044. * @hidden Internal global position in the PCS.
  66045. */
  66046. _globalPosition: Vector3;
  66047. /**
  66048. * Creates a Point Cloud object.
  66049. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66050. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66051. * @param group (PointsGroup) is the group the particle belongs to
  66052. * @param groupId (integer) is the group identifier in the PCS.
  66053. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66054. * @param pcs defines the PCS it is associated to
  66055. */
  66056. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66057. /**
  66058. * get point size
  66059. */
  66060. get size(): Vector3;
  66061. /**
  66062. * Set point size
  66063. */
  66064. set size(scale: Vector3);
  66065. /**
  66066. * Legacy support, changed quaternion to rotationQuaternion
  66067. */
  66068. get quaternion(): Nullable<Quaternion>;
  66069. /**
  66070. * Legacy support, changed quaternion to rotationQuaternion
  66071. */
  66072. set quaternion(q: Nullable<Quaternion>);
  66073. /**
  66074. * Returns a boolean. True if the particle intersects a mesh, else false
  66075. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66076. * @param target is the object (point or mesh) what the intersection is computed against
  66077. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66078. * @returns true if it intersects
  66079. */
  66080. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66081. /**
  66082. * get the rotation matrix of the particle
  66083. * @hidden
  66084. */
  66085. getRotationMatrix(m: Matrix): void;
  66086. }
  66087. /**
  66088. * Represents a group of points in a points cloud system
  66089. * * PCS internal tool, don't use it manually.
  66090. */
  66091. export class PointsGroup {
  66092. /**
  66093. * The group id
  66094. * @hidden
  66095. */
  66096. groupID: number;
  66097. /**
  66098. * image data for group (internal use)
  66099. * @hidden
  66100. */
  66101. _groupImageData: Nullable<ArrayBufferView>;
  66102. /**
  66103. * Image Width (internal use)
  66104. * @hidden
  66105. */
  66106. _groupImgWidth: number;
  66107. /**
  66108. * Image Height (internal use)
  66109. * @hidden
  66110. */
  66111. _groupImgHeight: number;
  66112. /**
  66113. * Custom position function (internal use)
  66114. * @hidden
  66115. */
  66116. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66117. /**
  66118. * density per facet for surface points
  66119. * @hidden
  66120. */
  66121. _groupDensity: number[];
  66122. /**
  66123. * Only when points are colored by texture carries pointer to texture list array
  66124. * @hidden
  66125. */
  66126. _textureNb: number;
  66127. /**
  66128. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66129. * PCS internal tool, don't use it manually.
  66130. * @hidden
  66131. */
  66132. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66133. }
  66134. }
  66135. declare module "babylonjs/Particles/index" {
  66136. export * from "babylonjs/Particles/baseParticleSystem";
  66137. export * from "babylonjs/Particles/EmitterTypes/index";
  66138. export * from "babylonjs/Particles/gpuParticleSystem";
  66139. export * from "babylonjs/Particles/IParticleSystem";
  66140. export * from "babylonjs/Particles/particle";
  66141. export * from "babylonjs/Particles/particleHelper";
  66142. export * from "babylonjs/Particles/particleSystem";
  66143. export * from "babylonjs/Particles/particleSystemComponent";
  66144. export * from "babylonjs/Particles/particleSystemSet";
  66145. export * from "babylonjs/Particles/solidParticle";
  66146. export * from "babylonjs/Particles/solidParticleSystem";
  66147. export * from "babylonjs/Particles/cloudPoint";
  66148. export * from "babylonjs/Particles/pointsCloudSystem";
  66149. export * from "babylonjs/Particles/subEmitter";
  66150. }
  66151. declare module "babylonjs/Physics/physicsEngineComponent" {
  66152. import { Nullable } from "babylonjs/types";
  66153. import { Observable, Observer } from "babylonjs/Misc/observable";
  66154. import { Vector3 } from "babylonjs/Maths/math.vector";
  66155. import { Mesh } from "babylonjs/Meshes/mesh";
  66156. import { ISceneComponent } from "babylonjs/sceneComponent";
  66157. import { Scene } from "babylonjs/scene";
  66158. import { Node } from "babylonjs/node";
  66159. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  66160. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66161. module "babylonjs/scene" {
  66162. interface Scene {
  66163. /** @hidden (Backing field) */
  66164. _physicsEngine: Nullable<IPhysicsEngine>;
  66165. /** @hidden */
  66166. _physicsTimeAccumulator: number;
  66167. /**
  66168. * Gets the current physics engine
  66169. * @returns a IPhysicsEngine or null if none attached
  66170. */
  66171. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66172. /**
  66173. * Enables physics to the current scene
  66174. * @param gravity defines the scene's gravity for the physics engine
  66175. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66176. * @return a boolean indicating if the physics engine was initialized
  66177. */
  66178. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66179. /**
  66180. * Disables and disposes the physics engine associated with the scene
  66181. */
  66182. disablePhysicsEngine(): void;
  66183. /**
  66184. * Gets a boolean indicating if there is an active physics engine
  66185. * @returns a boolean indicating if there is an active physics engine
  66186. */
  66187. isPhysicsEnabled(): boolean;
  66188. /**
  66189. * Deletes a physics compound impostor
  66190. * @param compound defines the compound to delete
  66191. */
  66192. deleteCompoundImpostor(compound: any): void;
  66193. /**
  66194. * An event triggered when physic simulation is about to be run
  66195. */
  66196. onBeforePhysicsObservable: Observable<Scene>;
  66197. /**
  66198. * An event triggered when physic simulation has been done
  66199. */
  66200. onAfterPhysicsObservable: Observable<Scene>;
  66201. }
  66202. }
  66203. module "babylonjs/Meshes/abstractMesh" {
  66204. interface AbstractMesh {
  66205. /** @hidden */
  66206. _physicsImpostor: Nullable<PhysicsImpostor>;
  66207. /**
  66208. * Gets or sets impostor used for physic simulation
  66209. * @see http://doc.babylonjs.com/features/physics_engine
  66210. */
  66211. physicsImpostor: Nullable<PhysicsImpostor>;
  66212. /**
  66213. * Gets the current physics impostor
  66214. * @see http://doc.babylonjs.com/features/physics_engine
  66215. * @returns a physics impostor or null
  66216. */
  66217. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66218. /** Apply a physic impulse to the mesh
  66219. * @param force defines the force to apply
  66220. * @param contactPoint defines where to apply the force
  66221. * @returns the current mesh
  66222. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66223. */
  66224. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66225. /**
  66226. * Creates a physic joint between two meshes
  66227. * @param otherMesh defines the other mesh to use
  66228. * @param pivot1 defines the pivot to use on this mesh
  66229. * @param pivot2 defines the pivot to use on the other mesh
  66230. * @param options defines additional options (can be plugin dependent)
  66231. * @returns the current mesh
  66232. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66233. */
  66234. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66235. /** @hidden */
  66236. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66237. }
  66238. }
  66239. /**
  66240. * Defines the physics engine scene component responsible to manage a physics engine
  66241. */
  66242. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66243. /**
  66244. * The component name helpful to identify the component in the list of scene components.
  66245. */
  66246. readonly name: string;
  66247. /**
  66248. * The scene the component belongs to.
  66249. */
  66250. scene: Scene;
  66251. /**
  66252. * Creates a new instance of the component for the given scene
  66253. * @param scene Defines the scene to register the component in
  66254. */
  66255. constructor(scene: Scene);
  66256. /**
  66257. * Registers the component in a given scene
  66258. */
  66259. register(): void;
  66260. /**
  66261. * Rebuilds the elements related to this component in case of
  66262. * context lost for instance.
  66263. */
  66264. rebuild(): void;
  66265. /**
  66266. * Disposes the component and the associated ressources
  66267. */
  66268. dispose(): void;
  66269. }
  66270. }
  66271. declare module "babylonjs/Physics/physicsHelper" {
  66272. import { Nullable } from "babylonjs/types";
  66273. import { Vector3 } from "babylonjs/Maths/math.vector";
  66274. import { Mesh } from "babylonjs/Meshes/mesh";
  66275. import { Scene } from "babylonjs/scene";
  66276. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66277. /**
  66278. * A helper for physics simulations
  66279. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66280. */
  66281. export class PhysicsHelper {
  66282. private _scene;
  66283. private _physicsEngine;
  66284. /**
  66285. * Initializes the Physics helper
  66286. * @param scene Babylon.js scene
  66287. */
  66288. constructor(scene: Scene);
  66289. /**
  66290. * Applies a radial explosion impulse
  66291. * @param origin the origin of the explosion
  66292. * @param radiusOrEventOptions the radius or the options of radial explosion
  66293. * @param strength the explosion strength
  66294. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66295. * @returns A physics radial explosion event, or null
  66296. */
  66297. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66298. /**
  66299. * Applies a radial explosion force
  66300. * @param origin the origin of the explosion
  66301. * @param radiusOrEventOptions the radius or the options of radial explosion
  66302. * @param strength the explosion strength
  66303. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66304. * @returns A physics radial explosion event, or null
  66305. */
  66306. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66307. /**
  66308. * Creates a gravitational field
  66309. * @param origin the origin of the explosion
  66310. * @param radiusOrEventOptions the radius or the options of radial explosion
  66311. * @param strength the explosion strength
  66312. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66313. * @returns A physics gravitational field event, or null
  66314. */
  66315. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66316. /**
  66317. * Creates a physics updraft event
  66318. * @param origin the origin of the updraft
  66319. * @param radiusOrEventOptions the radius or the options of the updraft
  66320. * @param strength the strength of the updraft
  66321. * @param height the height of the updraft
  66322. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66323. * @returns A physics updraft event, or null
  66324. */
  66325. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66326. /**
  66327. * Creates a physics vortex event
  66328. * @param origin the of the vortex
  66329. * @param radiusOrEventOptions the radius or the options of the vortex
  66330. * @param strength the strength of the vortex
  66331. * @param height the height of the vortex
  66332. * @returns a Physics vortex event, or null
  66333. * A physics vortex event or null
  66334. */
  66335. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66336. }
  66337. /**
  66338. * Represents a physics radial explosion event
  66339. */
  66340. class PhysicsRadialExplosionEvent {
  66341. private _scene;
  66342. private _options;
  66343. private _sphere;
  66344. private _dataFetched;
  66345. /**
  66346. * Initializes a radial explosioin event
  66347. * @param _scene BabylonJS scene
  66348. * @param _options The options for the vortex event
  66349. */
  66350. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66351. /**
  66352. * Returns the data related to the radial explosion event (sphere).
  66353. * @returns The radial explosion event data
  66354. */
  66355. getData(): PhysicsRadialExplosionEventData;
  66356. /**
  66357. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  66358. * @param impostor A physics imposter
  66359. * @param origin the origin of the explosion
  66360. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  66361. */
  66362. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  66363. /**
  66364. * Triggers affecterd impostors callbacks
  66365. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  66366. */
  66367. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  66368. /**
  66369. * Disposes the sphere.
  66370. * @param force Specifies if the sphere should be disposed by force
  66371. */
  66372. dispose(force?: boolean): void;
  66373. /*** Helpers ***/
  66374. private _prepareSphere;
  66375. private _intersectsWithSphere;
  66376. }
  66377. /**
  66378. * Represents a gravitational field event
  66379. */
  66380. class PhysicsGravitationalFieldEvent {
  66381. private _physicsHelper;
  66382. private _scene;
  66383. private _origin;
  66384. private _options;
  66385. private _tickCallback;
  66386. private _sphere;
  66387. private _dataFetched;
  66388. /**
  66389. * Initializes the physics gravitational field event
  66390. * @param _physicsHelper A physics helper
  66391. * @param _scene BabylonJS scene
  66392. * @param _origin The origin position of the gravitational field event
  66393. * @param _options The options for the vortex event
  66394. */
  66395. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  66396. /**
  66397. * Returns the data related to the gravitational field event (sphere).
  66398. * @returns A gravitational field event
  66399. */
  66400. getData(): PhysicsGravitationalFieldEventData;
  66401. /**
  66402. * Enables the gravitational field.
  66403. */
  66404. enable(): void;
  66405. /**
  66406. * Disables the gravitational field.
  66407. */
  66408. disable(): void;
  66409. /**
  66410. * Disposes the sphere.
  66411. * @param force The force to dispose from the gravitational field event
  66412. */
  66413. dispose(force?: boolean): void;
  66414. private _tick;
  66415. }
  66416. /**
  66417. * Represents a physics updraft event
  66418. */
  66419. class PhysicsUpdraftEvent {
  66420. private _scene;
  66421. private _origin;
  66422. private _options;
  66423. private _physicsEngine;
  66424. private _originTop;
  66425. private _originDirection;
  66426. private _tickCallback;
  66427. private _cylinder;
  66428. private _cylinderPosition;
  66429. private _dataFetched;
  66430. /**
  66431. * Initializes the physics updraft event
  66432. * @param _scene BabylonJS scene
  66433. * @param _origin The origin position of the updraft
  66434. * @param _options The options for the updraft event
  66435. */
  66436. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  66437. /**
  66438. * Returns the data related to the updraft event (cylinder).
  66439. * @returns A physics updraft event
  66440. */
  66441. getData(): PhysicsUpdraftEventData;
  66442. /**
  66443. * Enables the updraft.
  66444. */
  66445. enable(): void;
  66446. /**
  66447. * Disables the updraft.
  66448. */
  66449. disable(): void;
  66450. /**
  66451. * Disposes the cylinder.
  66452. * @param force Specifies if the updraft should be disposed by force
  66453. */
  66454. dispose(force?: boolean): void;
  66455. private getImpostorHitData;
  66456. private _tick;
  66457. /*** Helpers ***/
  66458. private _prepareCylinder;
  66459. private _intersectsWithCylinder;
  66460. }
  66461. /**
  66462. * Represents a physics vortex event
  66463. */
  66464. class PhysicsVortexEvent {
  66465. private _scene;
  66466. private _origin;
  66467. private _options;
  66468. private _physicsEngine;
  66469. private _originTop;
  66470. private _tickCallback;
  66471. private _cylinder;
  66472. private _cylinderPosition;
  66473. private _dataFetched;
  66474. /**
  66475. * Initializes the physics vortex event
  66476. * @param _scene The BabylonJS scene
  66477. * @param _origin The origin position of the vortex
  66478. * @param _options The options for the vortex event
  66479. */
  66480. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  66481. /**
  66482. * Returns the data related to the vortex event (cylinder).
  66483. * @returns The physics vortex event data
  66484. */
  66485. getData(): PhysicsVortexEventData;
  66486. /**
  66487. * Enables the vortex.
  66488. */
  66489. enable(): void;
  66490. /**
  66491. * Disables the cortex.
  66492. */
  66493. disable(): void;
  66494. /**
  66495. * Disposes the sphere.
  66496. * @param force
  66497. */
  66498. dispose(force?: boolean): void;
  66499. private getImpostorHitData;
  66500. private _tick;
  66501. /*** Helpers ***/
  66502. private _prepareCylinder;
  66503. private _intersectsWithCylinder;
  66504. }
  66505. /**
  66506. * Options fot the radial explosion event
  66507. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66508. */
  66509. export class PhysicsRadialExplosionEventOptions {
  66510. /**
  66511. * The radius of the sphere for the radial explosion.
  66512. */
  66513. radius: number;
  66514. /**
  66515. * The strenth of the explosion.
  66516. */
  66517. strength: number;
  66518. /**
  66519. * The strenght of the force in correspondence to the distance of the affected object
  66520. */
  66521. falloff: PhysicsRadialImpulseFalloff;
  66522. /**
  66523. * Sphere options for the radial explosion.
  66524. */
  66525. sphere: {
  66526. segments: number;
  66527. diameter: number;
  66528. };
  66529. /**
  66530. * Sphere options for the radial explosion.
  66531. */
  66532. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  66533. }
  66534. /**
  66535. * Options fot the updraft event
  66536. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66537. */
  66538. export class PhysicsUpdraftEventOptions {
  66539. /**
  66540. * The radius of the cylinder for the vortex
  66541. */
  66542. radius: number;
  66543. /**
  66544. * The strenth of the updraft.
  66545. */
  66546. strength: number;
  66547. /**
  66548. * The height of the cylinder for the updraft.
  66549. */
  66550. height: number;
  66551. /**
  66552. * The mode for the the updraft.
  66553. */
  66554. updraftMode: PhysicsUpdraftMode;
  66555. }
  66556. /**
  66557. * Options fot the vortex event
  66558. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66559. */
  66560. export class PhysicsVortexEventOptions {
  66561. /**
  66562. * The radius of the cylinder for the vortex
  66563. */
  66564. radius: number;
  66565. /**
  66566. * The strenth of the vortex.
  66567. */
  66568. strength: number;
  66569. /**
  66570. * The height of the cylinder for the vortex.
  66571. */
  66572. height: number;
  66573. /**
  66574. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  66575. */
  66576. centripetalForceThreshold: number;
  66577. /**
  66578. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  66579. */
  66580. centripetalForceMultiplier: number;
  66581. /**
  66582. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  66583. */
  66584. centrifugalForceMultiplier: number;
  66585. /**
  66586. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  66587. */
  66588. updraftForceMultiplier: number;
  66589. }
  66590. /**
  66591. * The strenght of the force in correspondence to the distance of the affected object
  66592. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66593. */
  66594. export enum PhysicsRadialImpulseFalloff {
  66595. /** Defines that impulse is constant in strength across it's whole radius */
  66596. Constant = 0,
  66597. /** Defines that impulse gets weaker if it's further from the origin */
  66598. Linear = 1
  66599. }
  66600. /**
  66601. * The strength of the force in correspondence to the distance of the affected object
  66602. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66603. */
  66604. export enum PhysicsUpdraftMode {
  66605. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  66606. Center = 0,
  66607. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  66608. Perpendicular = 1
  66609. }
  66610. /**
  66611. * Interface for a physics hit data
  66612. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66613. */
  66614. export interface PhysicsHitData {
  66615. /**
  66616. * The force applied at the contact point
  66617. */
  66618. force: Vector3;
  66619. /**
  66620. * The contact point
  66621. */
  66622. contactPoint: Vector3;
  66623. /**
  66624. * The distance from the origin to the contact point
  66625. */
  66626. distanceFromOrigin: number;
  66627. }
  66628. /**
  66629. * Interface for radial explosion event data
  66630. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66631. */
  66632. export interface PhysicsRadialExplosionEventData {
  66633. /**
  66634. * A sphere used for the radial explosion event
  66635. */
  66636. sphere: Mesh;
  66637. }
  66638. /**
  66639. * Interface for gravitational field event data
  66640. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66641. */
  66642. export interface PhysicsGravitationalFieldEventData {
  66643. /**
  66644. * A sphere mesh used for the gravitational field event
  66645. */
  66646. sphere: Mesh;
  66647. }
  66648. /**
  66649. * Interface for updraft event data
  66650. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66651. */
  66652. export interface PhysicsUpdraftEventData {
  66653. /**
  66654. * A cylinder used for the updraft event
  66655. */
  66656. cylinder: Mesh;
  66657. }
  66658. /**
  66659. * Interface for vortex event data
  66660. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66661. */
  66662. export interface PhysicsVortexEventData {
  66663. /**
  66664. * A cylinder used for the vortex event
  66665. */
  66666. cylinder: Mesh;
  66667. }
  66668. /**
  66669. * Interface for an affected physics impostor
  66670. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66671. */
  66672. export interface PhysicsAffectedImpostorWithData {
  66673. /**
  66674. * The impostor affected by the effect
  66675. */
  66676. impostor: PhysicsImpostor;
  66677. /**
  66678. * The data about the hit/horce from the explosion
  66679. */
  66680. hitData: PhysicsHitData;
  66681. }
  66682. }
  66683. declare module "babylonjs/Physics/Plugins/index" {
  66684. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  66685. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  66686. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  66687. }
  66688. declare module "babylonjs/Physics/index" {
  66689. export * from "babylonjs/Physics/IPhysicsEngine";
  66690. export * from "babylonjs/Physics/physicsEngine";
  66691. export * from "babylonjs/Physics/physicsEngineComponent";
  66692. export * from "babylonjs/Physics/physicsHelper";
  66693. export * from "babylonjs/Physics/physicsImpostor";
  66694. export * from "babylonjs/Physics/physicsJoint";
  66695. export * from "babylonjs/Physics/Plugins/index";
  66696. }
  66697. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  66698. /** @hidden */
  66699. export var blackAndWhitePixelShader: {
  66700. name: string;
  66701. shader: string;
  66702. };
  66703. }
  66704. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  66705. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66706. import { Camera } from "babylonjs/Cameras/camera";
  66707. import { Engine } from "babylonjs/Engines/engine";
  66708. import "babylonjs/Shaders/blackAndWhite.fragment";
  66709. /**
  66710. * Post process used to render in black and white
  66711. */
  66712. export class BlackAndWhitePostProcess extends PostProcess {
  66713. /**
  66714. * Linear about to convert he result to black and white (default: 1)
  66715. */
  66716. degree: number;
  66717. /**
  66718. * Creates a black and white post process
  66719. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  66720. * @param name The name of the effect.
  66721. * @param options The required width/height ratio to downsize to before computing the render pass.
  66722. * @param camera The camera to apply the render pass to.
  66723. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66724. * @param engine The engine which the post process will be applied. (default: current engine)
  66725. * @param reusable If the post process can be reused on the same frame. (default: false)
  66726. */
  66727. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66728. }
  66729. }
  66730. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  66731. import { Nullable } from "babylonjs/types";
  66732. import { Camera } from "babylonjs/Cameras/camera";
  66733. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66734. import { Engine } from "babylonjs/Engines/engine";
  66735. /**
  66736. * This represents a set of one or more post processes in Babylon.
  66737. * A post process can be used to apply a shader to a texture after it is rendered.
  66738. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66739. */
  66740. export class PostProcessRenderEffect {
  66741. private _postProcesses;
  66742. private _getPostProcesses;
  66743. private _singleInstance;
  66744. private _cameras;
  66745. private _indicesForCamera;
  66746. /**
  66747. * Name of the effect
  66748. * @hidden
  66749. */
  66750. _name: string;
  66751. /**
  66752. * Instantiates a post process render effect.
  66753. * A post process can be used to apply a shader to a texture after it is rendered.
  66754. * @param engine The engine the effect is tied to
  66755. * @param name The name of the effect
  66756. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  66757. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  66758. */
  66759. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  66760. /**
  66761. * Checks if all the post processes in the effect are supported.
  66762. */
  66763. get isSupported(): boolean;
  66764. /**
  66765. * Updates the current state of the effect
  66766. * @hidden
  66767. */
  66768. _update(): void;
  66769. /**
  66770. * Attaches the effect on cameras
  66771. * @param cameras The camera to attach to.
  66772. * @hidden
  66773. */
  66774. _attachCameras(cameras: Camera): void;
  66775. /**
  66776. * Attaches the effect on cameras
  66777. * @param cameras The camera to attach to.
  66778. * @hidden
  66779. */
  66780. _attachCameras(cameras: Camera[]): void;
  66781. /**
  66782. * Detaches the effect on cameras
  66783. * @param cameras The camera to detatch from.
  66784. * @hidden
  66785. */
  66786. _detachCameras(cameras: Camera): void;
  66787. /**
  66788. * Detatches the effect on cameras
  66789. * @param cameras The camera to detatch from.
  66790. * @hidden
  66791. */
  66792. _detachCameras(cameras: Camera[]): void;
  66793. /**
  66794. * Enables the effect on given cameras
  66795. * @param cameras The camera to enable.
  66796. * @hidden
  66797. */
  66798. _enable(cameras: Camera): void;
  66799. /**
  66800. * Enables the effect on given cameras
  66801. * @param cameras The camera to enable.
  66802. * @hidden
  66803. */
  66804. _enable(cameras: Nullable<Camera[]>): void;
  66805. /**
  66806. * Disables the effect on the given cameras
  66807. * @param cameras The camera to disable.
  66808. * @hidden
  66809. */
  66810. _disable(cameras: Camera): void;
  66811. /**
  66812. * Disables the effect on the given cameras
  66813. * @param cameras The camera to disable.
  66814. * @hidden
  66815. */
  66816. _disable(cameras: Nullable<Camera[]>): void;
  66817. /**
  66818. * Gets a list of the post processes contained in the effect.
  66819. * @param camera The camera to get the post processes on.
  66820. * @returns The list of the post processes in the effect.
  66821. */
  66822. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  66823. }
  66824. }
  66825. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  66826. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66827. /** @hidden */
  66828. export var extractHighlightsPixelShader: {
  66829. name: string;
  66830. shader: string;
  66831. };
  66832. }
  66833. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  66834. import { Nullable } from "babylonjs/types";
  66835. import { Camera } from "babylonjs/Cameras/camera";
  66836. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66837. import { Engine } from "babylonjs/Engines/engine";
  66838. import "babylonjs/Shaders/extractHighlights.fragment";
  66839. /**
  66840. * 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.
  66841. */
  66842. export class ExtractHighlightsPostProcess extends PostProcess {
  66843. /**
  66844. * The luminance threshold, pixels below this value will be set to black.
  66845. */
  66846. threshold: number;
  66847. /** @hidden */
  66848. _exposure: number;
  66849. /**
  66850. * Post process which has the input texture to be used when performing highlight extraction
  66851. * @hidden
  66852. */
  66853. _inputPostProcess: Nullable<PostProcess>;
  66854. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66855. }
  66856. }
  66857. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  66858. /** @hidden */
  66859. export var bloomMergePixelShader: {
  66860. name: string;
  66861. shader: string;
  66862. };
  66863. }
  66864. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  66865. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66866. import { Nullable } from "babylonjs/types";
  66867. import { Engine } from "babylonjs/Engines/engine";
  66868. import { Camera } from "babylonjs/Cameras/camera";
  66869. import "babylonjs/Shaders/bloomMerge.fragment";
  66870. /**
  66871. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  66872. */
  66873. export class BloomMergePostProcess extends PostProcess {
  66874. /** Weight of the bloom to be added to the original input. */
  66875. weight: number;
  66876. /**
  66877. * Creates a new instance of @see BloomMergePostProcess
  66878. * @param name The name of the effect.
  66879. * @param originalFromInput Post process which's input will be used for the merge.
  66880. * @param blurred Blurred highlights post process which's output will be used.
  66881. * @param weight Weight of the bloom to be added to the original input.
  66882. * @param options The required width/height ratio to downsize to before computing the render pass.
  66883. * @param camera The camera to apply the render pass to.
  66884. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66885. * @param engine The engine which the post process will be applied. (default: current engine)
  66886. * @param reusable If the post process can be reused on the same frame. (default: false)
  66887. * @param textureType Type of textures used when performing the post process. (default: 0)
  66888. * @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)
  66889. */
  66890. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  66891. /** Weight of the bloom to be added to the original input. */
  66892. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66893. }
  66894. }
  66895. declare module "babylonjs/PostProcesses/bloomEffect" {
  66896. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  66897. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66898. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  66899. import { Camera } from "babylonjs/Cameras/camera";
  66900. import { Scene } from "babylonjs/scene";
  66901. /**
  66902. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  66903. */
  66904. export class BloomEffect extends PostProcessRenderEffect {
  66905. private bloomScale;
  66906. /**
  66907. * @hidden Internal
  66908. */
  66909. _effects: Array<PostProcess>;
  66910. /**
  66911. * @hidden Internal
  66912. */
  66913. _downscale: ExtractHighlightsPostProcess;
  66914. private _blurX;
  66915. private _blurY;
  66916. private _merge;
  66917. /**
  66918. * The luminance threshold to find bright areas of the image to bloom.
  66919. */
  66920. get threshold(): number;
  66921. set threshold(value: number);
  66922. /**
  66923. * The strength of the bloom.
  66924. */
  66925. get weight(): number;
  66926. set weight(value: number);
  66927. /**
  66928. * Specifies the size of the bloom blur kernel, relative to the final output size
  66929. */
  66930. get kernel(): number;
  66931. set kernel(value: number);
  66932. /**
  66933. * Creates a new instance of @see BloomEffect
  66934. * @param scene The scene the effect belongs to.
  66935. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  66936. * @param bloomKernel The size of the kernel to be used when applying the blur.
  66937. * @param bloomWeight The the strength of bloom.
  66938. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  66939. * @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)
  66940. */
  66941. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  66942. /**
  66943. * Disposes each of the internal effects for a given camera.
  66944. * @param camera The camera to dispose the effect on.
  66945. */
  66946. disposeEffects(camera: Camera): void;
  66947. /**
  66948. * @hidden Internal
  66949. */
  66950. _updateEffects(): void;
  66951. /**
  66952. * Internal
  66953. * @returns if all the contained post processes are ready.
  66954. * @hidden
  66955. */
  66956. _isReady(): boolean;
  66957. }
  66958. }
  66959. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  66960. /** @hidden */
  66961. export var chromaticAberrationPixelShader: {
  66962. name: string;
  66963. shader: string;
  66964. };
  66965. }
  66966. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  66967. import { Vector2 } from "babylonjs/Maths/math.vector";
  66968. import { Nullable } from "babylonjs/types";
  66969. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66970. import { Camera } from "babylonjs/Cameras/camera";
  66971. import { Engine } from "babylonjs/Engines/engine";
  66972. import "babylonjs/Shaders/chromaticAberration.fragment";
  66973. /**
  66974. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  66975. */
  66976. export class ChromaticAberrationPostProcess extends PostProcess {
  66977. /**
  66978. * The amount of seperation of rgb channels (default: 30)
  66979. */
  66980. aberrationAmount: number;
  66981. /**
  66982. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  66983. */
  66984. radialIntensity: number;
  66985. /**
  66986. * 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))
  66987. */
  66988. direction: Vector2;
  66989. /**
  66990. * 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))
  66991. */
  66992. centerPosition: Vector2;
  66993. /**
  66994. * Creates a new instance ChromaticAberrationPostProcess
  66995. * @param name The name of the effect.
  66996. * @param screenWidth The width of the screen to apply the effect on.
  66997. * @param screenHeight The height of the screen to apply the effect on.
  66998. * @param options The required width/height ratio to downsize to before computing the render pass.
  66999. * @param camera The camera to apply the render pass to.
  67000. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67001. * @param engine The engine which the post process will be applied. (default: current engine)
  67002. * @param reusable If the post process can be reused on the same frame. (default: false)
  67003. * @param textureType Type of textures used when performing the post process. (default: 0)
  67004. * @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)
  67005. */
  67006. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67007. }
  67008. }
  67009. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  67010. /** @hidden */
  67011. export var circleOfConfusionPixelShader: {
  67012. name: string;
  67013. shader: string;
  67014. };
  67015. }
  67016. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  67017. import { Nullable } from "babylonjs/types";
  67018. import { Engine } from "babylonjs/Engines/engine";
  67019. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67020. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67021. import { Camera } from "babylonjs/Cameras/camera";
  67022. import "babylonjs/Shaders/circleOfConfusion.fragment";
  67023. /**
  67024. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67025. */
  67026. export class CircleOfConfusionPostProcess extends PostProcess {
  67027. /**
  67028. * 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.
  67029. */
  67030. lensSize: number;
  67031. /**
  67032. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67033. */
  67034. fStop: number;
  67035. /**
  67036. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67037. */
  67038. focusDistance: number;
  67039. /**
  67040. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67041. */
  67042. focalLength: number;
  67043. private _depthTexture;
  67044. /**
  67045. * Creates a new instance CircleOfConfusionPostProcess
  67046. * @param name The name of the effect.
  67047. * @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.
  67048. * @param options The required width/height ratio to downsize to before computing the render pass.
  67049. * @param camera The camera to apply the render pass to.
  67050. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67051. * @param engine The engine which the post process will be applied. (default: current engine)
  67052. * @param reusable If the post process can be reused on the same frame. (default: false)
  67053. * @param textureType Type of textures used when performing the post process. (default: 0)
  67054. * @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)
  67055. */
  67056. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67057. /**
  67058. * 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.
  67059. */
  67060. set depthTexture(value: RenderTargetTexture);
  67061. }
  67062. }
  67063. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  67064. /** @hidden */
  67065. export var colorCorrectionPixelShader: {
  67066. name: string;
  67067. shader: string;
  67068. };
  67069. }
  67070. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  67071. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67072. import { Engine } from "babylonjs/Engines/engine";
  67073. import { Camera } from "babylonjs/Cameras/camera";
  67074. import "babylonjs/Shaders/colorCorrection.fragment";
  67075. /**
  67076. *
  67077. * This post-process allows the modification of rendered colors by using
  67078. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67079. *
  67080. * The object needs to be provided an url to a texture containing the color
  67081. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67082. * Use an image editing software to tweak the LUT to match your needs.
  67083. *
  67084. * For an example of a color LUT, see here:
  67085. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67086. * For explanations on color grading, see here:
  67087. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67088. *
  67089. */
  67090. export class ColorCorrectionPostProcess extends PostProcess {
  67091. private _colorTableTexture;
  67092. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67093. }
  67094. }
  67095. declare module "babylonjs/Shaders/convolution.fragment" {
  67096. /** @hidden */
  67097. export var convolutionPixelShader: {
  67098. name: string;
  67099. shader: string;
  67100. };
  67101. }
  67102. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  67103. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67104. import { Nullable } from "babylonjs/types";
  67105. import { Camera } from "babylonjs/Cameras/camera";
  67106. import { Engine } from "babylonjs/Engines/engine";
  67107. import "babylonjs/Shaders/convolution.fragment";
  67108. /**
  67109. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67110. * input texture to perform effects such as edge detection or sharpening
  67111. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67112. */
  67113. export class ConvolutionPostProcess extends PostProcess {
  67114. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67115. kernel: number[];
  67116. /**
  67117. * Creates a new instance ConvolutionPostProcess
  67118. * @param name The name of the effect.
  67119. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67120. * @param options The required width/height ratio to downsize to before computing the render pass.
  67121. * @param camera The camera to apply the render pass to.
  67122. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67123. * @param engine The engine which the post process will be applied. (default: current engine)
  67124. * @param reusable If the post process can be reused on the same frame. (default: false)
  67125. * @param textureType Type of textures used when performing the post process. (default: 0)
  67126. */
  67127. constructor(name: string,
  67128. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67129. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67130. /**
  67131. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67132. */
  67133. static EdgeDetect0Kernel: number[];
  67134. /**
  67135. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67136. */
  67137. static EdgeDetect1Kernel: number[];
  67138. /**
  67139. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67140. */
  67141. static EdgeDetect2Kernel: number[];
  67142. /**
  67143. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67144. */
  67145. static SharpenKernel: number[];
  67146. /**
  67147. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67148. */
  67149. static EmbossKernel: number[];
  67150. /**
  67151. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67152. */
  67153. static GaussianKernel: number[];
  67154. }
  67155. }
  67156. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  67157. import { Nullable } from "babylonjs/types";
  67158. import { Vector2 } from "babylonjs/Maths/math.vector";
  67159. import { Camera } from "babylonjs/Cameras/camera";
  67160. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67161. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  67162. import { Engine } from "babylonjs/Engines/engine";
  67163. import { Scene } from "babylonjs/scene";
  67164. /**
  67165. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67166. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67167. * based on samples that have a large difference in distance than the center pixel.
  67168. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67169. */
  67170. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67171. direction: Vector2;
  67172. /**
  67173. * Creates a new instance CircleOfConfusionPostProcess
  67174. * @param name The name of the effect.
  67175. * @param scene The scene the effect belongs to.
  67176. * @param direction The direction the blur should be applied.
  67177. * @param kernel The size of the kernel used to blur.
  67178. * @param options The required width/height ratio to downsize to before computing the render pass.
  67179. * @param camera The camera to apply the render pass to.
  67180. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67181. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67182. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67183. * @param engine The engine which the post process will be applied. (default: current engine)
  67184. * @param reusable If the post process can be reused on the same frame. (default: false)
  67185. * @param textureType Type of textures used when performing the post process. (default: 0)
  67186. * @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)
  67187. */
  67188. 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);
  67189. }
  67190. }
  67191. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  67192. /** @hidden */
  67193. export var depthOfFieldMergePixelShader: {
  67194. name: string;
  67195. shader: string;
  67196. };
  67197. }
  67198. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  67199. import { Nullable } from "babylonjs/types";
  67200. import { Camera } from "babylonjs/Cameras/camera";
  67201. import { Effect } from "babylonjs/Materials/effect";
  67202. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67203. import { Engine } from "babylonjs/Engines/engine";
  67204. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  67205. /**
  67206. * Options to be set when merging outputs from the default pipeline.
  67207. */
  67208. export class DepthOfFieldMergePostProcessOptions {
  67209. /**
  67210. * The original image to merge on top of
  67211. */
  67212. originalFromInput: PostProcess;
  67213. /**
  67214. * Parameters to perform the merge of the depth of field effect
  67215. */
  67216. depthOfField?: {
  67217. circleOfConfusion: PostProcess;
  67218. blurSteps: Array<PostProcess>;
  67219. };
  67220. /**
  67221. * Parameters to perform the merge of bloom effect
  67222. */
  67223. bloom?: {
  67224. blurred: PostProcess;
  67225. weight: number;
  67226. };
  67227. }
  67228. /**
  67229. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67230. */
  67231. export class DepthOfFieldMergePostProcess extends PostProcess {
  67232. private blurSteps;
  67233. /**
  67234. * Creates a new instance of DepthOfFieldMergePostProcess
  67235. * @param name The name of the effect.
  67236. * @param originalFromInput Post process which's input will be used for the merge.
  67237. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67238. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67239. * @param options The required width/height ratio to downsize to before computing the render pass.
  67240. * @param camera The camera to apply the render pass to.
  67241. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67242. * @param engine The engine which the post process will be applied. (default: current engine)
  67243. * @param reusable If the post process can be reused on the same frame. (default: false)
  67244. * @param textureType Type of textures used when performing the post process. (default: 0)
  67245. * @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)
  67246. */
  67247. 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);
  67248. /**
  67249. * Updates the effect with the current post process compile time values and recompiles the shader.
  67250. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67251. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67252. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67253. * @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
  67254. * @param onCompiled Called when the shader has been compiled.
  67255. * @param onError Called if there is an error when compiling a shader.
  67256. */
  67257. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67258. }
  67259. }
  67260. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  67261. import { Nullable } from "babylonjs/types";
  67262. import { Camera } from "babylonjs/Cameras/camera";
  67263. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67264. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67265. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67266. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  67267. import { Scene } from "babylonjs/scene";
  67268. /**
  67269. * Specifies the level of max blur that should be applied when using the depth of field effect
  67270. */
  67271. export enum DepthOfFieldEffectBlurLevel {
  67272. /**
  67273. * Subtle blur
  67274. */
  67275. Low = 0,
  67276. /**
  67277. * Medium blur
  67278. */
  67279. Medium = 1,
  67280. /**
  67281. * Large blur
  67282. */
  67283. High = 2
  67284. }
  67285. /**
  67286. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67287. */
  67288. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67289. private _circleOfConfusion;
  67290. /**
  67291. * @hidden Internal, blurs from high to low
  67292. */
  67293. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67294. private _depthOfFieldBlurY;
  67295. private _dofMerge;
  67296. /**
  67297. * @hidden Internal post processes in depth of field effect
  67298. */
  67299. _effects: Array<PostProcess>;
  67300. /**
  67301. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67302. */
  67303. set focalLength(value: number);
  67304. get focalLength(): number;
  67305. /**
  67306. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67307. */
  67308. set fStop(value: number);
  67309. get fStop(): number;
  67310. /**
  67311. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67312. */
  67313. set focusDistance(value: number);
  67314. get focusDistance(): number;
  67315. /**
  67316. * 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.
  67317. */
  67318. set lensSize(value: number);
  67319. get lensSize(): number;
  67320. /**
  67321. * Creates a new instance DepthOfFieldEffect
  67322. * @param scene The scene the effect belongs to.
  67323. * @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.
  67324. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67325. * @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)
  67326. */
  67327. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67328. /**
  67329. * Get the current class name of the current effet
  67330. * @returns "DepthOfFieldEffect"
  67331. */
  67332. getClassName(): string;
  67333. /**
  67334. * 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.
  67335. */
  67336. set depthTexture(value: RenderTargetTexture);
  67337. /**
  67338. * Disposes each of the internal effects for a given camera.
  67339. * @param camera The camera to dispose the effect on.
  67340. */
  67341. disposeEffects(camera: Camera): void;
  67342. /**
  67343. * @hidden Internal
  67344. */
  67345. _updateEffects(): void;
  67346. /**
  67347. * Internal
  67348. * @returns if all the contained post processes are ready.
  67349. * @hidden
  67350. */
  67351. _isReady(): boolean;
  67352. }
  67353. }
  67354. declare module "babylonjs/Shaders/displayPass.fragment" {
  67355. /** @hidden */
  67356. export var displayPassPixelShader: {
  67357. name: string;
  67358. shader: string;
  67359. };
  67360. }
  67361. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  67362. import { Nullable } from "babylonjs/types";
  67363. import { Camera } from "babylonjs/Cameras/camera";
  67364. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67365. import { Engine } from "babylonjs/Engines/engine";
  67366. import "babylonjs/Shaders/displayPass.fragment";
  67367. /**
  67368. * DisplayPassPostProcess which produces an output the same as it's input
  67369. */
  67370. export class DisplayPassPostProcess extends PostProcess {
  67371. /**
  67372. * Creates the DisplayPassPostProcess
  67373. * @param name The name of the effect.
  67374. * @param options The required width/height ratio to downsize to before computing the render pass.
  67375. * @param camera The camera to apply the render pass to.
  67376. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67377. * @param engine The engine which the post process will be applied. (default: current engine)
  67378. * @param reusable If the post process can be reused on the same frame. (default: false)
  67379. */
  67380. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67381. }
  67382. }
  67383. declare module "babylonjs/Shaders/filter.fragment" {
  67384. /** @hidden */
  67385. export var filterPixelShader: {
  67386. name: string;
  67387. shader: string;
  67388. };
  67389. }
  67390. declare module "babylonjs/PostProcesses/filterPostProcess" {
  67391. import { Nullable } from "babylonjs/types";
  67392. import { Matrix } from "babylonjs/Maths/math.vector";
  67393. import { Camera } from "babylonjs/Cameras/camera";
  67394. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67395. import { Engine } from "babylonjs/Engines/engine";
  67396. import "babylonjs/Shaders/filter.fragment";
  67397. /**
  67398. * Applies a kernel filter to the image
  67399. */
  67400. export class FilterPostProcess extends PostProcess {
  67401. /** The matrix to be applied to the image */
  67402. kernelMatrix: Matrix;
  67403. /**
  67404. *
  67405. * @param name The name of the effect.
  67406. * @param kernelMatrix The matrix to be applied to the image
  67407. * @param options The required width/height ratio to downsize to before computing the render pass.
  67408. * @param camera The camera to apply the render pass to.
  67409. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67410. * @param engine The engine which the post process will be applied. (default: current engine)
  67411. * @param reusable If the post process can be reused on the same frame. (default: false)
  67412. */
  67413. constructor(name: string,
  67414. /** The matrix to be applied to the image */
  67415. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67416. }
  67417. }
  67418. declare module "babylonjs/Shaders/fxaa.fragment" {
  67419. /** @hidden */
  67420. export var fxaaPixelShader: {
  67421. name: string;
  67422. shader: string;
  67423. };
  67424. }
  67425. declare module "babylonjs/Shaders/fxaa.vertex" {
  67426. /** @hidden */
  67427. export var fxaaVertexShader: {
  67428. name: string;
  67429. shader: string;
  67430. };
  67431. }
  67432. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  67433. import { Nullable } from "babylonjs/types";
  67434. import { Camera } from "babylonjs/Cameras/camera";
  67435. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67436. import { Engine } from "babylonjs/Engines/engine";
  67437. import "babylonjs/Shaders/fxaa.fragment";
  67438. import "babylonjs/Shaders/fxaa.vertex";
  67439. /**
  67440. * Fxaa post process
  67441. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  67442. */
  67443. export class FxaaPostProcess extends PostProcess {
  67444. /** @hidden */
  67445. texelWidth: number;
  67446. /** @hidden */
  67447. texelHeight: number;
  67448. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67449. private _getDefines;
  67450. }
  67451. }
  67452. declare module "babylonjs/Shaders/grain.fragment" {
  67453. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67454. /** @hidden */
  67455. export var grainPixelShader: {
  67456. name: string;
  67457. shader: string;
  67458. };
  67459. }
  67460. declare module "babylonjs/PostProcesses/grainPostProcess" {
  67461. import { Nullable } from "babylonjs/types";
  67462. import { Camera } from "babylonjs/Cameras/camera";
  67463. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67464. import { Engine } from "babylonjs/Engines/engine";
  67465. import "babylonjs/Shaders/grain.fragment";
  67466. /**
  67467. * The GrainPostProcess adds noise to the image at mid luminance levels
  67468. */
  67469. export class GrainPostProcess extends PostProcess {
  67470. /**
  67471. * The intensity of the grain added (default: 30)
  67472. */
  67473. intensity: number;
  67474. /**
  67475. * If the grain should be randomized on every frame
  67476. */
  67477. animated: boolean;
  67478. /**
  67479. * Creates a new instance of @see GrainPostProcess
  67480. * @param name The name of the effect.
  67481. * @param options The required width/height ratio to downsize to before computing the render pass.
  67482. * @param camera The camera to apply the render pass to.
  67483. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67484. * @param engine The engine which the post process will be applied. (default: current engine)
  67485. * @param reusable If the post process can be reused on the same frame. (default: false)
  67486. * @param textureType Type of textures used when performing the post process. (default: 0)
  67487. * @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)
  67488. */
  67489. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67490. }
  67491. }
  67492. declare module "babylonjs/Shaders/highlights.fragment" {
  67493. /** @hidden */
  67494. export var highlightsPixelShader: {
  67495. name: string;
  67496. shader: string;
  67497. };
  67498. }
  67499. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  67500. import { Nullable } from "babylonjs/types";
  67501. import { Camera } from "babylonjs/Cameras/camera";
  67502. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67503. import { Engine } from "babylonjs/Engines/engine";
  67504. import "babylonjs/Shaders/highlights.fragment";
  67505. /**
  67506. * Extracts highlights from the image
  67507. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67508. */
  67509. export class HighlightsPostProcess extends PostProcess {
  67510. /**
  67511. * Extracts highlights from the image
  67512. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67513. * @param name The name of the effect.
  67514. * @param options The required width/height ratio to downsize to before computing the render pass.
  67515. * @param camera The camera to apply the render pass to.
  67516. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67517. * @param engine The engine which the post process will be applied. (default: current engine)
  67518. * @param reusable If the post process can be reused on the same frame. (default: false)
  67519. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  67520. */
  67521. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67522. }
  67523. }
  67524. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  67525. /** @hidden */
  67526. export var mrtFragmentDeclaration: {
  67527. name: string;
  67528. shader: string;
  67529. };
  67530. }
  67531. declare module "babylonjs/Shaders/geometry.fragment" {
  67532. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  67533. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  67534. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  67535. /** @hidden */
  67536. export var geometryPixelShader: {
  67537. name: string;
  67538. shader: string;
  67539. };
  67540. }
  67541. declare module "babylonjs/Shaders/geometry.vertex" {
  67542. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67543. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67544. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67545. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67546. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67547. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67548. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67549. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  67550. /** @hidden */
  67551. export var geometryVertexShader: {
  67552. name: string;
  67553. shader: string;
  67554. };
  67555. }
  67556. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  67557. import { Matrix } from "babylonjs/Maths/math.vector";
  67558. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67559. import { Mesh } from "babylonjs/Meshes/mesh";
  67560. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  67561. import { Effect } from "babylonjs/Materials/effect";
  67562. import { Scene } from "babylonjs/scene";
  67563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67564. import "babylonjs/Shaders/geometry.fragment";
  67565. import "babylonjs/Shaders/geometry.vertex";
  67566. /** @hidden */
  67567. interface ISavedTransformationMatrix {
  67568. world: Matrix;
  67569. viewProjection: Matrix;
  67570. }
  67571. /**
  67572. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  67573. */
  67574. export class GeometryBufferRenderer {
  67575. /**
  67576. * Constant used to retrieve the position texture index in the G-Buffer textures array
  67577. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  67578. */
  67579. static readonly POSITION_TEXTURE_TYPE: number;
  67580. /**
  67581. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  67582. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  67583. */
  67584. static readonly VELOCITY_TEXTURE_TYPE: number;
  67585. /**
  67586. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  67587. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  67588. */
  67589. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  67590. /**
  67591. * Dictionary used to store the previous transformation matrices of each rendered mesh
  67592. * in order to compute objects velocities when enableVelocity is set to "true"
  67593. * @hidden
  67594. */
  67595. _previousTransformationMatrices: {
  67596. [index: number]: ISavedTransformationMatrix;
  67597. };
  67598. /**
  67599. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  67600. * in order to compute objects velocities when enableVelocity is set to "true"
  67601. * @hidden
  67602. */
  67603. _previousBonesTransformationMatrices: {
  67604. [index: number]: Float32Array;
  67605. };
  67606. /**
  67607. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  67608. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  67609. */
  67610. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  67611. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  67612. renderTransparentMeshes: boolean;
  67613. private _scene;
  67614. private _multiRenderTarget;
  67615. private _ratio;
  67616. private _enablePosition;
  67617. private _enableVelocity;
  67618. private _enableReflectivity;
  67619. private _positionIndex;
  67620. private _velocityIndex;
  67621. private _reflectivityIndex;
  67622. protected _effect: Effect;
  67623. protected _cachedDefines: string;
  67624. /**
  67625. * Set the render list (meshes to be rendered) used in the G buffer.
  67626. */
  67627. set renderList(meshes: Mesh[]);
  67628. /**
  67629. * Gets wether or not G buffer are supported by the running hardware.
  67630. * This requires draw buffer supports
  67631. */
  67632. get isSupported(): boolean;
  67633. /**
  67634. * Returns the index of the given texture type in the G-Buffer textures array
  67635. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  67636. * @returns the index of the given texture type in the G-Buffer textures array
  67637. */
  67638. getTextureIndex(textureType: number): number;
  67639. /**
  67640. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  67641. */
  67642. get enablePosition(): boolean;
  67643. /**
  67644. * Sets whether or not objects positions are enabled for the G buffer.
  67645. */
  67646. set enablePosition(enable: boolean);
  67647. /**
  67648. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  67649. */
  67650. get enableVelocity(): boolean;
  67651. /**
  67652. * Sets wether or not objects velocities are enabled for the G buffer.
  67653. */
  67654. set enableVelocity(enable: boolean);
  67655. /**
  67656. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  67657. */
  67658. get enableReflectivity(): boolean;
  67659. /**
  67660. * Sets wether or not objects roughness are enabled for the G buffer.
  67661. */
  67662. set enableReflectivity(enable: boolean);
  67663. /**
  67664. * Gets the scene associated with the buffer.
  67665. */
  67666. get scene(): Scene;
  67667. /**
  67668. * Gets the ratio used by the buffer during its creation.
  67669. * How big is the buffer related to the main canvas.
  67670. */
  67671. get ratio(): number;
  67672. /** @hidden */
  67673. static _SceneComponentInitialization: (scene: Scene) => void;
  67674. /**
  67675. * Creates a new G Buffer for the scene
  67676. * @param scene The scene the buffer belongs to
  67677. * @param ratio How big is the buffer related to the main canvas.
  67678. */
  67679. constructor(scene: Scene, ratio?: number);
  67680. /**
  67681. * Checks wether everything is ready to render a submesh to the G buffer.
  67682. * @param subMesh the submesh to check readiness for
  67683. * @param useInstances is the mesh drawn using instance or not
  67684. * @returns true if ready otherwise false
  67685. */
  67686. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67687. /**
  67688. * Gets the current underlying G Buffer.
  67689. * @returns the buffer
  67690. */
  67691. getGBuffer(): MultiRenderTarget;
  67692. /**
  67693. * Gets the number of samples used to render the buffer (anti aliasing).
  67694. */
  67695. get samples(): number;
  67696. /**
  67697. * Sets the number of samples used to render the buffer (anti aliasing).
  67698. */
  67699. set samples(value: number);
  67700. /**
  67701. * Disposes the renderer and frees up associated resources.
  67702. */
  67703. dispose(): void;
  67704. protected _createRenderTargets(): void;
  67705. private _copyBonesTransformationMatrices;
  67706. }
  67707. }
  67708. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  67709. import { Nullable } from "babylonjs/types";
  67710. import { Scene } from "babylonjs/scene";
  67711. import { ISceneComponent } from "babylonjs/sceneComponent";
  67712. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  67713. module "babylonjs/scene" {
  67714. interface Scene {
  67715. /** @hidden (Backing field) */
  67716. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  67717. /**
  67718. * Gets or Sets the current geometry buffer associated to the scene.
  67719. */
  67720. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  67721. /**
  67722. * Enables a GeometryBufferRender and associates it with the scene
  67723. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  67724. * @returns the GeometryBufferRenderer
  67725. */
  67726. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  67727. /**
  67728. * Disables the GeometryBufferRender associated with the scene
  67729. */
  67730. disableGeometryBufferRenderer(): void;
  67731. }
  67732. }
  67733. /**
  67734. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  67735. * in several rendering techniques.
  67736. */
  67737. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  67738. /**
  67739. * The component name helpful to identify the component in the list of scene components.
  67740. */
  67741. readonly name: string;
  67742. /**
  67743. * The scene the component belongs to.
  67744. */
  67745. scene: Scene;
  67746. /**
  67747. * Creates a new instance of the component for the given scene
  67748. * @param scene Defines the scene to register the component in
  67749. */
  67750. constructor(scene: Scene);
  67751. /**
  67752. * Registers the component in a given scene
  67753. */
  67754. register(): void;
  67755. /**
  67756. * Rebuilds the elements related to this component in case of
  67757. * context lost for instance.
  67758. */
  67759. rebuild(): void;
  67760. /**
  67761. * Disposes the component and the associated ressources
  67762. */
  67763. dispose(): void;
  67764. private _gatherRenderTargets;
  67765. }
  67766. }
  67767. declare module "babylonjs/Shaders/motionBlur.fragment" {
  67768. /** @hidden */
  67769. export var motionBlurPixelShader: {
  67770. name: string;
  67771. shader: string;
  67772. };
  67773. }
  67774. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  67775. import { Nullable } from "babylonjs/types";
  67776. import { Camera } from "babylonjs/Cameras/camera";
  67777. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67778. import { Scene } from "babylonjs/scene";
  67779. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67780. import "babylonjs/Animations/animatable";
  67781. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  67782. import "babylonjs/Shaders/motionBlur.fragment";
  67783. import { Engine } from "babylonjs/Engines/engine";
  67784. /**
  67785. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  67786. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  67787. * As an example, all you have to do is to create the post-process:
  67788. * var mb = new BABYLON.MotionBlurPostProcess(
  67789. * 'mb', // The name of the effect.
  67790. * scene, // The scene containing the objects to blur according to their velocity.
  67791. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  67792. * camera // The camera to apply the render pass to.
  67793. * );
  67794. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  67795. */
  67796. export class MotionBlurPostProcess extends PostProcess {
  67797. /**
  67798. * Defines how much the image is blurred by the movement. Default value is equal to 1
  67799. */
  67800. motionStrength: number;
  67801. /**
  67802. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  67803. */
  67804. get motionBlurSamples(): number;
  67805. /**
  67806. * Sets the number of iterations to be used for motion blur quality
  67807. */
  67808. set motionBlurSamples(samples: number);
  67809. private _motionBlurSamples;
  67810. private _geometryBufferRenderer;
  67811. /**
  67812. * Creates a new instance MotionBlurPostProcess
  67813. * @param name The name of the effect.
  67814. * @param scene The scene containing the objects to blur according to their velocity.
  67815. * @param options The required width/height ratio to downsize to before computing the render pass.
  67816. * @param camera The camera to apply the render pass to.
  67817. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67818. * @param engine The engine which the post process will be applied. (default: current engine)
  67819. * @param reusable If the post process can be reused on the same frame. (default: false)
  67820. * @param textureType Type of textures used when performing the post process. (default: 0)
  67821. * @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)
  67822. */
  67823. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67824. /**
  67825. * Excludes the given skinned mesh from computing bones velocities.
  67826. * 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.
  67827. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  67828. */
  67829. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  67830. /**
  67831. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  67832. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  67833. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  67834. */
  67835. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  67836. /**
  67837. * Disposes the post process.
  67838. * @param camera The camera to dispose the post process on.
  67839. */
  67840. dispose(camera?: Camera): void;
  67841. }
  67842. }
  67843. declare module "babylonjs/Shaders/refraction.fragment" {
  67844. /** @hidden */
  67845. export var refractionPixelShader: {
  67846. name: string;
  67847. shader: string;
  67848. };
  67849. }
  67850. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  67851. import { Color3 } from "babylonjs/Maths/math.color";
  67852. import { Camera } from "babylonjs/Cameras/camera";
  67853. import { Texture } from "babylonjs/Materials/Textures/texture";
  67854. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67855. import { Engine } from "babylonjs/Engines/engine";
  67856. import "babylonjs/Shaders/refraction.fragment";
  67857. /**
  67858. * Post process which applies a refractin texture
  67859. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  67860. */
  67861. export class RefractionPostProcess extends PostProcess {
  67862. /** the base color of the refraction (used to taint the rendering) */
  67863. color: Color3;
  67864. /** simulated refraction depth */
  67865. depth: number;
  67866. /** the coefficient of the base color (0 to remove base color tainting) */
  67867. colorLevel: number;
  67868. private _refTexture;
  67869. private _ownRefractionTexture;
  67870. /**
  67871. * Gets or sets the refraction texture
  67872. * Please note that you are responsible for disposing the texture if you set it manually
  67873. */
  67874. get refractionTexture(): Texture;
  67875. set refractionTexture(value: Texture);
  67876. /**
  67877. * Initializes the RefractionPostProcess
  67878. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  67879. * @param name The name of the effect.
  67880. * @param refractionTextureUrl Url of the refraction texture to use
  67881. * @param color the base color of the refraction (used to taint the rendering)
  67882. * @param depth simulated refraction depth
  67883. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  67884. * @param camera The camera to apply the render pass to.
  67885. * @param options The required width/height ratio to downsize to before computing the render pass.
  67886. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67887. * @param engine The engine which the post process will be applied. (default: current engine)
  67888. * @param reusable If the post process can be reused on the same frame. (default: false)
  67889. */
  67890. constructor(name: string, refractionTextureUrl: string,
  67891. /** the base color of the refraction (used to taint the rendering) */
  67892. color: Color3,
  67893. /** simulated refraction depth */
  67894. depth: number,
  67895. /** the coefficient of the base color (0 to remove base color tainting) */
  67896. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67897. /**
  67898. * Disposes of the post process
  67899. * @param camera Camera to dispose post process on
  67900. */
  67901. dispose(camera: Camera): void;
  67902. }
  67903. }
  67904. declare module "babylonjs/Shaders/sharpen.fragment" {
  67905. /** @hidden */
  67906. export var sharpenPixelShader: {
  67907. name: string;
  67908. shader: string;
  67909. };
  67910. }
  67911. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  67912. import { Nullable } from "babylonjs/types";
  67913. import { Camera } from "babylonjs/Cameras/camera";
  67914. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67915. import "babylonjs/Shaders/sharpen.fragment";
  67916. import { Engine } from "babylonjs/Engines/engine";
  67917. /**
  67918. * The SharpenPostProcess applies a sharpen kernel to every pixel
  67919. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67920. */
  67921. export class SharpenPostProcess extends PostProcess {
  67922. /**
  67923. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  67924. */
  67925. colorAmount: number;
  67926. /**
  67927. * How much sharpness should be applied (default: 0.3)
  67928. */
  67929. edgeAmount: number;
  67930. /**
  67931. * Creates a new instance ConvolutionPostProcess
  67932. * @param name The name of the effect.
  67933. * @param options The required width/height ratio to downsize to before computing the render pass.
  67934. * @param camera The camera to apply the render pass to.
  67935. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67936. * @param engine The engine which the post process will be applied. (default: current engine)
  67937. * @param reusable If the post process can be reused on the same frame. (default: false)
  67938. * @param textureType Type of textures used when performing the post process. (default: 0)
  67939. * @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)
  67940. */
  67941. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67942. }
  67943. }
  67944. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  67945. import { Nullable } from "babylonjs/types";
  67946. import { Camera } from "babylonjs/Cameras/camera";
  67947. import { Engine } from "babylonjs/Engines/engine";
  67948. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67949. import { IInspectable } from "babylonjs/Misc/iInspectable";
  67950. /**
  67951. * PostProcessRenderPipeline
  67952. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67953. */
  67954. export class PostProcessRenderPipeline {
  67955. private engine;
  67956. private _renderEffects;
  67957. private _renderEffectsForIsolatedPass;
  67958. /**
  67959. * List of inspectable custom properties (used by the Inspector)
  67960. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  67961. */
  67962. inspectableCustomProperties: IInspectable[];
  67963. /**
  67964. * @hidden
  67965. */
  67966. protected _cameras: Camera[];
  67967. /** @hidden */
  67968. _name: string;
  67969. /**
  67970. * Gets pipeline name
  67971. */
  67972. get name(): string;
  67973. /** Gets the list of attached cameras */
  67974. get cameras(): Camera[];
  67975. /**
  67976. * Initializes a PostProcessRenderPipeline
  67977. * @param engine engine to add the pipeline to
  67978. * @param name name of the pipeline
  67979. */
  67980. constructor(engine: Engine, name: string);
  67981. /**
  67982. * Gets the class name
  67983. * @returns "PostProcessRenderPipeline"
  67984. */
  67985. getClassName(): string;
  67986. /**
  67987. * If all the render effects in the pipeline are supported
  67988. */
  67989. get isSupported(): boolean;
  67990. /**
  67991. * Adds an effect to the pipeline
  67992. * @param renderEffect the effect to add
  67993. */
  67994. addEffect(renderEffect: PostProcessRenderEffect): void;
  67995. /** @hidden */
  67996. _rebuild(): void;
  67997. /** @hidden */
  67998. _enableEffect(renderEffectName: string, cameras: Camera): void;
  67999. /** @hidden */
  68000. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68001. /** @hidden */
  68002. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68003. /** @hidden */
  68004. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68005. /** @hidden */
  68006. _attachCameras(cameras: Camera, unique: boolean): void;
  68007. /** @hidden */
  68008. _attachCameras(cameras: Camera[], unique: boolean): void;
  68009. /** @hidden */
  68010. _detachCameras(cameras: Camera): void;
  68011. /** @hidden */
  68012. _detachCameras(cameras: Nullable<Camera[]>): void;
  68013. /** @hidden */
  68014. _update(): void;
  68015. /** @hidden */
  68016. _reset(): void;
  68017. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68018. /**
  68019. * Disposes of the pipeline
  68020. */
  68021. dispose(): void;
  68022. }
  68023. }
  68024. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  68025. import { Camera } from "babylonjs/Cameras/camera";
  68026. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68027. /**
  68028. * PostProcessRenderPipelineManager class
  68029. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68030. */
  68031. export class PostProcessRenderPipelineManager {
  68032. private _renderPipelines;
  68033. /**
  68034. * Initializes a PostProcessRenderPipelineManager
  68035. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68036. */
  68037. constructor();
  68038. /**
  68039. * Gets the list of supported render pipelines
  68040. */
  68041. get supportedPipelines(): PostProcessRenderPipeline[];
  68042. /**
  68043. * Adds a pipeline to the manager
  68044. * @param renderPipeline The pipeline to add
  68045. */
  68046. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68047. /**
  68048. * Attaches a camera to the pipeline
  68049. * @param renderPipelineName The name of the pipeline to attach to
  68050. * @param cameras the camera to attach
  68051. * @param unique if the camera can be attached multiple times to the pipeline
  68052. */
  68053. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68054. /**
  68055. * Detaches a camera from the pipeline
  68056. * @param renderPipelineName The name of the pipeline to detach from
  68057. * @param cameras the camera to detach
  68058. */
  68059. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68060. /**
  68061. * Enables an effect by name on a pipeline
  68062. * @param renderPipelineName the name of the pipeline to enable the effect in
  68063. * @param renderEffectName the name of the effect to enable
  68064. * @param cameras the cameras that the effect should be enabled on
  68065. */
  68066. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68067. /**
  68068. * Disables an effect by name on a pipeline
  68069. * @param renderPipelineName the name of the pipeline to disable the effect in
  68070. * @param renderEffectName the name of the effect to disable
  68071. * @param cameras the cameras that the effect should be disabled on
  68072. */
  68073. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68074. /**
  68075. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68076. */
  68077. update(): void;
  68078. /** @hidden */
  68079. _rebuild(): void;
  68080. /**
  68081. * Disposes of the manager and pipelines
  68082. */
  68083. dispose(): void;
  68084. }
  68085. }
  68086. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  68087. import { ISceneComponent } from "babylonjs/sceneComponent";
  68088. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  68089. import { Scene } from "babylonjs/scene";
  68090. module "babylonjs/scene" {
  68091. interface Scene {
  68092. /** @hidden (Backing field) */
  68093. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68094. /**
  68095. * Gets the postprocess render pipeline manager
  68096. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68097. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68098. */
  68099. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68100. }
  68101. }
  68102. /**
  68103. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68104. */
  68105. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68106. /**
  68107. * The component name helpfull to identify the component in the list of scene components.
  68108. */
  68109. readonly name: string;
  68110. /**
  68111. * The scene the component belongs to.
  68112. */
  68113. scene: Scene;
  68114. /**
  68115. * Creates a new instance of the component for the given scene
  68116. * @param scene Defines the scene to register the component in
  68117. */
  68118. constructor(scene: Scene);
  68119. /**
  68120. * Registers the component in a given scene
  68121. */
  68122. register(): void;
  68123. /**
  68124. * Rebuilds the elements related to this component in case of
  68125. * context lost for instance.
  68126. */
  68127. rebuild(): void;
  68128. /**
  68129. * Disposes the component and the associated ressources
  68130. */
  68131. dispose(): void;
  68132. private _gatherRenderTargets;
  68133. }
  68134. }
  68135. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  68136. import { Nullable } from "babylonjs/types";
  68137. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68138. import { Camera } from "babylonjs/Cameras/camera";
  68139. import { IDisposable } from "babylonjs/scene";
  68140. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  68141. import { Scene } from "babylonjs/scene";
  68142. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  68143. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  68144. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  68145. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  68146. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  68147. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68148. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  68149. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68150. import { Animation } from "babylonjs/Animations/animation";
  68151. /**
  68152. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68153. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68154. */
  68155. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68156. private _scene;
  68157. private _camerasToBeAttached;
  68158. /**
  68159. * ID of the sharpen post process,
  68160. */
  68161. private readonly SharpenPostProcessId;
  68162. /**
  68163. * @ignore
  68164. * ID of the image processing post process;
  68165. */
  68166. readonly ImageProcessingPostProcessId: string;
  68167. /**
  68168. * @ignore
  68169. * ID of the Fast Approximate Anti-Aliasing post process;
  68170. */
  68171. readonly FxaaPostProcessId: string;
  68172. /**
  68173. * ID of the chromatic aberration post process,
  68174. */
  68175. private readonly ChromaticAberrationPostProcessId;
  68176. /**
  68177. * ID of the grain post process
  68178. */
  68179. private readonly GrainPostProcessId;
  68180. /**
  68181. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68182. */
  68183. sharpen: SharpenPostProcess;
  68184. private _sharpenEffect;
  68185. private bloom;
  68186. /**
  68187. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68188. */
  68189. depthOfField: DepthOfFieldEffect;
  68190. /**
  68191. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68192. */
  68193. fxaa: FxaaPostProcess;
  68194. /**
  68195. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68196. */
  68197. imageProcessing: ImageProcessingPostProcess;
  68198. /**
  68199. * Chromatic aberration post process which will shift rgb colors in the image
  68200. */
  68201. chromaticAberration: ChromaticAberrationPostProcess;
  68202. private _chromaticAberrationEffect;
  68203. /**
  68204. * Grain post process which add noise to the image
  68205. */
  68206. grain: GrainPostProcess;
  68207. private _grainEffect;
  68208. /**
  68209. * Glow post process which adds a glow to emissive areas of the image
  68210. */
  68211. private _glowLayer;
  68212. /**
  68213. * Animations which can be used to tweak settings over a period of time
  68214. */
  68215. animations: Animation[];
  68216. private _imageProcessingConfigurationObserver;
  68217. private _sharpenEnabled;
  68218. private _bloomEnabled;
  68219. private _depthOfFieldEnabled;
  68220. private _depthOfFieldBlurLevel;
  68221. private _fxaaEnabled;
  68222. private _imageProcessingEnabled;
  68223. private _defaultPipelineTextureType;
  68224. private _bloomScale;
  68225. private _chromaticAberrationEnabled;
  68226. private _grainEnabled;
  68227. private _buildAllowed;
  68228. /**
  68229. * Gets active scene
  68230. */
  68231. get scene(): Scene;
  68232. /**
  68233. * Enable or disable the sharpen process from the pipeline
  68234. */
  68235. set sharpenEnabled(enabled: boolean);
  68236. get sharpenEnabled(): boolean;
  68237. private _resizeObserver;
  68238. private _hardwareScaleLevel;
  68239. private _bloomKernel;
  68240. /**
  68241. * Specifies the size of the bloom blur kernel, relative to the final output size
  68242. */
  68243. get bloomKernel(): number;
  68244. set bloomKernel(value: number);
  68245. /**
  68246. * Specifies the weight of the bloom in the final rendering
  68247. */
  68248. private _bloomWeight;
  68249. /**
  68250. * Specifies the luma threshold for the area that will be blurred by the bloom
  68251. */
  68252. private _bloomThreshold;
  68253. private _hdr;
  68254. /**
  68255. * The strength of the bloom.
  68256. */
  68257. set bloomWeight(value: number);
  68258. get bloomWeight(): number;
  68259. /**
  68260. * The strength of the bloom.
  68261. */
  68262. set bloomThreshold(value: number);
  68263. get bloomThreshold(): number;
  68264. /**
  68265. * The scale of the bloom, lower value will provide better performance.
  68266. */
  68267. set bloomScale(value: number);
  68268. get bloomScale(): number;
  68269. /**
  68270. * Enable or disable the bloom from the pipeline
  68271. */
  68272. set bloomEnabled(enabled: boolean);
  68273. get bloomEnabled(): boolean;
  68274. private _rebuildBloom;
  68275. /**
  68276. * If the depth of field is enabled.
  68277. */
  68278. get depthOfFieldEnabled(): boolean;
  68279. set depthOfFieldEnabled(enabled: boolean);
  68280. /**
  68281. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68282. */
  68283. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68284. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68285. /**
  68286. * If the anti aliasing is enabled.
  68287. */
  68288. set fxaaEnabled(enabled: boolean);
  68289. get fxaaEnabled(): boolean;
  68290. private _samples;
  68291. /**
  68292. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68293. */
  68294. set samples(sampleCount: number);
  68295. get samples(): number;
  68296. /**
  68297. * If image processing is enabled.
  68298. */
  68299. set imageProcessingEnabled(enabled: boolean);
  68300. get imageProcessingEnabled(): boolean;
  68301. /**
  68302. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68303. */
  68304. set glowLayerEnabled(enabled: boolean);
  68305. get glowLayerEnabled(): boolean;
  68306. /**
  68307. * Gets the glow layer (or null if not defined)
  68308. */
  68309. get glowLayer(): Nullable<GlowLayer>;
  68310. /**
  68311. * Enable or disable the chromaticAberration process from the pipeline
  68312. */
  68313. set chromaticAberrationEnabled(enabled: boolean);
  68314. get chromaticAberrationEnabled(): boolean;
  68315. /**
  68316. * Enable or disable the grain process from the pipeline
  68317. */
  68318. set grainEnabled(enabled: boolean);
  68319. get grainEnabled(): boolean;
  68320. /**
  68321. * @constructor
  68322. * @param name - The rendering pipeline name (default: "")
  68323. * @param hdr - If high dynamic range textures should be used (default: true)
  68324. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68325. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68326. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68327. */
  68328. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68329. /**
  68330. * Get the class name
  68331. * @returns "DefaultRenderingPipeline"
  68332. */
  68333. getClassName(): string;
  68334. /**
  68335. * Force the compilation of the entire pipeline.
  68336. */
  68337. prepare(): void;
  68338. private _hasCleared;
  68339. private _prevPostProcess;
  68340. private _prevPrevPostProcess;
  68341. private _setAutoClearAndTextureSharing;
  68342. private _depthOfFieldSceneObserver;
  68343. private _buildPipeline;
  68344. private _disposePostProcesses;
  68345. /**
  68346. * Adds a camera to the pipeline
  68347. * @param camera the camera to be added
  68348. */
  68349. addCamera(camera: Camera): void;
  68350. /**
  68351. * Removes a camera from the pipeline
  68352. * @param camera the camera to remove
  68353. */
  68354. removeCamera(camera: Camera): void;
  68355. /**
  68356. * Dispose of the pipeline and stop all post processes
  68357. */
  68358. dispose(): void;
  68359. /**
  68360. * Serialize the rendering pipeline (Used when exporting)
  68361. * @returns the serialized object
  68362. */
  68363. serialize(): any;
  68364. /**
  68365. * Parse the serialized pipeline
  68366. * @param source Source pipeline.
  68367. * @param scene The scene to load the pipeline to.
  68368. * @param rootUrl The URL of the serialized pipeline.
  68369. * @returns An instantiated pipeline from the serialized object.
  68370. */
  68371. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  68372. }
  68373. }
  68374. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  68375. /** @hidden */
  68376. export var lensHighlightsPixelShader: {
  68377. name: string;
  68378. shader: string;
  68379. };
  68380. }
  68381. declare module "babylonjs/Shaders/depthOfField.fragment" {
  68382. /** @hidden */
  68383. export var depthOfFieldPixelShader: {
  68384. name: string;
  68385. shader: string;
  68386. };
  68387. }
  68388. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  68389. import { Camera } from "babylonjs/Cameras/camera";
  68390. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68391. import { Scene } from "babylonjs/scene";
  68392. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68393. import "babylonjs/Shaders/chromaticAberration.fragment";
  68394. import "babylonjs/Shaders/lensHighlights.fragment";
  68395. import "babylonjs/Shaders/depthOfField.fragment";
  68396. /**
  68397. * BABYLON.JS Chromatic Aberration GLSL Shader
  68398. * Author: Olivier Guyot
  68399. * Separates very slightly R, G and B colors on the edges of the screen
  68400. * Inspired by Francois Tarlier & Martins Upitis
  68401. */
  68402. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  68403. /**
  68404. * @ignore
  68405. * The chromatic aberration PostProcess id in the pipeline
  68406. */
  68407. LensChromaticAberrationEffect: string;
  68408. /**
  68409. * @ignore
  68410. * The highlights enhancing PostProcess id in the pipeline
  68411. */
  68412. HighlightsEnhancingEffect: string;
  68413. /**
  68414. * @ignore
  68415. * The depth-of-field PostProcess id in the pipeline
  68416. */
  68417. LensDepthOfFieldEffect: string;
  68418. private _scene;
  68419. private _depthTexture;
  68420. private _grainTexture;
  68421. private _chromaticAberrationPostProcess;
  68422. private _highlightsPostProcess;
  68423. private _depthOfFieldPostProcess;
  68424. private _edgeBlur;
  68425. private _grainAmount;
  68426. private _chromaticAberration;
  68427. private _distortion;
  68428. private _highlightsGain;
  68429. private _highlightsThreshold;
  68430. private _dofDistance;
  68431. private _dofAperture;
  68432. private _dofDarken;
  68433. private _dofPentagon;
  68434. private _blurNoise;
  68435. /**
  68436. * @constructor
  68437. *
  68438. * Effect parameters are as follow:
  68439. * {
  68440. * chromatic_aberration: number; // from 0 to x (1 for realism)
  68441. * edge_blur: number; // from 0 to x (1 for realism)
  68442. * distortion: number; // from 0 to x (1 for realism)
  68443. * grain_amount: number; // from 0 to 1
  68444. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  68445. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  68446. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  68447. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  68448. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  68449. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  68450. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  68451. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  68452. * }
  68453. * Note: if an effect parameter is unset, effect is disabled
  68454. *
  68455. * @param name The rendering pipeline name
  68456. * @param parameters - An object containing all parameters (see above)
  68457. * @param scene The scene linked to this pipeline
  68458. * @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)
  68459. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68460. */
  68461. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  68462. /**
  68463. * Get the class name
  68464. * @returns "LensRenderingPipeline"
  68465. */
  68466. getClassName(): string;
  68467. /**
  68468. * Gets associated scene
  68469. */
  68470. get scene(): Scene;
  68471. /**
  68472. * Gets or sets the edge blur
  68473. */
  68474. get edgeBlur(): number;
  68475. set edgeBlur(value: number);
  68476. /**
  68477. * Gets or sets the grain amount
  68478. */
  68479. get grainAmount(): number;
  68480. set grainAmount(value: number);
  68481. /**
  68482. * Gets or sets the chromatic aberration amount
  68483. */
  68484. get chromaticAberration(): number;
  68485. set chromaticAberration(value: number);
  68486. /**
  68487. * Gets or sets the depth of field aperture
  68488. */
  68489. get dofAperture(): number;
  68490. set dofAperture(value: number);
  68491. /**
  68492. * Gets or sets the edge distortion
  68493. */
  68494. get edgeDistortion(): number;
  68495. set edgeDistortion(value: number);
  68496. /**
  68497. * Gets or sets the depth of field distortion
  68498. */
  68499. get dofDistortion(): number;
  68500. set dofDistortion(value: number);
  68501. /**
  68502. * Gets or sets the darken out of focus amount
  68503. */
  68504. get darkenOutOfFocus(): number;
  68505. set darkenOutOfFocus(value: number);
  68506. /**
  68507. * Gets or sets a boolean indicating if blur noise is enabled
  68508. */
  68509. get blurNoise(): boolean;
  68510. set blurNoise(value: boolean);
  68511. /**
  68512. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  68513. */
  68514. get pentagonBokeh(): boolean;
  68515. set pentagonBokeh(value: boolean);
  68516. /**
  68517. * Gets or sets the highlight grain amount
  68518. */
  68519. get highlightsGain(): number;
  68520. set highlightsGain(value: number);
  68521. /**
  68522. * Gets or sets the highlight threshold
  68523. */
  68524. get highlightsThreshold(): number;
  68525. set highlightsThreshold(value: number);
  68526. /**
  68527. * Sets the amount of blur at the edges
  68528. * @param amount blur amount
  68529. */
  68530. setEdgeBlur(amount: number): void;
  68531. /**
  68532. * Sets edge blur to 0
  68533. */
  68534. disableEdgeBlur(): void;
  68535. /**
  68536. * Sets the amout of grain
  68537. * @param amount Amount of grain
  68538. */
  68539. setGrainAmount(amount: number): void;
  68540. /**
  68541. * Set grain amount to 0
  68542. */
  68543. disableGrain(): void;
  68544. /**
  68545. * Sets the chromatic aberration amount
  68546. * @param amount amount of chromatic aberration
  68547. */
  68548. setChromaticAberration(amount: number): void;
  68549. /**
  68550. * Sets chromatic aberration amount to 0
  68551. */
  68552. disableChromaticAberration(): void;
  68553. /**
  68554. * Sets the EdgeDistortion amount
  68555. * @param amount amount of EdgeDistortion
  68556. */
  68557. setEdgeDistortion(amount: number): void;
  68558. /**
  68559. * Sets edge distortion to 0
  68560. */
  68561. disableEdgeDistortion(): void;
  68562. /**
  68563. * Sets the FocusDistance amount
  68564. * @param amount amount of FocusDistance
  68565. */
  68566. setFocusDistance(amount: number): void;
  68567. /**
  68568. * Disables depth of field
  68569. */
  68570. disableDepthOfField(): void;
  68571. /**
  68572. * Sets the Aperture amount
  68573. * @param amount amount of Aperture
  68574. */
  68575. setAperture(amount: number): void;
  68576. /**
  68577. * Sets the DarkenOutOfFocus amount
  68578. * @param amount amount of DarkenOutOfFocus
  68579. */
  68580. setDarkenOutOfFocus(amount: number): void;
  68581. private _pentagonBokehIsEnabled;
  68582. /**
  68583. * Creates a pentagon bokeh effect
  68584. */
  68585. enablePentagonBokeh(): void;
  68586. /**
  68587. * Disables the pentagon bokeh effect
  68588. */
  68589. disablePentagonBokeh(): void;
  68590. /**
  68591. * Enables noise blur
  68592. */
  68593. enableNoiseBlur(): void;
  68594. /**
  68595. * Disables noise blur
  68596. */
  68597. disableNoiseBlur(): void;
  68598. /**
  68599. * Sets the HighlightsGain amount
  68600. * @param amount amount of HighlightsGain
  68601. */
  68602. setHighlightsGain(amount: number): void;
  68603. /**
  68604. * Sets the HighlightsThreshold amount
  68605. * @param amount amount of HighlightsThreshold
  68606. */
  68607. setHighlightsThreshold(amount: number): void;
  68608. /**
  68609. * Disables highlights
  68610. */
  68611. disableHighlights(): void;
  68612. /**
  68613. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  68614. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  68615. */
  68616. dispose(disableDepthRender?: boolean): void;
  68617. private _createChromaticAberrationPostProcess;
  68618. private _createHighlightsPostProcess;
  68619. private _createDepthOfFieldPostProcess;
  68620. private _createGrainTexture;
  68621. }
  68622. }
  68623. declare module "babylonjs/Shaders/ssao2.fragment" {
  68624. /** @hidden */
  68625. export var ssao2PixelShader: {
  68626. name: string;
  68627. shader: string;
  68628. };
  68629. }
  68630. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  68631. /** @hidden */
  68632. export var ssaoCombinePixelShader: {
  68633. name: string;
  68634. shader: string;
  68635. };
  68636. }
  68637. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  68638. import { Camera } from "babylonjs/Cameras/camera";
  68639. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68640. import { Scene } from "babylonjs/scene";
  68641. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68642. import "babylonjs/Shaders/ssao2.fragment";
  68643. import "babylonjs/Shaders/ssaoCombine.fragment";
  68644. /**
  68645. * Render pipeline to produce ssao effect
  68646. */
  68647. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  68648. /**
  68649. * @ignore
  68650. * The PassPostProcess id in the pipeline that contains the original scene color
  68651. */
  68652. SSAOOriginalSceneColorEffect: string;
  68653. /**
  68654. * @ignore
  68655. * The SSAO PostProcess id in the pipeline
  68656. */
  68657. SSAORenderEffect: string;
  68658. /**
  68659. * @ignore
  68660. * The horizontal blur PostProcess id in the pipeline
  68661. */
  68662. SSAOBlurHRenderEffect: string;
  68663. /**
  68664. * @ignore
  68665. * The vertical blur PostProcess id in the pipeline
  68666. */
  68667. SSAOBlurVRenderEffect: string;
  68668. /**
  68669. * @ignore
  68670. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  68671. */
  68672. SSAOCombineRenderEffect: string;
  68673. /**
  68674. * The output strength of the SSAO post-process. Default value is 1.0.
  68675. */
  68676. totalStrength: number;
  68677. /**
  68678. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  68679. */
  68680. maxZ: number;
  68681. /**
  68682. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  68683. */
  68684. minZAspect: number;
  68685. private _samples;
  68686. /**
  68687. * Number of samples used for the SSAO calculations. Default value is 8
  68688. */
  68689. set samples(n: number);
  68690. get samples(): number;
  68691. private _textureSamples;
  68692. /**
  68693. * Number of samples to use for antialiasing
  68694. */
  68695. set textureSamples(n: number);
  68696. get textureSamples(): number;
  68697. /**
  68698. * Ratio object used for SSAO ratio and blur ratio
  68699. */
  68700. private _ratio;
  68701. /**
  68702. * Dynamically generated sphere sampler.
  68703. */
  68704. private _sampleSphere;
  68705. /**
  68706. * Blur filter offsets
  68707. */
  68708. private _samplerOffsets;
  68709. private _expensiveBlur;
  68710. /**
  68711. * If bilateral blur should be used
  68712. */
  68713. set expensiveBlur(b: boolean);
  68714. get expensiveBlur(): boolean;
  68715. /**
  68716. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  68717. */
  68718. radius: number;
  68719. /**
  68720. * The base color of the SSAO post-process
  68721. * The final result is "base + ssao" between [0, 1]
  68722. */
  68723. base: number;
  68724. /**
  68725. * Support test.
  68726. */
  68727. static get IsSupported(): boolean;
  68728. private _scene;
  68729. private _depthTexture;
  68730. private _normalTexture;
  68731. private _randomTexture;
  68732. private _originalColorPostProcess;
  68733. private _ssaoPostProcess;
  68734. private _blurHPostProcess;
  68735. private _blurVPostProcess;
  68736. private _ssaoCombinePostProcess;
  68737. /**
  68738. * Gets active scene
  68739. */
  68740. get scene(): Scene;
  68741. /**
  68742. * @constructor
  68743. * @param name The rendering pipeline name
  68744. * @param scene The scene linked to this pipeline
  68745. * @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 }
  68746. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68747. */
  68748. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  68749. /**
  68750. * Get the class name
  68751. * @returns "SSAO2RenderingPipeline"
  68752. */
  68753. getClassName(): string;
  68754. /**
  68755. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  68756. */
  68757. dispose(disableGeometryBufferRenderer?: boolean): void;
  68758. private _createBlurPostProcess;
  68759. /** @hidden */
  68760. _rebuild(): void;
  68761. private _bits;
  68762. private _radicalInverse_VdC;
  68763. private _hammersley;
  68764. private _hemisphereSample_uniform;
  68765. private _generateHemisphere;
  68766. private _createSSAOPostProcess;
  68767. private _createSSAOCombinePostProcess;
  68768. private _createRandomTexture;
  68769. /**
  68770. * Serialize the rendering pipeline (Used when exporting)
  68771. * @returns the serialized object
  68772. */
  68773. serialize(): any;
  68774. /**
  68775. * Parse the serialized pipeline
  68776. * @param source Source pipeline.
  68777. * @param scene The scene to load the pipeline to.
  68778. * @param rootUrl The URL of the serialized pipeline.
  68779. * @returns An instantiated pipeline from the serialized object.
  68780. */
  68781. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  68782. }
  68783. }
  68784. declare module "babylonjs/Shaders/ssao.fragment" {
  68785. /** @hidden */
  68786. export var ssaoPixelShader: {
  68787. name: string;
  68788. shader: string;
  68789. };
  68790. }
  68791. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  68792. import { Camera } from "babylonjs/Cameras/camera";
  68793. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68794. import { Scene } from "babylonjs/scene";
  68795. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68796. import "babylonjs/Shaders/ssao.fragment";
  68797. import "babylonjs/Shaders/ssaoCombine.fragment";
  68798. /**
  68799. * Render pipeline to produce ssao effect
  68800. */
  68801. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  68802. /**
  68803. * @ignore
  68804. * The PassPostProcess id in the pipeline that contains the original scene color
  68805. */
  68806. SSAOOriginalSceneColorEffect: string;
  68807. /**
  68808. * @ignore
  68809. * The SSAO PostProcess id in the pipeline
  68810. */
  68811. SSAORenderEffect: string;
  68812. /**
  68813. * @ignore
  68814. * The horizontal blur PostProcess id in the pipeline
  68815. */
  68816. SSAOBlurHRenderEffect: string;
  68817. /**
  68818. * @ignore
  68819. * The vertical blur PostProcess id in the pipeline
  68820. */
  68821. SSAOBlurVRenderEffect: string;
  68822. /**
  68823. * @ignore
  68824. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  68825. */
  68826. SSAOCombineRenderEffect: string;
  68827. /**
  68828. * The output strength of the SSAO post-process. Default value is 1.0.
  68829. */
  68830. totalStrength: number;
  68831. /**
  68832. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  68833. */
  68834. radius: number;
  68835. /**
  68836. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  68837. * Must not be equal to fallOff and superior to fallOff.
  68838. * Default value is 0.0075
  68839. */
  68840. area: number;
  68841. /**
  68842. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  68843. * Must not be equal to area and inferior to area.
  68844. * Default value is 0.000001
  68845. */
  68846. fallOff: number;
  68847. /**
  68848. * The base color of the SSAO post-process
  68849. * The final result is "base + ssao" between [0, 1]
  68850. */
  68851. base: number;
  68852. private _scene;
  68853. private _depthTexture;
  68854. private _randomTexture;
  68855. private _originalColorPostProcess;
  68856. private _ssaoPostProcess;
  68857. private _blurHPostProcess;
  68858. private _blurVPostProcess;
  68859. private _ssaoCombinePostProcess;
  68860. private _firstUpdate;
  68861. /**
  68862. * Gets active scene
  68863. */
  68864. get scene(): Scene;
  68865. /**
  68866. * @constructor
  68867. * @param name - The rendering pipeline name
  68868. * @param scene - The scene linked to this pipeline
  68869. * @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 }
  68870. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  68871. */
  68872. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  68873. /**
  68874. * Get the class name
  68875. * @returns "SSAORenderingPipeline"
  68876. */
  68877. getClassName(): string;
  68878. /**
  68879. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  68880. */
  68881. dispose(disableDepthRender?: boolean): void;
  68882. private _createBlurPostProcess;
  68883. /** @hidden */
  68884. _rebuild(): void;
  68885. private _createSSAOPostProcess;
  68886. private _createSSAOCombinePostProcess;
  68887. private _createRandomTexture;
  68888. }
  68889. }
  68890. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  68891. /** @hidden */
  68892. export var screenSpaceReflectionPixelShader: {
  68893. name: string;
  68894. shader: string;
  68895. };
  68896. }
  68897. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  68898. import { Nullable } from "babylonjs/types";
  68899. import { Camera } from "babylonjs/Cameras/camera";
  68900. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68901. import { Scene } from "babylonjs/scene";
  68902. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  68903. import { Engine } from "babylonjs/Engines/engine";
  68904. /**
  68905. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  68906. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  68907. */
  68908. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  68909. /**
  68910. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  68911. */
  68912. threshold: number;
  68913. /**
  68914. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  68915. */
  68916. strength: number;
  68917. /**
  68918. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  68919. */
  68920. reflectionSpecularFalloffExponent: number;
  68921. /**
  68922. * Gets or sets the step size used to iterate until the effect finds the color of the reflection's pixel. Typically in interval [0.1, 1.0]
  68923. */
  68924. step: number;
  68925. /**
  68926. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  68927. */
  68928. roughnessFactor: number;
  68929. private _geometryBufferRenderer;
  68930. private _enableSmoothReflections;
  68931. private _reflectionSamples;
  68932. private _smoothSteps;
  68933. /**
  68934. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  68935. * @param name The name of the effect.
  68936. * @param scene The scene containing the objects to calculate reflections.
  68937. * @param options The required width/height ratio to downsize to before computing the render pass.
  68938. * @param camera The camera to apply the render pass to.
  68939. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68940. * @param engine The engine which the post process will be applied. (default: current engine)
  68941. * @param reusable If the post process can be reused on the same frame. (default: false)
  68942. * @param textureType Type of textures used when performing the post process. (default: 0)
  68943. * @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)
  68944. */
  68945. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68946. /**
  68947. * Gets wether or not smoothing reflections is enabled.
  68948. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  68949. */
  68950. get enableSmoothReflections(): boolean;
  68951. /**
  68952. * Sets wether or not smoothing reflections is enabled.
  68953. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  68954. */
  68955. set enableSmoothReflections(enabled: boolean);
  68956. /**
  68957. * Gets the number of samples taken while computing reflections. More samples count is high,
  68958. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  68959. */
  68960. get reflectionSamples(): number;
  68961. /**
  68962. * Sets the number of samples taken while computing reflections. More samples count is high,
  68963. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  68964. */
  68965. set reflectionSamples(samples: number);
  68966. /**
  68967. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  68968. * more the post-process will require GPU power and can generate a drop in FPS.
  68969. * Default value (5.0) work pretty well in all cases but can be adjusted.
  68970. */
  68971. get smoothSteps(): number;
  68972. set smoothSteps(steps: number);
  68973. private _updateEffectDefines;
  68974. }
  68975. }
  68976. declare module "babylonjs/Shaders/standard.fragment" {
  68977. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  68978. /** @hidden */
  68979. export var standardPixelShader: {
  68980. name: string;
  68981. shader: string;
  68982. };
  68983. }
  68984. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  68985. import { Nullable } from "babylonjs/types";
  68986. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68987. import { Camera } from "babylonjs/Cameras/camera";
  68988. import { Texture } from "babylonjs/Materials/Textures/texture";
  68989. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  68990. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68991. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  68992. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  68993. import { IDisposable } from "babylonjs/scene";
  68994. import { SpotLight } from "babylonjs/Lights/spotLight";
  68995. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  68996. import { Scene } from "babylonjs/scene";
  68997. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  68998. import { Animation } from "babylonjs/Animations/animation";
  68999. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69000. import "babylonjs/Shaders/standard.fragment";
  69001. /**
  69002. * Standard rendering pipeline
  69003. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69004. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69005. */
  69006. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69007. /**
  69008. * Public members
  69009. */
  69010. /**
  69011. * Post-process which contains the original scene color before the pipeline applies all the effects
  69012. */
  69013. originalPostProcess: Nullable<PostProcess>;
  69014. /**
  69015. * Post-process used to down scale an image x4
  69016. */
  69017. downSampleX4PostProcess: Nullable<PostProcess>;
  69018. /**
  69019. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69020. */
  69021. brightPassPostProcess: Nullable<PostProcess>;
  69022. /**
  69023. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69024. */
  69025. blurHPostProcesses: PostProcess[];
  69026. /**
  69027. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69028. */
  69029. blurVPostProcesses: PostProcess[];
  69030. /**
  69031. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69032. */
  69033. textureAdderPostProcess: Nullable<PostProcess>;
  69034. /**
  69035. * Post-process used to create volumetric lighting effect
  69036. */
  69037. volumetricLightPostProcess: Nullable<PostProcess>;
  69038. /**
  69039. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69040. */
  69041. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69042. /**
  69043. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69044. */
  69045. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69046. /**
  69047. * Post-process used to merge the volumetric light effect and the real scene color
  69048. */
  69049. volumetricLightMergePostProces: Nullable<PostProcess>;
  69050. /**
  69051. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69052. */
  69053. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69054. /**
  69055. * Base post-process used to calculate the average luminance of the final image for HDR
  69056. */
  69057. luminancePostProcess: Nullable<PostProcess>;
  69058. /**
  69059. * Post-processes used to create down sample post-processes in order to get
  69060. * the average luminance of the final image for HDR
  69061. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69062. */
  69063. luminanceDownSamplePostProcesses: PostProcess[];
  69064. /**
  69065. * Post-process used to create a HDR effect (light adaptation)
  69066. */
  69067. hdrPostProcess: Nullable<PostProcess>;
  69068. /**
  69069. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69070. */
  69071. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69072. /**
  69073. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69074. */
  69075. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69076. /**
  69077. * Post-process used to merge the final HDR post-process and the real scene color
  69078. */
  69079. hdrFinalPostProcess: Nullable<PostProcess>;
  69080. /**
  69081. * Post-process used to create a lens flare effect
  69082. */
  69083. lensFlarePostProcess: Nullable<PostProcess>;
  69084. /**
  69085. * Post-process that merges the result of the lens flare post-process and the real scene color
  69086. */
  69087. lensFlareComposePostProcess: Nullable<PostProcess>;
  69088. /**
  69089. * Post-process used to create a motion blur effect
  69090. */
  69091. motionBlurPostProcess: Nullable<PostProcess>;
  69092. /**
  69093. * Post-process used to create a depth of field effect
  69094. */
  69095. depthOfFieldPostProcess: Nullable<PostProcess>;
  69096. /**
  69097. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69098. */
  69099. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69100. /**
  69101. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69102. */
  69103. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69104. /**
  69105. * Represents the brightness threshold in order to configure the illuminated surfaces
  69106. */
  69107. brightThreshold: number;
  69108. /**
  69109. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69110. */
  69111. blurWidth: number;
  69112. /**
  69113. * Sets if the blur for highlighted surfaces must be only horizontal
  69114. */
  69115. horizontalBlur: boolean;
  69116. /**
  69117. * Gets the overall exposure used by the pipeline
  69118. */
  69119. get exposure(): number;
  69120. /**
  69121. * Sets the overall exposure used by the pipeline
  69122. */
  69123. set exposure(value: number);
  69124. /**
  69125. * Texture used typically to simulate "dirty" on camera lens
  69126. */
  69127. lensTexture: Nullable<Texture>;
  69128. /**
  69129. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69130. */
  69131. volumetricLightCoefficient: number;
  69132. /**
  69133. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69134. */
  69135. volumetricLightPower: number;
  69136. /**
  69137. * Used the set the blur intensity to smooth the volumetric lights
  69138. */
  69139. volumetricLightBlurScale: number;
  69140. /**
  69141. * Light (spot or directional) used to generate the volumetric lights rays
  69142. * The source light must have a shadow generate so the pipeline can get its
  69143. * depth map
  69144. */
  69145. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69146. /**
  69147. * For eye adaptation, represents the minimum luminance the eye can see
  69148. */
  69149. hdrMinimumLuminance: number;
  69150. /**
  69151. * For eye adaptation, represents the decrease luminance speed
  69152. */
  69153. hdrDecreaseRate: number;
  69154. /**
  69155. * For eye adaptation, represents the increase luminance speed
  69156. */
  69157. hdrIncreaseRate: number;
  69158. /**
  69159. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69160. */
  69161. get hdrAutoExposure(): boolean;
  69162. /**
  69163. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69164. */
  69165. set hdrAutoExposure(value: boolean);
  69166. /**
  69167. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69168. */
  69169. lensColorTexture: Nullable<Texture>;
  69170. /**
  69171. * The overall strengh for the lens flare effect
  69172. */
  69173. lensFlareStrength: number;
  69174. /**
  69175. * Dispersion coefficient for lens flare ghosts
  69176. */
  69177. lensFlareGhostDispersal: number;
  69178. /**
  69179. * Main lens flare halo width
  69180. */
  69181. lensFlareHaloWidth: number;
  69182. /**
  69183. * Based on the lens distortion effect, defines how much the lens flare result
  69184. * is distorted
  69185. */
  69186. lensFlareDistortionStrength: number;
  69187. /**
  69188. * Configures the blur intensity used for for lens flare (halo)
  69189. */
  69190. lensFlareBlurWidth: number;
  69191. /**
  69192. * Lens star texture must be used to simulate rays on the flares and is available
  69193. * in the documentation
  69194. */
  69195. lensStarTexture: Nullable<Texture>;
  69196. /**
  69197. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69198. * flare effect by taking account of the dirt texture
  69199. */
  69200. lensFlareDirtTexture: Nullable<Texture>;
  69201. /**
  69202. * Represents the focal length for the depth of field effect
  69203. */
  69204. depthOfFieldDistance: number;
  69205. /**
  69206. * Represents the blur intensity for the blurred part of the depth of field effect
  69207. */
  69208. depthOfFieldBlurWidth: number;
  69209. /**
  69210. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69211. */
  69212. get motionStrength(): number;
  69213. /**
  69214. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69215. */
  69216. set motionStrength(strength: number);
  69217. /**
  69218. * Gets wether or not the motion blur post-process is object based or screen based.
  69219. */
  69220. get objectBasedMotionBlur(): boolean;
  69221. /**
  69222. * Sets wether or not the motion blur post-process should be object based or screen based
  69223. */
  69224. set objectBasedMotionBlur(value: boolean);
  69225. /**
  69226. * List of animations for the pipeline (IAnimatable implementation)
  69227. */
  69228. animations: Animation[];
  69229. /**
  69230. * Private members
  69231. */
  69232. private _scene;
  69233. private _currentDepthOfFieldSource;
  69234. private _basePostProcess;
  69235. private _fixedExposure;
  69236. private _currentExposure;
  69237. private _hdrAutoExposure;
  69238. private _hdrCurrentLuminance;
  69239. private _motionStrength;
  69240. private _isObjectBasedMotionBlur;
  69241. private _floatTextureType;
  69242. private _camerasToBeAttached;
  69243. private _ratio;
  69244. private _bloomEnabled;
  69245. private _depthOfFieldEnabled;
  69246. private _vlsEnabled;
  69247. private _lensFlareEnabled;
  69248. private _hdrEnabled;
  69249. private _motionBlurEnabled;
  69250. private _fxaaEnabled;
  69251. private _screenSpaceReflectionsEnabled;
  69252. private _motionBlurSamples;
  69253. private _volumetricLightStepsCount;
  69254. private _samples;
  69255. /**
  69256. * @ignore
  69257. * Specifies if the bloom pipeline is enabled
  69258. */
  69259. get BloomEnabled(): boolean;
  69260. set BloomEnabled(enabled: boolean);
  69261. /**
  69262. * @ignore
  69263. * Specifies if the depth of field pipeline is enabed
  69264. */
  69265. get DepthOfFieldEnabled(): boolean;
  69266. set DepthOfFieldEnabled(enabled: boolean);
  69267. /**
  69268. * @ignore
  69269. * Specifies if the lens flare pipeline is enabed
  69270. */
  69271. get LensFlareEnabled(): boolean;
  69272. set LensFlareEnabled(enabled: boolean);
  69273. /**
  69274. * @ignore
  69275. * Specifies if the HDR pipeline is enabled
  69276. */
  69277. get HDREnabled(): boolean;
  69278. set HDREnabled(enabled: boolean);
  69279. /**
  69280. * @ignore
  69281. * Specifies if the volumetric lights scattering effect is enabled
  69282. */
  69283. get VLSEnabled(): boolean;
  69284. set VLSEnabled(enabled: boolean);
  69285. /**
  69286. * @ignore
  69287. * Specifies if the motion blur effect is enabled
  69288. */
  69289. get MotionBlurEnabled(): boolean;
  69290. set MotionBlurEnabled(enabled: boolean);
  69291. /**
  69292. * Specifies if anti-aliasing is enabled
  69293. */
  69294. get fxaaEnabled(): boolean;
  69295. set fxaaEnabled(enabled: boolean);
  69296. /**
  69297. * Specifies if screen space reflections are enabled.
  69298. */
  69299. get screenSpaceReflectionsEnabled(): boolean;
  69300. set screenSpaceReflectionsEnabled(enabled: boolean);
  69301. /**
  69302. * Specifies the number of steps used to calculate the volumetric lights
  69303. * Typically in interval [50, 200]
  69304. */
  69305. get volumetricLightStepsCount(): number;
  69306. set volumetricLightStepsCount(count: number);
  69307. /**
  69308. * Specifies the number of samples used for the motion blur effect
  69309. * Typically in interval [16, 64]
  69310. */
  69311. get motionBlurSamples(): number;
  69312. set motionBlurSamples(samples: number);
  69313. /**
  69314. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69315. */
  69316. get samples(): number;
  69317. set samples(sampleCount: number);
  69318. /**
  69319. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69320. * @constructor
  69321. * @param name The rendering pipeline name
  69322. * @param scene The scene linked to this pipeline
  69323. * @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)
  69324. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69325. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69326. */
  69327. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69328. private _buildPipeline;
  69329. private _createDownSampleX4PostProcess;
  69330. private _createBrightPassPostProcess;
  69331. private _createBlurPostProcesses;
  69332. private _createTextureAdderPostProcess;
  69333. private _createVolumetricLightPostProcess;
  69334. private _createLuminancePostProcesses;
  69335. private _createHdrPostProcess;
  69336. private _createLensFlarePostProcess;
  69337. private _createDepthOfFieldPostProcess;
  69338. private _createMotionBlurPostProcess;
  69339. private _getDepthTexture;
  69340. private _disposePostProcesses;
  69341. /**
  69342. * Dispose of the pipeline and stop all post processes
  69343. */
  69344. dispose(): void;
  69345. /**
  69346. * Serialize the rendering pipeline (Used when exporting)
  69347. * @returns the serialized object
  69348. */
  69349. serialize(): any;
  69350. /**
  69351. * Parse the serialized pipeline
  69352. * @param source Source pipeline.
  69353. * @param scene The scene to load the pipeline to.
  69354. * @param rootUrl The URL of the serialized pipeline.
  69355. * @returns An instantiated pipeline from the serialized object.
  69356. */
  69357. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69358. /**
  69359. * Luminance steps
  69360. */
  69361. static LuminanceSteps: number;
  69362. }
  69363. }
  69364. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  69365. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  69366. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  69367. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  69368. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  69369. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  69370. }
  69371. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  69372. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  69373. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69374. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69375. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  69376. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69377. }
  69378. declare module "babylonjs/Shaders/tonemap.fragment" {
  69379. /** @hidden */
  69380. export var tonemapPixelShader: {
  69381. name: string;
  69382. shader: string;
  69383. };
  69384. }
  69385. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  69386. import { Camera } from "babylonjs/Cameras/camera";
  69387. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69388. import "babylonjs/Shaders/tonemap.fragment";
  69389. import { Engine } from "babylonjs/Engines/engine";
  69390. /** Defines operator used for tonemapping */
  69391. export enum TonemappingOperator {
  69392. /** Hable */
  69393. Hable = 0,
  69394. /** Reinhard */
  69395. Reinhard = 1,
  69396. /** HejiDawson */
  69397. HejiDawson = 2,
  69398. /** Photographic */
  69399. Photographic = 3
  69400. }
  69401. /**
  69402. * Defines a post process to apply tone mapping
  69403. */
  69404. export class TonemapPostProcess extends PostProcess {
  69405. private _operator;
  69406. /** Defines the required exposure adjustement */
  69407. exposureAdjustment: number;
  69408. /**
  69409. * Creates a new TonemapPostProcess
  69410. * @param name defines the name of the postprocess
  69411. * @param _operator defines the operator to use
  69412. * @param exposureAdjustment defines the required exposure adjustement
  69413. * @param camera defines the camera to use (can be null)
  69414. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  69415. * @param engine defines the hosting engine (can be ignore if camera is set)
  69416. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69417. */
  69418. constructor(name: string, _operator: TonemappingOperator,
  69419. /** Defines the required exposure adjustement */
  69420. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  69421. }
  69422. }
  69423. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  69424. /** @hidden */
  69425. export var volumetricLightScatteringPixelShader: {
  69426. name: string;
  69427. shader: string;
  69428. };
  69429. }
  69430. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  69431. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  69432. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  69433. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  69434. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  69435. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  69436. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  69437. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  69438. /** @hidden */
  69439. export var volumetricLightScatteringPassVertexShader: {
  69440. name: string;
  69441. shader: string;
  69442. };
  69443. }
  69444. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  69445. /** @hidden */
  69446. export var volumetricLightScatteringPassPixelShader: {
  69447. name: string;
  69448. shader: string;
  69449. };
  69450. }
  69451. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  69452. import { Vector3 } from "babylonjs/Maths/math.vector";
  69453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69454. import { Mesh } from "babylonjs/Meshes/mesh";
  69455. import { Camera } from "babylonjs/Cameras/camera";
  69456. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  69457. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69458. import { Scene } from "babylonjs/scene";
  69459. import "babylonjs/Meshes/Builders/planeBuilder";
  69460. import "babylonjs/Shaders/depth.vertex";
  69461. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  69462. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  69463. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  69464. import { Engine } from "babylonjs/Engines/engine";
  69465. /**
  69466. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  69467. */
  69468. export class VolumetricLightScatteringPostProcess extends PostProcess {
  69469. private _volumetricLightScatteringPass;
  69470. private _volumetricLightScatteringRTT;
  69471. private _viewPort;
  69472. private _screenCoordinates;
  69473. private _cachedDefines;
  69474. /**
  69475. * If not undefined, the mesh position is computed from the attached node position
  69476. */
  69477. attachedNode: {
  69478. position: Vector3;
  69479. };
  69480. /**
  69481. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  69482. */
  69483. customMeshPosition: Vector3;
  69484. /**
  69485. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  69486. */
  69487. useCustomMeshPosition: boolean;
  69488. /**
  69489. * If the post-process should inverse the light scattering direction
  69490. */
  69491. invert: boolean;
  69492. /**
  69493. * The internal mesh used by the post-process
  69494. */
  69495. mesh: Mesh;
  69496. /**
  69497. * @hidden
  69498. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  69499. */
  69500. get useDiffuseColor(): boolean;
  69501. set useDiffuseColor(useDiffuseColor: boolean);
  69502. /**
  69503. * Array containing the excluded meshes not rendered in the internal pass
  69504. */
  69505. excludedMeshes: AbstractMesh[];
  69506. /**
  69507. * Controls the overall intensity of the post-process
  69508. */
  69509. exposure: number;
  69510. /**
  69511. * Dissipates each sample's contribution in range [0, 1]
  69512. */
  69513. decay: number;
  69514. /**
  69515. * Controls the overall intensity of each sample
  69516. */
  69517. weight: number;
  69518. /**
  69519. * Controls the density of each sample
  69520. */
  69521. density: number;
  69522. /**
  69523. * @constructor
  69524. * @param name The post-process name
  69525. * @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)
  69526. * @param camera The camera that the post-process will be attached to
  69527. * @param mesh The mesh used to create the light scattering
  69528. * @param samples The post-process quality, default 100
  69529. * @param samplingModeThe post-process filtering mode
  69530. * @param engine The babylon engine
  69531. * @param reusable If the post-process is reusable
  69532. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  69533. */
  69534. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  69535. /**
  69536. * Returns the string "VolumetricLightScatteringPostProcess"
  69537. * @returns "VolumetricLightScatteringPostProcess"
  69538. */
  69539. getClassName(): string;
  69540. private _isReady;
  69541. /**
  69542. * Sets the new light position for light scattering effect
  69543. * @param position The new custom light position
  69544. */
  69545. setCustomMeshPosition(position: Vector3): void;
  69546. /**
  69547. * Returns the light position for light scattering effect
  69548. * @return Vector3 The custom light position
  69549. */
  69550. getCustomMeshPosition(): Vector3;
  69551. /**
  69552. * Disposes the internal assets and detaches the post-process from the camera
  69553. */
  69554. dispose(camera: Camera): void;
  69555. /**
  69556. * Returns the render target texture used by the post-process
  69557. * @return the render target texture used by the post-process
  69558. */
  69559. getPass(): RenderTargetTexture;
  69560. private _meshExcluded;
  69561. private _createPass;
  69562. private _updateMeshScreenCoordinates;
  69563. /**
  69564. * Creates a default mesh for the Volumeric Light Scattering post-process
  69565. * @param name The mesh name
  69566. * @param scene The scene where to create the mesh
  69567. * @return the default mesh
  69568. */
  69569. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  69570. }
  69571. }
  69572. declare module "babylonjs/PostProcesses/index" {
  69573. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  69574. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  69575. export * from "babylonjs/PostProcesses/bloomEffect";
  69576. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  69577. export * from "babylonjs/PostProcesses/blurPostProcess";
  69578. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  69579. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  69580. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  69581. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  69582. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  69583. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  69584. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  69585. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  69586. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  69587. export * from "babylonjs/PostProcesses/filterPostProcess";
  69588. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  69589. export * from "babylonjs/PostProcesses/grainPostProcess";
  69590. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  69591. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  69592. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  69593. export * from "babylonjs/PostProcesses/passPostProcess";
  69594. export * from "babylonjs/PostProcesses/postProcess";
  69595. export * from "babylonjs/PostProcesses/postProcessManager";
  69596. export * from "babylonjs/PostProcesses/refractionPostProcess";
  69597. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  69598. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  69599. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  69600. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  69601. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  69602. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  69603. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  69604. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69605. }
  69606. declare module "babylonjs/Probes/index" {
  69607. export * from "babylonjs/Probes/reflectionProbe";
  69608. }
  69609. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  69610. import { Scene } from "babylonjs/scene";
  69611. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69612. import { SmartArray } from "babylonjs/Misc/smartArray";
  69613. import { ISceneComponent } from "babylonjs/sceneComponent";
  69614. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  69615. import "babylonjs/Meshes/Builders/boxBuilder";
  69616. import "babylonjs/Shaders/color.fragment";
  69617. import "babylonjs/Shaders/color.vertex";
  69618. import { Color3 } from "babylonjs/Maths/math.color";
  69619. module "babylonjs/scene" {
  69620. interface Scene {
  69621. /** @hidden (Backing field) */
  69622. _boundingBoxRenderer: BoundingBoxRenderer;
  69623. /** @hidden (Backing field) */
  69624. _forceShowBoundingBoxes: boolean;
  69625. /**
  69626. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  69627. */
  69628. forceShowBoundingBoxes: boolean;
  69629. /**
  69630. * Gets the bounding box renderer associated with the scene
  69631. * @returns a BoundingBoxRenderer
  69632. */
  69633. getBoundingBoxRenderer(): BoundingBoxRenderer;
  69634. }
  69635. }
  69636. module "babylonjs/Meshes/abstractMesh" {
  69637. interface AbstractMesh {
  69638. /** @hidden (Backing field) */
  69639. _showBoundingBox: boolean;
  69640. /**
  69641. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  69642. */
  69643. showBoundingBox: boolean;
  69644. }
  69645. }
  69646. /**
  69647. * Component responsible of rendering the bounding box of the meshes in a scene.
  69648. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  69649. */
  69650. export class BoundingBoxRenderer implements ISceneComponent {
  69651. /**
  69652. * The component name helpfull to identify the component in the list of scene components.
  69653. */
  69654. readonly name: string;
  69655. /**
  69656. * The scene the component belongs to.
  69657. */
  69658. scene: Scene;
  69659. /**
  69660. * Color of the bounding box lines placed in front of an object
  69661. */
  69662. frontColor: Color3;
  69663. /**
  69664. * Color of the bounding box lines placed behind an object
  69665. */
  69666. backColor: Color3;
  69667. /**
  69668. * Defines if the renderer should show the back lines or not
  69669. */
  69670. showBackLines: boolean;
  69671. /**
  69672. * @hidden
  69673. */
  69674. renderList: SmartArray<BoundingBox>;
  69675. private _colorShader;
  69676. private _vertexBuffers;
  69677. private _indexBuffer;
  69678. private _fillIndexBuffer;
  69679. private _fillIndexData;
  69680. /**
  69681. * Instantiates a new bounding box renderer in a scene.
  69682. * @param scene the scene the renderer renders in
  69683. */
  69684. constructor(scene: Scene);
  69685. /**
  69686. * Registers the component in a given scene
  69687. */
  69688. register(): void;
  69689. private _evaluateSubMesh;
  69690. private _activeMesh;
  69691. private _prepareRessources;
  69692. private _createIndexBuffer;
  69693. /**
  69694. * Rebuilds the elements related to this component in case of
  69695. * context lost for instance.
  69696. */
  69697. rebuild(): void;
  69698. /**
  69699. * @hidden
  69700. */
  69701. reset(): void;
  69702. /**
  69703. * Render the bounding boxes of a specific rendering group
  69704. * @param renderingGroupId defines the rendering group to render
  69705. */
  69706. render(renderingGroupId: number): void;
  69707. /**
  69708. * In case of occlusion queries, we can render the occlusion bounding box through this method
  69709. * @param mesh Define the mesh to render the occlusion bounding box for
  69710. */
  69711. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  69712. /**
  69713. * Dispose and release the resources attached to this renderer.
  69714. */
  69715. dispose(): void;
  69716. }
  69717. }
  69718. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  69719. import { Nullable } from "babylonjs/types";
  69720. import { Scene } from "babylonjs/scene";
  69721. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  69722. import { Camera } from "babylonjs/Cameras/camera";
  69723. import { ISceneComponent } from "babylonjs/sceneComponent";
  69724. module "babylonjs/scene" {
  69725. interface Scene {
  69726. /** @hidden (Backing field) */
  69727. _depthRenderer: {
  69728. [id: string]: DepthRenderer;
  69729. };
  69730. /**
  69731. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  69732. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  69733. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  69734. * @returns the created depth renderer
  69735. */
  69736. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  69737. /**
  69738. * Disables a depth renderer for a given camera
  69739. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  69740. */
  69741. disableDepthRenderer(camera?: Nullable<Camera>): void;
  69742. }
  69743. }
  69744. /**
  69745. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  69746. * in several rendering techniques.
  69747. */
  69748. export class DepthRendererSceneComponent implements ISceneComponent {
  69749. /**
  69750. * The component name helpfull to identify the component in the list of scene components.
  69751. */
  69752. readonly name: string;
  69753. /**
  69754. * The scene the component belongs to.
  69755. */
  69756. scene: Scene;
  69757. /**
  69758. * Creates a new instance of the component for the given scene
  69759. * @param scene Defines the scene to register the component in
  69760. */
  69761. constructor(scene: Scene);
  69762. /**
  69763. * Registers the component in a given scene
  69764. */
  69765. register(): void;
  69766. /**
  69767. * Rebuilds the elements related to this component in case of
  69768. * context lost for instance.
  69769. */
  69770. rebuild(): void;
  69771. /**
  69772. * Disposes the component and the associated ressources
  69773. */
  69774. dispose(): void;
  69775. private _gatherRenderTargets;
  69776. private _gatherActiveCameraRenderTargets;
  69777. }
  69778. }
  69779. declare module "babylonjs/Shaders/outline.fragment" {
  69780. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  69781. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  69782. /** @hidden */
  69783. export var outlinePixelShader: {
  69784. name: string;
  69785. shader: string;
  69786. };
  69787. }
  69788. declare module "babylonjs/Shaders/outline.vertex" {
  69789. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  69790. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  69791. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  69792. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  69793. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  69794. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  69795. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  69796. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  69797. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  69798. /** @hidden */
  69799. export var outlineVertexShader: {
  69800. name: string;
  69801. shader: string;
  69802. };
  69803. }
  69804. declare module "babylonjs/Rendering/outlineRenderer" {
  69805. import { SubMesh } from "babylonjs/Meshes/subMesh";
  69806. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  69807. import { Scene } from "babylonjs/scene";
  69808. import { ISceneComponent } from "babylonjs/sceneComponent";
  69809. import "babylonjs/Shaders/outline.fragment";
  69810. import "babylonjs/Shaders/outline.vertex";
  69811. module "babylonjs/scene" {
  69812. interface Scene {
  69813. /** @hidden */
  69814. _outlineRenderer: OutlineRenderer;
  69815. /**
  69816. * Gets the outline renderer associated with the scene
  69817. * @returns a OutlineRenderer
  69818. */
  69819. getOutlineRenderer(): OutlineRenderer;
  69820. }
  69821. }
  69822. module "babylonjs/Meshes/abstractMesh" {
  69823. interface AbstractMesh {
  69824. /** @hidden (Backing field) */
  69825. _renderOutline: boolean;
  69826. /**
  69827. * Gets or sets a boolean indicating if the outline must be rendered as well
  69828. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  69829. */
  69830. renderOutline: boolean;
  69831. /** @hidden (Backing field) */
  69832. _renderOverlay: boolean;
  69833. /**
  69834. * Gets or sets a boolean indicating if the overlay must be rendered as well
  69835. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  69836. */
  69837. renderOverlay: boolean;
  69838. }
  69839. }
  69840. /**
  69841. * This class is responsible to draw bothe outline/overlay of meshes.
  69842. * It should not be used directly but through the available method on mesh.
  69843. */
  69844. export class OutlineRenderer implements ISceneComponent {
  69845. /**
  69846. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  69847. */
  69848. private static _StencilReference;
  69849. /**
  69850. * The name of the component. Each component must have a unique name.
  69851. */
  69852. name: string;
  69853. /**
  69854. * The scene the component belongs to.
  69855. */
  69856. scene: Scene;
  69857. /**
  69858. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  69859. */
  69860. zOffset: number;
  69861. private _engine;
  69862. private _effect;
  69863. private _cachedDefines;
  69864. private _savedDepthWrite;
  69865. /**
  69866. * Instantiates a new outline renderer. (There could be only one per scene).
  69867. * @param scene Defines the scene it belongs to
  69868. */
  69869. constructor(scene: Scene);
  69870. /**
  69871. * Register the component to one instance of a scene.
  69872. */
  69873. register(): void;
  69874. /**
  69875. * Rebuilds the elements related to this component in case of
  69876. * context lost for instance.
  69877. */
  69878. rebuild(): void;
  69879. /**
  69880. * Disposes the component and the associated ressources.
  69881. */
  69882. dispose(): void;
  69883. /**
  69884. * Renders the outline in the canvas.
  69885. * @param subMesh Defines the sumesh to render
  69886. * @param batch Defines the batch of meshes in case of instances
  69887. * @param useOverlay Defines if the rendering is for the overlay or the outline
  69888. */
  69889. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  69890. /**
  69891. * Returns whether or not the outline renderer is ready for a given submesh.
  69892. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  69893. * @param subMesh Defines the submesh to check readyness for
  69894. * @param useInstances Defines wheter wee are trying to render instances or not
  69895. * @returns true if ready otherwise false
  69896. */
  69897. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69898. private _beforeRenderingMesh;
  69899. private _afterRenderingMesh;
  69900. }
  69901. }
  69902. declare module "babylonjs/Rendering/index" {
  69903. export * from "babylonjs/Rendering/boundingBoxRenderer";
  69904. export * from "babylonjs/Rendering/depthRenderer";
  69905. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  69906. export * from "babylonjs/Rendering/edgesRenderer";
  69907. export * from "babylonjs/Rendering/geometryBufferRenderer";
  69908. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  69909. export * from "babylonjs/Rendering/outlineRenderer";
  69910. export * from "babylonjs/Rendering/renderingGroup";
  69911. export * from "babylonjs/Rendering/renderingManager";
  69912. export * from "babylonjs/Rendering/utilityLayerRenderer";
  69913. }
  69914. declare module "babylonjs/Sprites/ISprites" {
  69915. /**
  69916. * Defines the basic options interface of a Sprite Frame Source Size.
  69917. */
  69918. export interface ISpriteJSONSpriteSourceSize {
  69919. /**
  69920. * number of the original width of the Frame
  69921. */
  69922. w: number;
  69923. /**
  69924. * number of the original height of the Frame
  69925. */
  69926. h: number;
  69927. }
  69928. /**
  69929. * Defines the basic options interface of a Sprite Frame Data.
  69930. */
  69931. export interface ISpriteJSONSpriteFrameData {
  69932. /**
  69933. * number of the x offset of the Frame
  69934. */
  69935. x: number;
  69936. /**
  69937. * number of the y offset of the Frame
  69938. */
  69939. y: number;
  69940. /**
  69941. * number of the width of the Frame
  69942. */
  69943. w: number;
  69944. /**
  69945. * number of the height of the Frame
  69946. */
  69947. h: number;
  69948. }
  69949. /**
  69950. * Defines the basic options interface of a JSON Sprite.
  69951. */
  69952. export interface ISpriteJSONSprite {
  69953. /**
  69954. * string name of the Frame
  69955. */
  69956. filename: string;
  69957. /**
  69958. * ISpriteJSONSpriteFrame basic object of the frame data
  69959. */
  69960. frame: ISpriteJSONSpriteFrameData;
  69961. /**
  69962. * boolean to flag is the frame was rotated.
  69963. */
  69964. rotated: boolean;
  69965. /**
  69966. * boolean to flag is the frame was trimmed.
  69967. */
  69968. trimmed: boolean;
  69969. /**
  69970. * ISpriteJSONSpriteFrame basic object of the source data
  69971. */
  69972. spriteSourceSize: ISpriteJSONSpriteFrameData;
  69973. /**
  69974. * ISpriteJSONSpriteFrame basic object of the source data
  69975. */
  69976. sourceSize: ISpriteJSONSpriteSourceSize;
  69977. }
  69978. /**
  69979. * Defines the basic options interface of a JSON atlas.
  69980. */
  69981. export interface ISpriteJSONAtlas {
  69982. /**
  69983. * Array of objects that contain the frame data.
  69984. */
  69985. frames: Array<ISpriteJSONSprite>;
  69986. /**
  69987. * object basic object containing the sprite meta data.
  69988. */
  69989. meta?: object;
  69990. }
  69991. }
  69992. declare module "babylonjs/Shaders/spriteMap.fragment" {
  69993. /** @hidden */
  69994. export var spriteMapPixelShader: {
  69995. name: string;
  69996. shader: string;
  69997. };
  69998. }
  69999. declare module "babylonjs/Shaders/spriteMap.vertex" {
  70000. /** @hidden */
  70001. export var spriteMapVertexShader: {
  70002. name: string;
  70003. shader: string;
  70004. };
  70005. }
  70006. declare module "babylonjs/Sprites/spriteMap" {
  70007. import { IDisposable, Scene } from "babylonjs/scene";
  70008. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  70009. import { Texture } from "babylonjs/Materials/Textures/texture";
  70010. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70011. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  70012. import "babylonjs/Meshes/Builders/planeBuilder";
  70013. import "babylonjs/Shaders/spriteMap.fragment";
  70014. import "babylonjs/Shaders/spriteMap.vertex";
  70015. /**
  70016. * Defines the basic options interface of a SpriteMap
  70017. */
  70018. export interface ISpriteMapOptions {
  70019. /**
  70020. * Vector2 of the number of cells in the grid.
  70021. */
  70022. stageSize?: Vector2;
  70023. /**
  70024. * Vector2 of the size of the output plane in World Units.
  70025. */
  70026. outputSize?: Vector2;
  70027. /**
  70028. * Vector3 of the position of the output plane in World Units.
  70029. */
  70030. outputPosition?: Vector3;
  70031. /**
  70032. * Vector3 of the rotation of the output plane.
  70033. */
  70034. outputRotation?: Vector3;
  70035. /**
  70036. * number of layers that the system will reserve in resources.
  70037. */
  70038. layerCount?: number;
  70039. /**
  70040. * number of max animation frames a single cell will reserve in resources.
  70041. */
  70042. maxAnimationFrames?: number;
  70043. /**
  70044. * number cell index of the base tile when the system compiles.
  70045. */
  70046. baseTile?: number;
  70047. /**
  70048. * boolean flip the sprite after its been repositioned by the framing data.
  70049. */
  70050. flipU?: boolean;
  70051. /**
  70052. * Vector3 scalar of the global RGB values of the SpriteMap.
  70053. */
  70054. colorMultiply?: Vector3;
  70055. }
  70056. /**
  70057. * Defines the IDisposable interface in order to be cleanable from resources.
  70058. */
  70059. export interface ISpriteMap extends IDisposable {
  70060. /**
  70061. * String name of the SpriteMap.
  70062. */
  70063. name: string;
  70064. /**
  70065. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70066. */
  70067. atlasJSON: ISpriteJSONAtlas;
  70068. /**
  70069. * Texture of the SpriteMap.
  70070. */
  70071. spriteSheet: Texture;
  70072. /**
  70073. * The parameters to initialize the SpriteMap with.
  70074. */
  70075. options: ISpriteMapOptions;
  70076. }
  70077. /**
  70078. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70079. */
  70080. export class SpriteMap implements ISpriteMap {
  70081. /** The Name of the spriteMap */
  70082. name: string;
  70083. /** The JSON file with the frame and meta data */
  70084. atlasJSON: ISpriteJSONAtlas;
  70085. /** The systems Sprite Sheet Texture */
  70086. spriteSheet: Texture;
  70087. /** Arguments passed with the Constructor */
  70088. options: ISpriteMapOptions;
  70089. /** Public Sprite Storage array, parsed from atlasJSON */
  70090. sprites: Array<ISpriteJSONSprite>;
  70091. /** Returns the Number of Sprites in the System */
  70092. get spriteCount(): number;
  70093. /** Returns the Position of Output Plane*/
  70094. get position(): Vector3;
  70095. /** Returns the Position of Output Plane*/
  70096. set position(v: Vector3);
  70097. /** Returns the Rotation of Output Plane*/
  70098. get rotation(): Vector3;
  70099. /** Returns the Rotation of Output Plane*/
  70100. set rotation(v: Vector3);
  70101. /** Sets the AnimationMap*/
  70102. get animationMap(): RawTexture;
  70103. /** Sets the AnimationMap*/
  70104. set animationMap(v: RawTexture);
  70105. /** Scene that the SpriteMap was created in */
  70106. private _scene;
  70107. /** Texture Buffer of Float32 that holds tile frame data*/
  70108. private _frameMap;
  70109. /** Texture Buffers of Float32 that holds tileMap data*/
  70110. private _tileMaps;
  70111. /** Texture Buffer of Float32 that holds Animation Data*/
  70112. private _animationMap;
  70113. /** Custom ShaderMaterial Central to the System*/
  70114. private _material;
  70115. /** Custom ShaderMaterial Central to the System*/
  70116. private _output;
  70117. /** Systems Time Ticker*/
  70118. private _time;
  70119. /**
  70120. * Creates a new SpriteMap
  70121. * @param name defines the SpriteMaps Name
  70122. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70123. * @param spriteSheet is the Texture that the Sprites are on.
  70124. * @param options a basic deployment configuration
  70125. * @param scene The Scene that the map is deployed on
  70126. */
  70127. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70128. /**
  70129. * Returns tileID location
  70130. * @returns Vector2 the cell position ID
  70131. */
  70132. getTileID(): Vector2;
  70133. /**
  70134. * Gets the UV location of the mouse over the SpriteMap.
  70135. * @returns Vector2 the UV position of the mouse interaction
  70136. */
  70137. getMousePosition(): Vector2;
  70138. /**
  70139. * Creates the "frame" texture Buffer
  70140. * -------------------------------------
  70141. * Structure of frames
  70142. * "filename": "Falling-Water-2.png",
  70143. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70144. * "rotated": true,
  70145. * "trimmed": true,
  70146. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70147. * "sourceSize": {"w":32,"h":32}
  70148. * @returns RawTexture of the frameMap
  70149. */
  70150. private _createFrameBuffer;
  70151. /**
  70152. * Creates the tileMap texture Buffer
  70153. * @param buffer normally and array of numbers, or a false to generate from scratch
  70154. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70155. * @returns RawTexture of the tileMap
  70156. */
  70157. private _createTileBuffer;
  70158. /**
  70159. * Modifies the data of the tileMaps
  70160. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70161. * @param pos is the iVector2 Coordinates of the Tile
  70162. * @param tile The SpriteIndex of the new Tile
  70163. */
  70164. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70165. /**
  70166. * Creates the animationMap texture Buffer
  70167. * @param buffer normally and array of numbers, or a false to generate from scratch
  70168. * @returns RawTexture of the animationMap
  70169. */
  70170. private _createTileAnimationBuffer;
  70171. /**
  70172. * Modifies the data of the animationMap
  70173. * @param cellID is the Index of the Sprite
  70174. * @param _frame is the target Animation frame
  70175. * @param toCell is the Target Index of the next frame of the animation
  70176. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70177. * @param speed is a global scalar of the time variable on the map.
  70178. */
  70179. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70180. /**
  70181. * Exports the .tilemaps file
  70182. */
  70183. saveTileMaps(): void;
  70184. /**
  70185. * Imports the .tilemaps file
  70186. * @param url of the .tilemaps file
  70187. */
  70188. loadTileMaps(url: string): void;
  70189. /**
  70190. * Release associated resources
  70191. */
  70192. dispose(): void;
  70193. }
  70194. }
  70195. declare module "babylonjs/Sprites/spritePackedManager" {
  70196. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  70197. import { Scene } from "babylonjs/scene";
  70198. /**
  70199. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70200. * @see http://doc.babylonjs.com/babylon101/sprites
  70201. */
  70202. export class SpritePackedManager extends SpriteManager {
  70203. /** defines the packed manager's name */
  70204. name: string;
  70205. /**
  70206. * Creates a new sprite manager from a packed sprite sheet
  70207. * @param name defines the manager's name
  70208. * @param imgUrl defines the sprite sheet url
  70209. * @param capacity defines the maximum allowed number of sprites
  70210. * @param scene defines the hosting scene
  70211. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70212. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70213. * @param samplingMode defines the smapling mode to use with spritesheet
  70214. * @param fromPacked set to true; do not alter
  70215. */
  70216. constructor(
  70217. /** defines the packed manager's name */
  70218. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70219. }
  70220. }
  70221. declare module "babylonjs/Sprites/index" {
  70222. export * from "babylonjs/Sprites/sprite";
  70223. export * from "babylonjs/Sprites/ISprites";
  70224. export * from "babylonjs/Sprites/spriteManager";
  70225. export * from "babylonjs/Sprites/spriteMap";
  70226. export * from "babylonjs/Sprites/spritePackedManager";
  70227. export * from "babylonjs/Sprites/spriteSceneComponent";
  70228. }
  70229. declare module "babylonjs/States/index" {
  70230. export * from "babylonjs/States/alphaCullingState";
  70231. export * from "babylonjs/States/depthCullingState";
  70232. export * from "babylonjs/States/stencilState";
  70233. }
  70234. declare module "babylonjs/Misc/assetsManager" {
  70235. import { Scene } from "babylonjs/scene";
  70236. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70237. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70238. import { Skeleton } from "babylonjs/Bones/skeleton";
  70239. import { Observable } from "babylonjs/Misc/observable";
  70240. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  70241. import { Texture } from "babylonjs/Materials/Textures/texture";
  70242. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  70243. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  70244. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  70245. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  70246. /**
  70247. * Defines the list of states available for a task inside a AssetsManager
  70248. */
  70249. export enum AssetTaskState {
  70250. /**
  70251. * Initialization
  70252. */
  70253. INIT = 0,
  70254. /**
  70255. * Running
  70256. */
  70257. RUNNING = 1,
  70258. /**
  70259. * Done
  70260. */
  70261. DONE = 2,
  70262. /**
  70263. * Error
  70264. */
  70265. ERROR = 3
  70266. }
  70267. /**
  70268. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70269. */
  70270. export abstract class AbstractAssetTask {
  70271. /**
  70272. * Task name
  70273. */ name: string;
  70274. /**
  70275. * Callback called when the task is successful
  70276. */
  70277. onSuccess: (task: any) => void;
  70278. /**
  70279. * Callback called when the task is not successful
  70280. */
  70281. onError: (task: any, message?: string, exception?: any) => void;
  70282. /**
  70283. * Creates a new AssetsManager
  70284. * @param name defines the name of the task
  70285. */
  70286. constructor(
  70287. /**
  70288. * Task name
  70289. */ name: string);
  70290. private _isCompleted;
  70291. private _taskState;
  70292. private _errorObject;
  70293. /**
  70294. * Get if the task is completed
  70295. */
  70296. get isCompleted(): boolean;
  70297. /**
  70298. * Gets the current state of the task
  70299. */
  70300. get taskState(): AssetTaskState;
  70301. /**
  70302. * Gets the current error object (if task is in error)
  70303. */
  70304. get errorObject(): {
  70305. message?: string;
  70306. exception?: any;
  70307. };
  70308. /**
  70309. * Internal only
  70310. * @hidden
  70311. */
  70312. _setErrorObject(message?: string, exception?: any): void;
  70313. /**
  70314. * Execute the current task
  70315. * @param scene defines the scene where you want your assets to be loaded
  70316. * @param onSuccess is a callback called when the task is successfully executed
  70317. * @param onError is a callback called if an error occurs
  70318. */
  70319. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70320. /**
  70321. * Execute the current task
  70322. * @param scene defines the scene where you want your assets to be loaded
  70323. * @param onSuccess is a callback called when the task is successfully executed
  70324. * @param onError is a callback called if an error occurs
  70325. */
  70326. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70327. /**
  70328. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70329. * This can be used with failed tasks that have the reason for failure fixed.
  70330. */
  70331. reset(): void;
  70332. private onErrorCallback;
  70333. private onDoneCallback;
  70334. }
  70335. /**
  70336. * Define the interface used by progress events raised during assets loading
  70337. */
  70338. export interface IAssetsProgressEvent {
  70339. /**
  70340. * Defines the number of remaining tasks to process
  70341. */
  70342. remainingCount: number;
  70343. /**
  70344. * Defines the total number of tasks
  70345. */
  70346. totalCount: number;
  70347. /**
  70348. * Defines the task that was just processed
  70349. */
  70350. task: AbstractAssetTask;
  70351. }
  70352. /**
  70353. * Class used to share progress information about assets loading
  70354. */
  70355. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70356. /**
  70357. * Defines the number of remaining tasks to process
  70358. */
  70359. remainingCount: number;
  70360. /**
  70361. * Defines the total number of tasks
  70362. */
  70363. totalCount: number;
  70364. /**
  70365. * Defines the task that was just processed
  70366. */
  70367. task: AbstractAssetTask;
  70368. /**
  70369. * Creates a AssetsProgressEvent
  70370. * @param remainingCount defines the number of remaining tasks to process
  70371. * @param totalCount defines the total number of tasks
  70372. * @param task defines the task that was just processed
  70373. */
  70374. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70375. }
  70376. /**
  70377. * Define a task used by AssetsManager to load meshes
  70378. */
  70379. export class MeshAssetTask extends AbstractAssetTask {
  70380. /**
  70381. * Defines the name of the task
  70382. */
  70383. name: string;
  70384. /**
  70385. * Defines the list of mesh's names you want to load
  70386. */
  70387. meshesNames: any;
  70388. /**
  70389. * Defines the root url to use as a base to load your meshes and associated resources
  70390. */
  70391. rootUrl: string;
  70392. /**
  70393. * Defines the filename of the scene to load from
  70394. */
  70395. sceneFilename: string;
  70396. /**
  70397. * Gets the list of loaded meshes
  70398. */
  70399. loadedMeshes: Array<AbstractMesh>;
  70400. /**
  70401. * Gets the list of loaded particle systems
  70402. */
  70403. loadedParticleSystems: Array<IParticleSystem>;
  70404. /**
  70405. * Gets the list of loaded skeletons
  70406. */
  70407. loadedSkeletons: Array<Skeleton>;
  70408. /**
  70409. * Gets the list of loaded animation groups
  70410. */
  70411. loadedAnimationGroups: Array<AnimationGroup>;
  70412. /**
  70413. * Callback called when the task is successful
  70414. */
  70415. onSuccess: (task: MeshAssetTask) => void;
  70416. /**
  70417. * Callback called when the task is successful
  70418. */
  70419. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70420. /**
  70421. * Creates a new MeshAssetTask
  70422. * @param name defines the name of the task
  70423. * @param meshesNames defines the list of mesh's names you want to load
  70424. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70425. * @param sceneFilename defines the filename of the scene to load from
  70426. */
  70427. constructor(
  70428. /**
  70429. * Defines the name of the task
  70430. */
  70431. name: string,
  70432. /**
  70433. * Defines the list of mesh's names you want to load
  70434. */
  70435. meshesNames: any,
  70436. /**
  70437. * Defines the root url to use as a base to load your meshes and associated resources
  70438. */
  70439. rootUrl: string,
  70440. /**
  70441. * Defines the filename of the scene to load from
  70442. */
  70443. sceneFilename: string);
  70444. /**
  70445. * Execute the current task
  70446. * @param scene defines the scene where you want your assets to be loaded
  70447. * @param onSuccess is a callback called when the task is successfully executed
  70448. * @param onError is a callback called if an error occurs
  70449. */
  70450. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70451. }
  70452. /**
  70453. * Define a task used by AssetsManager to load text content
  70454. */
  70455. export class TextFileAssetTask extends AbstractAssetTask {
  70456. /**
  70457. * Defines the name of the task
  70458. */
  70459. name: string;
  70460. /**
  70461. * Defines the location of the file to load
  70462. */
  70463. url: string;
  70464. /**
  70465. * Gets the loaded text string
  70466. */
  70467. text: string;
  70468. /**
  70469. * Callback called when the task is successful
  70470. */
  70471. onSuccess: (task: TextFileAssetTask) => void;
  70472. /**
  70473. * Callback called when the task is successful
  70474. */
  70475. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70476. /**
  70477. * Creates a new TextFileAssetTask object
  70478. * @param name defines the name of the task
  70479. * @param url defines the location of the file to load
  70480. */
  70481. constructor(
  70482. /**
  70483. * Defines the name of the task
  70484. */
  70485. name: string,
  70486. /**
  70487. * Defines the location of the file to load
  70488. */
  70489. url: string);
  70490. /**
  70491. * Execute the current task
  70492. * @param scene defines the scene where you want your assets to be loaded
  70493. * @param onSuccess is a callback called when the task is successfully executed
  70494. * @param onError is a callback called if an error occurs
  70495. */
  70496. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70497. }
  70498. /**
  70499. * Define a task used by AssetsManager to load binary data
  70500. */
  70501. export class BinaryFileAssetTask extends AbstractAssetTask {
  70502. /**
  70503. * Defines the name of the task
  70504. */
  70505. name: string;
  70506. /**
  70507. * Defines the location of the file to load
  70508. */
  70509. url: string;
  70510. /**
  70511. * Gets the lodaded data (as an array buffer)
  70512. */
  70513. data: ArrayBuffer;
  70514. /**
  70515. * Callback called when the task is successful
  70516. */
  70517. onSuccess: (task: BinaryFileAssetTask) => void;
  70518. /**
  70519. * Callback called when the task is successful
  70520. */
  70521. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  70522. /**
  70523. * Creates a new BinaryFileAssetTask object
  70524. * @param name defines the name of the new task
  70525. * @param url defines the location of the file to load
  70526. */
  70527. constructor(
  70528. /**
  70529. * Defines the name of the task
  70530. */
  70531. name: string,
  70532. /**
  70533. * Defines the location of the file to load
  70534. */
  70535. url: string);
  70536. /**
  70537. * Execute the current task
  70538. * @param scene defines the scene where you want your assets to be loaded
  70539. * @param onSuccess is a callback called when the task is successfully executed
  70540. * @param onError is a callback called if an error occurs
  70541. */
  70542. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70543. }
  70544. /**
  70545. * Define a task used by AssetsManager to load images
  70546. */
  70547. export class ImageAssetTask extends AbstractAssetTask {
  70548. /**
  70549. * Defines the name of the task
  70550. */
  70551. name: string;
  70552. /**
  70553. * Defines the location of the image to load
  70554. */
  70555. url: string;
  70556. /**
  70557. * Gets the loaded images
  70558. */
  70559. image: HTMLImageElement;
  70560. /**
  70561. * Callback called when the task is successful
  70562. */
  70563. onSuccess: (task: ImageAssetTask) => void;
  70564. /**
  70565. * Callback called when the task is successful
  70566. */
  70567. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  70568. /**
  70569. * Creates a new ImageAssetTask
  70570. * @param name defines the name of the task
  70571. * @param url defines the location of the image to load
  70572. */
  70573. constructor(
  70574. /**
  70575. * Defines the name of the task
  70576. */
  70577. name: string,
  70578. /**
  70579. * Defines the location of the image to load
  70580. */
  70581. url: string);
  70582. /**
  70583. * Execute the current task
  70584. * @param scene defines the scene where you want your assets to be loaded
  70585. * @param onSuccess is a callback called when the task is successfully executed
  70586. * @param onError is a callback called if an error occurs
  70587. */
  70588. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70589. }
  70590. /**
  70591. * Defines the interface used by texture loading tasks
  70592. */
  70593. export interface ITextureAssetTask<TEX extends BaseTexture> {
  70594. /**
  70595. * Gets the loaded texture
  70596. */
  70597. texture: TEX;
  70598. }
  70599. /**
  70600. * Define a task used by AssetsManager to load 2D textures
  70601. */
  70602. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  70603. /**
  70604. * Defines the name of the task
  70605. */
  70606. name: string;
  70607. /**
  70608. * Defines the location of the file to load
  70609. */
  70610. url: string;
  70611. /**
  70612. * Defines if mipmap should not be generated (default is false)
  70613. */
  70614. noMipmap?: boolean | undefined;
  70615. /**
  70616. * Defines if texture must be inverted on Y axis (default is false)
  70617. */
  70618. invertY?: boolean | undefined;
  70619. /**
  70620. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70621. */
  70622. samplingMode: number;
  70623. /**
  70624. * Gets the loaded texture
  70625. */
  70626. texture: Texture;
  70627. /**
  70628. * Callback called when the task is successful
  70629. */
  70630. onSuccess: (task: TextureAssetTask) => void;
  70631. /**
  70632. * Callback called when the task is successful
  70633. */
  70634. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  70635. /**
  70636. * Creates a new TextureAssetTask object
  70637. * @param name defines the name of the task
  70638. * @param url defines the location of the file to load
  70639. * @param noMipmap defines if mipmap should not be generated (default is false)
  70640. * @param invertY defines if texture must be inverted on Y axis (default is false)
  70641. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70642. */
  70643. constructor(
  70644. /**
  70645. * Defines the name of the task
  70646. */
  70647. name: string,
  70648. /**
  70649. * Defines the location of the file to load
  70650. */
  70651. url: string,
  70652. /**
  70653. * Defines if mipmap should not be generated (default is false)
  70654. */
  70655. noMipmap?: boolean | undefined,
  70656. /**
  70657. * Defines if texture must be inverted on Y axis (default is false)
  70658. */
  70659. invertY?: boolean | undefined,
  70660. /**
  70661. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70662. */
  70663. samplingMode?: number);
  70664. /**
  70665. * Execute the current task
  70666. * @param scene defines the scene where you want your assets to be loaded
  70667. * @param onSuccess is a callback called when the task is successfully executed
  70668. * @param onError is a callback called if an error occurs
  70669. */
  70670. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70671. }
  70672. /**
  70673. * Define a task used by AssetsManager to load cube textures
  70674. */
  70675. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  70676. /**
  70677. * Defines the name of the task
  70678. */
  70679. name: string;
  70680. /**
  70681. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70682. */
  70683. url: string;
  70684. /**
  70685. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70686. */
  70687. extensions?: string[] | undefined;
  70688. /**
  70689. * Defines if mipmaps should not be generated (default is false)
  70690. */
  70691. noMipmap?: boolean | undefined;
  70692. /**
  70693. * Defines the explicit list of files (undefined by default)
  70694. */
  70695. files?: string[] | undefined;
  70696. /**
  70697. * Gets the loaded texture
  70698. */
  70699. texture: CubeTexture;
  70700. /**
  70701. * Callback called when the task is successful
  70702. */
  70703. onSuccess: (task: CubeTextureAssetTask) => void;
  70704. /**
  70705. * Callback called when the task is successful
  70706. */
  70707. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  70708. /**
  70709. * Creates a new CubeTextureAssetTask
  70710. * @param name defines the name of the task
  70711. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70712. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70713. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70714. * @param files defines the explicit list of files (undefined by default)
  70715. */
  70716. constructor(
  70717. /**
  70718. * Defines the name of the task
  70719. */
  70720. name: string,
  70721. /**
  70722. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70723. */
  70724. url: string,
  70725. /**
  70726. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70727. */
  70728. extensions?: string[] | undefined,
  70729. /**
  70730. * Defines if mipmaps should not be generated (default is false)
  70731. */
  70732. noMipmap?: boolean | undefined,
  70733. /**
  70734. * Defines the explicit list of files (undefined by default)
  70735. */
  70736. files?: string[] | undefined);
  70737. /**
  70738. * Execute the current task
  70739. * @param scene defines the scene where you want your assets to be loaded
  70740. * @param onSuccess is a callback called when the task is successfully executed
  70741. * @param onError is a callback called if an error occurs
  70742. */
  70743. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70744. }
  70745. /**
  70746. * Define a task used by AssetsManager to load HDR cube textures
  70747. */
  70748. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  70749. /**
  70750. * Defines the name of the task
  70751. */
  70752. name: string;
  70753. /**
  70754. * Defines the location of the file to load
  70755. */
  70756. url: string;
  70757. /**
  70758. * Defines the desired size (the more it increases the longer the generation will be)
  70759. */
  70760. size: number;
  70761. /**
  70762. * Defines if mipmaps should not be generated (default is false)
  70763. */
  70764. noMipmap: boolean;
  70765. /**
  70766. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70767. */
  70768. generateHarmonics: boolean;
  70769. /**
  70770. * 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)
  70771. */
  70772. gammaSpace: boolean;
  70773. /**
  70774. * Internal Use Only
  70775. */
  70776. reserved: boolean;
  70777. /**
  70778. * Gets the loaded texture
  70779. */
  70780. texture: HDRCubeTexture;
  70781. /**
  70782. * Callback called when the task is successful
  70783. */
  70784. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  70785. /**
  70786. * Callback called when the task is successful
  70787. */
  70788. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  70789. /**
  70790. * Creates a new HDRCubeTextureAssetTask object
  70791. * @param name defines the name of the task
  70792. * @param url defines the location of the file to load
  70793. * @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.
  70794. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70795. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70796. * @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)
  70797. * @param reserved Internal use only
  70798. */
  70799. constructor(
  70800. /**
  70801. * Defines the name of the task
  70802. */
  70803. name: string,
  70804. /**
  70805. * Defines the location of the file to load
  70806. */
  70807. url: string,
  70808. /**
  70809. * Defines the desired size (the more it increases the longer the generation will be)
  70810. */
  70811. size: number,
  70812. /**
  70813. * Defines if mipmaps should not be generated (default is false)
  70814. */
  70815. noMipmap?: boolean,
  70816. /**
  70817. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70818. */
  70819. generateHarmonics?: boolean,
  70820. /**
  70821. * 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)
  70822. */
  70823. gammaSpace?: boolean,
  70824. /**
  70825. * Internal Use Only
  70826. */
  70827. reserved?: boolean);
  70828. /**
  70829. * Execute the current task
  70830. * @param scene defines the scene where you want your assets to be loaded
  70831. * @param onSuccess is a callback called when the task is successfully executed
  70832. * @param onError is a callback called if an error occurs
  70833. */
  70834. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70835. }
  70836. /**
  70837. * Define a task used by AssetsManager to load Equirectangular cube textures
  70838. */
  70839. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  70840. /**
  70841. * Defines the name of the task
  70842. */
  70843. name: string;
  70844. /**
  70845. * Defines the location of the file to load
  70846. */
  70847. url: string;
  70848. /**
  70849. * Defines the desired size (the more it increases the longer the generation will be)
  70850. */
  70851. size: number;
  70852. /**
  70853. * Defines if mipmaps should not be generated (default is false)
  70854. */
  70855. noMipmap: boolean;
  70856. /**
  70857. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  70858. * but the standard material would require them in Gamma space) (default is true)
  70859. */
  70860. gammaSpace: boolean;
  70861. /**
  70862. * Gets the loaded texture
  70863. */
  70864. texture: EquiRectangularCubeTexture;
  70865. /**
  70866. * Callback called when the task is successful
  70867. */
  70868. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  70869. /**
  70870. * Callback called when the task is successful
  70871. */
  70872. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  70873. /**
  70874. * Creates a new EquiRectangularCubeTextureAssetTask object
  70875. * @param name defines the name of the task
  70876. * @param url defines the location of the file to load
  70877. * @param size defines the desired size (the more it increases the longer the generation will be)
  70878. * If the size is omitted this implies you are using a preprocessed cubemap.
  70879. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70880. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  70881. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  70882. * (default is true)
  70883. */
  70884. constructor(
  70885. /**
  70886. * Defines the name of the task
  70887. */
  70888. name: string,
  70889. /**
  70890. * Defines the location of the file to load
  70891. */
  70892. url: string,
  70893. /**
  70894. * Defines the desired size (the more it increases the longer the generation will be)
  70895. */
  70896. size: number,
  70897. /**
  70898. * Defines if mipmaps should not be generated (default is false)
  70899. */
  70900. noMipmap?: boolean,
  70901. /**
  70902. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  70903. * but the standard material would require them in Gamma space) (default is true)
  70904. */
  70905. gammaSpace?: boolean);
  70906. /**
  70907. * Execute the current task
  70908. * @param scene defines the scene where you want your assets to be loaded
  70909. * @param onSuccess is a callback called when the task is successfully executed
  70910. * @param onError is a callback called if an error occurs
  70911. */
  70912. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70913. }
  70914. /**
  70915. * This class can be used to easily import assets into a scene
  70916. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  70917. */
  70918. export class AssetsManager {
  70919. private _scene;
  70920. private _isLoading;
  70921. protected _tasks: AbstractAssetTask[];
  70922. protected _waitingTasksCount: number;
  70923. protected _totalTasksCount: number;
  70924. /**
  70925. * Callback called when all tasks are processed
  70926. */
  70927. onFinish: (tasks: AbstractAssetTask[]) => void;
  70928. /**
  70929. * Callback called when a task is successful
  70930. */
  70931. onTaskSuccess: (task: AbstractAssetTask) => void;
  70932. /**
  70933. * Callback called when a task had an error
  70934. */
  70935. onTaskError: (task: AbstractAssetTask) => void;
  70936. /**
  70937. * Callback called when a task is done (whatever the result is)
  70938. */
  70939. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  70940. /**
  70941. * Observable called when all tasks are processed
  70942. */
  70943. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  70944. /**
  70945. * Observable called when a task had an error
  70946. */
  70947. onTaskErrorObservable: Observable<AbstractAssetTask>;
  70948. /**
  70949. * Observable called when all tasks were executed
  70950. */
  70951. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  70952. /**
  70953. * Observable called when a task is done (whatever the result is)
  70954. */
  70955. onProgressObservable: Observable<IAssetsProgressEvent>;
  70956. /**
  70957. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  70958. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  70959. */
  70960. useDefaultLoadingScreen: boolean;
  70961. /**
  70962. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  70963. * when all assets have been downloaded.
  70964. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  70965. */
  70966. autoHideLoadingUI: boolean;
  70967. /**
  70968. * Creates a new AssetsManager
  70969. * @param scene defines the scene to work on
  70970. */
  70971. constructor(scene: Scene);
  70972. /**
  70973. * Add a MeshAssetTask to the list of active tasks
  70974. * @param taskName defines the name of the new task
  70975. * @param meshesNames defines the name of meshes to load
  70976. * @param rootUrl defines the root url to use to locate files
  70977. * @param sceneFilename defines the filename of the scene file
  70978. * @returns a new MeshAssetTask object
  70979. */
  70980. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  70981. /**
  70982. * Add a TextFileAssetTask to the list of active tasks
  70983. * @param taskName defines the name of the new task
  70984. * @param url defines the url of the file to load
  70985. * @returns a new TextFileAssetTask object
  70986. */
  70987. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  70988. /**
  70989. * Add a BinaryFileAssetTask to the list of active tasks
  70990. * @param taskName defines the name of the new task
  70991. * @param url defines the url of the file to load
  70992. * @returns a new BinaryFileAssetTask object
  70993. */
  70994. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  70995. /**
  70996. * Add a ImageAssetTask to the list of active tasks
  70997. * @param taskName defines the name of the new task
  70998. * @param url defines the url of the file to load
  70999. * @returns a new ImageAssetTask object
  71000. */
  71001. addImageTask(taskName: string, url: string): ImageAssetTask;
  71002. /**
  71003. * Add a TextureAssetTask to the list of active tasks
  71004. * @param taskName defines the name of the new task
  71005. * @param url defines the url of the file to load
  71006. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71007. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71008. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71009. * @returns a new TextureAssetTask object
  71010. */
  71011. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71012. /**
  71013. * Add a CubeTextureAssetTask to the list of active tasks
  71014. * @param taskName defines the name of the new task
  71015. * @param url defines the url of the file to load
  71016. * @param extensions defines the extension to use to load the cube map (can be null)
  71017. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71018. * @param files defines the list of files to load (can be null)
  71019. * @returns a new CubeTextureAssetTask object
  71020. */
  71021. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71022. /**
  71023. *
  71024. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71025. * @param taskName defines the name of the new task
  71026. * @param url defines the url of the file to load
  71027. * @param size defines the size you want for the cubemap (can be null)
  71028. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71029. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71030. * @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)
  71031. * @param reserved Internal use only
  71032. * @returns a new HDRCubeTextureAssetTask object
  71033. */
  71034. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71035. /**
  71036. *
  71037. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71038. * @param taskName defines the name of the new task
  71039. * @param url defines the url of the file to load
  71040. * @param size defines the size you want for the cubemap (can be null)
  71041. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71042. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71043. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71044. * @returns a new EquiRectangularCubeTextureAssetTask object
  71045. */
  71046. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71047. /**
  71048. * Remove a task from the assets manager.
  71049. * @param task the task to remove
  71050. */
  71051. removeTask(task: AbstractAssetTask): void;
  71052. private _decreaseWaitingTasksCount;
  71053. private _runTask;
  71054. /**
  71055. * Reset the AssetsManager and remove all tasks
  71056. * @return the current instance of the AssetsManager
  71057. */
  71058. reset(): AssetsManager;
  71059. /**
  71060. * Start the loading process
  71061. * @return the current instance of the AssetsManager
  71062. */
  71063. load(): AssetsManager;
  71064. /**
  71065. * Start the loading process as an async operation
  71066. * @return a promise returning the list of failed tasks
  71067. */
  71068. loadAsync(): Promise<void>;
  71069. }
  71070. }
  71071. declare module "babylonjs/Misc/deferred" {
  71072. /**
  71073. * Wrapper class for promise with external resolve and reject.
  71074. */
  71075. export class Deferred<T> {
  71076. /**
  71077. * The promise associated with this deferred object.
  71078. */
  71079. readonly promise: Promise<T>;
  71080. private _resolve;
  71081. private _reject;
  71082. /**
  71083. * The resolve method of the promise associated with this deferred object.
  71084. */
  71085. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71086. /**
  71087. * The reject method of the promise associated with this deferred object.
  71088. */
  71089. get reject(): (reason?: any) => void;
  71090. /**
  71091. * Constructor for this deferred object.
  71092. */
  71093. constructor();
  71094. }
  71095. }
  71096. declare module "babylonjs/Misc/meshExploder" {
  71097. import { Mesh } from "babylonjs/Meshes/mesh";
  71098. /**
  71099. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71100. */
  71101. export class MeshExploder {
  71102. private _centerMesh;
  71103. private _meshes;
  71104. private _meshesOrigins;
  71105. private _toCenterVectors;
  71106. private _scaledDirection;
  71107. private _newPosition;
  71108. private _centerPosition;
  71109. /**
  71110. * Explodes meshes from a center mesh.
  71111. * @param meshes The meshes to explode.
  71112. * @param centerMesh The mesh to be center of explosion.
  71113. */
  71114. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71115. private _setCenterMesh;
  71116. /**
  71117. * Get class name
  71118. * @returns "MeshExploder"
  71119. */
  71120. getClassName(): string;
  71121. /**
  71122. * "Exploded meshes"
  71123. * @returns Array of meshes with the centerMesh at index 0.
  71124. */
  71125. getMeshes(): Array<Mesh>;
  71126. /**
  71127. * Explodes meshes giving a specific direction
  71128. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71129. */
  71130. explode(direction?: number): void;
  71131. }
  71132. }
  71133. declare module "babylonjs/Misc/filesInput" {
  71134. import { Engine } from "babylonjs/Engines/engine";
  71135. import { Scene } from "babylonjs/scene";
  71136. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  71137. /**
  71138. * Class used to help managing file picking and drag'n'drop
  71139. */
  71140. export class FilesInput {
  71141. /**
  71142. * List of files ready to be loaded
  71143. */
  71144. static get FilesToLoad(): {
  71145. [key: string]: File;
  71146. };
  71147. /**
  71148. * Callback called when a file is processed
  71149. */
  71150. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71151. private _engine;
  71152. private _currentScene;
  71153. private _sceneLoadedCallback;
  71154. private _progressCallback;
  71155. private _additionalRenderLoopLogicCallback;
  71156. private _textureLoadingCallback;
  71157. private _startingProcessingFilesCallback;
  71158. private _onReloadCallback;
  71159. private _errorCallback;
  71160. private _elementToMonitor;
  71161. private _sceneFileToLoad;
  71162. private _filesToLoad;
  71163. /**
  71164. * Creates a new FilesInput
  71165. * @param engine defines the rendering engine
  71166. * @param scene defines the hosting scene
  71167. * @param sceneLoadedCallback callback called when scene is loaded
  71168. * @param progressCallback callback called to track progress
  71169. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71170. * @param textureLoadingCallback callback called when a texture is loading
  71171. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71172. * @param onReloadCallback callback called when a reload is requested
  71173. * @param errorCallback callback call if an error occurs
  71174. */
  71175. 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);
  71176. private _dragEnterHandler;
  71177. private _dragOverHandler;
  71178. private _dropHandler;
  71179. /**
  71180. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71181. * @param elementToMonitor defines the DOM element to track
  71182. */
  71183. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71184. /**
  71185. * Release all associated resources
  71186. */
  71187. dispose(): void;
  71188. private renderFunction;
  71189. private drag;
  71190. private drop;
  71191. private _traverseFolder;
  71192. private _processFiles;
  71193. /**
  71194. * Load files from a drop event
  71195. * @param event defines the drop event to use as source
  71196. */
  71197. loadFiles(event: any): void;
  71198. private _processReload;
  71199. /**
  71200. * Reload the current scene from the loaded files
  71201. */
  71202. reload(): void;
  71203. }
  71204. }
  71205. declare module "babylonjs/Misc/HighDynamicRange/index" {
  71206. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  71207. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  71208. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  71209. }
  71210. declare module "babylonjs/Misc/sceneOptimizer" {
  71211. import { Scene, IDisposable } from "babylonjs/scene";
  71212. import { Observable } from "babylonjs/Misc/observable";
  71213. /**
  71214. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71215. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71216. */
  71217. export class SceneOptimization {
  71218. /**
  71219. * Defines the priority of this optimization (0 by default which means first in the list)
  71220. */
  71221. priority: number;
  71222. /**
  71223. * Gets a string describing the action executed by the current optimization
  71224. * @returns description string
  71225. */
  71226. getDescription(): string;
  71227. /**
  71228. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71229. * @param scene defines the current scene where to apply this optimization
  71230. * @param optimizer defines the current optimizer
  71231. * @returns true if everything that can be done was applied
  71232. */
  71233. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71234. /**
  71235. * Creates the SceneOptimization object
  71236. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71237. * @param desc defines the description associated with the optimization
  71238. */
  71239. constructor(
  71240. /**
  71241. * Defines the priority of this optimization (0 by default which means first in the list)
  71242. */
  71243. priority?: number);
  71244. }
  71245. /**
  71246. * Defines an optimization used to reduce the size of render target textures
  71247. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71248. */
  71249. export class TextureOptimization extends SceneOptimization {
  71250. /**
  71251. * Defines the priority of this optimization (0 by default which means first in the list)
  71252. */
  71253. priority: number;
  71254. /**
  71255. * 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
  71256. */
  71257. maximumSize: number;
  71258. /**
  71259. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71260. */
  71261. step: number;
  71262. /**
  71263. * Gets a string describing the action executed by the current optimization
  71264. * @returns description string
  71265. */
  71266. getDescription(): string;
  71267. /**
  71268. * Creates the TextureOptimization object
  71269. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71270. * @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
  71271. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71272. */
  71273. constructor(
  71274. /**
  71275. * Defines the priority of this optimization (0 by default which means first in the list)
  71276. */
  71277. priority?: number,
  71278. /**
  71279. * 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
  71280. */
  71281. maximumSize?: number,
  71282. /**
  71283. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71284. */
  71285. step?: number);
  71286. /**
  71287. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71288. * @param scene defines the current scene where to apply this optimization
  71289. * @param optimizer defines the current optimizer
  71290. * @returns true if everything that can be done was applied
  71291. */
  71292. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71293. }
  71294. /**
  71295. * Defines an optimization used to increase or decrease the rendering resolution
  71296. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71297. */
  71298. export class HardwareScalingOptimization extends SceneOptimization {
  71299. /**
  71300. * Defines the priority of this optimization (0 by default which means first in the list)
  71301. */
  71302. priority: number;
  71303. /**
  71304. * Defines the maximum scale to use (2 by default)
  71305. */
  71306. maximumScale: number;
  71307. /**
  71308. * Defines the step to use between two passes (0.5 by default)
  71309. */
  71310. step: number;
  71311. private _currentScale;
  71312. private _directionOffset;
  71313. /**
  71314. * Gets a string describing the action executed by the current optimization
  71315. * @return description string
  71316. */
  71317. getDescription(): string;
  71318. /**
  71319. * Creates the HardwareScalingOptimization object
  71320. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71321. * @param maximumScale defines the maximum scale to use (2 by default)
  71322. * @param step defines the step to use between two passes (0.5 by default)
  71323. */
  71324. constructor(
  71325. /**
  71326. * Defines the priority of this optimization (0 by default which means first in the list)
  71327. */
  71328. priority?: number,
  71329. /**
  71330. * Defines the maximum scale to use (2 by default)
  71331. */
  71332. maximumScale?: number,
  71333. /**
  71334. * Defines the step to use between two passes (0.5 by default)
  71335. */
  71336. step?: number);
  71337. /**
  71338. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71339. * @param scene defines the current scene where to apply this optimization
  71340. * @param optimizer defines the current optimizer
  71341. * @returns true if everything that can be done was applied
  71342. */
  71343. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71344. }
  71345. /**
  71346. * Defines an optimization used to remove shadows
  71347. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71348. */
  71349. export class ShadowsOptimization extends SceneOptimization {
  71350. /**
  71351. * Gets a string describing the action executed by the current optimization
  71352. * @return description string
  71353. */
  71354. getDescription(): string;
  71355. /**
  71356. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71357. * @param scene defines the current scene where to apply this optimization
  71358. * @param optimizer defines the current optimizer
  71359. * @returns true if everything that can be done was applied
  71360. */
  71361. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71362. }
  71363. /**
  71364. * Defines an optimization used to turn post-processes off
  71365. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71366. */
  71367. export class PostProcessesOptimization extends SceneOptimization {
  71368. /**
  71369. * Gets a string describing the action executed by the current optimization
  71370. * @return description string
  71371. */
  71372. getDescription(): string;
  71373. /**
  71374. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71375. * @param scene defines the current scene where to apply this optimization
  71376. * @param optimizer defines the current optimizer
  71377. * @returns true if everything that can be done was applied
  71378. */
  71379. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71380. }
  71381. /**
  71382. * Defines an optimization used to turn lens flares off
  71383. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71384. */
  71385. export class LensFlaresOptimization extends SceneOptimization {
  71386. /**
  71387. * Gets a string describing the action executed by the current optimization
  71388. * @return description string
  71389. */
  71390. getDescription(): string;
  71391. /**
  71392. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71393. * @param scene defines the current scene where to apply this optimization
  71394. * @param optimizer defines the current optimizer
  71395. * @returns true if everything that can be done was applied
  71396. */
  71397. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71398. }
  71399. /**
  71400. * Defines an optimization based on user defined callback.
  71401. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71402. */
  71403. export class CustomOptimization extends SceneOptimization {
  71404. /**
  71405. * Callback called to apply the custom optimization.
  71406. */
  71407. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71408. /**
  71409. * Callback called to get custom description
  71410. */
  71411. onGetDescription: () => string;
  71412. /**
  71413. * Gets a string describing the action executed by the current optimization
  71414. * @returns description string
  71415. */
  71416. getDescription(): string;
  71417. /**
  71418. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71419. * @param scene defines the current scene where to apply this optimization
  71420. * @param optimizer defines the current optimizer
  71421. * @returns true if everything that can be done was applied
  71422. */
  71423. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71424. }
  71425. /**
  71426. * Defines an optimization used to turn particles off
  71427. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71428. */
  71429. export class ParticlesOptimization extends SceneOptimization {
  71430. /**
  71431. * Gets a string describing the action executed by the current optimization
  71432. * @return description string
  71433. */
  71434. getDescription(): string;
  71435. /**
  71436. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71437. * @param scene defines the current scene where to apply this optimization
  71438. * @param optimizer defines the current optimizer
  71439. * @returns true if everything that can be done was applied
  71440. */
  71441. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71442. }
  71443. /**
  71444. * Defines an optimization used to turn render targets off
  71445. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71446. */
  71447. export class RenderTargetsOptimization extends SceneOptimization {
  71448. /**
  71449. * Gets a string describing the action executed by the current optimization
  71450. * @return description string
  71451. */
  71452. getDescription(): string;
  71453. /**
  71454. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71455. * @param scene defines the current scene where to apply this optimization
  71456. * @param optimizer defines the current optimizer
  71457. * @returns true if everything that can be done was applied
  71458. */
  71459. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71460. }
  71461. /**
  71462. * Defines an optimization used to merge meshes with compatible materials
  71463. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71464. */
  71465. export class MergeMeshesOptimization extends SceneOptimization {
  71466. private static _UpdateSelectionTree;
  71467. /**
  71468. * Gets or sets a boolean which defines if optimization octree has to be updated
  71469. */
  71470. static get UpdateSelectionTree(): boolean;
  71471. /**
  71472. * Gets or sets a boolean which defines if optimization octree has to be updated
  71473. */
  71474. static set UpdateSelectionTree(value: boolean);
  71475. /**
  71476. * Gets a string describing the action executed by the current optimization
  71477. * @return description string
  71478. */
  71479. getDescription(): string;
  71480. private _canBeMerged;
  71481. /**
  71482. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71483. * @param scene defines the current scene where to apply this optimization
  71484. * @param optimizer defines the current optimizer
  71485. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71486. * @returns true if everything that can be done was applied
  71487. */
  71488. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71489. }
  71490. /**
  71491. * Defines a list of options used by SceneOptimizer
  71492. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71493. */
  71494. export class SceneOptimizerOptions {
  71495. /**
  71496. * Defines the target frame rate to reach (60 by default)
  71497. */
  71498. targetFrameRate: number;
  71499. /**
  71500. * Defines the interval between two checkes (2000ms by default)
  71501. */
  71502. trackerDuration: number;
  71503. /**
  71504. * Gets the list of optimizations to apply
  71505. */
  71506. optimizations: SceneOptimization[];
  71507. /**
  71508. * Creates a new list of options used by SceneOptimizer
  71509. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  71510. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  71511. */
  71512. constructor(
  71513. /**
  71514. * Defines the target frame rate to reach (60 by default)
  71515. */
  71516. targetFrameRate?: number,
  71517. /**
  71518. * Defines the interval between two checkes (2000ms by default)
  71519. */
  71520. trackerDuration?: number);
  71521. /**
  71522. * Add a new optimization
  71523. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  71524. * @returns the current SceneOptimizerOptions
  71525. */
  71526. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  71527. /**
  71528. * Add a new custom optimization
  71529. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  71530. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  71531. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71532. * @returns the current SceneOptimizerOptions
  71533. */
  71534. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  71535. /**
  71536. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  71537. * @param targetFrameRate defines the target frame rate (60 by default)
  71538. * @returns a SceneOptimizerOptions object
  71539. */
  71540. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71541. /**
  71542. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  71543. * @param targetFrameRate defines the target frame rate (60 by default)
  71544. * @returns a SceneOptimizerOptions object
  71545. */
  71546. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71547. /**
  71548. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  71549. * @param targetFrameRate defines the target frame rate (60 by default)
  71550. * @returns a SceneOptimizerOptions object
  71551. */
  71552. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71553. }
  71554. /**
  71555. * Class used to run optimizations in order to reach a target frame rate
  71556. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71557. */
  71558. export class SceneOptimizer implements IDisposable {
  71559. private _isRunning;
  71560. private _options;
  71561. private _scene;
  71562. private _currentPriorityLevel;
  71563. private _targetFrameRate;
  71564. private _trackerDuration;
  71565. private _currentFrameRate;
  71566. private _sceneDisposeObserver;
  71567. private _improvementMode;
  71568. /**
  71569. * Defines an observable called when the optimizer reaches the target frame rate
  71570. */
  71571. onSuccessObservable: Observable<SceneOptimizer>;
  71572. /**
  71573. * Defines an observable called when the optimizer enables an optimization
  71574. */
  71575. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  71576. /**
  71577. * Defines an observable called when the optimizer is not able to reach the target frame rate
  71578. */
  71579. onFailureObservable: Observable<SceneOptimizer>;
  71580. /**
  71581. * Gets a boolean indicating if the optimizer is in improvement mode
  71582. */
  71583. get isInImprovementMode(): boolean;
  71584. /**
  71585. * Gets the current priority level (0 at start)
  71586. */
  71587. get currentPriorityLevel(): number;
  71588. /**
  71589. * Gets the current frame rate checked by the SceneOptimizer
  71590. */
  71591. get currentFrameRate(): number;
  71592. /**
  71593. * Gets or sets the current target frame rate (60 by default)
  71594. */
  71595. get targetFrameRate(): number;
  71596. /**
  71597. * Gets or sets the current target frame rate (60 by default)
  71598. */
  71599. set targetFrameRate(value: number);
  71600. /**
  71601. * Gets or sets the current interval between two checks (every 2000ms by default)
  71602. */
  71603. get trackerDuration(): number;
  71604. /**
  71605. * Gets or sets the current interval between two checks (every 2000ms by default)
  71606. */
  71607. set trackerDuration(value: number);
  71608. /**
  71609. * Gets the list of active optimizations
  71610. */
  71611. get optimizations(): SceneOptimization[];
  71612. /**
  71613. * Creates a new SceneOptimizer
  71614. * @param scene defines the scene to work on
  71615. * @param options defines the options to use with the SceneOptimizer
  71616. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  71617. * @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)
  71618. */
  71619. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  71620. /**
  71621. * Stops the current optimizer
  71622. */
  71623. stop(): void;
  71624. /**
  71625. * Reset the optimizer to initial step (current priority level = 0)
  71626. */
  71627. reset(): void;
  71628. /**
  71629. * Start the optimizer. By default it will try to reach a specific framerate
  71630. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  71631. */
  71632. start(): void;
  71633. private _checkCurrentState;
  71634. /**
  71635. * Release all resources
  71636. */
  71637. dispose(): void;
  71638. /**
  71639. * Helper function to create a SceneOptimizer with one single line of code
  71640. * @param scene defines the scene to work on
  71641. * @param options defines the options to use with the SceneOptimizer
  71642. * @param onSuccess defines a callback to call on success
  71643. * @param onFailure defines a callback to call on failure
  71644. * @returns the new SceneOptimizer object
  71645. */
  71646. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  71647. }
  71648. }
  71649. declare module "babylonjs/Misc/sceneSerializer" {
  71650. import { Scene } from "babylonjs/scene";
  71651. /**
  71652. * Class used to serialize a scene into a string
  71653. */
  71654. export class SceneSerializer {
  71655. /**
  71656. * Clear cache used by a previous serialization
  71657. */
  71658. static ClearCache(): void;
  71659. /**
  71660. * Serialize a scene into a JSON compatible object
  71661. * @param scene defines the scene to serialize
  71662. * @returns a JSON compatible object
  71663. */
  71664. static Serialize(scene: Scene): any;
  71665. /**
  71666. * Serialize a mesh into a JSON compatible object
  71667. * @param toSerialize defines the mesh to serialize
  71668. * @param withParents defines if parents must be serialized as well
  71669. * @param withChildren defines if children must be serialized as well
  71670. * @returns a JSON compatible object
  71671. */
  71672. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  71673. }
  71674. }
  71675. declare module "babylonjs/Misc/textureTools" {
  71676. import { Texture } from "babylonjs/Materials/Textures/texture";
  71677. /**
  71678. * Class used to host texture specific utilities
  71679. */
  71680. export class TextureTools {
  71681. /**
  71682. * Uses the GPU to create a copy texture rescaled at a given size
  71683. * @param texture Texture to copy from
  71684. * @param width defines the desired width
  71685. * @param height defines the desired height
  71686. * @param useBilinearMode defines if bilinear mode has to be used
  71687. * @return the generated texture
  71688. */
  71689. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  71690. }
  71691. }
  71692. declare module "babylonjs/Misc/videoRecorder" {
  71693. import { Nullable } from "babylonjs/types";
  71694. import { Engine } from "babylonjs/Engines/engine";
  71695. /**
  71696. * This represents the different options available for the video capture.
  71697. */
  71698. export interface VideoRecorderOptions {
  71699. /** Defines the mime type of the video. */
  71700. mimeType: string;
  71701. /** Defines the FPS the video should be recorded at. */
  71702. fps: number;
  71703. /** Defines the chunk size for the recording data. */
  71704. recordChunckSize: number;
  71705. /** The audio tracks to attach to the recording. */
  71706. audioTracks?: MediaStreamTrack[];
  71707. }
  71708. /**
  71709. * This can help with recording videos from BabylonJS.
  71710. * This is based on the available WebRTC functionalities of the browser.
  71711. *
  71712. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  71713. */
  71714. export class VideoRecorder {
  71715. private static readonly _defaultOptions;
  71716. /**
  71717. * Returns whether or not the VideoRecorder is available in your browser.
  71718. * @param engine Defines the Babylon Engine.
  71719. * @returns true if supported otherwise false.
  71720. */
  71721. static IsSupported(engine: Engine): boolean;
  71722. private readonly _options;
  71723. private _canvas;
  71724. private _mediaRecorder;
  71725. private _recordedChunks;
  71726. private _fileName;
  71727. private _resolve;
  71728. private _reject;
  71729. /**
  71730. * True when a recording is already in progress.
  71731. */
  71732. get isRecording(): boolean;
  71733. /**
  71734. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  71735. * @param engine Defines the BabylonJS Engine you wish to record.
  71736. * @param options Defines options that can be used to customize the capture.
  71737. */
  71738. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  71739. /**
  71740. * Stops the current recording before the default capture timeout passed in the startRecording function.
  71741. */
  71742. stopRecording(): void;
  71743. /**
  71744. * Starts recording the canvas for a max duration specified in parameters.
  71745. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  71746. * If null no automatic download will start and you can rely on the promise to get the data back.
  71747. * @param maxDuration Defines the maximum recording time in seconds.
  71748. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  71749. * @return A promise callback at the end of the recording with the video data in Blob.
  71750. */
  71751. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  71752. /**
  71753. * Releases internal resources used during the recording.
  71754. */
  71755. dispose(): void;
  71756. private _handleDataAvailable;
  71757. private _handleError;
  71758. private _handleStop;
  71759. }
  71760. }
  71761. declare module "babylonjs/Misc/screenshotTools" {
  71762. import { Camera } from "babylonjs/Cameras/camera";
  71763. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  71764. import { Engine } from "babylonjs/Engines/engine";
  71765. /**
  71766. * Class containing a set of static utilities functions for screenshots
  71767. */
  71768. export class ScreenshotTools {
  71769. /**
  71770. * Captures a screenshot of the current rendering
  71771. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71772. * @param engine defines the rendering engine
  71773. * @param camera defines the source camera
  71774. * @param size This parameter can be set to a single number or to an object with the
  71775. * following (optional) properties: precision, width, height. If a single number is passed,
  71776. * it will be used for both width and height. If an object is passed, the screenshot size
  71777. * will be derived from the parameters. The precision property is a multiplier allowing
  71778. * rendering at a higher or lower resolution
  71779. * @param successCallback defines the callback receives a single parameter which contains the
  71780. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  71781. * src parameter of an <img> to display it
  71782. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  71783. * Check your browser for supported MIME types
  71784. */
  71785. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  71786. /**
  71787. * Captures a screenshot of the current rendering
  71788. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71789. * @param engine defines the rendering engine
  71790. * @param camera defines the source camera
  71791. * @param size This parameter can be set to a single number or to an object with the
  71792. * following (optional) properties: precision, width, height. If a single number is passed,
  71793. * it will be used for both width and height. If an object is passed, the screenshot size
  71794. * will be derived from the parameters. The precision property is a multiplier allowing
  71795. * rendering at a higher or lower resolution
  71796. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  71797. * Check your browser for supported MIME types
  71798. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  71799. * to the src parameter of an <img> to display it
  71800. */
  71801. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  71802. /**
  71803. * Generates an image screenshot from the specified camera.
  71804. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71805. * @param engine The engine to use for rendering
  71806. * @param camera The camera to use for rendering
  71807. * @param size This parameter can be set to a single number or to an object with the
  71808. * following (optional) properties: precision, width, height. If a single number is passed,
  71809. * it will be used for both width and height. If an object is passed, the screenshot size
  71810. * will be derived from the parameters. The precision property is a multiplier allowing
  71811. * rendering at a higher or lower resolution
  71812. * @param successCallback The callback receives a single parameter which contains the
  71813. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  71814. * src parameter of an <img> to display it
  71815. * @param mimeType The MIME type of the screenshot image (default: image/png).
  71816. * Check your browser for supported MIME types
  71817. * @param samples Texture samples (default: 1)
  71818. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  71819. * @param fileName A name for for the downloaded file.
  71820. */
  71821. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  71822. /**
  71823. * Generates an image screenshot from the specified camera.
  71824. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71825. * @param engine The engine to use for rendering
  71826. * @param camera The camera to use for rendering
  71827. * @param size This parameter can be set to a single number or to an object with the
  71828. * following (optional) properties: precision, width, height. If a single number is passed,
  71829. * it will be used for both width and height. If an object is passed, the screenshot size
  71830. * will be derived from the parameters. The precision property is a multiplier allowing
  71831. * rendering at a higher or lower resolution
  71832. * @param mimeType The MIME type of the screenshot image (default: image/png).
  71833. * Check your browser for supported MIME types
  71834. * @param samples Texture samples (default: 1)
  71835. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  71836. * @param fileName A name for for the downloaded file.
  71837. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  71838. * to the src parameter of an <img> to display it
  71839. */
  71840. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  71841. /**
  71842. * Gets height and width for screenshot size
  71843. * @private
  71844. */
  71845. private static _getScreenshotSize;
  71846. }
  71847. }
  71848. declare module "babylonjs/Misc/dataReader" {
  71849. /**
  71850. * Interface for a data buffer
  71851. */
  71852. export interface IDataBuffer {
  71853. /**
  71854. * Reads bytes from the data buffer.
  71855. * @param byteOffset The byte offset to read
  71856. * @param byteLength The byte length to read
  71857. * @returns A promise that resolves when the bytes are read
  71858. */
  71859. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  71860. /**
  71861. * The byte length of the buffer.
  71862. */
  71863. readonly byteLength: number;
  71864. }
  71865. /**
  71866. * Utility class for reading from a data buffer
  71867. */
  71868. export class DataReader {
  71869. /**
  71870. * The data buffer associated with this data reader.
  71871. */
  71872. readonly buffer: IDataBuffer;
  71873. /**
  71874. * The current byte offset from the beginning of the data buffer.
  71875. */
  71876. byteOffset: number;
  71877. private _dataView;
  71878. private _dataByteOffset;
  71879. /**
  71880. * Constructor
  71881. * @param buffer The buffer to read
  71882. */
  71883. constructor(buffer: IDataBuffer);
  71884. /**
  71885. * Loads the given byte length.
  71886. * @param byteLength The byte length to load
  71887. * @returns A promise that resolves when the load is complete
  71888. */
  71889. loadAsync(byteLength: number): Promise<void>;
  71890. /**
  71891. * Read a unsigned 32-bit integer from the currently loaded data range.
  71892. * @returns The 32-bit integer read
  71893. */
  71894. readUint32(): number;
  71895. /**
  71896. * Read a byte array from the currently loaded data range.
  71897. * @param byteLength The byte length to read
  71898. * @returns The byte array read
  71899. */
  71900. readUint8Array(byteLength: number): Uint8Array;
  71901. /**
  71902. * Read a string from the currently loaded data range.
  71903. * @param byteLength The byte length to read
  71904. * @returns The string read
  71905. */
  71906. readString(byteLength: number): string;
  71907. /**
  71908. * Skips the given byte length the currently loaded data range.
  71909. * @param byteLength The byte length to skip
  71910. */
  71911. skipBytes(byteLength: number): void;
  71912. }
  71913. }
  71914. declare module "babylonjs/Misc/index" {
  71915. export * from "babylonjs/Misc/andOrNotEvaluator";
  71916. export * from "babylonjs/Misc/assetsManager";
  71917. export * from "babylonjs/Misc/basis";
  71918. export * from "babylonjs/Misc/dds";
  71919. export * from "babylonjs/Misc/decorators";
  71920. export * from "babylonjs/Misc/deferred";
  71921. export * from "babylonjs/Misc/environmentTextureTools";
  71922. export * from "babylonjs/Misc/meshExploder";
  71923. export * from "babylonjs/Misc/filesInput";
  71924. export * from "babylonjs/Misc/HighDynamicRange/index";
  71925. export * from "babylonjs/Misc/khronosTextureContainer";
  71926. export * from "babylonjs/Misc/observable";
  71927. export * from "babylonjs/Misc/performanceMonitor";
  71928. export * from "babylonjs/Misc/promise";
  71929. export * from "babylonjs/Misc/sceneOptimizer";
  71930. export * from "babylonjs/Misc/sceneSerializer";
  71931. export * from "babylonjs/Misc/smartArray";
  71932. export * from "babylonjs/Misc/stringDictionary";
  71933. export * from "babylonjs/Misc/tags";
  71934. export * from "babylonjs/Misc/textureTools";
  71935. export * from "babylonjs/Misc/tga";
  71936. export * from "babylonjs/Misc/tools";
  71937. export * from "babylonjs/Misc/videoRecorder";
  71938. export * from "babylonjs/Misc/virtualJoystick";
  71939. export * from "babylonjs/Misc/workerPool";
  71940. export * from "babylonjs/Misc/logger";
  71941. export * from "babylonjs/Misc/typeStore";
  71942. export * from "babylonjs/Misc/filesInputStore";
  71943. export * from "babylonjs/Misc/deepCopier";
  71944. export * from "babylonjs/Misc/pivotTools";
  71945. export * from "babylonjs/Misc/precisionDate";
  71946. export * from "babylonjs/Misc/screenshotTools";
  71947. export * from "babylonjs/Misc/typeStore";
  71948. export * from "babylonjs/Misc/webRequest";
  71949. export * from "babylonjs/Misc/iInspectable";
  71950. export * from "babylonjs/Misc/brdfTextureTools";
  71951. export * from "babylonjs/Misc/rgbdTextureTools";
  71952. export * from "babylonjs/Misc/gradients";
  71953. export * from "babylonjs/Misc/perfCounter";
  71954. export * from "babylonjs/Misc/fileRequest";
  71955. export * from "babylonjs/Misc/customAnimationFrameRequester";
  71956. export * from "babylonjs/Misc/retryStrategy";
  71957. export * from "babylonjs/Misc/interfaces/screenshotSize";
  71958. export * from "babylonjs/Misc/canvasGenerator";
  71959. export * from "babylonjs/Misc/fileTools";
  71960. export * from "babylonjs/Misc/stringTools";
  71961. export * from "babylonjs/Misc/dataReader";
  71962. export * from "babylonjs/Misc/minMaxReducer";
  71963. export * from "babylonjs/Misc/depthReducer";
  71964. }
  71965. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  71966. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  71967. import { Observable } from "babylonjs/Misc/observable";
  71968. import { Matrix } from "babylonjs/Maths/math.vector";
  71969. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71970. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  71971. /**
  71972. * Options used for hit testing
  71973. */
  71974. export interface IWebXRHitTestOptions {
  71975. /**
  71976. * Only test when user interacted with the scene. Default - hit test every frame
  71977. */
  71978. testOnPointerDownOnly?: boolean;
  71979. /**
  71980. * The node to use to transform the local results to world coordinates
  71981. */
  71982. worldParentNode?: TransformNode;
  71983. }
  71984. /**
  71985. * Interface defining the babylon result of raycasting/hit-test
  71986. */
  71987. export interface IWebXRHitResult {
  71988. /**
  71989. * The native hit test result
  71990. */
  71991. xrHitResult: XRHitResult;
  71992. /**
  71993. * Transformation matrix that can be applied to a node that will put it in the hit point location
  71994. */
  71995. transformationMatrix: Matrix;
  71996. }
  71997. /**
  71998. * The currently-working hit-test module.
  71999. * Hit test (or raycasting) is used to interact with the real world.
  72000. * For further information read here - https://github.com/immersive-web/hit-test
  72001. */
  72002. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  72003. /**
  72004. * options to use when constructing this feature
  72005. */
  72006. readonly options: IWebXRHitTestOptions;
  72007. /**
  72008. * The module's name
  72009. */
  72010. static readonly Name: string;
  72011. /**
  72012. * The (Babylon) version of this module.
  72013. * This is an integer representing the implementation version.
  72014. * This number does not correspond to the webxr specs version
  72015. */
  72016. static readonly Version: number;
  72017. /**
  72018. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72019. * @param event the (select) event to use to select with
  72020. * @param referenceSpace the reference space to use for this hit test
  72021. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72022. */
  72023. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72024. /**
  72025. * execute a hit test with an XR Ray
  72026. *
  72027. * @param xrSession a native xrSession that will execute this hit test
  72028. * @param xrRay the ray (position and direction) to use for raycasting
  72029. * @param referenceSpace native XR reference space to use for the hit-test
  72030. * @param filter filter function that will filter the results
  72031. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72032. */
  72033. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72034. /**
  72035. * Triggered when new babylon (transformed) hit test results are available
  72036. */
  72037. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72038. private _onSelectEnabled;
  72039. /**
  72040. * Creates a new instance of the (legacy version) hit test feature
  72041. * @param _xrSessionManager an instance of WebXRSessionManager
  72042. * @param options options to use when constructing this feature
  72043. */
  72044. constructor(_xrSessionManager: WebXRSessionManager,
  72045. /**
  72046. * options to use when constructing this feature
  72047. */
  72048. options?: IWebXRHitTestOptions);
  72049. /**
  72050. * Populated with the last native XR Hit Results
  72051. */
  72052. lastNativeXRHitResults: XRHitResult[];
  72053. /**
  72054. * attach this feature
  72055. * Will usually be called by the features manager
  72056. *
  72057. * @returns true if successful.
  72058. */
  72059. attach(): boolean;
  72060. /**
  72061. * detach this feature.
  72062. * Will usually be called by the features manager
  72063. *
  72064. * @returns true if successful.
  72065. */
  72066. detach(): boolean;
  72067. private _onHitTestResults;
  72068. private _origin;
  72069. private _direction;
  72070. private _mat;
  72071. protected _onXRFrame(frame: XRFrame): void;
  72072. private _onSelect;
  72073. /**
  72074. * Dispose this feature and all of the resources attached
  72075. */
  72076. dispose(): void;
  72077. }
  72078. }
  72079. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  72080. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72081. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72082. import { Observable } from "babylonjs/Misc/observable";
  72083. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  72084. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72085. /**
  72086. * Options used in the plane detector module
  72087. */
  72088. export interface IWebXRPlaneDetectorOptions {
  72089. /**
  72090. * The node to use to transform the local results to world coordinates
  72091. */
  72092. worldParentNode?: TransformNode;
  72093. }
  72094. /**
  72095. * A babylon interface for a webxr plane.
  72096. * A Plane is actually a polygon, built from N points in space
  72097. *
  72098. * Supported in chrome 79, not supported in canary 81 ATM
  72099. */
  72100. export interface IWebXRPlane {
  72101. /**
  72102. * a babylon-assigned ID for this polygon
  72103. */
  72104. id: number;
  72105. /**
  72106. * the native xr-plane object
  72107. */
  72108. xrPlane: XRPlane;
  72109. /**
  72110. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72111. */
  72112. polygonDefinition: Array<Vector3>;
  72113. /**
  72114. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72115. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72116. */
  72117. transformationMatrix: Matrix;
  72118. }
  72119. /**
  72120. * The plane detector is used to detect planes in the real world when in AR
  72121. * For more information see https://github.com/immersive-web/real-world-geometry/
  72122. */
  72123. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  72124. private _options;
  72125. /**
  72126. * The module's name
  72127. */
  72128. static readonly Name: string;
  72129. /**
  72130. * The (Babylon) version of this module.
  72131. * This is an integer representing the implementation version.
  72132. * This number does not correspond to the webxr specs version
  72133. */
  72134. static readonly Version: number;
  72135. /**
  72136. * Observers registered here will be executed when a new plane was added to the session
  72137. */
  72138. onPlaneAddedObservable: Observable<IWebXRPlane>;
  72139. /**
  72140. * Observers registered here will be executed when a plane is no longer detected in the session
  72141. */
  72142. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  72143. /**
  72144. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  72145. * This can execute N times every frame
  72146. */
  72147. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  72148. private _enabled;
  72149. private _detectedPlanes;
  72150. private _lastFrameDetected;
  72151. /**
  72152. * construct a new Plane Detector
  72153. * @param _xrSessionManager an instance of xr Session manager
  72154. * @param _options configuration to use when constructing this feature
  72155. */
  72156. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  72157. private _init;
  72158. protected _onXRFrame(frame: XRFrame): void;
  72159. /**
  72160. * Dispose this feature and all of the resources attached
  72161. */
  72162. dispose(): void;
  72163. private _updatePlaneWithXRPlane;
  72164. /**
  72165. * avoiding using Array.find for global support.
  72166. * @param xrPlane the plane to find in the array
  72167. */
  72168. private findIndexInPlaneArray;
  72169. }
  72170. }
  72171. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  72172. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72173. import { Observable } from "babylonjs/Misc/observable";
  72174. import { Matrix } from "babylonjs/Maths/math.vector";
  72175. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72176. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  72177. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  72178. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72179. /**
  72180. * Configuration options of the anchor system
  72181. */
  72182. export interface IWebXRAnchorSystemOptions {
  72183. /**
  72184. * a node that will be used to convert local to world coordinates
  72185. */
  72186. worldParentNode?: TransformNode;
  72187. /**
  72188. * should the anchor system use plane detection.
  72189. * If set to true, the plane-detection feature should be set using setPlaneDetector
  72190. */
  72191. usePlaneDetection?: boolean;
  72192. /**
  72193. * Should a new anchor be added every time a select event is triggered
  72194. */
  72195. addAnchorOnSelect?: boolean;
  72196. }
  72197. /**
  72198. * A babylon container for an XR Anchor
  72199. */
  72200. export interface IWebXRAnchor {
  72201. /**
  72202. * A babylon-assigned ID for this anchor
  72203. */
  72204. id: number;
  72205. /**
  72206. * The native anchor object
  72207. */
  72208. xrAnchor: XRAnchor;
  72209. /**
  72210. * Transformation matrix to apply to an object attached to this anchor
  72211. */
  72212. transformationMatrix: Matrix;
  72213. }
  72214. /**
  72215. * An implementation of the anchor system of WebXR.
  72216. * Note that the current documented implementation is not available in any browser. Future implementations
  72217. * will use the frame to create an anchor and not the session or a detected plane
  72218. * For further information see https://github.com/immersive-web/anchors/
  72219. */
  72220. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72221. private _options;
  72222. /**
  72223. * The module's name
  72224. */
  72225. static readonly Name: string;
  72226. /**
  72227. * The (Babylon) version of this module.
  72228. * This is an integer representing the implementation version.
  72229. * This number does not correspond to the webxr specs version
  72230. */
  72231. static readonly Version: number;
  72232. /**
  72233. * Observers registered here will be executed when a new anchor was added to the session
  72234. */
  72235. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72236. /**
  72237. * Observers registered here will be executed when an existing anchor updates
  72238. * This can execute N times every frame
  72239. */
  72240. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72241. /**
  72242. * Observers registered here will be executed when an anchor was removed from the session
  72243. */
  72244. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72245. private _planeDetector;
  72246. private _hitTestModule;
  72247. private _enabled;
  72248. private _trackedAnchors;
  72249. private _lastFrameDetected;
  72250. /**
  72251. * constructs a new anchor system
  72252. * @param _xrSessionManager an instance of WebXRSessionManager
  72253. * @param _options configuration object for this feature
  72254. */
  72255. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72256. /**
  72257. * set the plane detector to use in order to create anchors from frames
  72258. * @param planeDetector the plane-detector module to use
  72259. * @param enable enable plane-anchors. default is true
  72260. */
  72261. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  72262. /**
  72263. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  72264. * @param hitTestModule the hit-test module to use.
  72265. */
  72266. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  72267. /**
  72268. * attach this feature
  72269. * Will usually be called by the features manager
  72270. *
  72271. * @returns true if successful.
  72272. */
  72273. attach(): boolean;
  72274. /**
  72275. * detach this feature.
  72276. * Will usually be called by the features manager
  72277. *
  72278. * @returns true if successful.
  72279. */
  72280. detach(): boolean;
  72281. /**
  72282. * Dispose this feature and all of the resources attached
  72283. */
  72284. dispose(): void;
  72285. protected _onXRFrame(frame: XRFrame): void;
  72286. private _onSelect;
  72287. /**
  72288. * Add anchor at a specific XR point.
  72289. *
  72290. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  72291. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  72292. * @returns a promise the fulfills when the anchor was created
  72293. */
  72294. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  72295. private _updateAnchorWithXRFrame;
  72296. /**
  72297. * avoiding using Array.find for global support.
  72298. * @param xrAnchor the plane to find in the array
  72299. */
  72300. private _findIndexInAnchorArray;
  72301. }
  72302. }
  72303. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  72304. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72305. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72306. import { Observable } from "babylonjs/Misc/observable";
  72307. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72308. /**
  72309. * Options interface for the background remover plugin
  72310. */
  72311. export interface IWebXRBackgroundRemoverOptions {
  72312. /**
  72313. * don't disable the environment helper
  72314. */
  72315. ignoreEnvironmentHelper?: boolean;
  72316. /**
  72317. * flags to configure the removal of the environment helper.
  72318. * If not set, the entire background will be removed. If set, flags should be set as well.
  72319. */
  72320. environmentHelperRemovalFlags?: {
  72321. /**
  72322. * Should the skybox be removed (default false)
  72323. */
  72324. skyBox?: boolean;
  72325. /**
  72326. * Should the ground be removed (default false)
  72327. */
  72328. ground?: boolean;
  72329. };
  72330. /**
  72331. * Further background meshes to disable when entering AR
  72332. */
  72333. backgroundMeshes?: AbstractMesh[];
  72334. }
  72335. /**
  72336. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  72337. */
  72338. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  72339. /**
  72340. * read-only options to be used in this module
  72341. */
  72342. readonly options: IWebXRBackgroundRemoverOptions;
  72343. /**
  72344. * The module's name
  72345. */
  72346. static readonly Name: string;
  72347. /**
  72348. * The (Babylon) version of this module.
  72349. * This is an integer representing the implementation version.
  72350. * This number does not correspond to the webxr specs version
  72351. */
  72352. static readonly Version: number;
  72353. /**
  72354. * registered observers will be triggered when the background state changes
  72355. */
  72356. onBackgroundStateChangedObservable: Observable<boolean>;
  72357. /**
  72358. * constructs a new background remover module
  72359. * @param _xrSessionManager the session manager for this module
  72360. * @param options read-only options to be used in this module
  72361. */
  72362. constructor(_xrSessionManager: WebXRSessionManager,
  72363. /**
  72364. * read-only options to be used in this module
  72365. */
  72366. options?: IWebXRBackgroundRemoverOptions);
  72367. /**
  72368. * attach this feature
  72369. * Will usually be called by the features manager
  72370. *
  72371. * @returns true if successful.
  72372. */
  72373. attach(): boolean;
  72374. /**
  72375. * detach this feature.
  72376. * Will usually be called by the features manager
  72377. *
  72378. * @returns true if successful.
  72379. */
  72380. detach(): boolean;
  72381. private _setBackgroundState;
  72382. /**
  72383. * Dispose this feature and all of the resources attached
  72384. */
  72385. dispose(): void;
  72386. protected _onXRFrame(_xrFrame: XRFrame): void;
  72387. }
  72388. }
  72389. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  72390. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72391. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  72392. import { WebXRInput } from "babylonjs/XR/webXRInput";
  72393. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72394. /**
  72395. * Options for the controller physics feature
  72396. */
  72397. export class IWebXRControllerPhysicsOptions {
  72398. /**
  72399. * the xr input to use with this pointer selection
  72400. */
  72401. xrInput: WebXRInput;
  72402. /**
  72403. * The physics properties of the future impostors
  72404. */
  72405. physicsProperties?: {
  72406. /**
  72407. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  72408. * Note that this requires a physics engine that supports mesh impostors!
  72409. */
  72410. useControllerMesh?: boolean;
  72411. /**
  72412. * The type of impostor to create. Default is sphere
  72413. */
  72414. impostorType?: number;
  72415. /**
  72416. * the size of the impostor. Defaults to 10cm
  72417. */
  72418. impostorSize?: number | {
  72419. width: number;
  72420. height: number;
  72421. depth: number;
  72422. };
  72423. /**
  72424. * Friction definitions
  72425. */
  72426. friction?: number;
  72427. /**
  72428. * Restitution
  72429. */
  72430. restitution?: number;
  72431. };
  72432. }
  72433. /**
  72434. * Add physics impostor to your webxr controllers,
  72435. * including naive calculation of their linear and angular velocity
  72436. */
  72437. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  72438. private readonly _options;
  72439. /**
  72440. * The module's name
  72441. */
  72442. static readonly Name: string;
  72443. /**
  72444. * The (Babylon) version of this module.
  72445. * This is an integer representing the implementation version.
  72446. * This number does not correspond to the webxr specs version
  72447. */
  72448. static readonly Version: number;
  72449. private _lastTimestamp;
  72450. private _delta;
  72451. private _controllers;
  72452. private _tmpVector;
  72453. private _tmpQuaternion;
  72454. /**
  72455. * Construct a new Controller Physics Feature
  72456. * @param _xrSessionManager the corresponding xr session manager
  72457. * @param _options options to create this feature with
  72458. */
  72459. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  72460. /**
  72461. * Update the physics properties provided in the constructor
  72462. * @param newProperties the new properties object
  72463. */
  72464. setPhysicsProperties(newProperties: {
  72465. impostorType?: number;
  72466. impostorSize?: number | {
  72467. width: number;
  72468. height: number;
  72469. depth: number;
  72470. };
  72471. friction?: number;
  72472. restitution?: number;
  72473. }): void;
  72474. /**
  72475. * attach this feature
  72476. * Will usually be called by the features manager
  72477. *
  72478. * @returns true if successful.
  72479. */
  72480. attach(): boolean;
  72481. /**
  72482. * detach this feature.
  72483. * Will usually be called by the features manager
  72484. *
  72485. * @returns true if successful.
  72486. */
  72487. detach(): boolean;
  72488. /**
  72489. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  72490. * @param xrController the controller to add
  72491. */
  72492. addController(xrController: WebXRInputSource): void;
  72493. private _debugMode;
  72494. /**
  72495. * @hidden
  72496. * enable debugging - will show console outputs and the impostor mesh
  72497. */
  72498. _enablePhysicsDebug(): void;
  72499. private _attachController;
  72500. private _detachController;
  72501. protected _onXRFrame(_xrFrame: any): void;
  72502. }
  72503. }
  72504. declare module "babylonjs/XR/features/index" {
  72505. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  72506. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  72507. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  72508. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  72509. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  72510. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  72511. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  72512. }
  72513. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  72514. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  72515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72516. import { Scene } from "babylonjs/scene";
  72517. /**
  72518. * The motion controller class for all microsoft mixed reality controllers
  72519. */
  72520. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  72521. /**
  72522. * The base url used to load the left and right controller models
  72523. */
  72524. static MODEL_BASE_URL: string;
  72525. /**
  72526. * The name of the left controller model file
  72527. */
  72528. static MODEL_LEFT_FILENAME: string;
  72529. /**
  72530. * The name of the right controller model file
  72531. */
  72532. static MODEL_RIGHT_FILENAME: string;
  72533. profileId: string;
  72534. protected readonly _mapping: {
  72535. defaultButton: {
  72536. "valueNodeName": string;
  72537. "unpressedNodeName": string;
  72538. "pressedNodeName": string;
  72539. };
  72540. defaultAxis: {
  72541. "valueNodeName": string;
  72542. "minNodeName": string;
  72543. "maxNodeName": string;
  72544. };
  72545. buttons: {
  72546. "xr-standard-trigger": {
  72547. "rootNodeName": string;
  72548. "componentProperty": string;
  72549. "states": string[];
  72550. };
  72551. "xr-standard-squeeze": {
  72552. "rootNodeName": string;
  72553. "componentProperty": string;
  72554. "states": string[];
  72555. };
  72556. "xr-standard-touchpad": {
  72557. "rootNodeName": string;
  72558. "labelAnchorNodeName": string;
  72559. "touchPointNodeName": string;
  72560. };
  72561. "xr-standard-thumbstick": {
  72562. "rootNodeName": string;
  72563. "componentProperty": string;
  72564. "states": string[];
  72565. };
  72566. };
  72567. axes: {
  72568. "xr-standard-touchpad": {
  72569. "x-axis": {
  72570. "rootNodeName": string;
  72571. };
  72572. "y-axis": {
  72573. "rootNodeName": string;
  72574. };
  72575. };
  72576. "xr-standard-thumbstick": {
  72577. "x-axis": {
  72578. "rootNodeName": string;
  72579. };
  72580. "y-axis": {
  72581. "rootNodeName": string;
  72582. };
  72583. };
  72584. };
  72585. };
  72586. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  72587. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72588. protected _getFilenameAndPath(): {
  72589. filename: string;
  72590. path: string;
  72591. };
  72592. protected _updateModel(): void;
  72593. protected _getModelLoadingConstraints(): boolean;
  72594. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72595. }
  72596. }
  72597. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  72598. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  72599. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72600. import { Scene } from "babylonjs/scene";
  72601. /**
  72602. * The motion controller class for oculus touch (quest, rift).
  72603. * This class supports legacy mapping as well the standard xr mapping
  72604. */
  72605. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  72606. private _forceLegacyControllers;
  72607. /**
  72608. * The base url used to load the left and right controller models
  72609. */
  72610. static MODEL_BASE_URL: string;
  72611. /**
  72612. * The name of the left controller model file
  72613. */
  72614. static MODEL_LEFT_FILENAME: string;
  72615. /**
  72616. * The name of the right controller model file
  72617. */
  72618. static MODEL_RIGHT_FILENAME: string;
  72619. /**
  72620. * Base Url for the Quest controller model.
  72621. */
  72622. static QUEST_MODEL_BASE_URL: string;
  72623. profileId: string;
  72624. private _modelRootNode;
  72625. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  72626. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72627. protected _getFilenameAndPath(): {
  72628. filename: string;
  72629. path: string;
  72630. };
  72631. /**
  72632. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  72633. * between the touch and touch 2.
  72634. */
  72635. private _isQuest;
  72636. protected _updateModel(): void;
  72637. protected _getModelLoadingConstraints(): boolean;
  72638. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72639. }
  72640. }
  72641. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  72642. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  72643. import { Scene } from "babylonjs/scene";
  72644. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72645. /**
  72646. * The motion controller class for the standard HTC-Vive controllers
  72647. */
  72648. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  72649. /**
  72650. * The base url used to load the left and right controller models
  72651. */
  72652. static MODEL_BASE_URL: string;
  72653. /**
  72654. * File name for the controller model.
  72655. */
  72656. static MODEL_FILENAME: string;
  72657. profileId: string;
  72658. private _modelRootNode;
  72659. /**
  72660. * Create a new Vive motion controller object
  72661. * @param scene the scene to use to create this controller
  72662. * @param gamepadObject the corresponding gamepad object
  72663. * @param handness the handness of the controller
  72664. */
  72665. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  72666. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72667. protected _getFilenameAndPath(): {
  72668. filename: string;
  72669. path: string;
  72670. };
  72671. protected _updateModel(): void;
  72672. protected _getModelLoadingConstraints(): boolean;
  72673. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72674. }
  72675. }
  72676. declare module "babylonjs/XR/motionController/index" {
  72677. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  72678. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  72679. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  72680. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  72681. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  72682. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  72683. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  72684. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  72685. }
  72686. declare module "babylonjs/XR/index" {
  72687. export * from "babylonjs/XR/webXRCamera";
  72688. export * from "babylonjs/XR/webXREnterExitUI";
  72689. export * from "babylonjs/XR/webXRExperienceHelper";
  72690. export * from "babylonjs/XR/webXRInput";
  72691. export * from "babylonjs/XR/webXRInputSource";
  72692. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  72693. export * from "babylonjs/XR/webXRTypes";
  72694. export * from "babylonjs/XR/webXRSessionManager";
  72695. export * from "babylonjs/XR/webXRDefaultExperience";
  72696. export * from "babylonjs/XR/webXRFeaturesManager";
  72697. export * from "babylonjs/XR/features/index";
  72698. export * from "babylonjs/XR/motionController/index";
  72699. }
  72700. declare module "babylonjs/index" {
  72701. export * from "babylonjs/abstractScene";
  72702. export * from "babylonjs/Actions/index";
  72703. export * from "babylonjs/Animations/index";
  72704. export * from "babylonjs/assetContainer";
  72705. export * from "babylonjs/Audio/index";
  72706. export * from "babylonjs/Behaviors/index";
  72707. export * from "babylonjs/Bones/index";
  72708. export * from "babylonjs/Cameras/index";
  72709. export * from "babylonjs/Collisions/index";
  72710. export * from "babylonjs/Culling/index";
  72711. export * from "babylonjs/Debug/index";
  72712. export * from "babylonjs/Engines/index";
  72713. export * from "babylonjs/Events/index";
  72714. export * from "babylonjs/Gamepads/index";
  72715. export * from "babylonjs/Gizmos/index";
  72716. export * from "babylonjs/Helpers/index";
  72717. export * from "babylonjs/Instrumentation/index";
  72718. export * from "babylonjs/Layers/index";
  72719. export * from "babylonjs/LensFlares/index";
  72720. export * from "babylonjs/Lights/index";
  72721. export * from "babylonjs/Loading/index";
  72722. export * from "babylonjs/Materials/index";
  72723. export * from "babylonjs/Maths/index";
  72724. export * from "babylonjs/Meshes/index";
  72725. export * from "babylonjs/Morph/index";
  72726. export * from "babylonjs/Navigation/index";
  72727. export * from "babylonjs/node";
  72728. export * from "babylonjs/Offline/index";
  72729. export * from "babylonjs/Particles/index";
  72730. export * from "babylonjs/Physics/index";
  72731. export * from "babylonjs/PostProcesses/index";
  72732. export * from "babylonjs/Probes/index";
  72733. export * from "babylonjs/Rendering/index";
  72734. export * from "babylonjs/scene";
  72735. export * from "babylonjs/sceneComponent";
  72736. export * from "babylonjs/Sprites/index";
  72737. export * from "babylonjs/States/index";
  72738. export * from "babylonjs/Misc/index";
  72739. export * from "babylonjs/XR/index";
  72740. export * from "babylonjs/types";
  72741. }
  72742. declare module "babylonjs/Animations/pathCursor" {
  72743. import { Vector3 } from "babylonjs/Maths/math.vector";
  72744. import { Path2 } from "babylonjs/Maths/math.path";
  72745. /**
  72746. * A cursor which tracks a point on a path
  72747. */
  72748. export class PathCursor {
  72749. private path;
  72750. /**
  72751. * Stores path cursor callbacks for when an onchange event is triggered
  72752. */
  72753. private _onchange;
  72754. /**
  72755. * The value of the path cursor
  72756. */
  72757. value: number;
  72758. /**
  72759. * The animation array of the path cursor
  72760. */
  72761. animations: Animation[];
  72762. /**
  72763. * Initializes the path cursor
  72764. * @param path The path to track
  72765. */
  72766. constructor(path: Path2);
  72767. /**
  72768. * Gets the cursor point on the path
  72769. * @returns A point on the path cursor at the cursor location
  72770. */
  72771. getPoint(): Vector3;
  72772. /**
  72773. * Moves the cursor ahead by the step amount
  72774. * @param step The amount to move the cursor forward
  72775. * @returns This path cursor
  72776. */
  72777. moveAhead(step?: number): PathCursor;
  72778. /**
  72779. * Moves the cursor behind by the step amount
  72780. * @param step The amount to move the cursor back
  72781. * @returns This path cursor
  72782. */
  72783. moveBack(step?: number): PathCursor;
  72784. /**
  72785. * Moves the cursor by the step amount
  72786. * If the step amount is greater than one, an exception is thrown
  72787. * @param step The amount to move the cursor
  72788. * @returns This path cursor
  72789. */
  72790. move(step: number): PathCursor;
  72791. /**
  72792. * Ensures that the value is limited between zero and one
  72793. * @returns This path cursor
  72794. */
  72795. private ensureLimits;
  72796. /**
  72797. * Runs onchange callbacks on change (used by the animation engine)
  72798. * @returns This path cursor
  72799. */
  72800. private raiseOnChange;
  72801. /**
  72802. * Executes a function on change
  72803. * @param f A path cursor onchange callback
  72804. * @returns This path cursor
  72805. */
  72806. onchange(f: (cursor: PathCursor) => void): PathCursor;
  72807. }
  72808. }
  72809. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  72810. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  72811. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  72812. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  72813. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  72814. }
  72815. declare module "babylonjs/Engines/Processors/Expressions/index" {
  72816. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  72817. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  72818. }
  72819. declare module "babylonjs/Engines/Processors/index" {
  72820. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  72821. export * from "babylonjs/Engines/Processors/Expressions/index";
  72822. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  72823. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  72824. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  72825. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  72826. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  72827. export * from "babylonjs/Engines/Processors/shaderProcessor";
  72828. }
  72829. declare module "babylonjs/Legacy/legacy" {
  72830. import * as Babylon from "babylonjs/index";
  72831. export * from "babylonjs/index";
  72832. }
  72833. declare module "babylonjs/Shaders/blur.fragment" {
  72834. /** @hidden */
  72835. export var blurPixelShader: {
  72836. name: string;
  72837. shader: string;
  72838. };
  72839. }
  72840. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  72841. /** @hidden */
  72842. export var pointCloudVertexDeclaration: {
  72843. name: string;
  72844. shader: string;
  72845. };
  72846. }
  72847. declare module "babylonjs" {
  72848. export * from "babylonjs/Legacy/legacy";
  72849. }
  72850. declare module BABYLON {
  72851. /** Alias type for value that can be null */
  72852. export type Nullable<T> = T | null;
  72853. /**
  72854. * Alias type for number that are floats
  72855. * @ignorenaming
  72856. */
  72857. export type float = number;
  72858. /**
  72859. * Alias type for number that are doubles.
  72860. * @ignorenaming
  72861. */
  72862. export type double = number;
  72863. /**
  72864. * Alias type for number that are integer
  72865. * @ignorenaming
  72866. */
  72867. export type int = number;
  72868. /** Alias type for number array or Float32Array */
  72869. export type FloatArray = number[] | Float32Array;
  72870. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  72871. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  72872. /**
  72873. * Alias for types that can be used by a Buffer or VertexBuffer.
  72874. */
  72875. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  72876. /**
  72877. * Alias type for primitive types
  72878. * @ignorenaming
  72879. */
  72880. type Primitive = undefined | null | boolean | string | number | Function;
  72881. /**
  72882. * Type modifier to make all the properties of an object Readonly
  72883. */
  72884. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  72885. /**
  72886. * Type modifier to make all the properties of an object Readonly recursively
  72887. */
  72888. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  72889. /**
  72890. * Type modifier to make object properties readonly.
  72891. */
  72892. export type DeepImmutableObject<T> = {
  72893. readonly [K in keyof T]: DeepImmutable<T[K]>;
  72894. };
  72895. /** @hidden */
  72896. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  72897. }
  72898. }
  72899. declare module BABYLON {
  72900. /**
  72901. * A class serves as a medium between the observable and its observers
  72902. */
  72903. export class EventState {
  72904. /**
  72905. * Create a new EventState
  72906. * @param mask defines the mask associated with this state
  72907. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  72908. * @param target defines the original target of the state
  72909. * @param currentTarget defines the current target of the state
  72910. */
  72911. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  72912. /**
  72913. * Initialize the current event state
  72914. * @param mask defines the mask associated with this state
  72915. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  72916. * @param target defines the original target of the state
  72917. * @param currentTarget defines the current target of the state
  72918. * @returns the current event state
  72919. */
  72920. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72921. /**
  72922. * An Observer can set this property to true to prevent subsequent observers of being notified
  72923. */
  72924. skipNextObservers: boolean;
  72925. /**
  72926. * Get the mask value that were used to trigger the event corresponding to this EventState object
  72927. */
  72928. mask: number;
  72929. /**
  72930. * The object that originally notified the event
  72931. */
  72932. target?: any;
  72933. /**
  72934. * The current object in the bubbling phase
  72935. */
  72936. currentTarget?: any;
  72937. /**
  72938. * This will be populated with the return value of the last function that was executed.
  72939. * If it is the first function in the callback chain it will be the event data.
  72940. */
  72941. lastReturnValue?: any;
  72942. }
  72943. /**
  72944. * Represent an Observer registered to a given Observable object.
  72945. */
  72946. export class Observer<T> {
  72947. /**
  72948. * Defines the callback to call when the observer is notified
  72949. */
  72950. callback: (eventData: T, eventState: EventState) => void;
  72951. /**
  72952. * Defines the mask of the observer (used to filter notifications)
  72953. */
  72954. mask: number;
  72955. /**
  72956. * Defines the current scope used to restore the JS context
  72957. */
  72958. scope: any;
  72959. /** @hidden */
  72960. _willBeUnregistered: boolean;
  72961. /**
  72962. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  72963. */
  72964. unregisterOnNextCall: boolean;
  72965. /**
  72966. * Creates a new observer
  72967. * @param callback defines the callback to call when the observer is notified
  72968. * @param mask defines the mask of the observer (used to filter notifications)
  72969. * @param scope defines the current scope used to restore the JS context
  72970. */
  72971. constructor(
  72972. /**
  72973. * Defines the callback to call when the observer is notified
  72974. */
  72975. callback: (eventData: T, eventState: EventState) => void,
  72976. /**
  72977. * Defines the mask of the observer (used to filter notifications)
  72978. */
  72979. mask: number,
  72980. /**
  72981. * Defines the current scope used to restore the JS context
  72982. */
  72983. scope?: any);
  72984. }
  72985. /**
  72986. * Represent a list of observers registered to multiple Observables object.
  72987. */
  72988. export class MultiObserver<T> {
  72989. private _observers;
  72990. private _observables;
  72991. /**
  72992. * Release associated resources
  72993. */
  72994. dispose(): void;
  72995. /**
  72996. * Raise a callback when one of the observable will notify
  72997. * @param observables defines a list of observables to watch
  72998. * @param callback defines the callback to call on notification
  72999. * @param mask defines the mask used to filter notifications
  73000. * @param scope defines the current scope used to restore the JS context
  73001. * @returns the new MultiObserver
  73002. */
  73003. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  73004. }
  73005. /**
  73006. * The Observable class is a simple implementation of the Observable pattern.
  73007. *
  73008. * 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.
  73009. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  73010. * 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).
  73011. * 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.
  73012. */
  73013. export class Observable<T> {
  73014. private _observers;
  73015. private _eventState;
  73016. private _onObserverAdded;
  73017. /**
  73018. * Gets the list of observers
  73019. */
  73020. get observers(): Array<Observer<T>>;
  73021. /**
  73022. * Creates a new observable
  73023. * @param onObserverAdded defines a callback to call when a new observer is added
  73024. */
  73025. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  73026. /**
  73027. * Create a new Observer with the specified callback
  73028. * @param callback the callback that will be executed for that Observer
  73029. * @param mask the mask used to filter observers
  73030. * @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.
  73031. * @param scope optional scope for the callback to be called from
  73032. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  73033. * @returns the new observer created for the callback
  73034. */
  73035. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  73036. /**
  73037. * Create a new Observer with the specified callback and unregisters after the next notification
  73038. * @param callback the callback that will be executed for that Observer
  73039. * @returns the new observer created for the callback
  73040. */
  73041. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  73042. /**
  73043. * Remove an Observer from the Observable object
  73044. * @param observer the instance of the Observer to remove
  73045. * @returns false if it doesn't belong to this Observable
  73046. */
  73047. remove(observer: Nullable<Observer<T>>): boolean;
  73048. /**
  73049. * Remove a callback from the Observable object
  73050. * @param callback the callback to remove
  73051. * @param scope optional scope. If used only the callbacks with this scope will be removed
  73052. * @returns false if it doesn't belong to this Observable
  73053. */
  73054. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  73055. private _deferUnregister;
  73056. private _remove;
  73057. /**
  73058. * Moves the observable to the top of the observer list making it get called first when notified
  73059. * @param observer the observer to move
  73060. */
  73061. makeObserverTopPriority(observer: Observer<T>): void;
  73062. /**
  73063. * Moves the observable to the bottom of the observer list making it get called last when notified
  73064. * @param observer the observer to move
  73065. */
  73066. makeObserverBottomPriority(observer: Observer<T>): void;
  73067. /**
  73068. * Notify all Observers by calling their respective callback with the given data
  73069. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  73070. * @param eventData defines the data to send to all observers
  73071. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  73072. * @param target defines the original target of the state
  73073. * @param currentTarget defines the current target of the state
  73074. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  73075. */
  73076. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  73077. /**
  73078. * Calling this will execute each callback, expecting it to be a promise or return a value.
  73079. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  73080. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  73081. * and it is crucial that all callbacks will be executed.
  73082. * The order of the callbacks is kept, callbacks are not executed parallel.
  73083. *
  73084. * @param eventData The data to be sent to each callback
  73085. * @param mask is used to filter observers defaults to -1
  73086. * @param target defines the callback target (see EventState)
  73087. * @param currentTarget defines he current object in the bubbling phase
  73088. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  73089. */
  73090. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  73091. /**
  73092. * Notify a specific observer
  73093. * @param observer defines the observer to notify
  73094. * @param eventData defines the data to be sent to each callback
  73095. * @param mask is used to filter observers defaults to -1
  73096. */
  73097. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  73098. /**
  73099. * Gets a boolean indicating if the observable has at least one observer
  73100. * @returns true is the Observable has at least one Observer registered
  73101. */
  73102. hasObservers(): boolean;
  73103. /**
  73104. * Clear the list of observers
  73105. */
  73106. clear(): void;
  73107. /**
  73108. * Clone the current observable
  73109. * @returns a new observable
  73110. */
  73111. clone(): Observable<T>;
  73112. /**
  73113. * Does this observable handles observer registered with a given mask
  73114. * @param mask defines the mask to be tested
  73115. * @return whether or not one observer registered with the given mask is handeled
  73116. **/
  73117. hasSpecificMask(mask?: number): boolean;
  73118. }
  73119. }
  73120. declare module BABYLON {
  73121. /**
  73122. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  73123. * Babylon.js
  73124. */
  73125. export class DomManagement {
  73126. /**
  73127. * Checks if the window object exists
  73128. * @returns true if the window object exists
  73129. */
  73130. static IsWindowObjectExist(): boolean;
  73131. /**
  73132. * Checks if the navigator object exists
  73133. * @returns true if the navigator object exists
  73134. */
  73135. static IsNavigatorAvailable(): boolean;
  73136. /**
  73137. * Extracts text content from a DOM element hierarchy
  73138. * @param element defines the root element
  73139. * @returns a string
  73140. */
  73141. static GetDOMTextContent(element: HTMLElement): string;
  73142. }
  73143. }
  73144. declare module BABYLON {
  73145. /**
  73146. * Logger used througouht the application to allow configuration of
  73147. * the log level required for the messages.
  73148. */
  73149. export class Logger {
  73150. /**
  73151. * No log
  73152. */
  73153. static readonly NoneLogLevel: number;
  73154. /**
  73155. * Only message logs
  73156. */
  73157. static readonly MessageLogLevel: number;
  73158. /**
  73159. * Only warning logs
  73160. */
  73161. static readonly WarningLogLevel: number;
  73162. /**
  73163. * Only error logs
  73164. */
  73165. static readonly ErrorLogLevel: number;
  73166. /**
  73167. * All logs
  73168. */
  73169. static readonly AllLogLevel: number;
  73170. private static _LogCache;
  73171. /**
  73172. * Gets a value indicating the number of loading errors
  73173. * @ignorenaming
  73174. */
  73175. static errorsCount: number;
  73176. /**
  73177. * Callback called when a new log is added
  73178. */
  73179. static OnNewCacheEntry: (entry: string) => void;
  73180. private static _AddLogEntry;
  73181. private static _FormatMessage;
  73182. private static _LogDisabled;
  73183. private static _LogEnabled;
  73184. private static _WarnDisabled;
  73185. private static _WarnEnabled;
  73186. private static _ErrorDisabled;
  73187. private static _ErrorEnabled;
  73188. /**
  73189. * Log a message to the console
  73190. */
  73191. static Log: (message: string) => void;
  73192. /**
  73193. * Write a warning message to the console
  73194. */
  73195. static Warn: (message: string) => void;
  73196. /**
  73197. * Write an error message to the console
  73198. */
  73199. static Error: (message: string) => void;
  73200. /**
  73201. * Gets current log cache (list of logs)
  73202. */
  73203. static get LogCache(): string;
  73204. /**
  73205. * Clears the log cache
  73206. */
  73207. static ClearLogCache(): void;
  73208. /**
  73209. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  73210. */
  73211. static set LogLevels(level: number);
  73212. }
  73213. }
  73214. declare module BABYLON {
  73215. /** @hidden */
  73216. export class _TypeStore {
  73217. /** @hidden */
  73218. static RegisteredTypes: {
  73219. [key: string]: Object;
  73220. };
  73221. /** @hidden */
  73222. static GetClass(fqdn: string): any;
  73223. }
  73224. }
  73225. declare module BABYLON {
  73226. /**
  73227. * Helper to manipulate strings
  73228. */
  73229. export class StringTools {
  73230. /**
  73231. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  73232. * @param str Source string
  73233. * @param suffix Suffix to search for in the source string
  73234. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73235. */
  73236. static EndsWith(str: string, suffix: string): boolean;
  73237. /**
  73238. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  73239. * @param str Source string
  73240. * @param suffix Suffix to search for in the source string
  73241. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73242. */
  73243. static StartsWith(str: string, suffix: string): boolean;
  73244. /**
  73245. * Decodes a buffer into a string
  73246. * @param buffer The buffer to decode
  73247. * @returns The decoded string
  73248. */
  73249. static Decode(buffer: Uint8Array | Uint16Array): string;
  73250. /**
  73251. * Encode a buffer to a base64 string
  73252. * @param buffer defines the buffer to encode
  73253. * @returns the encoded string
  73254. */
  73255. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  73256. }
  73257. }
  73258. declare module BABYLON {
  73259. /**
  73260. * Class containing a set of static utilities functions for deep copy.
  73261. */
  73262. export class DeepCopier {
  73263. /**
  73264. * Tries to copy an object by duplicating every property
  73265. * @param source defines the source object
  73266. * @param destination defines the target object
  73267. * @param doNotCopyList defines a list of properties to avoid
  73268. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  73269. */
  73270. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  73271. }
  73272. }
  73273. declare module BABYLON {
  73274. /**
  73275. * Class containing a set of static utilities functions for precision date
  73276. */
  73277. export class PrecisionDate {
  73278. /**
  73279. * Gets either window.performance.now() if supported or Date.now() else
  73280. */
  73281. static get Now(): number;
  73282. }
  73283. }
  73284. declare module BABYLON {
  73285. /** @hidden */
  73286. export class _DevTools {
  73287. static WarnImport(name: string): string;
  73288. }
  73289. }
  73290. declare module BABYLON {
  73291. /**
  73292. * Interface used to define the mechanism to get data from the network
  73293. */
  73294. export interface IWebRequest {
  73295. /**
  73296. * Returns client's response url
  73297. */
  73298. responseURL: string;
  73299. /**
  73300. * Returns client's status
  73301. */
  73302. status: number;
  73303. /**
  73304. * Returns client's status as a text
  73305. */
  73306. statusText: string;
  73307. }
  73308. }
  73309. declare module BABYLON {
  73310. /**
  73311. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  73312. */
  73313. export class WebRequest implements IWebRequest {
  73314. private _xhr;
  73315. /**
  73316. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  73317. * i.e. when loading files, where the server/service expects an Authorization header
  73318. */
  73319. static CustomRequestHeaders: {
  73320. [key: string]: string;
  73321. };
  73322. /**
  73323. * Add callback functions in this array to update all the requests before they get sent to the network
  73324. */
  73325. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  73326. private _injectCustomRequestHeaders;
  73327. /**
  73328. * Gets or sets a function to be called when loading progress changes
  73329. */
  73330. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  73331. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  73332. /**
  73333. * Returns client's state
  73334. */
  73335. get readyState(): number;
  73336. /**
  73337. * Returns client's status
  73338. */
  73339. get status(): number;
  73340. /**
  73341. * Returns client's status as a text
  73342. */
  73343. get statusText(): string;
  73344. /**
  73345. * Returns client's response
  73346. */
  73347. get response(): any;
  73348. /**
  73349. * Returns client's response url
  73350. */
  73351. get responseURL(): string;
  73352. /**
  73353. * Returns client's response as text
  73354. */
  73355. get responseText(): string;
  73356. /**
  73357. * Gets or sets the expected response type
  73358. */
  73359. get responseType(): XMLHttpRequestResponseType;
  73360. set responseType(value: XMLHttpRequestResponseType);
  73361. /** @hidden */
  73362. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  73363. /** @hidden */
  73364. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  73365. /**
  73366. * Cancels any network activity
  73367. */
  73368. abort(): void;
  73369. /**
  73370. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  73371. * @param body defines an optional request body
  73372. */
  73373. send(body?: Document | BodyInit | null): void;
  73374. /**
  73375. * Sets the request method, request URL
  73376. * @param method defines the method to use (GET, POST, etc..)
  73377. * @param url defines the url to connect with
  73378. */
  73379. open(method: string, url: string): void;
  73380. /**
  73381. * Sets the value of a request header.
  73382. * @param name The name of the header whose value is to be set
  73383. * @param value The value to set as the body of the header
  73384. */
  73385. setRequestHeader(name: string, value: string): void;
  73386. /**
  73387. * Get the string containing the text of a particular header's value.
  73388. * @param name The name of the header
  73389. * @returns The string containing the text of the given header name
  73390. */
  73391. getResponseHeader(name: string): Nullable<string>;
  73392. }
  73393. }
  73394. declare module BABYLON {
  73395. /**
  73396. * File request interface
  73397. */
  73398. export interface IFileRequest {
  73399. /**
  73400. * Raised when the request is complete (success or error).
  73401. */
  73402. onCompleteObservable: Observable<IFileRequest>;
  73403. /**
  73404. * Aborts the request for a file.
  73405. */
  73406. abort: () => void;
  73407. }
  73408. }
  73409. declare module BABYLON {
  73410. /**
  73411. * Define options used to create a render target texture
  73412. */
  73413. export class RenderTargetCreationOptions {
  73414. /**
  73415. * Specifies is mipmaps must be generated
  73416. */
  73417. generateMipMaps?: boolean;
  73418. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  73419. generateDepthBuffer?: boolean;
  73420. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  73421. generateStencilBuffer?: boolean;
  73422. /** Defines texture type (int by default) */
  73423. type?: number;
  73424. /** Defines sampling mode (trilinear by default) */
  73425. samplingMode?: number;
  73426. /** Defines format (RGBA by default) */
  73427. format?: number;
  73428. }
  73429. }
  73430. declare module BABYLON {
  73431. /**
  73432. * @hidden
  73433. **/
  73434. export class _TimeToken {
  73435. _startTimeQuery: Nullable<WebGLQuery>;
  73436. _endTimeQuery: Nullable<WebGLQuery>;
  73437. _timeElapsedQuery: Nullable<WebGLQuery>;
  73438. _timeElapsedQueryEnded: boolean;
  73439. }
  73440. }
  73441. declare module BABYLON {
  73442. /** Defines the cross module used constants to avoid circular dependncies */
  73443. export class Constants {
  73444. /** Defines that alpha blending is disabled */
  73445. static readonly ALPHA_DISABLE: number;
  73446. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  73447. static readonly ALPHA_ADD: number;
  73448. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  73449. static readonly ALPHA_COMBINE: number;
  73450. /** Defines that alpha blending is DEST - SRC * DEST */
  73451. static readonly ALPHA_SUBTRACT: number;
  73452. /** Defines that alpha blending is SRC * DEST */
  73453. static readonly ALPHA_MULTIPLY: number;
  73454. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  73455. static readonly ALPHA_MAXIMIZED: number;
  73456. /** Defines that alpha blending is SRC + DEST */
  73457. static readonly ALPHA_ONEONE: number;
  73458. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  73459. static readonly ALPHA_PREMULTIPLIED: number;
  73460. /**
  73461. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  73462. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  73463. */
  73464. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  73465. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  73466. static readonly ALPHA_INTERPOLATE: number;
  73467. /**
  73468. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  73469. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  73470. */
  73471. static readonly ALPHA_SCREENMODE: number;
  73472. /**
  73473. * Defines that alpha blending is SRC + DST
  73474. * Alpha will be set to SRC ALPHA + DST ALPHA
  73475. */
  73476. static readonly ALPHA_ONEONE_ONEONE: number;
  73477. /**
  73478. * Defines that alpha blending is SRC * DST ALPHA + DST
  73479. * Alpha will be set to 0
  73480. */
  73481. static readonly ALPHA_ALPHATOCOLOR: number;
  73482. /**
  73483. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73484. */
  73485. static readonly ALPHA_REVERSEONEMINUS: number;
  73486. /**
  73487. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  73488. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  73489. */
  73490. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  73491. /**
  73492. * Defines that alpha blending is SRC + DST
  73493. * Alpha will be set to SRC ALPHA
  73494. */
  73495. static readonly ALPHA_ONEONE_ONEZERO: number;
  73496. /**
  73497. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73498. * Alpha will be set to DST ALPHA
  73499. */
  73500. static readonly ALPHA_EXCLUSION: number;
  73501. /** Defines that alpha blending equation a SUM */
  73502. static readonly ALPHA_EQUATION_ADD: number;
  73503. /** Defines that alpha blending equation a SUBSTRACTION */
  73504. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  73505. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  73506. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  73507. /** Defines that alpha blending equation a MAX operation */
  73508. static readonly ALPHA_EQUATION_MAX: number;
  73509. /** Defines that alpha blending equation a MIN operation */
  73510. static readonly ALPHA_EQUATION_MIN: number;
  73511. /**
  73512. * Defines that alpha blending equation a DARKEN operation:
  73513. * It takes the min of the src and sums the alpha channels.
  73514. */
  73515. static readonly ALPHA_EQUATION_DARKEN: number;
  73516. /** Defines that the ressource is not delayed*/
  73517. static readonly DELAYLOADSTATE_NONE: number;
  73518. /** Defines that the ressource was successfully delay loaded */
  73519. static readonly DELAYLOADSTATE_LOADED: number;
  73520. /** Defines that the ressource is currently delay loading */
  73521. static readonly DELAYLOADSTATE_LOADING: number;
  73522. /** Defines that the ressource is delayed and has not started loading */
  73523. static readonly DELAYLOADSTATE_NOTLOADED: number;
  73524. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  73525. static readonly NEVER: number;
  73526. /** 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 */
  73527. static readonly ALWAYS: number;
  73528. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  73529. static readonly LESS: number;
  73530. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  73531. static readonly EQUAL: number;
  73532. /** 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 */
  73533. static readonly LEQUAL: number;
  73534. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  73535. static readonly GREATER: number;
  73536. /** 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 */
  73537. static readonly GEQUAL: number;
  73538. /** 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 */
  73539. static readonly NOTEQUAL: number;
  73540. /** Passed to stencilOperation to specify that stencil value must be kept */
  73541. static readonly KEEP: number;
  73542. /** Passed to stencilOperation to specify that stencil value must be replaced */
  73543. static readonly REPLACE: number;
  73544. /** Passed to stencilOperation to specify that stencil value must be incremented */
  73545. static readonly INCR: number;
  73546. /** Passed to stencilOperation to specify that stencil value must be decremented */
  73547. static readonly DECR: number;
  73548. /** Passed to stencilOperation to specify that stencil value must be inverted */
  73549. static readonly INVERT: number;
  73550. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  73551. static readonly INCR_WRAP: number;
  73552. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  73553. static readonly DECR_WRAP: number;
  73554. /** Texture is not repeating outside of 0..1 UVs */
  73555. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  73556. /** Texture is repeating outside of 0..1 UVs */
  73557. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  73558. /** Texture is repeating and mirrored */
  73559. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  73560. /** ALPHA */
  73561. static readonly TEXTUREFORMAT_ALPHA: number;
  73562. /** LUMINANCE */
  73563. static readonly TEXTUREFORMAT_LUMINANCE: number;
  73564. /** LUMINANCE_ALPHA */
  73565. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  73566. /** RGB */
  73567. static readonly TEXTUREFORMAT_RGB: number;
  73568. /** RGBA */
  73569. static readonly TEXTUREFORMAT_RGBA: number;
  73570. /** RED */
  73571. static readonly TEXTUREFORMAT_RED: number;
  73572. /** RED (2nd reference) */
  73573. static readonly TEXTUREFORMAT_R: number;
  73574. /** RG */
  73575. static readonly TEXTUREFORMAT_RG: number;
  73576. /** RED_INTEGER */
  73577. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  73578. /** RED_INTEGER (2nd reference) */
  73579. static readonly TEXTUREFORMAT_R_INTEGER: number;
  73580. /** RG_INTEGER */
  73581. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  73582. /** RGB_INTEGER */
  73583. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  73584. /** RGBA_INTEGER */
  73585. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  73586. /** UNSIGNED_BYTE */
  73587. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  73588. /** UNSIGNED_BYTE (2nd reference) */
  73589. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  73590. /** FLOAT */
  73591. static readonly TEXTURETYPE_FLOAT: number;
  73592. /** HALF_FLOAT */
  73593. static readonly TEXTURETYPE_HALF_FLOAT: number;
  73594. /** BYTE */
  73595. static readonly TEXTURETYPE_BYTE: number;
  73596. /** SHORT */
  73597. static readonly TEXTURETYPE_SHORT: number;
  73598. /** UNSIGNED_SHORT */
  73599. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  73600. /** INT */
  73601. static readonly TEXTURETYPE_INT: number;
  73602. /** UNSIGNED_INT */
  73603. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  73604. /** UNSIGNED_SHORT_4_4_4_4 */
  73605. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  73606. /** UNSIGNED_SHORT_5_5_5_1 */
  73607. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  73608. /** UNSIGNED_SHORT_5_6_5 */
  73609. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  73610. /** UNSIGNED_INT_2_10_10_10_REV */
  73611. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  73612. /** UNSIGNED_INT_24_8 */
  73613. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  73614. /** UNSIGNED_INT_10F_11F_11F_REV */
  73615. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  73616. /** UNSIGNED_INT_5_9_9_9_REV */
  73617. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  73618. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  73619. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  73620. /** nearest is mag = nearest and min = nearest and no mip */
  73621. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  73622. /** mag = nearest and min = nearest and mip = none */
  73623. static readonly TEXTURE_NEAREST_NEAREST: number;
  73624. /** Bilinear is mag = linear and min = linear and no mip */
  73625. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  73626. /** mag = linear and min = linear and mip = none */
  73627. static readonly TEXTURE_LINEAR_LINEAR: number;
  73628. /** Trilinear is mag = linear and min = linear and mip = linear */
  73629. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  73630. /** Trilinear is mag = linear and min = linear and mip = linear */
  73631. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  73632. /** mag = nearest and min = nearest and mip = nearest */
  73633. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  73634. /** mag = nearest and min = linear and mip = nearest */
  73635. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  73636. /** mag = nearest and min = linear and mip = linear */
  73637. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  73638. /** mag = nearest and min = linear and mip = none */
  73639. static readonly TEXTURE_NEAREST_LINEAR: number;
  73640. /** nearest is mag = nearest and min = nearest and mip = linear */
  73641. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  73642. /** mag = linear and min = nearest and mip = nearest */
  73643. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  73644. /** mag = linear and min = nearest and mip = linear */
  73645. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  73646. /** Bilinear is mag = linear and min = linear and mip = nearest */
  73647. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  73648. /** mag = linear and min = nearest and mip = none */
  73649. static readonly TEXTURE_LINEAR_NEAREST: number;
  73650. /** Explicit coordinates mode */
  73651. static readonly TEXTURE_EXPLICIT_MODE: number;
  73652. /** Spherical coordinates mode */
  73653. static readonly TEXTURE_SPHERICAL_MODE: number;
  73654. /** Planar coordinates mode */
  73655. static readonly TEXTURE_PLANAR_MODE: number;
  73656. /** Cubic coordinates mode */
  73657. static readonly TEXTURE_CUBIC_MODE: number;
  73658. /** Projection coordinates mode */
  73659. static readonly TEXTURE_PROJECTION_MODE: number;
  73660. /** Skybox coordinates mode */
  73661. static readonly TEXTURE_SKYBOX_MODE: number;
  73662. /** Inverse Cubic coordinates mode */
  73663. static readonly TEXTURE_INVCUBIC_MODE: number;
  73664. /** Equirectangular coordinates mode */
  73665. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  73666. /** Equirectangular Fixed coordinates mode */
  73667. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  73668. /** Equirectangular Fixed Mirrored coordinates mode */
  73669. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  73670. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  73671. static readonly SCALEMODE_FLOOR: number;
  73672. /** Defines that texture rescaling will look for the nearest power of 2 size */
  73673. static readonly SCALEMODE_NEAREST: number;
  73674. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  73675. static readonly SCALEMODE_CEILING: number;
  73676. /**
  73677. * The dirty texture flag value
  73678. */
  73679. static readonly MATERIAL_TextureDirtyFlag: number;
  73680. /**
  73681. * The dirty light flag value
  73682. */
  73683. static readonly MATERIAL_LightDirtyFlag: number;
  73684. /**
  73685. * The dirty fresnel flag value
  73686. */
  73687. static readonly MATERIAL_FresnelDirtyFlag: number;
  73688. /**
  73689. * The dirty attribute flag value
  73690. */
  73691. static readonly MATERIAL_AttributesDirtyFlag: number;
  73692. /**
  73693. * The dirty misc flag value
  73694. */
  73695. static readonly MATERIAL_MiscDirtyFlag: number;
  73696. /**
  73697. * The all dirty flag value
  73698. */
  73699. static readonly MATERIAL_AllDirtyFlag: number;
  73700. /**
  73701. * Returns the triangle fill mode
  73702. */
  73703. static readonly MATERIAL_TriangleFillMode: number;
  73704. /**
  73705. * Returns the wireframe mode
  73706. */
  73707. static readonly MATERIAL_WireFrameFillMode: number;
  73708. /**
  73709. * Returns the point fill mode
  73710. */
  73711. static readonly MATERIAL_PointFillMode: number;
  73712. /**
  73713. * Returns the point list draw mode
  73714. */
  73715. static readonly MATERIAL_PointListDrawMode: number;
  73716. /**
  73717. * Returns the line list draw mode
  73718. */
  73719. static readonly MATERIAL_LineListDrawMode: number;
  73720. /**
  73721. * Returns the line loop draw mode
  73722. */
  73723. static readonly MATERIAL_LineLoopDrawMode: number;
  73724. /**
  73725. * Returns the line strip draw mode
  73726. */
  73727. static readonly MATERIAL_LineStripDrawMode: number;
  73728. /**
  73729. * Returns the triangle strip draw mode
  73730. */
  73731. static readonly MATERIAL_TriangleStripDrawMode: number;
  73732. /**
  73733. * Returns the triangle fan draw mode
  73734. */
  73735. static readonly MATERIAL_TriangleFanDrawMode: number;
  73736. /**
  73737. * Stores the clock-wise side orientation
  73738. */
  73739. static readonly MATERIAL_ClockWiseSideOrientation: number;
  73740. /**
  73741. * Stores the counter clock-wise side orientation
  73742. */
  73743. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  73744. /**
  73745. * Nothing
  73746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73747. */
  73748. static readonly ACTION_NothingTrigger: number;
  73749. /**
  73750. * On pick
  73751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73752. */
  73753. static readonly ACTION_OnPickTrigger: number;
  73754. /**
  73755. * On left pick
  73756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73757. */
  73758. static readonly ACTION_OnLeftPickTrigger: number;
  73759. /**
  73760. * On right pick
  73761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73762. */
  73763. static readonly ACTION_OnRightPickTrigger: number;
  73764. /**
  73765. * On center pick
  73766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73767. */
  73768. static readonly ACTION_OnCenterPickTrigger: number;
  73769. /**
  73770. * On pick down
  73771. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73772. */
  73773. static readonly ACTION_OnPickDownTrigger: number;
  73774. /**
  73775. * On double pick
  73776. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73777. */
  73778. static readonly ACTION_OnDoublePickTrigger: number;
  73779. /**
  73780. * On pick up
  73781. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73782. */
  73783. static readonly ACTION_OnPickUpTrigger: number;
  73784. /**
  73785. * On pick out.
  73786. * This trigger will only be raised if you also declared a OnPickDown
  73787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73788. */
  73789. static readonly ACTION_OnPickOutTrigger: number;
  73790. /**
  73791. * On long press
  73792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73793. */
  73794. static readonly ACTION_OnLongPressTrigger: number;
  73795. /**
  73796. * On pointer over
  73797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73798. */
  73799. static readonly ACTION_OnPointerOverTrigger: number;
  73800. /**
  73801. * On pointer out
  73802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73803. */
  73804. static readonly ACTION_OnPointerOutTrigger: number;
  73805. /**
  73806. * On every frame
  73807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73808. */
  73809. static readonly ACTION_OnEveryFrameTrigger: number;
  73810. /**
  73811. * On intersection enter
  73812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73813. */
  73814. static readonly ACTION_OnIntersectionEnterTrigger: number;
  73815. /**
  73816. * On intersection exit
  73817. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73818. */
  73819. static readonly ACTION_OnIntersectionExitTrigger: number;
  73820. /**
  73821. * On key down
  73822. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73823. */
  73824. static readonly ACTION_OnKeyDownTrigger: number;
  73825. /**
  73826. * On key up
  73827. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73828. */
  73829. static readonly ACTION_OnKeyUpTrigger: number;
  73830. /**
  73831. * Billboard mode will only apply to Y axis
  73832. */
  73833. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  73834. /**
  73835. * Billboard mode will apply to all axes
  73836. */
  73837. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  73838. /**
  73839. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  73840. */
  73841. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  73842. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  73843. * Test order :
  73844. * Is the bounding sphere outside the frustum ?
  73845. * If not, are the bounding box vertices outside the frustum ?
  73846. * It not, then the cullable object is in the frustum.
  73847. */
  73848. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  73849. /** Culling strategy : Bounding Sphere Only.
  73850. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  73851. * It's also less accurate than the standard because some not visible objects can still be selected.
  73852. * Test : is the bounding sphere outside the frustum ?
  73853. * If not, then the cullable object is in the frustum.
  73854. */
  73855. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  73856. /** Culling strategy : Optimistic Inclusion.
  73857. * This in an inclusion test first, then the standard exclusion test.
  73858. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  73859. * 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.
  73860. * Anyway, it's as accurate as the standard strategy.
  73861. * Test :
  73862. * Is the cullable object bounding sphere center in the frustum ?
  73863. * If not, apply the default culling strategy.
  73864. */
  73865. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  73866. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  73867. * This in an inclusion test first, then the bounding sphere only exclusion test.
  73868. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  73869. * 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.
  73870. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  73871. * Test :
  73872. * Is the cullable object bounding sphere center in the frustum ?
  73873. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  73874. */
  73875. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  73876. /**
  73877. * No logging while loading
  73878. */
  73879. static readonly SCENELOADER_NO_LOGGING: number;
  73880. /**
  73881. * Minimal logging while loading
  73882. */
  73883. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  73884. /**
  73885. * Summary logging while loading
  73886. */
  73887. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  73888. /**
  73889. * Detailled logging while loading
  73890. */
  73891. static readonly SCENELOADER_DETAILED_LOGGING: number;
  73892. }
  73893. }
  73894. declare module BABYLON {
  73895. /**
  73896. * This represents the required contract to create a new type of texture loader.
  73897. */
  73898. export interface IInternalTextureLoader {
  73899. /**
  73900. * Defines wether the loader supports cascade loading the different faces.
  73901. */
  73902. supportCascades: boolean;
  73903. /**
  73904. * This returns if the loader support the current file information.
  73905. * @param extension defines the file extension of the file being loaded
  73906. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73907. * @param fallback defines the fallback internal texture if any
  73908. * @param isBase64 defines whether the texture is encoded as a base64
  73909. * @param isBuffer defines whether the texture data are stored as a buffer
  73910. * @returns true if the loader can load the specified file
  73911. */
  73912. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  73913. /**
  73914. * Transform the url before loading if required.
  73915. * @param rootUrl the url of the texture
  73916. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73917. * @returns the transformed texture
  73918. */
  73919. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  73920. /**
  73921. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  73922. * @param rootUrl the url of the texture
  73923. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73924. * @returns the fallback texture
  73925. */
  73926. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  73927. /**
  73928. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  73929. * @param data contains the texture data
  73930. * @param texture defines the BabylonJS internal texture
  73931. * @param createPolynomials will be true if polynomials have been requested
  73932. * @param onLoad defines the callback to trigger once the texture is ready
  73933. * @param onError defines the callback to trigger in case of error
  73934. */
  73935. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  73936. /**
  73937. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  73938. * @param data contains the texture data
  73939. * @param texture defines the BabylonJS internal texture
  73940. * @param callback defines the method to call once ready to upload
  73941. */
  73942. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  73943. }
  73944. }
  73945. declare module BABYLON {
  73946. /**
  73947. * Class used to store and describe the pipeline context associated with an effect
  73948. */
  73949. export interface IPipelineContext {
  73950. /**
  73951. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  73952. */
  73953. isAsync: boolean;
  73954. /**
  73955. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  73956. */
  73957. isReady: boolean;
  73958. /** @hidden */
  73959. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  73960. }
  73961. }
  73962. declare module BABYLON {
  73963. /**
  73964. * Class used to store gfx data (like WebGLBuffer)
  73965. */
  73966. export class DataBuffer {
  73967. /**
  73968. * Gets or sets the number of objects referencing this buffer
  73969. */
  73970. references: number;
  73971. /** Gets or sets the size of the underlying buffer */
  73972. capacity: number;
  73973. /**
  73974. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  73975. */
  73976. is32Bits: boolean;
  73977. /**
  73978. * Gets the underlying buffer
  73979. */
  73980. get underlyingResource(): any;
  73981. }
  73982. }
  73983. declare module BABYLON {
  73984. /** @hidden */
  73985. export interface IShaderProcessor {
  73986. attributeProcessor?: (attribute: string) => string;
  73987. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  73988. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  73989. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  73990. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  73991. lineProcessor?: (line: string, isFragment: boolean) => string;
  73992. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  73993. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  73994. }
  73995. }
  73996. declare module BABYLON {
  73997. /** @hidden */
  73998. export interface ProcessingOptions {
  73999. defines: string[];
  74000. indexParameters: any;
  74001. isFragment: boolean;
  74002. shouldUseHighPrecisionShader: boolean;
  74003. supportsUniformBuffers: boolean;
  74004. shadersRepository: string;
  74005. includesShadersStore: {
  74006. [key: string]: string;
  74007. };
  74008. processor?: IShaderProcessor;
  74009. version: string;
  74010. platformName: string;
  74011. lookForClosingBracketForUniformBuffer?: boolean;
  74012. }
  74013. }
  74014. declare module BABYLON {
  74015. /** @hidden */
  74016. export class ShaderCodeNode {
  74017. line: string;
  74018. children: ShaderCodeNode[];
  74019. additionalDefineKey?: string;
  74020. additionalDefineValue?: string;
  74021. isValid(preprocessors: {
  74022. [key: string]: string;
  74023. }): boolean;
  74024. process(preprocessors: {
  74025. [key: string]: string;
  74026. }, options: ProcessingOptions): string;
  74027. }
  74028. }
  74029. declare module BABYLON {
  74030. /** @hidden */
  74031. export class ShaderCodeCursor {
  74032. private _lines;
  74033. lineIndex: number;
  74034. get currentLine(): string;
  74035. get canRead(): boolean;
  74036. set lines(value: string[]);
  74037. }
  74038. }
  74039. declare module BABYLON {
  74040. /** @hidden */
  74041. export class ShaderCodeConditionNode extends ShaderCodeNode {
  74042. process(preprocessors: {
  74043. [key: string]: string;
  74044. }, options: ProcessingOptions): string;
  74045. }
  74046. }
  74047. declare module BABYLON {
  74048. /** @hidden */
  74049. export class ShaderDefineExpression {
  74050. isTrue(preprocessors: {
  74051. [key: string]: string;
  74052. }): boolean;
  74053. }
  74054. }
  74055. declare module BABYLON {
  74056. /** @hidden */
  74057. export class ShaderCodeTestNode extends ShaderCodeNode {
  74058. testExpression: ShaderDefineExpression;
  74059. isValid(preprocessors: {
  74060. [key: string]: string;
  74061. }): boolean;
  74062. }
  74063. }
  74064. declare module BABYLON {
  74065. /** @hidden */
  74066. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  74067. define: string;
  74068. not: boolean;
  74069. constructor(define: string, not?: boolean);
  74070. isTrue(preprocessors: {
  74071. [key: string]: string;
  74072. }): boolean;
  74073. }
  74074. }
  74075. declare module BABYLON {
  74076. /** @hidden */
  74077. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  74078. leftOperand: ShaderDefineExpression;
  74079. rightOperand: ShaderDefineExpression;
  74080. isTrue(preprocessors: {
  74081. [key: string]: string;
  74082. }): boolean;
  74083. }
  74084. }
  74085. declare module BABYLON {
  74086. /** @hidden */
  74087. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  74088. leftOperand: ShaderDefineExpression;
  74089. rightOperand: ShaderDefineExpression;
  74090. isTrue(preprocessors: {
  74091. [key: string]: string;
  74092. }): boolean;
  74093. }
  74094. }
  74095. declare module BABYLON {
  74096. /** @hidden */
  74097. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  74098. define: string;
  74099. operand: string;
  74100. testValue: string;
  74101. constructor(define: string, operand: string, testValue: string);
  74102. isTrue(preprocessors: {
  74103. [key: string]: string;
  74104. }): boolean;
  74105. }
  74106. }
  74107. declare module BABYLON {
  74108. /**
  74109. * Class used to enable access to offline support
  74110. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  74111. */
  74112. export interface IOfflineProvider {
  74113. /**
  74114. * Gets a boolean indicating if scene must be saved in the database
  74115. */
  74116. enableSceneOffline: boolean;
  74117. /**
  74118. * Gets a boolean indicating if textures must be saved in the database
  74119. */
  74120. enableTexturesOffline: boolean;
  74121. /**
  74122. * Open the offline support and make it available
  74123. * @param successCallback defines the callback to call on success
  74124. * @param errorCallback defines the callback to call on error
  74125. */
  74126. open(successCallback: () => void, errorCallback: () => void): void;
  74127. /**
  74128. * Loads an image from the offline support
  74129. * @param url defines the url to load from
  74130. * @param image defines the target DOM image
  74131. */
  74132. loadImage(url: string, image: HTMLImageElement): void;
  74133. /**
  74134. * Loads a file from offline support
  74135. * @param url defines the URL to load from
  74136. * @param sceneLoaded defines a callback to call on success
  74137. * @param progressCallBack defines a callback to call when progress changed
  74138. * @param errorCallback defines a callback to call on error
  74139. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  74140. */
  74141. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  74142. }
  74143. }
  74144. declare module BABYLON {
  74145. /**
  74146. * Class used to help managing file picking and drag'n'drop
  74147. * File Storage
  74148. */
  74149. export class FilesInputStore {
  74150. /**
  74151. * List of files ready to be loaded
  74152. */
  74153. static FilesToLoad: {
  74154. [key: string]: File;
  74155. };
  74156. }
  74157. }
  74158. declare module BABYLON {
  74159. /**
  74160. * Class used to define a retry strategy when error happens while loading assets
  74161. */
  74162. export class RetryStrategy {
  74163. /**
  74164. * Function used to defines an exponential back off strategy
  74165. * @param maxRetries defines the maximum number of retries (3 by default)
  74166. * @param baseInterval defines the interval between retries
  74167. * @returns the strategy function to use
  74168. */
  74169. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  74170. }
  74171. }
  74172. declare module BABYLON {
  74173. /**
  74174. * @ignore
  74175. * Application error to support additional information when loading a file
  74176. */
  74177. export abstract class BaseError extends Error {
  74178. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  74179. }
  74180. }
  74181. declare module BABYLON {
  74182. /** @ignore */
  74183. export class LoadFileError extends BaseError {
  74184. request?: WebRequest;
  74185. file?: File;
  74186. /**
  74187. * Creates a new LoadFileError
  74188. * @param message defines the message of the error
  74189. * @param request defines the optional web request
  74190. * @param file defines the optional file
  74191. */
  74192. constructor(message: string, object?: WebRequest | File);
  74193. }
  74194. /** @ignore */
  74195. export class RequestFileError extends BaseError {
  74196. request: WebRequest;
  74197. /**
  74198. * Creates a new LoadFileError
  74199. * @param message defines the message of the error
  74200. * @param request defines the optional web request
  74201. */
  74202. constructor(message: string, request: WebRequest);
  74203. }
  74204. /** @ignore */
  74205. export class ReadFileError extends BaseError {
  74206. file: File;
  74207. /**
  74208. * Creates a new ReadFileError
  74209. * @param message defines the message of the error
  74210. * @param file defines the optional file
  74211. */
  74212. constructor(message: string, file: File);
  74213. }
  74214. /**
  74215. * @hidden
  74216. */
  74217. export class FileTools {
  74218. /**
  74219. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  74220. */
  74221. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  74222. /**
  74223. * Gets or sets the base URL to use to load assets
  74224. */
  74225. static BaseUrl: string;
  74226. /**
  74227. * Default behaviour for cors in the application.
  74228. * It can be a string if the expected behavior is identical in the entire app.
  74229. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  74230. */
  74231. static CorsBehavior: string | ((url: string | string[]) => string);
  74232. /**
  74233. * Gets or sets a function used to pre-process url before using them to load assets
  74234. */
  74235. static PreprocessUrl: (url: string) => string;
  74236. /**
  74237. * Removes unwanted characters from an url
  74238. * @param url defines the url to clean
  74239. * @returns the cleaned url
  74240. */
  74241. private static _CleanUrl;
  74242. /**
  74243. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  74244. * @param url define the url we are trying
  74245. * @param element define the dom element where to configure the cors policy
  74246. */
  74247. static SetCorsBehavior(url: string | string[], element: {
  74248. crossOrigin: string | null;
  74249. }): void;
  74250. /**
  74251. * Loads an image as an HTMLImageElement.
  74252. * @param input url string, ArrayBuffer, or Blob to load
  74253. * @param onLoad callback called when the image successfully loads
  74254. * @param onError callback called when the image fails to load
  74255. * @param offlineProvider offline provider for caching
  74256. * @param mimeType optional mime type
  74257. * @returns the HTMLImageElement of the loaded image
  74258. */
  74259. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  74260. /**
  74261. * Reads a file from a File object
  74262. * @param file defines the file to load
  74263. * @param onSuccess defines the callback to call when data is loaded
  74264. * @param onProgress defines the callback to call during loading process
  74265. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  74266. * @param onError defines the callback to call when an error occurs
  74267. * @returns a file request object
  74268. */
  74269. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  74270. /**
  74271. * Loads a file from a url
  74272. * @param url url to load
  74273. * @param onSuccess callback called when the file successfully loads
  74274. * @param onProgress callback called while file is loading (if the server supports this mode)
  74275. * @param offlineProvider defines the offline provider for caching
  74276. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74277. * @param onError callback called when the file fails to load
  74278. * @returns a file request object
  74279. */
  74280. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  74281. /**
  74282. * Loads a file
  74283. * @param url url to load
  74284. * @param onSuccess callback called when the file successfully loads
  74285. * @param onProgress callback called while file is loading (if the server supports this mode)
  74286. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74287. * @param onError callback called when the file fails to load
  74288. * @param onOpened callback called when the web request is opened
  74289. * @returns a file request object
  74290. */
  74291. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  74292. /**
  74293. * Checks if the loaded document was accessed via `file:`-Protocol.
  74294. * @returns boolean
  74295. */
  74296. static IsFileURL(): boolean;
  74297. }
  74298. }
  74299. declare module BABYLON {
  74300. /** @hidden */
  74301. export class ShaderProcessor {
  74302. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  74303. private static _ProcessPrecision;
  74304. private static _ExtractOperation;
  74305. private static _BuildSubExpression;
  74306. private static _BuildExpression;
  74307. private static _MoveCursorWithinIf;
  74308. private static _MoveCursor;
  74309. private static _EvaluatePreProcessors;
  74310. private static _PreparePreProcessors;
  74311. private static _ProcessShaderConversion;
  74312. private static _ProcessIncludes;
  74313. /**
  74314. * Loads a file from a url
  74315. * @param url url to load
  74316. * @param onSuccess callback called when the file successfully loads
  74317. * @param onProgress callback called while file is loading (if the server supports this mode)
  74318. * @param offlineProvider defines the offline provider for caching
  74319. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74320. * @param onError callback called when the file fails to load
  74321. * @returns a file request object
  74322. * @hidden
  74323. */
  74324. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  74325. }
  74326. }
  74327. declare module BABYLON {
  74328. /**
  74329. * @hidden
  74330. */
  74331. export interface IColor4Like {
  74332. r: float;
  74333. g: float;
  74334. b: float;
  74335. a: float;
  74336. }
  74337. /**
  74338. * @hidden
  74339. */
  74340. export interface IColor3Like {
  74341. r: float;
  74342. g: float;
  74343. b: float;
  74344. }
  74345. /**
  74346. * @hidden
  74347. */
  74348. export interface IVector4Like {
  74349. x: float;
  74350. y: float;
  74351. z: float;
  74352. w: float;
  74353. }
  74354. /**
  74355. * @hidden
  74356. */
  74357. export interface IVector3Like {
  74358. x: float;
  74359. y: float;
  74360. z: float;
  74361. }
  74362. /**
  74363. * @hidden
  74364. */
  74365. export interface IVector2Like {
  74366. x: float;
  74367. y: float;
  74368. }
  74369. /**
  74370. * @hidden
  74371. */
  74372. export interface IMatrixLike {
  74373. toArray(): DeepImmutable<Float32Array>;
  74374. updateFlag: int;
  74375. }
  74376. /**
  74377. * @hidden
  74378. */
  74379. export interface IViewportLike {
  74380. x: float;
  74381. y: float;
  74382. width: float;
  74383. height: float;
  74384. }
  74385. /**
  74386. * @hidden
  74387. */
  74388. export interface IPlaneLike {
  74389. normal: IVector3Like;
  74390. d: float;
  74391. normalize(): void;
  74392. }
  74393. }
  74394. declare module BABYLON {
  74395. /**
  74396. * Interface used to define common properties for effect fallbacks
  74397. */
  74398. export interface IEffectFallbacks {
  74399. /**
  74400. * Removes the defines that should be removed when falling back.
  74401. * @param currentDefines defines the current define statements for the shader.
  74402. * @param effect defines the current effect we try to compile
  74403. * @returns The resulting defines with defines of the current rank removed.
  74404. */
  74405. reduce(currentDefines: string, effect: Effect): string;
  74406. /**
  74407. * Removes the fallback from the bound mesh.
  74408. */
  74409. unBindMesh(): void;
  74410. /**
  74411. * Checks to see if more fallbacks are still availible.
  74412. */
  74413. hasMoreFallbacks: boolean;
  74414. }
  74415. }
  74416. declare module BABYLON {
  74417. /**
  74418. * Class used to evalaute queries containing `and` and `or` operators
  74419. */
  74420. export class AndOrNotEvaluator {
  74421. /**
  74422. * Evaluate a query
  74423. * @param query defines the query to evaluate
  74424. * @param evaluateCallback defines the callback used to filter result
  74425. * @returns true if the query matches
  74426. */
  74427. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  74428. private static _HandleParenthesisContent;
  74429. private static _SimplifyNegation;
  74430. }
  74431. }
  74432. declare module BABYLON {
  74433. /**
  74434. * Class used to store custom tags
  74435. */
  74436. export class Tags {
  74437. /**
  74438. * Adds support for tags on the given object
  74439. * @param obj defines the object to use
  74440. */
  74441. static EnableFor(obj: any): void;
  74442. /**
  74443. * Removes tags support
  74444. * @param obj defines the object to use
  74445. */
  74446. static DisableFor(obj: any): void;
  74447. /**
  74448. * Gets a boolean indicating if the given object has tags
  74449. * @param obj defines the object to use
  74450. * @returns a boolean
  74451. */
  74452. static HasTags(obj: any): boolean;
  74453. /**
  74454. * Gets the tags available on a given object
  74455. * @param obj defines the object to use
  74456. * @param asString defines if the tags must be returned as a string instead of an array of strings
  74457. * @returns the tags
  74458. */
  74459. static GetTags(obj: any, asString?: boolean): any;
  74460. /**
  74461. * Adds tags to an object
  74462. * @param obj defines the object to use
  74463. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  74464. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  74465. */
  74466. static AddTagsTo(obj: any, tagsString: string): void;
  74467. /**
  74468. * @hidden
  74469. */
  74470. static _AddTagTo(obj: any, tag: string): void;
  74471. /**
  74472. * Removes specific tags from a specific object
  74473. * @param obj defines the object to use
  74474. * @param tagsString defines the tags to remove
  74475. */
  74476. static RemoveTagsFrom(obj: any, tagsString: string): void;
  74477. /**
  74478. * @hidden
  74479. */
  74480. static _RemoveTagFrom(obj: any, tag: string): void;
  74481. /**
  74482. * Defines if tags hosted on an object match a given query
  74483. * @param obj defines the object to use
  74484. * @param tagsQuery defines the tag query
  74485. * @returns a boolean
  74486. */
  74487. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  74488. }
  74489. }
  74490. declare module BABYLON {
  74491. /**
  74492. * Scalar computation library
  74493. */
  74494. export class Scalar {
  74495. /**
  74496. * Two pi constants convenient for computation.
  74497. */
  74498. static TwoPi: number;
  74499. /**
  74500. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74501. * @param a number
  74502. * @param b number
  74503. * @param epsilon (default = 1.401298E-45)
  74504. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74505. */
  74506. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  74507. /**
  74508. * Returns a string : the upper case translation of the number i to hexadecimal.
  74509. * @param i number
  74510. * @returns the upper case translation of the number i to hexadecimal.
  74511. */
  74512. static ToHex(i: number): string;
  74513. /**
  74514. * Returns -1 if value is negative and +1 is value is positive.
  74515. * @param value the value
  74516. * @returns the value itself if it's equal to zero.
  74517. */
  74518. static Sign(value: number): number;
  74519. /**
  74520. * Returns the value itself if it's between min and max.
  74521. * Returns min if the value is lower than min.
  74522. * Returns max if the value is greater than max.
  74523. * @param value the value to clmap
  74524. * @param min the min value to clamp to (default: 0)
  74525. * @param max the max value to clamp to (default: 1)
  74526. * @returns the clamped value
  74527. */
  74528. static Clamp(value: number, min?: number, max?: number): number;
  74529. /**
  74530. * the log2 of value.
  74531. * @param value the value to compute log2 of
  74532. * @returns the log2 of value.
  74533. */
  74534. static Log2(value: number): number;
  74535. /**
  74536. * Loops the value, so that it is never larger than length and never smaller than 0.
  74537. *
  74538. * This is similar to the modulo operator but it works with floating point numbers.
  74539. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  74540. * With t = 5 and length = 2.5, the result would be 0.0.
  74541. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  74542. * @param value the value
  74543. * @param length the length
  74544. * @returns the looped value
  74545. */
  74546. static Repeat(value: number, length: number): number;
  74547. /**
  74548. * Normalize the value between 0.0 and 1.0 using min and max values
  74549. * @param value value to normalize
  74550. * @param min max to normalize between
  74551. * @param max min to normalize between
  74552. * @returns the normalized value
  74553. */
  74554. static Normalize(value: number, min: number, max: number): number;
  74555. /**
  74556. * Denormalize the value from 0.0 and 1.0 using min and max values
  74557. * @param normalized value to denormalize
  74558. * @param min max to denormalize between
  74559. * @param max min to denormalize between
  74560. * @returns the denormalized value
  74561. */
  74562. static Denormalize(normalized: number, min: number, max: number): number;
  74563. /**
  74564. * Calculates the shortest difference between two given angles given in degrees.
  74565. * @param current current angle in degrees
  74566. * @param target target angle in degrees
  74567. * @returns the delta
  74568. */
  74569. static DeltaAngle(current: number, target: number): number;
  74570. /**
  74571. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  74572. * @param tx value
  74573. * @param length length
  74574. * @returns The returned value will move back and forth between 0 and length
  74575. */
  74576. static PingPong(tx: number, length: number): number;
  74577. /**
  74578. * Interpolates between min and max with smoothing at the limits.
  74579. *
  74580. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  74581. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  74582. * @param from from
  74583. * @param to to
  74584. * @param tx value
  74585. * @returns the smooth stepped value
  74586. */
  74587. static SmoothStep(from: number, to: number, tx: number): number;
  74588. /**
  74589. * Moves a value current towards target.
  74590. *
  74591. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  74592. * Negative values of maxDelta pushes the value away from target.
  74593. * @param current current value
  74594. * @param target target value
  74595. * @param maxDelta max distance to move
  74596. * @returns resulting value
  74597. */
  74598. static MoveTowards(current: number, target: number, maxDelta: number): number;
  74599. /**
  74600. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  74601. *
  74602. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  74603. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  74604. * @param current current value
  74605. * @param target target value
  74606. * @param maxDelta max distance to move
  74607. * @returns resulting angle
  74608. */
  74609. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  74610. /**
  74611. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  74612. * @param start start value
  74613. * @param end target value
  74614. * @param amount amount to lerp between
  74615. * @returns the lerped value
  74616. */
  74617. static Lerp(start: number, end: number, amount: number): number;
  74618. /**
  74619. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  74620. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  74621. * @param start start value
  74622. * @param end target value
  74623. * @param amount amount to lerp between
  74624. * @returns the lerped value
  74625. */
  74626. static LerpAngle(start: number, end: number, amount: number): number;
  74627. /**
  74628. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  74629. * @param a start value
  74630. * @param b target value
  74631. * @param value value between a and b
  74632. * @returns the inverseLerp value
  74633. */
  74634. static InverseLerp(a: number, b: number, value: number): number;
  74635. /**
  74636. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  74637. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  74638. * @param value1 spline value
  74639. * @param tangent1 spline value
  74640. * @param value2 spline value
  74641. * @param tangent2 spline value
  74642. * @param amount input value
  74643. * @returns hermite result
  74644. */
  74645. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  74646. /**
  74647. * Returns a random float number between and min and max values
  74648. * @param min min value of random
  74649. * @param max max value of random
  74650. * @returns random value
  74651. */
  74652. static RandomRange(min: number, max: number): number;
  74653. /**
  74654. * This function returns percentage of a number in a given range.
  74655. *
  74656. * RangeToPercent(40,20,60) will return 0.5 (50%)
  74657. * RangeToPercent(34,0,100) will return 0.34 (34%)
  74658. * @param number to convert to percentage
  74659. * @param min min range
  74660. * @param max max range
  74661. * @returns the percentage
  74662. */
  74663. static RangeToPercent(number: number, min: number, max: number): number;
  74664. /**
  74665. * This function returns number that corresponds to the percentage in a given range.
  74666. *
  74667. * PercentToRange(0.34,0,100) will return 34.
  74668. * @param percent to convert to number
  74669. * @param min min range
  74670. * @param max max range
  74671. * @returns the number
  74672. */
  74673. static PercentToRange(percent: number, min: number, max: number): number;
  74674. /**
  74675. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  74676. * @param angle The angle to normalize in radian.
  74677. * @return The converted angle.
  74678. */
  74679. static NormalizeRadians(angle: number): number;
  74680. }
  74681. }
  74682. declare module BABYLON {
  74683. /**
  74684. * Constant used to convert a value to gamma space
  74685. * @ignorenaming
  74686. */
  74687. export const ToGammaSpace: number;
  74688. /**
  74689. * Constant used to convert a value to linear space
  74690. * @ignorenaming
  74691. */
  74692. export const ToLinearSpace = 2.2;
  74693. /**
  74694. * Constant used to define the minimal number value in Babylon.js
  74695. * @ignorenaming
  74696. */
  74697. let Epsilon: number;
  74698. }
  74699. declare module BABYLON {
  74700. /**
  74701. * Class used to represent a viewport on screen
  74702. */
  74703. export class Viewport {
  74704. /** viewport left coordinate */
  74705. x: number;
  74706. /** viewport top coordinate */
  74707. y: number;
  74708. /**viewport width */
  74709. width: number;
  74710. /** viewport height */
  74711. height: number;
  74712. /**
  74713. * Creates a Viewport object located at (x, y) and sized (width, height)
  74714. * @param x defines viewport left coordinate
  74715. * @param y defines viewport top coordinate
  74716. * @param width defines the viewport width
  74717. * @param height defines the viewport height
  74718. */
  74719. constructor(
  74720. /** viewport left coordinate */
  74721. x: number,
  74722. /** viewport top coordinate */
  74723. y: number,
  74724. /**viewport width */
  74725. width: number,
  74726. /** viewport height */
  74727. height: number);
  74728. /**
  74729. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  74730. * @param renderWidth defines the rendering width
  74731. * @param renderHeight defines the rendering height
  74732. * @returns a new Viewport
  74733. */
  74734. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  74735. /**
  74736. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  74737. * @param renderWidth defines the rendering width
  74738. * @param renderHeight defines the rendering height
  74739. * @param ref defines the target viewport
  74740. * @returns the current viewport
  74741. */
  74742. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  74743. /**
  74744. * Returns a new Viewport copied from the current one
  74745. * @returns a new Viewport
  74746. */
  74747. clone(): Viewport;
  74748. }
  74749. }
  74750. declare module BABYLON {
  74751. /**
  74752. * Class containing a set of static utilities functions for arrays.
  74753. */
  74754. export class ArrayTools {
  74755. /**
  74756. * Returns an array of the given size filled with element built from the given constructor and the paramters
  74757. * @param size the number of element to construct and put in the array
  74758. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  74759. * @returns a new array filled with new objects
  74760. */
  74761. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  74762. }
  74763. }
  74764. declare module BABYLON {
  74765. /**
  74766. * Class representing a vector containing 2 coordinates
  74767. */
  74768. export class Vector2 {
  74769. /** defines the first coordinate */
  74770. x: number;
  74771. /** defines the second coordinate */
  74772. y: number;
  74773. /**
  74774. * Creates a new Vector2 from the given x and y coordinates
  74775. * @param x defines the first coordinate
  74776. * @param y defines the second coordinate
  74777. */
  74778. constructor(
  74779. /** defines the first coordinate */
  74780. x?: number,
  74781. /** defines the second coordinate */
  74782. y?: number);
  74783. /**
  74784. * Gets a string with the Vector2 coordinates
  74785. * @returns a string with the Vector2 coordinates
  74786. */
  74787. toString(): string;
  74788. /**
  74789. * Gets class name
  74790. * @returns the string "Vector2"
  74791. */
  74792. getClassName(): string;
  74793. /**
  74794. * Gets current vector hash code
  74795. * @returns the Vector2 hash code as a number
  74796. */
  74797. getHashCode(): number;
  74798. /**
  74799. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  74800. * @param array defines the source array
  74801. * @param index defines the offset in source array
  74802. * @returns the current Vector2
  74803. */
  74804. toArray(array: FloatArray, index?: number): Vector2;
  74805. /**
  74806. * Copy the current vector to an array
  74807. * @returns a new array with 2 elements: the Vector2 coordinates.
  74808. */
  74809. asArray(): number[];
  74810. /**
  74811. * Sets the Vector2 coordinates with the given Vector2 coordinates
  74812. * @param source defines the source Vector2
  74813. * @returns the current updated Vector2
  74814. */
  74815. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  74816. /**
  74817. * Sets the Vector2 coordinates with the given floats
  74818. * @param x defines the first coordinate
  74819. * @param y defines the second coordinate
  74820. * @returns the current updated Vector2
  74821. */
  74822. copyFromFloats(x: number, y: number): Vector2;
  74823. /**
  74824. * Sets the Vector2 coordinates with the given floats
  74825. * @param x defines the first coordinate
  74826. * @param y defines the second coordinate
  74827. * @returns the current updated Vector2
  74828. */
  74829. set(x: number, y: number): Vector2;
  74830. /**
  74831. * Add another vector with the current one
  74832. * @param otherVector defines the other vector
  74833. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  74834. */
  74835. add(otherVector: DeepImmutable<Vector2>): Vector2;
  74836. /**
  74837. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  74838. * @param otherVector defines the other vector
  74839. * @param result defines the target vector
  74840. * @returns the unmodified current Vector2
  74841. */
  74842. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  74843. /**
  74844. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  74845. * @param otherVector defines the other vector
  74846. * @returns the current updated Vector2
  74847. */
  74848. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  74849. /**
  74850. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  74851. * @param otherVector defines the other vector
  74852. * @returns a new Vector2
  74853. */
  74854. addVector3(otherVector: Vector3): Vector2;
  74855. /**
  74856. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  74857. * @param otherVector defines the other vector
  74858. * @returns a new Vector2
  74859. */
  74860. subtract(otherVector: Vector2): Vector2;
  74861. /**
  74862. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  74863. * @param otherVector defines the other vector
  74864. * @param result defines the target vector
  74865. * @returns the unmodified current Vector2
  74866. */
  74867. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  74868. /**
  74869. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  74870. * @param otherVector defines the other vector
  74871. * @returns the current updated Vector2
  74872. */
  74873. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  74874. /**
  74875. * Multiplies in place the current Vector2 coordinates by the given ones
  74876. * @param otherVector defines the other vector
  74877. * @returns the current updated Vector2
  74878. */
  74879. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  74880. /**
  74881. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  74882. * @param otherVector defines the other vector
  74883. * @returns a new Vector2
  74884. */
  74885. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  74886. /**
  74887. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  74888. * @param otherVector defines the other vector
  74889. * @param result defines the target vector
  74890. * @returns the unmodified current Vector2
  74891. */
  74892. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  74893. /**
  74894. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  74895. * @param x defines the first coordinate
  74896. * @param y defines the second coordinate
  74897. * @returns a new Vector2
  74898. */
  74899. multiplyByFloats(x: number, y: number): Vector2;
  74900. /**
  74901. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  74902. * @param otherVector defines the other vector
  74903. * @returns a new Vector2
  74904. */
  74905. divide(otherVector: Vector2): Vector2;
  74906. /**
  74907. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  74908. * @param otherVector defines the other vector
  74909. * @param result defines the target vector
  74910. * @returns the unmodified current Vector2
  74911. */
  74912. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  74913. /**
  74914. * Divides the current Vector2 coordinates by the given ones
  74915. * @param otherVector defines the other vector
  74916. * @returns the current updated Vector2
  74917. */
  74918. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  74919. /**
  74920. * Gets a new Vector2 with current Vector2 negated coordinates
  74921. * @returns a new Vector2
  74922. */
  74923. negate(): Vector2;
  74924. /**
  74925. * Negate this vector in place
  74926. * @returns this
  74927. */
  74928. negateInPlace(): Vector2;
  74929. /**
  74930. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  74931. * @param result defines the Vector3 object where to store the result
  74932. * @returns the current Vector2
  74933. */
  74934. negateToRef(result: Vector2): Vector2;
  74935. /**
  74936. * Multiply the Vector2 coordinates by scale
  74937. * @param scale defines the scaling factor
  74938. * @returns the current updated Vector2
  74939. */
  74940. scaleInPlace(scale: number): Vector2;
  74941. /**
  74942. * Returns a new Vector2 scaled by "scale" from the current Vector2
  74943. * @param scale defines the scaling factor
  74944. * @returns a new Vector2
  74945. */
  74946. scale(scale: number): Vector2;
  74947. /**
  74948. * Scale the current Vector2 values by a factor to a given Vector2
  74949. * @param scale defines the scale factor
  74950. * @param result defines the Vector2 object where to store the result
  74951. * @returns the unmodified current Vector2
  74952. */
  74953. scaleToRef(scale: number, result: Vector2): Vector2;
  74954. /**
  74955. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  74956. * @param scale defines the scale factor
  74957. * @param result defines the Vector2 object where to store the result
  74958. * @returns the unmodified current Vector2
  74959. */
  74960. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  74961. /**
  74962. * Gets a boolean if two vectors are equals
  74963. * @param otherVector defines the other vector
  74964. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  74965. */
  74966. equals(otherVector: DeepImmutable<Vector2>): boolean;
  74967. /**
  74968. * Gets a boolean if two vectors are equals (using an epsilon value)
  74969. * @param otherVector defines the other vector
  74970. * @param epsilon defines the minimal distance to consider equality
  74971. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  74972. */
  74973. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  74974. /**
  74975. * Gets a new Vector2 from current Vector2 floored values
  74976. * @returns a new Vector2
  74977. */
  74978. floor(): Vector2;
  74979. /**
  74980. * Gets a new Vector2 from current Vector2 floored values
  74981. * @returns a new Vector2
  74982. */
  74983. fract(): Vector2;
  74984. /**
  74985. * Gets the length of the vector
  74986. * @returns the vector length (float)
  74987. */
  74988. length(): number;
  74989. /**
  74990. * Gets the vector squared length
  74991. * @returns the vector squared length (float)
  74992. */
  74993. lengthSquared(): number;
  74994. /**
  74995. * Normalize the vector
  74996. * @returns the current updated Vector2
  74997. */
  74998. normalize(): Vector2;
  74999. /**
  75000. * Gets a new Vector2 copied from the Vector2
  75001. * @returns a new Vector2
  75002. */
  75003. clone(): Vector2;
  75004. /**
  75005. * Gets a new Vector2(0, 0)
  75006. * @returns a new Vector2
  75007. */
  75008. static Zero(): Vector2;
  75009. /**
  75010. * Gets a new Vector2(1, 1)
  75011. * @returns a new Vector2
  75012. */
  75013. static One(): Vector2;
  75014. /**
  75015. * Gets a new Vector2 set from the given index element of the given array
  75016. * @param array defines the data source
  75017. * @param offset defines the offset in the data source
  75018. * @returns a new Vector2
  75019. */
  75020. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  75021. /**
  75022. * Sets "result" from the given index element of the given array
  75023. * @param array defines the data source
  75024. * @param offset defines the offset in the data source
  75025. * @param result defines the target vector
  75026. */
  75027. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  75028. /**
  75029. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  75030. * @param value1 defines 1st point of control
  75031. * @param value2 defines 2nd point of control
  75032. * @param value3 defines 3rd point of control
  75033. * @param value4 defines 4th point of control
  75034. * @param amount defines the interpolation factor
  75035. * @returns a new Vector2
  75036. */
  75037. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  75038. /**
  75039. * 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".
  75040. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  75041. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  75042. * @param value defines the value to clamp
  75043. * @param min defines the lower limit
  75044. * @param max defines the upper limit
  75045. * @returns a new Vector2
  75046. */
  75047. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  75048. /**
  75049. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  75050. * @param value1 defines the 1st control point
  75051. * @param tangent1 defines the outgoing tangent
  75052. * @param value2 defines the 2nd control point
  75053. * @param tangent2 defines the incoming tangent
  75054. * @param amount defines the interpolation factor
  75055. * @returns a new Vector2
  75056. */
  75057. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  75058. /**
  75059. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  75060. * @param start defines the start vector
  75061. * @param end defines the end vector
  75062. * @param amount defines the interpolation factor
  75063. * @returns a new Vector2
  75064. */
  75065. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  75066. /**
  75067. * Gets the dot product of the vector "left" and the vector "right"
  75068. * @param left defines first vector
  75069. * @param right defines second vector
  75070. * @returns the dot product (float)
  75071. */
  75072. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  75073. /**
  75074. * Returns a new Vector2 equal to the normalized given vector
  75075. * @param vector defines the vector to normalize
  75076. * @returns a new Vector2
  75077. */
  75078. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  75079. /**
  75080. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  75081. * @param left defines 1st vector
  75082. * @param right defines 2nd vector
  75083. * @returns a new Vector2
  75084. */
  75085. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75086. /**
  75087. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  75088. * @param left defines 1st vector
  75089. * @param right defines 2nd vector
  75090. * @returns a new Vector2
  75091. */
  75092. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75093. /**
  75094. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  75095. * @param vector defines the vector to transform
  75096. * @param transformation defines the matrix to apply
  75097. * @returns a new Vector2
  75098. */
  75099. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  75100. /**
  75101. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  75102. * @param vector defines the vector to transform
  75103. * @param transformation defines the matrix to apply
  75104. * @param result defines the target vector
  75105. */
  75106. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  75107. /**
  75108. * Determines if a given vector is included in a triangle
  75109. * @param p defines the vector to test
  75110. * @param p0 defines 1st triangle point
  75111. * @param p1 defines 2nd triangle point
  75112. * @param p2 defines 3rd triangle point
  75113. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  75114. */
  75115. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  75116. /**
  75117. * Gets the distance between the vectors "value1" and "value2"
  75118. * @param value1 defines first vector
  75119. * @param value2 defines second vector
  75120. * @returns the distance between vectors
  75121. */
  75122. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75123. /**
  75124. * Returns the squared distance between the vectors "value1" and "value2"
  75125. * @param value1 defines first vector
  75126. * @param value2 defines second vector
  75127. * @returns the squared distance between vectors
  75128. */
  75129. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75130. /**
  75131. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  75132. * @param value1 defines first vector
  75133. * @param value2 defines second vector
  75134. * @returns a new Vector2
  75135. */
  75136. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  75137. /**
  75138. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  75139. * @param p defines the middle point
  75140. * @param segA defines one point of the segment
  75141. * @param segB defines the other point of the segment
  75142. * @returns the shortest distance
  75143. */
  75144. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  75145. }
  75146. /**
  75147. * Class used to store (x,y,z) vector representation
  75148. * A Vector3 is the main object used in 3D geometry
  75149. * It can represent etiher the coordinates of a point the space, either a direction
  75150. * Reminder: js uses a left handed forward facing system
  75151. */
  75152. export class Vector3 {
  75153. /**
  75154. * Defines the first coordinates (on X axis)
  75155. */
  75156. x: number;
  75157. /**
  75158. * Defines the second coordinates (on Y axis)
  75159. */
  75160. y: number;
  75161. /**
  75162. * Defines the third coordinates (on Z axis)
  75163. */
  75164. z: number;
  75165. private static _UpReadOnly;
  75166. private static _ZeroReadOnly;
  75167. /**
  75168. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  75169. * @param x defines the first coordinates (on X axis)
  75170. * @param y defines the second coordinates (on Y axis)
  75171. * @param z defines the third coordinates (on Z axis)
  75172. */
  75173. constructor(
  75174. /**
  75175. * Defines the first coordinates (on X axis)
  75176. */
  75177. x?: number,
  75178. /**
  75179. * Defines the second coordinates (on Y axis)
  75180. */
  75181. y?: number,
  75182. /**
  75183. * Defines the third coordinates (on Z axis)
  75184. */
  75185. z?: number);
  75186. /**
  75187. * Creates a string representation of the Vector3
  75188. * @returns a string with the Vector3 coordinates.
  75189. */
  75190. toString(): string;
  75191. /**
  75192. * Gets the class name
  75193. * @returns the string "Vector3"
  75194. */
  75195. getClassName(): string;
  75196. /**
  75197. * Creates the Vector3 hash code
  75198. * @returns a number which tends to be unique between Vector3 instances
  75199. */
  75200. getHashCode(): number;
  75201. /**
  75202. * Creates an array containing three elements : the coordinates of the Vector3
  75203. * @returns a new array of numbers
  75204. */
  75205. asArray(): number[];
  75206. /**
  75207. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  75208. * @param array defines the destination array
  75209. * @param index defines the offset in the destination array
  75210. * @returns the current Vector3
  75211. */
  75212. toArray(array: FloatArray, index?: number): Vector3;
  75213. /**
  75214. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  75215. * @returns a new Quaternion object, computed from the Vector3 coordinates
  75216. */
  75217. toQuaternion(): Quaternion;
  75218. /**
  75219. * Adds the given vector to the current Vector3
  75220. * @param otherVector defines the second operand
  75221. * @returns the current updated Vector3
  75222. */
  75223. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75224. /**
  75225. * Adds the given coordinates to the current Vector3
  75226. * @param x defines the x coordinate of the operand
  75227. * @param y defines the y coordinate of the operand
  75228. * @param z defines the z coordinate of the operand
  75229. * @returns the current updated Vector3
  75230. */
  75231. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75232. /**
  75233. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  75234. * @param otherVector defines the second operand
  75235. * @returns the resulting Vector3
  75236. */
  75237. add(otherVector: DeepImmutable<Vector3>): Vector3;
  75238. /**
  75239. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  75240. * @param otherVector defines the second operand
  75241. * @param result defines the Vector3 object where to store the result
  75242. * @returns the current Vector3
  75243. */
  75244. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75245. /**
  75246. * Subtract the given vector from the current Vector3
  75247. * @param otherVector defines the second operand
  75248. * @returns the current updated Vector3
  75249. */
  75250. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75251. /**
  75252. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  75253. * @param otherVector defines the second operand
  75254. * @returns the resulting Vector3
  75255. */
  75256. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  75257. /**
  75258. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  75259. * @param otherVector defines the second operand
  75260. * @param result defines the Vector3 object where to store the result
  75261. * @returns the current Vector3
  75262. */
  75263. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75264. /**
  75265. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  75266. * @param x defines the x coordinate of the operand
  75267. * @param y defines the y coordinate of the operand
  75268. * @param z defines the z coordinate of the operand
  75269. * @returns the resulting Vector3
  75270. */
  75271. subtractFromFloats(x: number, y: number, z: number): Vector3;
  75272. /**
  75273. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  75274. * @param x defines the x coordinate of the operand
  75275. * @param y defines the y coordinate of the operand
  75276. * @param z defines the z coordinate of the operand
  75277. * @param result defines the Vector3 object where to store the result
  75278. * @returns the current Vector3
  75279. */
  75280. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  75281. /**
  75282. * Gets a new Vector3 set with the current Vector3 negated coordinates
  75283. * @returns a new Vector3
  75284. */
  75285. negate(): Vector3;
  75286. /**
  75287. * Negate this vector in place
  75288. * @returns this
  75289. */
  75290. negateInPlace(): Vector3;
  75291. /**
  75292. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  75293. * @param result defines the Vector3 object where to store the result
  75294. * @returns the current Vector3
  75295. */
  75296. negateToRef(result: Vector3): Vector3;
  75297. /**
  75298. * Multiplies the Vector3 coordinates by the float "scale"
  75299. * @param scale defines the multiplier factor
  75300. * @returns the current updated Vector3
  75301. */
  75302. scaleInPlace(scale: number): Vector3;
  75303. /**
  75304. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  75305. * @param scale defines the multiplier factor
  75306. * @returns a new Vector3
  75307. */
  75308. scale(scale: number): Vector3;
  75309. /**
  75310. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  75311. * @param scale defines the multiplier factor
  75312. * @param result defines the Vector3 object where to store the result
  75313. * @returns the current Vector3
  75314. */
  75315. scaleToRef(scale: number, result: Vector3): Vector3;
  75316. /**
  75317. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  75318. * @param scale defines the scale factor
  75319. * @param result defines the Vector3 object where to store the result
  75320. * @returns the unmodified current Vector3
  75321. */
  75322. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  75323. /**
  75324. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  75325. * @param otherVector defines the second operand
  75326. * @returns true if both vectors are equals
  75327. */
  75328. equals(otherVector: DeepImmutable<Vector3>): boolean;
  75329. /**
  75330. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  75331. * @param otherVector defines the second operand
  75332. * @param epsilon defines the minimal distance to define values as equals
  75333. * @returns true if both vectors are distant less than epsilon
  75334. */
  75335. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  75336. /**
  75337. * Returns true if the current Vector3 coordinates equals the given floats
  75338. * @param x defines the x coordinate of the operand
  75339. * @param y defines the y coordinate of the operand
  75340. * @param z defines the z coordinate of the operand
  75341. * @returns true if both vectors are equals
  75342. */
  75343. equalsToFloats(x: number, y: number, z: number): boolean;
  75344. /**
  75345. * Multiplies the current Vector3 coordinates by the given ones
  75346. * @param otherVector defines the second operand
  75347. * @returns the current updated Vector3
  75348. */
  75349. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75350. /**
  75351. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  75352. * @param otherVector defines the second operand
  75353. * @returns the new Vector3
  75354. */
  75355. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  75356. /**
  75357. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  75358. * @param otherVector defines the second operand
  75359. * @param result defines the Vector3 object where to store the result
  75360. * @returns the current Vector3
  75361. */
  75362. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75363. /**
  75364. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  75365. * @param x defines the x coordinate of the operand
  75366. * @param y defines the y coordinate of the operand
  75367. * @param z defines the z coordinate of the operand
  75368. * @returns the new Vector3
  75369. */
  75370. multiplyByFloats(x: number, y: number, z: number): Vector3;
  75371. /**
  75372. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  75373. * @param otherVector defines the second operand
  75374. * @returns the new Vector3
  75375. */
  75376. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  75377. /**
  75378. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  75379. * @param otherVector defines the second operand
  75380. * @param result defines the Vector3 object where to store the result
  75381. * @returns the current Vector3
  75382. */
  75383. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75384. /**
  75385. * Divides the current Vector3 coordinates by the given ones.
  75386. * @param otherVector defines the second operand
  75387. * @returns the current updated Vector3
  75388. */
  75389. divideInPlace(otherVector: Vector3): Vector3;
  75390. /**
  75391. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  75392. * @param other defines the second operand
  75393. * @returns the current updated Vector3
  75394. */
  75395. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75396. /**
  75397. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  75398. * @param other defines the second operand
  75399. * @returns the current updated Vector3
  75400. */
  75401. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75402. /**
  75403. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  75404. * @param x defines the x coordinate of the operand
  75405. * @param y defines the y coordinate of the operand
  75406. * @param z defines the z coordinate of the operand
  75407. * @returns the current updated Vector3
  75408. */
  75409. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75410. /**
  75411. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  75412. * @param x defines the x coordinate of the operand
  75413. * @param y defines the y coordinate of the operand
  75414. * @param z defines the z coordinate of the operand
  75415. * @returns the current updated Vector3
  75416. */
  75417. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75418. /**
  75419. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  75420. * Check if is non uniform within a certain amount of decimal places to account for this
  75421. * @param epsilon the amount the values can differ
  75422. * @returns if the the vector is non uniform to a certain number of decimal places
  75423. */
  75424. isNonUniformWithinEpsilon(epsilon: number): boolean;
  75425. /**
  75426. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  75427. */
  75428. get isNonUniform(): boolean;
  75429. /**
  75430. * Gets a new Vector3 from current Vector3 floored values
  75431. * @returns a new Vector3
  75432. */
  75433. floor(): Vector3;
  75434. /**
  75435. * Gets a new Vector3 from current Vector3 floored values
  75436. * @returns a new Vector3
  75437. */
  75438. fract(): Vector3;
  75439. /**
  75440. * Gets the length of the Vector3
  75441. * @returns the length of the Vector3
  75442. */
  75443. length(): number;
  75444. /**
  75445. * Gets the squared length of the Vector3
  75446. * @returns squared length of the Vector3
  75447. */
  75448. lengthSquared(): number;
  75449. /**
  75450. * Normalize the current Vector3.
  75451. * Please note that this is an in place operation.
  75452. * @returns the current updated Vector3
  75453. */
  75454. normalize(): Vector3;
  75455. /**
  75456. * Reorders the x y z properties of the vector in place
  75457. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  75458. * @returns the current updated vector
  75459. */
  75460. reorderInPlace(order: string): this;
  75461. /**
  75462. * Rotates the vector around 0,0,0 by a quaternion
  75463. * @param quaternion the rotation quaternion
  75464. * @param result vector to store the result
  75465. * @returns the resulting vector
  75466. */
  75467. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  75468. /**
  75469. * Rotates a vector around a given point
  75470. * @param quaternion the rotation quaternion
  75471. * @param point the point to rotate around
  75472. * @param result vector to store the result
  75473. * @returns the resulting vector
  75474. */
  75475. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  75476. /**
  75477. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  75478. * The cross product is then orthogonal to both current and "other"
  75479. * @param other defines the right operand
  75480. * @returns the cross product
  75481. */
  75482. cross(other: Vector3): Vector3;
  75483. /**
  75484. * Normalize the current Vector3 with the given input length.
  75485. * Please note that this is an in place operation.
  75486. * @param len the length of the vector
  75487. * @returns the current updated Vector3
  75488. */
  75489. normalizeFromLength(len: number): Vector3;
  75490. /**
  75491. * Normalize the current Vector3 to a new vector
  75492. * @returns the new Vector3
  75493. */
  75494. normalizeToNew(): Vector3;
  75495. /**
  75496. * Normalize the current Vector3 to the reference
  75497. * @param reference define the Vector3 to update
  75498. * @returns the updated Vector3
  75499. */
  75500. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  75501. /**
  75502. * Creates a new Vector3 copied from the current Vector3
  75503. * @returns the new Vector3
  75504. */
  75505. clone(): Vector3;
  75506. /**
  75507. * Copies the given vector coordinates to the current Vector3 ones
  75508. * @param source defines the source Vector3
  75509. * @returns the current updated Vector3
  75510. */
  75511. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  75512. /**
  75513. * Copies the given floats to the current Vector3 coordinates
  75514. * @param x defines the x coordinate of the operand
  75515. * @param y defines the y coordinate of the operand
  75516. * @param z defines the z coordinate of the operand
  75517. * @returns the current updated Vector3
  75518. */
  75519. copyFromFloats(x: number, y: number, z: number): Vector3;
  75520. /**
  75521. * Copies the given floats to the current Vector3 coordinates
  75522. * @param x defines the x coordinate of the operand
  75523. * @param y defines the y coordinate of the operand
  75524. * @param z defines the z coordinate of the operand
  75525. * @returns the current updated Vector3
  75526. */
  75527. set(x: number, y: number, z: number): Vector3;
  75528. /**
  75529. * Copies the given float to the current Vector3 coordinates
  75530. * @param v defines the x, y and z coordinates of the operand
  75531. * @returns the current updated Vector3
  75532. */
  75533. setAll(v: number): Vector3;
  75534. /**
  75535. * Get the clip factor between two vectors
  75536. * @param vector0 defines the first operand
  75537. * @param vector1 defines the second operand
  75538. * @param axis defines the axis to use
  75539. * @param size defines the size along the axis
  75540. * @returns the clip factor
  75541. */
  75542. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  75543. /**
  75544. * Get angle between two vectors
  75545. * @param vector0 angle between vector0 and vector1
  75546. * @param vector1 angle between vector0 and vector1
  75547. * @param normal direction of the normal
  75548. * @return the angle between vector0 and vector1
  75549. */
  75550. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  75551. /**
  75552. * Returns a new Vector3 set from the index "offset" of the given array
  75553. * @param array defines the source array
  75554. * @param offset defines the offset in the source array
  75555. * @returns the new Vector3
  75556. */
  75557. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  75558. /**
  75559. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  75560. * @param array defines the source array
  75561. * @param offset defines the offset in the source array
  75562. * @returns the new Vector3
  75563. * @deprecated Please use FromArray instead.
  75564. */
  75565. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  75566. /**
  75567. * Sets the given vector "result" with the element values from the index "offset" of the given array
  75568. * @param array defines the source array
  75569. * @param offset defines the offset in the source array
  75570. * @param result defines the Vector3 where to store the result
  75571. */
  75572. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  75573. /**
  75574. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  75575. * @param array defines the source array
  75576. * @param offset defines the offset in the source array
  75577. * @param result defines the Vector3 where to store the result
  75578. * @deprecated Please use FromArrayToRef instead.
  75579. */
  75580. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  75581. /**
  75582. * Sets the given vector "result" with the given floats.
  75583. * @param x defines the x coordinate of the source
  75584. * @param y defines the y coordinate of the source
  75585. * @param z defines the z coordinate of the source
  75586. * @param result defines the Vector3 where to store the result
  75587. */
  75588. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  75589. /**
  75590. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  75591. * @returns a new empty Vector3
  75592. */
  75593. static Zero(): Vector3;
  75594. /**
  75595. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  75596. * @returns a new unit Vector3
  75597. */
  75598. static One(): Vector3;
  75599. /**
  75600. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  75601. * @returns a new up Vector3
  75602. */
  75603. static Up(): Vector3;
  75604. /**
  75605. * Gets a up Vector3 that must not be updated
  75606. */
  75607. static get UpReadOnly(): DeepImmutable<Vector3>;
  75608. /**
  75609. * Gets a zero Vector3 that must not be updated
  75610. */
  75611. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  75612. /**
  75613. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  75614. * @returns a new down Vector3
  75615. */
  75616. static Down(): Vector3;
  75617. /**
  75618. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  75619. * @returns a new forward Vector3
  75620. */
  75621. static Forward(): Vector3;
  75622. /**
  75623. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  75624. * @returns a new forward Vector3
  75625. */
  75626. static Backward(): Vector3;
  75627. /**
  75628. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  75629. * @returns a new right Vector3
  75630. */
  75631. static Right(): Vector3;
  75632. /**
  75633. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  75634. * @returns a new left Vector3
  75635. */
  75636. static Left(): Vector3;
  75637. /**
  75638. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  75639. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  75640. * @param vector defines the Vector3 to transform
  75641. * @param transformation defines the transformation matrix
  75642. * @returns the transformed Vector3
  75643. */
  75644. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  75645. /**
  75646. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  75647. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  75648. * @param vector defines the Vector3 to transform
  75649. * @param transformation defines the transformation matrix
  75650. * @param result defines the Vector3 where to store the result
  75651. */
  75652. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  75653. /**
  75654. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  75655. * This method computes tranformed coordinates only, not transformed direction vectors
  75656. * @param x define the x coordinate of the source vector
  75657. * @param y define the y coordinate of the source vector
  75658. * @param z define the z coordinate of the source vector
  75659. * @param transformation defines the transformation matrix
  75660. * @param result defines the Vector3 where to store the result
  75661. */
  75662. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  75663. /**
  75664. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  75665. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  75666. * @param vector defines the Vector3 to transform
  75667. * @param transformation defines the transformation matrix
  75668. * @returns the new Vector3
  75669. */
  75670. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  75671. /**
  75672. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  75673. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  75674. * @param vector defines the Vector3 to transform
  75675. * @param transformation defines the transformation matrix
  75676. * @param result defines the Vector3 where to store the result
  75677. */
  75678. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  75679. /**
  75680. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  75681. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  75682. * @param x define the x coordinate of the source vector
  75683. * @param y define the y coordinate of the source vector
  75684. * @param z define the z coordinate of the source vector
  75685. * @param transformation defines the transformation matrix
  75686. * @param result defines the Vector3 where to store the result
  75687. */
  75688. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  75689. /**
  75690. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  75691. * @param value1 defines the first control point
  75692. * @param value2 defines the second control point
  75693. * @param value3 defines the third control point
  75694. * @param value4 defines the fourth control point
  75695. * @param amount defines the amount on the spline to use
  75696. * @returns the new Vector3
  75697. */
  75698. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  75699. /**
  75700. * 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"
  75701. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  75702. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  75703. * @param value defines the current value
  75704. * @param min defines the lower range value
  75705. * @param max defines the upper range value
  75706. * @returns the new Vector3
  75707. */
  75708. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  75709. /**
  75710. * 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"
  75711. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  75712. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  75713. * @param value defines the current value
  75714. * @param min defines the lower range value
  75715. * @param max defines the upper range value
  75716. * @param result defines the Vector3 where to store the result
  75717. */
  75718. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  75719. /**
  75720. * Checks if a given vector is inside a specific range
  75721. * @param v defines the vector to test
  75722. * @param min defines the minimum range
  75723. * @param max defines the maximum range
  75724. */
  75725. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  75726. /**
  75727. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  75728. * @param value1 defines the first control point
  75729. * @param tangent1 defines the first tangent vector
  75730. * @param value2 defines the second control point
  75731. * @param tangent2 defines the second tangent vector
  75732. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  75733. * @returns the new Vector3
  75734. */
  75735. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  75736. /**
  75737. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  75738. * @param start defines the start value
  75739. * @param end defines the end value
  75740. * @param amount max defines amount between both (between 0 and 1)
  75741. * @returns the new Vector3
  75742. */
  75743. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  75744. /**
  75745. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  75746. * @param start defines the start value
  75747. * @param end defines the end value
  75748. * @param amount max defines amount between both (between 0 and 1)
  75749. * @param result defines the Vector3 where to store the result
  75750. */
  75751. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  75752. /**
  75753. * Returns the dot product (float) between the vectors "left" and "right"
  75754. * @param left defines the left operand
  75755. * @param right defines the right operand
  75756. * @returns the dot product
  75757. */
  75758. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  75759. /**
  75760. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  75761. * The cross product is then orthogonal to both "left" and "right"
  75762. * @param left defines the left operand
  75763. * @param right defines the right operand
  75764. * @returns the cross product
  75765. */
  75766. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  75767. /**
  75768. * Sets the given vector "result" with the cross product of "left" and "right"
  75769. * The cross product is then orthogonal to both "left" and "right"
  75770. * @param left defines the left operand
  75771. * @param right defines the right operand
  75772. * @param result defines the Vector3 where to store the result
  75773. */
  75774. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  75775. /**
  75776. * Returns a new Vector3 as the normalization of the given vector
  75777. * @param vector defines the Vector3 to normalize
  75778. * @returns the new Vector3
  75779. */
  75780. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  75781. /**
  75782. * Sets the given vector "result" with the normalization of the given first vector
  75783. * @param vector defines the Vector3 to normalize
  75784. * @param result defines the Vector3 where to store the result
  75785. */
  75786. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  75787. /**
  75788. * Project a Vector3 onto screen space
  75789. * @param vector defines the Vector3 to project
  75790. * @param world defines the world matrix to use
  75791. * @param transform defines the transform (view x projection) matrix to use
  75792. * @param viewport defines the screen viewport to use
  75793. * @returns the new Vector3
  75794. */
  75795. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  75796. /** @hidden */
  75797. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  75798. /**
  75799. * Unproject from screen space to object space
  75800. * @param source defines the screen space Vector3 to use
  75801. * @param viewportWidth defines the current width of the viewport
  75802. * @param viewportHeight defines the current height of the viewport
  75803. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75804. * @param transform defines the transform (view x projection) matrix to use
  75805. * @returns the new Vector3
  75806. */
  75807. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  75808. /**
  75809. * Unproject from screen space to object space
  75810. * @param source defines the screen space Vector3 to use
  75811. * @param viewportWidth defines the current width of the viewport
  75812. * @param viewportHeight defines the current height of the viewport
  75813. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75814. * @param view defines the view matrix to use
  75815. * @param projection defines the projection matrix to use
  75816. * @returns the new Vector3
  75817. */
  75818. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  75819. /**
  75820. * Unproject from screen space to object space
  75821. * @param source defines the screen space Vector3 to use
  75822. * @param viewportWidth defines the current width of the viewport
  75823. * @param viewportHeight defines the current height of the viewport
  75824. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75825. * @param view defines the view matrix to use
  75826. * @param projection defines the projection matrix to use
  75827. * @param result defines the Vector3 where to store the result
  75828. */
  75829. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  75830. /**
  75831. * Unproject from screen space to object space
  75832. * @param sourceX defines the screen space x coordinate to use
  75833. * @param sourceY defines the screen space y coordinate to use
  75834. * @param sourceZ defines the screen space z coordinate to use
  75835. * @param viewportWidth defines the current width of the viewport
  75836. * @param viewportHeight defines the current height of the viewport
  75837. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75838. * @param view defines the view matrix to use
  75839. * @param projection defines the projection matrix to use
  75840. * @param result defines the Vector3 where to store the result
  75841. */
  75842. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  75843. /**
  75844. * Gets the minimal coordinate values between two Vector3
  75845. * @param left defines the first operand
  75846. * @param right defines the second operand
  75847. * @returns the new Vector3
  75848. */
  75849. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  75850. /**
  75851. * Gets the maximal coordinate values between two Vector3
  75852. * @param left defines the first operand
  75853. * @param right defines the second operand
  75854. * @returns the new Vector3
  75855. */
  75856. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  75857. /**
  75858. * Returns the distance between the vectors "value1" and "value2"
  75859. * @param value1 defines the first operand
  75860. * @param value2 defines the second operand
  75861. * @returns the distance
  75862. */
  75863. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  75864. /**
  75865. * Returns the squared distance between the vectors "value1" and "value2"
  75866. * @param value1 defines the first operand
  75867. * @param value2 defines the second operand
  75868. * @returns the squared distance
  75869. */
  75870. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  75871. /**
  75872. * Returns a new Vector3 located at the center between "value1" and "value2"
  75873. * @param value1 defines the first operand
  75874. * @param value2 defines the second operand
  75875. * @returns the new Vector3
  75876. */
  75877. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  75878. /**
  75879. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  75880. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  75881. * to something in order to rotate it from its local system to the given target system
  75882. * Note: axis1, axis2 and axis3 are normalized during this operation
  75883. * @param axis1 defines the first axis
  75884. * @param axis2 defines the second axis
  75885. * @param axis3 defines the third axis
  75886. * @returns a new Vector3
  75887. */
  75888. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  75889. /**
  75890. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  75891. * @param axis1 defines the first axis
  75892. * @param axis2 defines the second axis
  75893. * @param axis3 defines the third axis
  75894. * @param ref defines the Vector3 where to store the result
  75895. */
  75896. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  75897. }
  75898. /**
  75899. * Vector4 class created for EulerAngle class conversion to Quaternion
  75900. */
  75901. export class Vector4 {
  75902. /** x value of the vector */
  75903. x: number;
  75904. /** y value of the vector */
  75905. y: number;
  75906. /** z value of the vector */
  75907. z: number;
  75908. /** w value of the vector */
  75909. w: number;
  75910. /**
  75911. * Creates a Vector4 object from the given floats.
  75912. * @param x x value of the vector
  75913. * @param y y value of the vector
  75914. * @param z z value of the vector
  75915. * @param w w value of the vector
  75916. */
  75917. constructor(
  75918. /** x value of the vector */
  75919. x: number,
  75920. /** y value of the vector */
  75921. y: number,
  75922. /** z value of the vector */
  75923. z: number,
  75924. /** w value of the vector */
  75925. w: number);
  75926. /**
  75927. * Returns the string with the Vector4 coordinates.
  75928. * @returns a string containing all the vector values
  75929. */
  75930. toString(): string;
  75931. /**
  75932. * Returns the string "Vector4".
  75933. * @returns "Vector4"
  75934. */
  75935. getClassName(): string;
  75936. /**
  75937. * Returns the Vector4 hash code.
  75938. * @returns a unique hash code
  75939. */
  75940. getHashCode(): number;
  75941. /**
  75942. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  75943. * @returns the resulting array
  75944. */
  75945. asArray(): number[];
  75946. /**
  75947. * Populates the given array from the given index with the Vector4 coordinates.
  75948. * @param array array to populate
  75949. * @param index index of the array to start at (default: 0)
  75950. * @returns the Vector4.
  75951. */
  75952. toArray(array: FloatArray, index?: number): Vector4;
  75953. /**
  75954. * Adds the given vector to the current Vector4.
  75955. * @param otherVector the vector to add
  75956. * @returns the updated Vector4.
  75957. */
  75958. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  75959. /**
  75960. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  75961. * @param otherVector the vector to add
  75962. * @returns the resulting vector
  75963. */
  75964. add(otherVector: DeepImmutable<Vector4>): Vector4;
  75965. /**
  75966. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  75967. * @param otherVector the vector to add
  75968. * @param result the vector to store the result
  75969. * @returns the current Vector4.
  75970. */
  75971. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  75972. /**
  75973. * Subtract in place the given vector from the current Vector4.
  75974. * @param otherVector the vector to subtract
  75975. * @returns the updated Vector4.
  75976. */
  75977. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  75978. /**
  75979. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  75980. * @param otherVector the vector to add
  75981. * @returns the new vector with the result
  75982. */
  75983. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  75984. /**
  75985. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  75986. * @param otherVector the vector to subtract
  75987. * @param result the vector to store the result
  75988. * @returns the current Vector4.
  75989. */
  75990. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  75991. /**
  75992. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  75993. */
  75994. /**
  75995. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  75996. * @param x value to subtract
  75997. * @param y value to subtract
  75998. * @param z value to subtract
  75999. * @param w value to subtract
  76000. * @returns new vector containing the result
  76001. */
  76002. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76003. /**
  76004. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76005. * @param x value to subtract
  76006. * @param y value to subtract
  76007. * @param z value to subtract
  76008. * @param w value to subtract
  76009. * @param result the vector to store the result in
  76010. * @returns the current Vector4.
  76011. */
  76012. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  76013. /**
  76014. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  76015. * @returns a new vector with the negated values
  76016. */
  76017. negate(): Vector4;
  76018. /**
  76019. * Negate this vector in place
  76020. * @returns this
  76021. */
  76022. negateInPlace(): Vector4;
  76023. /**
  76024. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  76025. * @param result defines the Vector3 object where to store the result
  76026. * @returns the current Vector4
  76027. */
  76028. negateToRef(result: Vector4): Vector4;
  76029. /**
  76030. * Multiplies the current Vector4 coordinates by scale (float).
  76031. * @param scale the number to scale with
  76032. * @returns the updated Vector4.
  76033. */
  76034. scaleInPlace(scale: number): Vector4;
  76035. /**
  76036. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  76037. * @param scale the number to scale with
  76038. * @returns a new vector with the result
  76039. */
  76040. scale(scale: number): Vector4;
  76041. /**
  76042. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  76043. * @param scale the number to scale with
  76044. * @param result a vector to store the result in
  76045. * @returns the current Vector4.
  76046. */
  76047. scaleToRef(scale: number, result: Vector4): Vector4;
  76048. /**
  76049. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  76050. * @param scale defines the scale factor
  76051. * @param result defines the Vector4 object where to store the result
  76052. * @returns the unmodified current Vector4
  76053. */
  76054. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  76055. /**
  76056. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  76057. * @param otherVector the vector to compare against
  76058. * @returns true if they are equal
  76059. */
  76060. equals(otherVector: DeepImmutable<Vector4>): boolean;
  76061. /**
  76062. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  76063. * @param otherVector vector to compare against
  76064. * @param epsilon (Default: very small number)
  76065. * @returns true if they are equal
  76066. */
  76067. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  76068. /**
  76069. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  76070. * @param x x value to compare against
  76071. * @param y y value to compare against
  76072. * @param z z value to compare against
  76073. * @param w w value to compare against
  76074. * @returns true if equal
  76075. */
  76076. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  76077. /**
  76078. * Multiplies in place the current Vector4 by the given one.
  76079. * @param otherVector vector to multiple with
  76080. * @returns the updated Vector4.
  76081. */
  76082. multiplyInPlace(otherVector: Vector4): Vector4;
  76083. /**
  76084. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  76085. * @param otherVector vector to multiple with
  76086. * @returns resulting new vector
  76087. */
  76088. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  76089. /**
  76090. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  76091. * @param otherVector vector to multiple with
  76092. * @param result vector to store the result
  76093. * @returns the current Vector4.
  76094. */
  76095. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76096. /**
  76097. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  76098. * @param x x value multiply with
  76099. * @param y y value multiply with
  76100. * @param z z value multiply with
  76101. * @param w w value multiply with
  76102. * @returns resulting new vector
  76103. */
  76104. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  76105. /**
  76106. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  76107. * @param otherVector vector to devide with
  76108. * @returns resulting new vector
  76109. */
  76110. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  76111. /**
  76112. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  76113. * @param otherVector vector to devide with
  76114. * @param result vector to store the result
  76115. * @returns the current Vector4.
  76116. */
  76117. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76118. /**
  76119. * Divides the current Vector3 coordinates by the given ones.
  76120. * @param otherVector vector to devide with
  76121. * @returns the updated Vector3.
  76122. */
  76123. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76124. /**
  76125. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  76126. * @param other defines the second operand
  76127. * @returns the current updated Vector4
  76128. */
  76129. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76130. /**
  76131. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  76132. * @param other defines the second operand
  76133. * @returns the current updated Vector4
  76134. */
  76135. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76136. /**
  76137. * Gets a new Vector4 from current Vector4 floored values
  76138. * @returns a new Vector4
  76139. */
  76140. floor(): Vector4;
  76141. /**
  76142. * Gets a new Vector4 from current Vector3 floored values
  76143. * @returns a new Vector4
  76144. */
  76145. fract(): Vector4;
  76146. /**
  76147. * Returns the Vector4 length (float).
  76148. * @returns the length
  76149. */
  76150. length(): number;
  76151. /**
  76152. * Returns the Vector4 squared length (float).
  76153. * @returns the length squared
  76154. */
  76155. lengthSquared(): number;
  76156. /**
  76157. * Normalizes in place the Vector4.
  76158. * @returns the updated Vector4.
  76159. */
  76160. normalize(): Vector4;
  76161. /**
  76162. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  76163. * @returns this converted to a new vector3
  76164. */
  76165. toVector3(): Vector3;
  76166. /**
  76167. * Returns a new Vector4 copied from the current one.
  76168. * @returns the new cloned vector
  76169. */
  76170. clone(): Vector4;
  76171. /**
  76172. * Updates the current Vector4 with the given one coordinates.
  76173. * @param source the source vector to copy from
  76174. * @returns the updated Vector4.
  76175. */
  76176. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  76177. /**
  76178. * Updates the current Vector4 coordinates with the given floats.
  76179. * @param x float to copy from
  76180. * @param y float to copy from
  76181. * @param z float to copy from
  76182. * @param w float to copy from
  76183. * @returns the updated Vector4.
  76184. */
  76185. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76186. /**
  76187. * Updates the current Vector4 coordinates with the given floats.
  76188. * @param x float to set from
  76189. * @param y float to set from
  76190. * @param z float to set from
  76191. * @param w float to set from
  76192. * @returns the updated Vector4.
  76193. */
  76194. set(x: number, y: number, z: number, w: number): Vector4;
  76195. /**
  76196. * Copies the given float to the current Vector3 coordinates
  76197. * @param v defines the x, y, z and w coordinates of the operand
  76198. * @returns the current updated Vector3
  76199. */
  76200. setAll(v: number): Vector4;
  76201. /**
  76202. * Returns a new Vector4 set from the starting index of the given array.
  76203. * @param array the array to pull values from
  76204. * @param offset the offset into the array to start at
  76205. * @returns the new vector
  76206. */
  76207. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  76208. /**
  76209. * Updates the given vector "result" from the starting index of the given array.
  76210. * @param array the array to pull values from
  76211. * @param offset the offset into the array to start at
  76212. * @param result the vector to store the result in
  76213. */
  76214. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  76215. /**
  76216. * Updates the given vector "result" from the starting index of the given Float32Array.
  76217. * @param array the array to pull values from
  76218. * @param offset the offset into the array to start at
  76219. * @param result the vector to store the result in
  76220. */
  76221. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  76222. /**
  76223. * Updates the given vector "result" coordinates from the given floats.
  76224. * @param x float to set from
  76225. * @param y float to set from
  76226. * @param z float to set from
  76227. * @param w float to set from
  76228. * @param result the vector to the floats in
  76229. */
  76230. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  76231. /**
  76232. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  76233. * @returns the new vector
  76234. */
  76235. static Zero(): Vector4;
  76236. /**
  76237. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  76238. * @returns the new vector
  76239. */
  76240. static One(): Vector4;
  76241. /**
  76242. * Returns a new normalized Vector4 from the given one.
  76243. * @param vector the vector to normalize
  76244. * @returns the vector
  76245. */
  76246. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  76247. /**
  76248. * Updates the given vector "result" from the normalization of the given one.
  76249. * @param vector the vector to normalize
  76250. * @param result the vector to store the result in
  76251. */
  76252. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  76253. /**
  76254. * Returns a vector with the minimum values from the left and right vectors
  76255. * @param left left vector to minimize
  76256. * @param right right vector to minimize
  76257. * @returns a new vector with the minimum of the left and right vector values
  76258. */
  76259. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76260. /**
  76261. * Returns a vector with the maximum values from the left and right vectors
  76262. * @param left left vector to maximize
  76263. * @param right right vector to maximize
  76264. * @returns a new vector with the maximum of the left and right vector values
  76265. */
  76266. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76267. /**
  76268. * Returns the distance (float) between the vectors "value1" and "value2".
  76269. * @param value1 value to calulate the distance between
  76270. * @param value2 value to calulate the distance between
  76271. * @return the distance between the two vectors
  76272. */
  76273. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76274. /**
  76275. * Returns the squared distance (float) between the vectors "value1" and "value2".
  76276. * @param value1 value to calulate the distance between
  76277. * @param value2 value to calulate the distance between
  76278. * @return the distance between the two vectors squared
  76279. */
  76280. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76281. /**
  76282. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  76283. * @param value1 value to calulate the center between
  76284. * @param value2 value to calulate the center between
  76285. * @return the center between the two vectors
  76286. */
  76287. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  76288. /**
  76289. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  76290. * This methods computes transformed normalized direction vectors only.
  76291. * @param vector the vector to transform
  76292. * @param transformation the transformation matrix to apply
  76293. * @returns the new vector
  76294. */
  76295. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  76296. /**
  76297. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  76298. * This methods computes transformed normalized direction vectors only.
  76299. * @param vector the vector to transform
  76300. * @param transformation the transformation matrix to apply
  76301. * @param result the vector to store the result in
  76302. */
  76303. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76304. /**
  76305. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  76306. * This methods computes transformed normalized direction vectors only.
  76307. * @param x value to transform
  76308. * @param y value to transform
  76309. * @param z value to transform
  76310. * @param w value to transform
  76311. * @param transformation the transformation matrix to apply
  76312. * @param result the vector to store the results in
  76313. */
  76314. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76315. /**
  76316. * Creates a new Vector4 from a Vector3
  76317. * @param source defines the source data
  76318. * @param w defines the 4th component (default is 0)
  76319. * @returns a new Vector4
  76320. */
  76321. static FromVector3(source: Vector3, w?: number): Vector4;
  76322. }
  76323. /**
  76324. * Class used to store quaternion data
  76325. * @see https://en.wikipedia.org/wiki/Quaternion
  76326. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  76327. */
  76328. export class Quaternion {
  76329. /** defines the first component (0 by default) */
  76330. x: number;
  76331. /** defines the second component (0 by default) */
  76332. y: number;
  76333. /** defines the third component (0 by default) */
  76334. z: number;
  76335. /** defines the fourth component (1.0 by default) */
  76336. w: number;
  76337. /**
  76338. * Creates a new Quaternion from the given floats
  76339. * @param x defines the first component (0 by default)
  76340. * @param y defines the second component (0 by default)
  76341. * @param z defines the third component (0 by default)
  76342. * @param w defines the fourth component (1.0 by default)
  76343. */
  76344. constructor(
  76345. /** defines the first component (0 by default) */
  76346. x?: number,
  76347. /** defines the second component (0 by default) */
  76348. y?: number,
  76349. /** defines the third component (0 by default) */
  76350. z?: number,
  76351. /** defines the fourth component (1.0 by default) */
  76352. w?: number);
  76353. /**
  76354. * Gets a string representation for the current quaternion
  76355. * @returns a string with the Quaternion coordinates
  76356. */
  76357. toString(): string;
  76358. /**
  76359. * Gets the class name of the quaternion
  76360. * @returns the string "Quaternion"
  76361. */
  76362. getClassName(): string;
  76363. /**
  76364. * Gets a hash code for this quaternion
  76365. * @returns the quaternion hash code
  76366. */
  76367. getHashCode(): number;
  76368. /**
  76369. * Copy the quaternion to an array
  76370. * @returns a new array populated with 4 elements from the quaternion coordinates
  76371. */
  76372. asArray(): number[];
  76373. /**
  76374. * Check if two quaternions are equals
  76375. * @param otherQuaternion defines the second operand
  76376. * @return true if the current quaternion and the given one coordinates are strictly equals
  76377. */
  76378. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  76379. /**
  76380. * Gets a boolean if two quaternions are equals (using an epsilon value)
  76381. * @param otherQuaternion defines the other quaternion
  76382. * @param epsilon defines the minimal distance to consider equality
  76383. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  76384. */
  76385. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  76386. /**
  76387. * Clone the current quaternion
  76388. * @returns a new quaternion copied from the current one
  76389. */
  76390. clone(): Quaternion;
  76391. /**
  76392. * Copy a quaternion to the current one
  76393. * @param other defines the other quaternion
  76394. * @returns the updated current quaternion
  76395. */
  76396. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  76397. /**
  76398. * Updates the current quaternion with the given float coordinates
  76399. * @param x defines the x coordinate
  76400. * @param y defines the y coordinate
  76401. * @param z defines the z coordinate
  76402. * @param w defines the w coordinate
  76403. * @returns the updated current quaternion
  76404. */
  76405. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  76406. /**
  76407. * Updates the current quaternion from the given float coordinates
  76408. * @param x defines the x coordinate
  76409. * @param y defines the y coordinate
  76410. * @param z defines the z coordinate
  76411. * @param w defines the w coordinate
  76412. * @returns the updated current quaternion
  76413. */
  76414. set(x: number, y: number, z: number, w: number): Quaternion;
  76415. /**
  76416. * Adds two quaternions
  76417. * @param other defines the second operand
  76418. * @returns a new quaternion as the addition result of the given one and the current quaternion
  76419. */
  76420. add(other: DeepImmutable<Quaternion>): Quaternion;
  76421. /**
  76422. * Add a quaternion to the current one
  76423. * @param other defines the quaternion to add
  76424. * @returns the current quaternion
  76425. */
  76426. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  76427. /**
  76428. * Subtract two quaternions
  76429. * @param other defines the second operand
  76430. * @returns a new quaternion as the subtraction result of the given one from the current one
  76431. */
  76432. subtract(other: Quaternion): Quaternion;
  76433. /**
  76434. * Multiplies the current quaternion by a scale factor
  76435. * @param value defines the scale factor
  76436. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  76437. */
  76438. scale(value: number): Quaternion;
  76439. /**
  76440. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  76441. * @param scale defines the scale factor
  76442. * @param result defines the Quaternion object where to store the result
  76443. * @returns the unmodified current quaternion
  76444. */
  76445. scaleToRef(scale: number, result: Quaternion): Quaternion;
  76446. /**
  76447. * Multiplies in place the current quaternion by a scale factor
  76448. * @param value defines the scale factor
  76449. * @returns the current modified quaternion
  76450. */
  76451. scaleInPlace(value: number): Quaternion;
  76452. /**
  76453. * Scale the current quaternion values by a factor and add the result to a given quaternion
  76454. * @param scale defines the scale factor
  76455. * @param result defines the Quaternion object where to store the result
  76456. * @returns the unmodified current quaternion
  76457. */
  76458. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  76459. /**
  76460. * Multiplies two quaternions
  76461. * @param q1 defines the second operand
  76462. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  76463. */
  76464. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  76465. /**
  76466. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  76467. * @param q1 defines the second operand
  76468. * @param result defines the target quaternion
  76469. * @returns the current quaternion
  76470. */
  76471. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  76472. /**
  76473. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  76474. * @param q1 defines the second operand
  76475. * @returns the currentupdated quaternion
  76476. */
  76477. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  76478. /**
  76479. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  76480. * @param ref defines the target quaternion
  76481. * @returns the current quaternion
  76482. */
  76483. conjugateToRef(ref: Quaternion): Quaternion;
  76484. /**
  76485. * Conjugates in place (1-q) the current quaternion
  76486. * @returns the current updated quaternion
  76487. */
  76488. conjugateInPlace(): Quaternion;
  76489. /**
  76490. * Conjugates in place (1-q) the current quaternion
  76491. * @returns a new quaternion
  76492. */
  76493. conjugate(): Quaternion;
  76494. /**
  76495. * Gets length of current quaternion
  76496. * @returns the quaternion length (float)
  76497. */
  76498. length(): number;
  76499. /**
  76500. * Normalize in place the current quaternion
  76501. * @returns the current updated quaternion
  76502. */
  76503. normalize(): Quaternion;
  76504. /**
  76505. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  76506. * @param order is a reserved parameter and is ignore for now
  76507. * @returns a new Vector3 containing the Euler angles
  76508. */
  76509. toEulerAngles(order?: string): Vector3;
  76510. /**
  76511. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  76512. * @param result defines the vector which will be filled with the Euler angles
  76513. * @param order is a reserved parameter and is ignore for now
  76514. * @returns the current unchanged quaternion
  76515. */
  76516. toEulerAnglesToRef(result: Vector3): Quaternion;
  76517. /**
  76518. * Updates the given rotation matrix with the current quaternion values
  76519. * @param result defines the target matrix
  76520. * @returns the current unchanged quaternion
  76521. */
  76522. toRotationMatrix(result: Matrix): Quaternion;
  76523. /**
  76524. * Updates the current quaternion from the given rotation matrix values
  76525. * @param matrix defines the source matrix
  76526. * @returns the current updated quaternion
  76527. */
  76528. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76529. /**
  76530. * Creates a new quaternion from a rotation matrix
  76531. * @param matrix defines the source matrix
  76532. * @returns a new quaternion created from the given rotation matrix values
  76533. */
  76534. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76535. /**
  76536. * Updates the given quaternion with the given rotation matrix values
  76537. * @param matrix defines the source matrix
  76538. * @param result defines the target quaternion
  76539. */
  76540. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  76541. /**
  76542. * Returns the dot product (float) between the quaternions "left" and "right"
  76543. * @param left defines the left operand
  76544. * @param right defines the right operand
  76545. * @returns the dot product
  76546. */
  76547. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  76548. /**
  76549. * Checks if the two quaternions are close to each other
  76550. * @param quat0 defines the first quaternion to check
  76551. * @param quat1 defines the second quaternion to check
  76552. * @returns true if the two quaternions are close to each other
  76553. */
  76554. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  76555. /**
  76556. * Creates an empty quaternion
  76557. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  76558. */
  76559. static Zero(): Quaternion;
  76560. /**
  76561. * Inverse a given quaternion
  76562. * @param q defines the source quaternion
  76563. * @returns a new quaternion as the inverted current quaternion
  76564. */
  76565. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  76566. /**
  76567. * Inverse a given quaternion
  76568. * @param q defines the source quaternion
  76569. * @param result the quaternion the result will be stored in
  76570. * @returns the result quaternion
  76571. */
  76572. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  76573. /**
  76574. * Creates an identity quaternion
  76575. * @returns the identity quaternion
  76576. */
  76577. static Identity(): Quaternion;
  76578. /**
  76579. * Gets a boolean indicating if the given quaternion is identity
  76580. * @param quaternion defines the quaternion to check
  76581. * @returns true if the quaternion is identity
  76582. */
  76583. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  76584. /**
  76585. * Creates a quaternion from a rotation around an axis
  76586. * @param axis defines the axis to use
  76587. * @param angle defines the angle to use
  76588. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  76589. */
  76590. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  76591. /**
  76592. * Creates a rotation around an axis and stores it into the given quaternion
  76593. * @param axis defines the axis to use
  76594. * @param angle defines the angle to use
  76595. * @param result defines the target quaternion
  76596. * @returns the target quaternion
  76597. */
  76598. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  76599. /**
  76600. * Creates a new quaternion from data stored into an array
  76601. * @param array defines the data source
  76602. * @param offset defines the offset in the source array where the data starts
  76603. * @returns a new quaternion
  76604. */
  76605. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  76606. /**
  76607. * Create a quaternion from Euler rotation angles
  76608. * @param x Pitch
  76609. * @param y Yaw
  76610. * @param z Roll
  76611. * @returns the new Quaternion
  76612. */
  76613. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  76614. /**
  76615. * Updates a quaternion from Euler rotation angles
  76616. * @param x Pitch
  76617. * @param y Yaw
  76618. * @param z Roll
  76619. * @param result the quaternion to store the result
  76620. * @returns the updated quaternion
  76621. */
  76622. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  76623. /**
  76624. * Create a quaternion from Euler rotation vector
  76625. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  76626. * @returns the new Quaternion
  76627. */
  76628. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  76629. /**
  76630. * Updates a quaternion from Euler rotation vector
  76631. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  76632. * @param result the quaternion to store the result
  76633. * @returns the updated quaternion
  76634. */
  76635. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  76636. /**
  76637. * Creates a new quaternion from the given Euler float angles (y, x, z)
  76638. * @param yaw defines the rotation around Y axis
  76639. * @param pitch defines the rotation around X axis
  76640. * @param roll defines the rotation around Z axis
  76641. * @returns the new quaternion
  76642. */
  76643. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  76644. /**
  76645. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  76646. * @param yaw defines the rotation around Y axis
  76647. * @param pitch defines the rotation around X axis
  76648. * @param roll defines the rotation around Z axis
  76649. * @param result defines the target quaternion
  76650. */
  76651. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  76652. /**
  76653. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  76654. * @param alpha defines the rotation around first axis
  76655. * @param beta defines the rotation around second axis
  76656. * @param gamma defines the rotation around third axis
  76657. * @returns the new quaternion
  76658. */
  76659. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  76660. /**
  76661. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  76662. * @param alpha defines the rotation around first axis
  76663. * @param beta defines the rotation around second axis
  76664. * @param gamma defines the rotation around third axis
  76665. * @param result defines the target quaternion
  76666. */
  76667. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  76668. /**
  76669. * 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)
  76670. * @param axis1 defines the first axis
  76671. * @param axis2 defines the second axis
  76672. * @param axis3 defines the third axis
  76673. * @returns the new quaternion
  76674. */
  76675. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  76676. /**
  76677. * 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
  76678. * @param axis1 defines the first axis
  76679. * @param axis2 defines the second axis
  76680. * @param axis3 defines the third axis
  76681. * @param ref defines the target quaternion
  76682. */
  76683. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  76684. /**
  76685. * Interpolates between two quaternions
  76686. * @param left defines first quaternion
  76687. * @param right defines second quaternion
  76688. * @param amount defines the gradient to use
  76689. * @returns the new interpolated quaternion
  76690. */
  76691. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  76692. /**
  76693. * Interpolates between two quaternions and stores it into a target quaternion
  76694. * @param left defines first quaternion
  76695. * @param right defines second quaternion
  76696. * @param amount defines the gradient to use
  76697. * @param result defines the target quaternion
  76698. */
  76699. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  76700. /**
  76701. * Interpolate between two quaternions using Hermite interpolation
  76702. * @param value1 defines first quaternion
  76703. * @param tangent1 defines the incoming tangent
  76704. * @param value2 defines second quaternion
  76705. * @param tangent2 defines the outgoing tangent
  76706. * @param amount defines the target quaternion
  76707. * @returns the new interpolated quaternion
  76708. */
  76709. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  76710. }
  76711. /**
  76712. * Class used to store matrix data (4x4)
  76713. */
  76714. export class Matrix {
  76715. private static _updateFlagSeed;
  76716. private static _identityReadOnly;
  76717. private _isIdentity;
  76718. private _isIdentityDirty;
  76719. private _isIdentity3x2;
  76720. private _isIdentity3x2Dirty;
  76721. /**
  76722. * Gets the update flag of the matrix which is an unique number for the matrix.
  76723. * It will be incremented every time the matrix data change.
  76724. * You can use it to speed the comparison between two versions of the same matrix.
  76725. */
  76726. updateFlag: number;
  76727. private readonly _m;
  76728. /**
  76729. * Gets the internal data of the matrix
  76730. */
  76731. get m(): DeepImmutable<Float32Array>;
  76732. /** @hidden */
  76733. _markAsUpdated(): void;
  76734. /** @hidden */
  76735. private _updateIdentityStatus;
  76736. /**
  76737. * Creates an empty matrix (filled with zeros)
  76738. */
  76739. constructor();
  76740. /**
  76741. * Check if the current matrix is identity
  76742. * @returns true is the matrix is the identity matrix
  76743. */
  76744. isIdentity(): boolean;
  76745. /**
  76746. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  76747. * @returns true is the matrix is the identity matrix
  76748. */
  76749. isIdentityAs3x2(): boolean;
  76750. /**
  76751. * Gets the determinant of the matrix
  76752. * @returns the matrix determinant
  76753. */
  76754. determinant(): number;
  76755. /**
  76756. * Returns the matrix as a Float32Array
  76757. * @returns the matrix underlying array
  76758. */
  76759. toArray(): DeepImmutable<Float32Array>;
  76760. /**
  76761. * Returns the matrix as a Float32Array
  76762. * @returns the matrix underlying array.
  76763. */
  76764. asArray(): DeepImmutable<Float32Array>;
  76765. /**
  76766. * Inverts the current matrix in place
  76767. * @returns the current inverted matrix
  76768. */
  76769. invert(): Matrix;
  76770. /**
  76771. * Sets all the matrix elements to zero
  76772. * @returns the current matrix
  76773. */
  76774. reset(): Matrix;
  76775. /**
  76776. * Adds the current matrix with a second one
  76777. * @param other defines the matrix to add
  76778. * @returns a new matrix as the addition of the current matrix and the given one
  76779. */
  76780. add(other: DeepImmutable<Matrix>): Matrix;
  76781. /**
  76782. * Sets the given matrix "result" to the addition of the current matrix and the given one
  76783. * @param other defines the matrix to add
  76784. * @param result defines the target matrix
  76785. * @returns the current matrix
  76786. */
  76787. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  76788. /**
  76789. * Adds in place the given matrix to the current matrix
  76790. * @param other defines the second operand
  76791. * @returns the current updated matrix
  76792. */
  76793. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  76794. /**
  76795. * Sets the given matrix to the current inverted Matrix
  76796. * @param other defines the target matrix
  76797. * @returns the unmodified current matrix
  76798. */
  76799. invertToRef(other: Matrix): Matrix;
  76800. /**
  76801. * add a value at the specified position in the current Matrix
  76802. * @param index the index of the value within the matrix. between 0 and 15.
  76803. * @param value the value to be added
  76804. * @returns the current updated matrix
  76805. */
  76806. addAtIndex(index: number, value: number): Matrix;
  76807. /**
  76808. * mutiply the specified position in the current Matrix by a value
  76809. * @param index the index of the value within the matrix. between 0 and 15.
  76810. * @param value the value to be added
  76811. * @returns the current updated matrix
  76812. */
  76813. multiplyAtIndex(index: number, value: number): Matrix;
  76814. /**
  76815. * Inserts the translation vector (using 3 floats) in the current matrix
  76816. * @param x defines the 1st component of the translation
  76817. * @param y defines the 2nd component of the translation
  76818. * @param z defines the 3rd component of the translation
  76819. * @returns the current updated matrix
  76820. */
  76821. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  76822. /**
  76823. * Adds the translation vector (using 3 floats) in the current matrix
  76824. * @param x defines the 1st component of the translation
  76825. * @param y defines the 2nd component of the translation
  76826. * @param z defines the 3rd component of the translation
  76827. * @returns the current updated matrix
  76828. */
  76829. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  76830. /**
  76831. * Inserts the translation vector in the current matrix
  76832. * @param vector3 defines the translation to insert
  76833. * @returns the current updated matrix
  76834. */
  76835. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  76836. /**
  76837. * Gets the translation value of the current matrix
  76838. * @returns a new Vector3 as the extracted translation from the matrix
  76839. */
  76840. getTranslation(): Vector3;
  76841. /**
  76842. * Fill a Vector3 with the extracted translation from the matrix
  76843. * @param result defines the Vector3 where to store the translation
  76844. * @returns the current matrix
  76845. */
  76846. getTranslationToRef(result: Vector3): Matrix;
  76847. /**
  76848. * Remove rotation and scaling part from the matrix
  76849. * @returns the updated matrix
  76850. */
  76851. removeRotationAndScaling(): Matrix;
  76852. /**
  76853. * Multiply two matrices
  76854. * @param other defines the second operand
  76855. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  76856. */
  76857. multiply(other: DeepImmutable<Matrix>): Matrix;
  76858. /**
  76859. * Copy the current matrix from the given one
  76860. * @param other defines the source matrix
  76861. * @returns the current updated matrix
  76862. */
  76863. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  76864. /**
  76865. * Populates the given array from the starting index with the current matrix values
  76866. * @param array defines the target array
  76867. * @param offset defines the offset in the target array where to start storing values
  76868. * @returns the current matrix
  76869. */
  76870. copyToArray(array: Float32Array, offset?: number): Matrix;
  76871. /**
  76872. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  76873. * @param other defines the second operand
  76874. * @param result defines the matrix where to store the multiplication
  76875. * @returns the current matrix
  76876. */
  76877. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  76878. /**
  76879. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  76880. * @param other defines the second operand
  76881. * @param result defines the array where to store the multiplication
  76882. * @param offset defines the offset in the target array where to start storing values
  76883. * @returns the current matrix
  76884. */
  76885. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  76886. /**
  76887. * Check equality between this matrix and a second one
  76888. * @param value defines the second matrix to compare
  76889. * @returns true is the current matrix and the given one values are strictly equal
  76890. */
  76891. equals(value: DeepImmutable<Matrix>): boolean;
  76892. /**
  76893. * Clone the current matrix
  76894. * @returns a new matrix from the current matrix
  76895. */
  76896. clone(): Matrix;
  76897. /**
  76898. * Returns the name of the current matrix class
  76899. * @returns the string "Matrix"
  76900. */
  76901. getClassName(): string;
  76902. /**
  76903. * Gets the hash code of the current matrix
  76904. * @returns the hash code
  76905. */
  76906. getHashCode(): number;
  76907. /**
  76908. * Decomposes the current Matrix into a translation, rotation and scaling components
  76909. * @param scale defines the scale vector3 given as a reference to update
  76910. * @param rotation defines the rotation quaternion given as a reference to update
  76911. * @param translation defines the translation vector3 given as a reference to update
  76912. * @returns true if operation was successful
  76913. */
  76914. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  76915. /**
  76916. * Gets specific row of the matrix
  76917. * @param index defines the number of the row to get
  76918. * @returns the index-th row of the current matrix as a new Vector4
  76919. */
  76920. getRow(index: number): Nullable<Vector4>;
  76921. /**
  76922. * Sets the index-th row of the current matrix to the vector4 values
  76923. * @param index defines the number of the row to set
  76924. * @param row defines the target vector4
  76925. * @returns the updated current matrix
  76926. */
  76927. setRow(index: number, row: Vector4): Matrix;
  76928. /**
  76929. * Compute the transpose of the matrix
  76930. * @returns the new transposed matrix
  76931. */
  76932. transpose(): Matrix;
  76933. /**
  76934. * Compute the transpose of the matrix and store it in a given matrix
  76935. * @param result defines the target matrix
  76936. * @returns the current matrix
  76937. */
  76938. transposeToRef(result: Matrix): Matrix;
  76939. /**
  76940. * Sets the index-th row of the current matrix with the given 4 x float values
  76941. * @param index defines the row index
  76942. * @param x defines the x component to set
  76943. * @param y defines the y component to set
  76944. * @param z defines the z component to set
  76945. * @param w defines the w component to set
  76946. * @returns the updated current matrix
  76947. */
  76948. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  76949. /**
  76950. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  76951. * @param scale defines the scale factor
  76952. * @returns a new matrix
  76953. */
  76954. scale(scale: number): Matrix;
  76955. /**
  76956. * Scale the current matrix values by a factor to a given result matrix
  76957. * @param scale defines the scale factor
  76958. * @param result defines the matrix to store the result
  76959. * @returns the current matrix
  76960. */
  76961. scaleToRef(scale: number, result: Matrix): Matrix;
  76962. /**
  76963. * Scale the current matrix values by a factor and add the result to a given matrix
  76964. * @param scale defines the scale factor
  76965. * @param result defines the Matrix to store the result
  76966. * @returns the current matrix
  76967. */
  76968. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  76969. /**
  76970. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  76971. * @param ref matrix to store the result
  76972. */
  76973. toNormalMatrix(ref: Matrix): void;
  76974. /**
  76975. * Gets only rotation part of the current matrix
  76976. * @returns a new matrix sets to the extracted rotation matrix from the current one
  76977. */
  76978. getRotationMatrix(): Matrix;
  76979. /**
  76980. * Extracts the rotation matrix from the current one and sets it as the given "result"
  76981. * @param result defines the target matrix to store data to
  76982. * @returns the current matrix
  76983. */
  76984. getRotationMatrixToRef(result: Matrix): Matrix;
  76985. /**
  76986. * Toggles model matrix from being right handed to left handed in place and vice versa
  76987. */
  76988. toggleModelMatrixHandInPlace(): void;
  76989. /**
  76990. * Toggles projection matrix from being right handed to left handed in place and vice versa
  76991. */
  76992. toggleProjectionMatrixHandInPlace(): void;
  76993. /**
  76994. * Creates a matrix from an array
  76995. * @param array defines the source array
  76996. * @param offset defines an offset in the source array
  76997. * @returns a new Matrix set from the starting index of the given array
  76998. */
  76999. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  77000. /**
  77001. * Copy the content of an array into a given matrix
  77002. * @param array defines the source array
  77003. * @param offset defines an offset in the source array
  77004. * @param result defines the target matrix
  77005. */
  77006. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  77007. /**
  77008. * Stores an array into a matrix after having multiplied each component by a given factor
  77009. * @param array defines the source array
  77010. * @param offset defines the offset in the source array
  77011. * @param scale defines the scaling factor
  77012. * @param result defines the target matrix
  77013. */
  77014. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  77015. /**
  77016. * Gets an identity matrix that must not be updated
  77017. */
  77018. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  77019. /**
  77020. * Stores a list of values (16) inside a given matrix
  77021. * @param initialM11 defines 1st value of 1st row
  77022. * @param initialM12 defines 2nd value of 1st row
  77023. * @param initialM13 defines 3rd value of 1st row
  77024. * @param initialM14 defines 4th value of 1st row
  77025. * @param initialM21 defines 1st value of 2nd row
  77026. * @param initialM22 defines 2nd value of 2nd row
  77027. * @param initialM23 defines 3rd value of 2nd row
  77028. * @param initialM24 defines 4th value of 2nd row
  77029. * @param initialM31 defines 1st value of 3rd row
  77030. * @param initialM32 defines 2nd value of 3rd row
  77031. * @param initialM33 defines 3rd value of 3rd row
  77032. * @param initialM34 defines 4th value of 3rd row
  77033. * @param initialM41 defines 1st value of 4th row
  77034. * @param initialM42 defines 2nd value of 4th row
  77035. * @param initialM43 defines 3rd value of 4th row
  77036. * @param initialM44 defines 4th value of 4th row
  77037. * @param result defines the target matrix
  77038. */
  77039. 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;
  77040. /**
  77041. * Creates new matrix from a list of values (16)
  77042. * @param initialM11 defines 1st value of 1st row
  77043. * @param initialM12 defines 2nd value of 1st row
  77044. * @param initialM13 defines 3rd value of 1st row
  77045. * @param initialM14 defines 4th value of 1st row
  77046. * @param initialM21 defines 1st value of 2nd row
  77047. * @param initialM22 defines 2nd value of 2nd row
  77048. * @param initialM23 defines 3rd value of 2nd row
  77049. * @param initialM24 defines 4th value of 2nd row
  77050. * @param initialM31 defines 1st value of 3rd row
  77051. * @param initialM32 defines 2nd value of 3rd row
  77052. * @param initialM33 defines 3rd value of 3rd row
  77053. * @param initialM34 defines 4th value of 3rd row
  77054. * @param initialM41 defines 1st value of 4th row
  77055. * @param initialM42 defines 2nd value of 4th row
  77056. * @param initialM43 defines 3rd value of 4th row
  77057. * @param initialM44 defines 4th value of 4th row
  77058. * @returns the new matrix
  77059. */
  77060. 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;
  77061. /**
  77062. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77063. * @param scale defines the scale vector3
  77064. * @param rotation defines the rotation quaternion
  77065. * @param translation defines the translation vector3
  77066. * @returns a new matrix
  77067. */
  77068. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  77069. /**
  77070. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77071. * @param scale defines the scale vector3
  77072. * @param rotation defines the rotation quaternion
  77073. * @param translation defines the translation vector3
  77074. * @param result defines the target matrix
  77075. */
  77076. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  77077. /**
  77078. * Creates a new identity matrix
  77079. * @returns a new identity matrix
  77080. */
  77081. static Identity(): Matrix;
  77082. /**
  77083. * Creates a new identity matrix and stores the result in a given matrix
  77084. * @param result defines the target matrix
  77085. */
  77086. static IdentityToRef(result: Matrix): void;
  77087. /**
  77088. * Creates a new zero matrix
  77089. * @returns a new zero matrix
  77090. */
  77091. static Zero(): Matrix;
  77092. /**
  77093. * Creates a new rotation matrix for "angle" radians around the X axis
  77094. * @param angle defines the angle (in radians) to use
  77095. * @return the new matrix
  77096. */
  77097. static RotationX(angle: number): Matrix;
  77098. /**
  77099. * Creates a new matrix as the invert of a given matrix
  77100. * @param source defines the source matrix
  77101. * @returns the new matrix
  77102. */
  77103. static Invert(source: DeepImmutable<Matrix>): Matrix;
  77104. /**
  77105. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  77106. * @param angle defines the angle (in radians) to use
  77107. * @param result defines the target matrix
  77108. */
  77109. static RotationXToRef(angle: number, result: Matrix): void;
  77110. /**
  77111. * Creates a new rotation matrix for "angle" radians around the Y axis
  77112. * @param angle defines the angle (in radians) to use
  77113. * @return the new matrix
  77114. */
  77115. static RotationY(angle: number): Matrix;
  77116. /**
  77117. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  77118. * @param angle defines the angle (in radians) to use
  77119. * @param result defines the target matrix
  77120. */
  77121. static RotationYToRef(angle: number, result: Matrix): void;
  77122. /**
  77123. * Creates a new rotation matrix for "angle" radians around the Z axis
  77124. * @param angle defines the angle (in radians) to use
  77125. * @return the new matrix
  77126. */
  77127. static RotationZ(angle: number): Matrix;
  77128. /**
  77129. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  77130. * @param angle defines the angle (in radians) to use
  77131. * @param result defines the target matrix
  77132. */
  77133. static RotationZToRef(angle: number, result: Matrix): void;
  77134. /**
  77135. * Creates a new rotation matrix for "angle" radians around the given axis
  77136. * @param axis defines the axis to use
  77137. * @param angle defines the angle (in radians) to use
  77138. * @return the new matrix
  77139. */
  77140. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  77141. /**
  77142. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  77143. * @param axis defines the axis to use
  77144. * @param angle defines the angle (in radians) to use
  77145. * @param result defines the target matrix
  77146. */
  77147. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  77148. /**
  77149. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  77150. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  77151. * @param from defines the vector to align
  77152. * @param to defines the vector to align to
  77153. * @param result defines the target matrix
  77154. */
  77155. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  77156. /**
  77157. * Creates a rotation matrix
  77158. * @param yaw defines the yaw angle in radians (Y axis)
  77159. * @param pitch defines the pitch angle in radians (X axis)
  77160. * @param roll defines the roll angle in radians (X axis)
  77161. * @returns the new rotation matrix
  77162. */
  77163. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  77164. /**
  77165. * Creates a rotation matrix and stores it in a given matrix
  77166. * @param yaw defines the yaw angle in radians (Y axis)
  77167. * @param pitch defines the pitch angle in radians (X axis)
  77168. * @param roll defines the roll angle in radians (X axis)
  77169. * @param result defines the target matrix
  77170. */
  77171. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  77172. /**
  77173. * Creates a scaling matrix
  77174. * @param x defines the scale factor on X axis
  77175. * @param y defines the scale factor on Y axis
  77176. * @param z defines the scale factor on Z axis
  77177. * @returns the new matrix
  77178. */
  77179. static Scaling(x: number, y: number, z: number): Matrix;
  77180. /**
  77181. * Creates a scaling matrix and stores it in a given matrix
  77182. * @param x defines the scale factor on X axis
  77183. * @param y defines the scale factor on Y axis
  77184. * @param z defines the scale factor on Z axis
  77185. * @param result defines the target matrix
  77186. */
  77187. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  77188. /**
  77189. * Creates a translation matrix
  77190. * @param x defines the translation on X axis
  77191. * @param y defines the translation on Y axis
  77192. * @param z defines the translationon Z axis
  77193. * @returns the new matrix
  77194. */
  77195. static Translation(x: number, y: number, z: number): Matrix;
  77196. /**
  77197. * Creates a translation matrix and stores it in a given matrix
  77198. * @param x defines the translation on X axis
  77199. * @param y defines the translation on Y axis
  77200. * @param z defines the translationon Z axis
  77201. * @param result defines the target matrix
  77202. */
  77203. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  77204. /**
  77205. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77206. * @param startValue defines the start value
  77207. * @param endValue defines the end value
  77208. * @param gradient defines the gradient factor
  77209. * @returns the new matrix
  77210. */
  77211. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77212. /**
  77213. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77214. * @param startValue defines the start value
  77215. * @param endValue defines the end value
  77216. * @param gradient defines the gradient factor
  77217. * @param result defines the Matrix object where to store data
  77218. */
  77219. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77220. /**
  77221. * Builds a new matrix whose values are computed by:
  77222. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77223. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77224. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77225. * @param startValue defines the first matrix
  77226. * @param endValue defines the second matrix
  77227. * @param gradient defines the gradient between the two matrices
  77228. * @returns the new matrix
  77229. */
  77230. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77231. /**
  77232. * Update a matrix to values which are computed by:
  77233. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77234. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77235. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77236. * @param startValue defines the first matrix
  77237. * @param endValue defines the second matrix
  77238. * @param gradient defines the gradient between the two matrices
  77239. * @param result defines the target matrix
  77240. */
  77241. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77242. /**
  77243. * 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"
  77244. * This function works in left handed mode
  77245. * @param eye defines the final position of the entity
  77246. * @param target defines where the entity should look at
  77247. * @param up defines the up vector for the entity
  77248. * @returns the new matrix
  77249. */
  77250. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77251. /**
  77252. * 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".
  77253. * This function works in left handed mode
  77254. * @param eye defines the final position of the entity
  77255. * @param target defines where the entity should look at
  77256. * @param up defines the up vector for the entity
  77257. * @param result defines the target matrix
  77258. */
  77259. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77260. /**
  77261. * 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"
  77262. * This function works in right handed mode
  77263. * @param eye defines the final position of the entity
  77264. * @param target defines where the entity should look at
  77265. * @param up defines the up vector for the entity
  77266. * @returns the new matrix
  77267. */
  77268. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77269. /**
  77270. * 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".
  77271. * This function works in right handed mode
  77272. * @param eye defines the final position of the entity
  77273. * @param target defines where the entity should look at
  77274. * @param up defines the up vector for the entity
  77275. * @param result defines the target matrix
  77276. */
  77277. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77278. /**
  77279. * Create a left-handed orthographic projection matrix
  77280. * @param width defines the viewport width
  77281. * @param height defines the viewport height
  77282. * @param znear defines the near clip plane
  77283. * @param zfar defines the far clip plane
  77284. * @returns a new matrix as a left-handed orthographic projection matrix
  77285. */
  77286. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77287. /**
  77288. * Store a left-handed orthographic projection to a given matrix
  77289. * @param width defines the viewport width
  77290. * @param height defines the viewport height
  77291. * @param znear defines the near clip plane
  77292. * @param zfar defines the far clip plane
  77293. * @param result defines the target matrix
  77294. */
  77295. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  77296. /**
  77297. * Create a left-handed orthographic projection matrix
  77298. * @param left defines the viewport left coordinate
  77299. * @param right defines the viewport right coordinate
  77300. * @param bottom defines the viewport bottom coordinate
  77301. * @param top defines the viewport top coordinate
  77302. * @param znear defines the near clip plane
  77303. * @param zfar defines the far clip plane
  77304. * @returns a new matrix as a left-handed orthographic projection matrix
  77305. */
  77306. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77307. /**
  77308. * Stores a left-handed orthographic projection into a given matrix
  77309. * @param left defines the viewport left coordinate
  77310. * @param right defines the viewport right coordinate
  77311. * @param bottom defines the viewport bottom coordinate
  77312. * @param top defines the viewport top coordinate
  77313. * @param znear defines the near clip plane
  77314. * @param zfar defines the far clip plane
  77315. * @param result defines the target matrix
  77316. */
  77317. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77318. /**
  77319. * Creates a right-handed orthographic projection matrix
  77320. * @param left defines the viewport left coordinate
  77321. * @param right defines the viewport right coordinate
  77322. * @param bottom defines the viewport bottom coordinate
  77323. * @param top defines the viewport top coordinate
  77324. * @param znear defines the near clip plane
  77325. * @param zfar defines the far clip plane
  77326. * @returns a new matrix as a right-handed orthographic projection matrix
  77327. */
  77328. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77329. /**
  77330. * Stores a right-handed orthographic projection into a given matrix
  77331. * @param left defines the viewport left coordinate
  77332. * @param right defines the viewport right coordinate
  77333. * @param bottom defines the viewport bottom coordinate
  77334. * @param top defines the viewport top coordinate
  77335. * @param znear defines the near clip plane
  77336. * @param zfar defines the far clip plane
  77337. * @param result defines the target matrix
  77338. */
  77339. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77340. /**
  77341. * Creates a left-handed perspective projection matrix
  77342. * @param width defines the viewport width
  77343. * @param height defines the viewport height
  77344. * @param znear defines the near clip plane
  77345. * @param zfar defines the far clip plane
  77346. * @returns a new matrix as a left-handed perspective projection matrix
  77347. */
  77348. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77349. /**
  77350. * Creates a left-handed perspective projection matrix
  77351. * @param fov defines the horizontal field of view
  77352. * @param aspect defines the aspect ratio
  77353. * @param znear defines the near clip plane
  77354. * @param zfar defines the far clip plane
  77355. * @returns a new matrix as a left-handed perspective projection matrix
  77356. */
  77357. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77358. /**
  77359. * Stores a left-handed perspective projection into a given matrix
  77360. * @param fov defines the horizontal field of view
  77361. * @param aspect defines the aspect ratio
  77362. * @param znear defines the near clip plane
  77363. * @param zfar defines the far clip plane
  77364. * @param result defines the target matrix
  77365. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77366. */
  77367. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77368. /**
  77369. * Stores a left-handed perspective projection into a given matrix with depth reversed
  77370. * @param fov defines the horizontal field of view
  77371. * @param aspect defines the aspect ratio
  77372. * @param znear defines the near clip plane
  77373. * @param zfar not used as infinity is used as far clip
  77374. * @param result defines the target matrix
  77375. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77376. */
  77377. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77378. /**
  77379. * Creates a right-handed perspective projection matrix
  77380. * @param fov defines the horizontal field of view
  77381. * @param aspect defines the aspect ratio
  77382. * @param znear defines the near clip plane
  77383. * @param zfar defines the far clip plane
  77384. * @returns a new matrix as a right-handed perspective projection matrix
  77385. */
  77386. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77387. /**
  77388. * Stores a right-handed perspective projection into a given matrix
  77389. * @param fov defines the horizontal field of view
  77390. * @param aspect defines the aspect ratio
  77391. * @param znear defines the near clip plane
  77392. * @param zfar defines the far clip plane
  77393. * @param result defines the target matrix
  77394. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77395. */
  77396. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77397. /**
  77398. * Stores a right-handed perspective projection into a given matrix
  77399. * @param fov defines the horizontal field of view
  77400. * @param aspect defines the aspect ratio
  77401. * @param znear defines the near clip plane
  77402. * @param zfar not used as infinity is used as far clip
  77403. * @param result defines the target matrix
  77404. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77405. */
  77406. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77407. /**
  77408. * Stores a perspective projection for WebVR info a given matrix
  77409. * @param fov defines the field of view
  77410. * @param znear defines the near clip plane
  77411. * @param zfar defines the far clip plane
  77412. * @param result defines the target matrix
  77413. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  77414. */
  77415. static PerspectiveFovWebVRToRef(fov: {
  77416. upDegrees: number;
  77417. downDegrees: number;
  77418. leftDegrees: number;
  77419. rightDegrees: number;
  77420. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  77421. /**
  77422. * Computes a complete transformation matrix
  77423. * @param viewport defines the viewport to use
  77424. * @param world defines the world matrix
  77425. * @param view defines the view matrix
  77426. * @param projection defines the projection matrix
  77427. * @param zmin defines the near clip plane
  77428. * @param zmax defines the far clip plane
  77429. * @returns the transformation matrix
  77430. */
  77431. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  77432. /**
  77433. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  77434. * @param matrix defines the matrix to use
  77435. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  77436. */
  77437. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  77438. /**
  77439. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  77440. * @param matrix defines the matrix to use
  77441. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  77442. */
  77443. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  77444. /**
  77445. * Compute the transpose of a given matrix
  77446. * @param matrix defines the matrix to transpose
  77447. * @returns the new matrix
  77448. */
  77449. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  77450. /**
  77451. * Compute the transpose of a matrix and store it in a target matrix
  77452. * @param matrix defines the matrix to transpose
  77453. * @param result defines the target matrix
  77454. */
  77455. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  77456. /**
  77457. * Computes a reflection matrix from a plane
  77458. * @param plane defines the reflection plane
  77459. * @returns a new matrix
  77460. */
  77461. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  77462. /**
  77463. * Computes a reflection matrix from a plane
  77464. * @param plane defines the reflection plane
  77465. * @param result defines the target matrix
  77466. */
  77467. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  77468. /**
  77469. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  77470. * @param xaxis defines the value of the 1st axis
  77471. * @param yaxis defines the value of the 2nd axis
  77472. * @param zaxis defines the value of the 3rd axis
  77473. * @param result defines the target matrix
  77474. */
  77475. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  77476. /**
  77477. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  77478. * @param quat defines the quaternion to use
  77479. * @param result defines the target matrix
  77480. */
  77481. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  77482. }
  77483. /**
  77484. * @hidden
  77485. */
  77486. export class TmpVectors {
  77487. static Vector2: Vector2[];
  77488. static Vector3: Vector3[];
  77489. static Vector4: Vector4[];
  77490. static Quaternion: Quaternion[];
  77491. static Matrix: Matrix[];
  77492. }
  77493. }
  77494. declare module BABYLON {
  77495. /**
  77496. * Defines potential orientation for back face culling
  77497. */
  77498. export enum Orientation {
  77499. /**
  77500. * Clockwise
  77501. */
  77502. CW = 0,
  77503. /** Counter clockwise */
  77504. CCW = 1
  77505. }
  77506. /** Class used to represent a Bezier curve */
  77507. export class BezierCurve {
  77508. /**
  77509. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  77510. * @param t defines the time
  77511. * @param x1 defines the left coordinate on X axis
  77512. * @param y1 defines the left coordinate on Y axis
  77513. * @param x2 defines the right coordinate on X axis
  77514. * @param y2 defines the right coordinate on Y axis
  77515. * @returns the interpolated value
  77516. */
  77517. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  77518. }
  77519. /**
  77520. * Defines angle representation
  77521. */
  77522. export class Angle {
  77523. private _radians;
  77524. /**
  77525. * Creates an Angle object of "radians" radians (float).
  77526. * @param radians the angle in radians
  77527. */
  77528. constructor(radians: number);
  77529. /**
  77530. * Get value in degrees
  77531. * @returns the Angle value in degrees (float)
  77532. */
  77533. degrees(): number;
  77534. /**
  77535. * Get value in radians
  77536. * @returns the Angle value in radians (float)
  77537. */
  77538. radians(): number;
  77539. /**
  77540. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  77541. * @param a defines first vector
  77542. * @param b defines second vector
  77543. * @returns a new Angle
  77544. */
  77545. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  77546. /**
  77547. * Gets a new Angle object from the given float in radians
  77548. * @param radians defines the angle value in radians
  77549. * @returns a new Angle
  77550. */
  77551. static FromRadians(radians: number): Angle;
  77552. /**
  77553. * Gets a new Angle object from the given float in degrees
  77554. * @param degrees defines the angle value in degrees
  77555. * @returns a new Angle
  77556. */
  77557. static FromDegrees(degrees: number): Angle;
  77558. }
  77559. /**
  77560. * This represents an arc in a 2d space.
  77561. */
  77562. export class Arc2 {
  77563. /** Defines the start point of the arc */
  77564. startPoint: Vector2;
  77565. /** Defines the mid point of the arc */
  77566. midPoint: Vector2;
  77567. /** Defines the end point of the arc */
  77568. endPoint: Vector2;
  77569. /**
  77570. * Defines the center point of the arc.
  77571. */
  77572. centerPoint: Vector2;
  77573. /**
  77574. * Defines the radius of the arc.
  77575. */
  77576. radius: number;
  77577. /**
  77578. * Defines the angle of the arc (from mid point to end point).
  77579. */
  77580. angle: Angle;
  77581. /**
  77582. * Defines the start angle of the arc (from start point to middle point).
  77583. */
  77584. startAngle: Angle;
  77585. /**
  77586. * Defines the orientation of the arc (clock wise/counter clock wise).
  77587. */
  77588. orientation: Orientation;
  77589. /**
  77590. * Creates an Arc object from the three given points : start, middle and end.
  77591. * @param startPoint Defines the start point of the arc
  77592. * @param midPoint Defines the midlle point of the arc
  77593. * @param endPoint Defines the end point of the arc
  77594. */
  77595. constructor(
  77596. /** Defines the start point of the arc */
  77597. startPoint: Vector2,
  77598. /** Defines the mid point of the arc */
  77599. midPoint: Vector2,
  77600. /** Defines the end point of the arc */
  77601. endPoint: Vector2);
  77602. }
  77603. /**
  77604. * Represents a 2D path made up of multiple 2D points
  77605. */
  77606. export class Path2 {
  77607. private _points;
  77608. private _length;
  77609. /**
  77610. * If the path start and end point are the same
  77611. */
  77612. closed: boolean;
  77613. /**
  77614. * Creates a Path2 object from the starting 2D coordinates x and y.
  77615. * @param x the starting points x value
  77616. * @param y the starting points y value
  77617. */
  77618. constructor(x: number, y: number);
  77619. /**
  77620. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  77621. * @param x the added points x value
  77622. * @param y the added points y value
  77623. * @returns the updated Path2.
  77624. */
  77625. addLineTo(x: number, y: number): Path2;
  77626. /**
  77627. * 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.
  77628. * @param midX middle point x value
  77629. * @param midY middle point y value
  77630. * @param endX end point x value
  77631. * @param endY end point y value
  77632. * @param numberOfSegments (default: 36)
  77633. * @returns the updated Path2.
  77634. */
  77635. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  77636. /**
  77637. * Closes the Path2.
  77638. * @returns the Path2.
  77639. */
  77640. close(): Path2;
  77641. /**
  77642. * Gets the sum of the distance between each sequential point in the path
  77643. * @returns the Path2 total length (float).
  77644. */
  77645. length(): number;
  77646. /**
  77647. * Gets the points which construct the path
  77648. * @returns the Path2 internal array of points.
  77649. */
  77650. getPoints(): Vector2[];
  77651. /**
  77652. * Retreives the point at the distance aways from the starting point
  77653. * @param normalizedLengthPosition the length along the path to retreive the point from
  77654. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  77655. */
  77656. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  77657. /**
  77658. * Creates a new path starting from an x and y position
  77659. * @param x starting x value
  77660. * @param y starting y value
  77661. * @returns a new Path2 starting at the coordinates (x, y).
  77662. */
  77663. static StartingAt(x: number, y: number): Path2;
  77664. }
  77665. /**
  77666. * Represents a 3D path made up of multiple 3D points
  77667. */
  77668. export class Path3D {
  77669. /**
  77670. * an array of Vector3, the curve axis of the Path3D
  77671. */
  77672. path: Vector3[];
  77673. private _curve;
  77674. private _distances;
  77675. private _tangents;
  77676. private _normals;
  77677. private _binormals;
  77678. private _raw;
  77679. private _alignTangentsWithPath;
  77680. private readonly _pointAtData;
  77681. /**
  77682. * new Path3D(path, normal, raw)
  77683. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  77684. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  77685. * @param path an array of Vector3, the curve axis of the Path3D
  77686. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  77687. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  77688. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  77689. */
  77690. constructor(
  77691. /**
  77692. * an array of Vector3, the curve axis of the Path3D
  77693. */
  77694. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  77695. /**
  77696. * Returns the Path3D array of successive Vector3 designing its curve.
  77697. * @returns the Path3D array of successive Vector3 designing its curve.
  77698. */
  77699. getCurve(): Vector3[];
  77700. /**
  77701. * Returns the Path3D array of successive Vector3 designing its curve.
  77702. * @returns the Path3D array of successive Vector3 designing its curve.
  77703. */
  77704. getPoints(): Vector3[];
  77705. /**
  77706. * @returns the computed length (float) of the path.
  77707. */
  77708. length(): number;
  77709. /**
  77710. * Returns an array populated with tangent vectors on each Path3D curve point.
  77711. * @returns an array populated with tangent vectors on each Path3D curve point.
  77712. */
  77713. getTangents(): Vector3[];
  77714. /**
  77715. * Returns an array populated with normal vectors on each Path3D curve point.
  77716. * @returns an array populated with normal vectors on each Path3D curve point.
  77717. */
  77718. getNormals(): Vector3[];
  77719. /**
  77720. * Returns an array populated with binormal vectors on each Path3D curve point.
  77721. * @returns an array populated with binormal vectors on each Path3D curve point.
  77722. */
  77723. getBinormals(): Vector3[];
  77724. /**
  77725. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  77726. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  77727. */
  77728. getDistances(): number[];
  77729. /**
  77730. * Returns an interpolated point along this path
  77731. * @param position the position of the point along this path, from 0.0 to 1.0
  77732. * @returns a new Vector3 as the point
  77733. */
  77734. getPointAt(position: number): Vector3;
  77735. /**
  77736. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  77737. * @param position the position of the point along this path, from 0.0 to 1.0
  77738. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  77739. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  77740. */
  77741. getTangentAt(position: number, interpolated?: boolean): Vector3;
  77742. /**
  77743. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  77744. * @param position the position of the point along this path, from 0.0 to 1.0
  77745. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  77746. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  77747. */
  77748. getNormalAt(position: number, interpolated?: boolean): Vector3;
  77749. /**
  77750. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  77751. * @param position the position of the point along this path, from 0.0 to 1.0
  77752. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  77753. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  77754. */
  77755. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  77756. /**
  77757. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  77758. * @param position the position of the point along this path, from 0.0 to 1.0
  77759. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  77760. */
  77761. getDistanceAt(position: number): number;
  77762. /**
  77763. * Returns the array index of the previous point of an interpolated point along this path
  77764. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  77765. * @returns the array index
  77766. */
  77767. getPreviousPointIndexAt(position: number): number;
  77768. /**
  77769. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  77770. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  77771. * @returns the sub position
  77772. */
  77773. getSubPositionAt(position: number): number;
  77774. /**
  77775. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  77776. * @param target the vector of which to get the closest position to
  77777. * @returns the position of the closest virtual point on this path to the target vector
  77778. */
  77779. getClosestPositionTo(target: Vector3): number;
  77780. /**
  77781. * Returns a sub path (slice) of this path
  77782. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  77783. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  77784. * @returns a sub path (slice) of this path
  77785. */
  77786. slice(start?: number, end?: number): Path3D;
  77787. /**
  77788. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  77789. * @param path path which all values are copied into the curves points
  77790. * @param firstNormal which should be projected onto the curve
  77791. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  77792. * @returns the same object updated.
  77793. */
  77794. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  77795. private _compute;
  77796. private _getFirstNonNullVector;
  77797. private _getLastNonNullVector;
  77798. private _normalVector;
  77799. /**
  77800. * Updates the point at data for an interpolated point along this curve
  77801. * @param position the position of the point along this curve, from 0.0 to 1.0
  77802. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  77803. * @returns the (updated) point at data
  77804. */
  77805. private _updatePointAtData;
  77806. /**
  77807. * Updates the point at data from the specified parameters
  77808. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  77809. * @param point the interpolated point
  77810. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  77811. */
  77812. private _setPointAtData;
  77813. /**
  77814. * Updates the point at interpolation matrix for the tangents, normals and binormals
  77815. */
  77816. private _updateInterpolationMatrix;
  77817. }
  77818. /**
  77819. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  77820. * A Curve3 is designed from a series of successive Vector3.
  77821. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  77822. */
  77823. export class Curve3 {
  77824. private _points;
  77825. private _length;
  77826. /**
  77827. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  77828. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  77829. * @param v1 (Vector3) the control point
  77830. * @param v2 (Vector3) the end point of the Quadratic Bezier
  77831. * @param nbPoints (integer) the wanted number of points in the curve
  77832. * @returns the created Curve3
  77833. */
  77834. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  77835. /**
  77836. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  77837. * @param v0 (Vector3) the origin point of the Cubic Bezier
  77838. * @param v1 (Vector3) the first control point
  77839. * @param v2 (Vector3) the second control point
  77840. * @param v3 (Vector3) the end point of the Cubic Bezier
  77841. * @param nbPoints (integer) the wanted number of points in the curve
  77842. * @returns the created Curve3
  77843. */
  77844. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  77845. /**
  77846. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  77847. * @param p1 (Vector3) the origin point of the Hermite Spline
  77848. * @param t1 (Vector3) the tangent vector at the origin point
  77849. * @param p2 (Vector3) the end point of the Hermite Spline
  77850. * @param t2 (Vector3) the tangent vector at the end point
  77851. * @param nbPoints (integer) the wanted number of points in the curve
  77852. * @returns the created Curve3
  77853. */
  77854. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  77855. /**
  77856. * Returns a Curve3 object along a CatmullRom Spline curve :
  77857. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  77858. * @param nbPoints (integer) the wanted number of points between each curve control points
  77859. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  77860. * @returns the created Curve3
  77861. */
  77862. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  77863. /**
  77864. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  77865. * A Curve3 is designed from a series of successive Vector3.
  77866. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  77867. * @param points points which make up the curve
  77868. */
  77869. constructor(points: Vector3[]);
  77870. /**
  77871. * @returns the Curve3 stored array of successive Vector3
  77872. */
  77873. getPoints(): Vector3[];
  77874. /**
  77875. * @returns the computed length (float) of the curve.
  77876. */
  77877. length(): number;
  77878. /**
  77879. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  77880. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  77881. * curveA and curveB keep unchanged.
  77882. * @param curve the curve to continue from this curve
  77883. * @returns the newly constructed curve
  77884. */
  77885. continue(curve: DeepImmutable<Curve3>): Curve3;
  77886. private _computeLength;
  77887. }
  77888. }
  77889. declare module BABYLON {
  77890. /**
  77891. * This represents the main contract an easing function should follow.
  77892. * Easing functions are used throughout the animation system.
  77893. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77894. */
  77895. export interface IEasingFunction {
  77896. /**
  77897. * Given an input gradient between 0 and 1, this returns the corrseponding value
  77898. * of the easing function.
  77899. * The link below provides some of the most common examples of easing functions.
  77900. * @see https://easings.net/
  77901. * @param gradient Defines the value between 0 and 1 we want the easing value for
  77902. * @returns the corresponding value on the curve defined by the easing function
  77903. */
  77904. ease(gradient: number): number;
  77905. }
  77906. /**
  77907. * Base class used for every default easing function.
  77908. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77909. */
  77910. export class EasingFunction implements IEasingFunction {
  77911. /**
  77912. * Interpolation follows the mathematical formula associated with the easing function.
  77913. */
  77914. static readonly EASINGMODE_EASEIN: number;
  77915. /**
  77916. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  77917. */
  77918. static readonly EASINGMODE_EASEOUT: number;
  77919. /**
  77920. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  77921. */
  77922. static readonly EASINGMODE_EASEINOUT: number;
  77923. private _easingMode;
  77924. /**
  77925. * Sets the easing mode of the current function.
  77926. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  77927. */
  77928. setEasingMode(easingMode: number): void;
  77929. /**
  77930. * Gets the current easing mode.
  77931. * @returns the easing mode
  77932. */
  77933. getEasingMode(): number;
  77934. /**
  77935. * @hidden
  77936. */
  77937. easeInCore(gradient: number): number;
  77938. /**
  77939. * Given an input gradient between 0 and 1, this returns the corresponding value
  77940. * of the easing function.
  77941. * @param gradient Defines the value between 0 and 1 we want the easing value for
  77942. * @returns the corresponding value on the curve defined by the easing function
  77943. */
  77944. ease(gradient: number): number;
  77945. }
  77946. /**
  77947. * Easing function with a circle shape (see link below).
  77948. * @see https://easings.net/#easeInCirc
  77949. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77950. */
  77951. export class CircleEase extends EasingFunction implements IEasingFunction {
  77952. /** @hidden */
  77953. easeInCore(gradient: number): number;
  77954. }
  77955. /**
  77956. * Easing function with a ease back shape (see link below).
  77957. * @see https://easings.net/#easeInBack
  77958. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77959. */
  77960. export class BackEase extends EasingFunction implements IEasingFunction {
  77961. /** Defines the amplitude of the function */
  77962. amplitude: number;
  77963. /**
  77964. * Instantiates a back ease easing
  77965. * @see https://easings.net/#easeInBack
  77966. * @param amplitude Defines the amplitude of the function
  77967. */
  77968. constructor(
  77969. /** Defines the amplitude of the function */
  77970. amplitude?: number);
  77971. /** @hidden */
  77972. easeInCore(gradient: number): number;
  77973. }
  77974. /**
  77975. * Easing function with a bouncing shape (see link below).
  77976. * @see https://easings.net/#easeInBounce
  77977. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  77978. */
  77979. export class BounceEase extends EasingFunction implements IEasingFunction {
  77980. /** Defines the number of bounces */
  77981. bounces: number;
  77982. /** Defines the amplitude of the bounce */
  77983. bounciness: number;
  77984. /**
  77985. * Instantiates a bounce easing
  77986. * @see https://easings.net/#easeInBounce
  77987. * @param bounces Defines the number of bounces
  77988. * @param bounciness Defines the amplitude of the bounce
  77989. */
  77990. constructor(
  77991. /** Defines the number of bounces */
  77992. bounces?: number,
  77993. /** Defines the amplitude of the bounce */
  77994. bounciness?: number);
  77995. /** @hidden */
  77996. easeInCore(gradient: number): number;
  77997. }
  77998. /**
  77999. * Easing function with a power of 3 shape (see link below).
  78000. * @see https://easings.net/#easeInCubic
  78001. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78002. */
  78003. export class CubicEase extends EasingFunction implements IEasingFunction {
  78004. /** @hidden */
  78005. easeInCore(gradient: number): number;
  78006. }
  78007. /**
  78008. * Easing function with an elastic shape (see link below).
  78009. * @see https://easings.net/#easeInElastic
  78010. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78011. */
  78012. export class ElasticEase extends EasingFunction implements IEasingFunction {
  78013. /** Defines the number of oscillations*/
  78014. oscillations: number;
  78015. /** Defines the amplitude of the oscillations*/
  78016. springiness: number;
  78017. /**
  78018. * Instantiates an elastic easing function
  78019. * @see https://easings.net/#easeInElastic
  78020. * @param oscillations Defines the number of oscillations
  78021. * @param springiness Defines the amplitude of the oscillations
  78022. */
  78023. constructor(
  78024. /** Defines the number of oscillations*/
  78025. oscillations?: number,
  78026. /** Defines the amplitude of the oscillations*/
  78027. springiness?: number);
  78028. /** @hidden */
  78029. easeInCore(gradient: number): number;
  78030. }
  78031. /**
  78032. * Easing function with an exponential shape (see link below).
  78033. * @see https://easings.net/#easeInExpo
  78034. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78035. */
  78036. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  78037. /** Defines the exponent of the function */
  78038. exponent: number;
  78039. /**
  78040. * Instantiates an exponential easing function
  78041. * @see https://easings.net/#easeInExpo
  78042. * @param exponent Defines the exponent of the function
  78043. */
  78044. constructor(
  78045. /** Defines the exponent of the function */
  78046. exponent?: number);
  78047. /** @hidden */
  78048. easeInCore(gradient: number): number;
  78049. }
  78050. /**
  78051. * Easing function with a power shape (see link below).
  78052. * @see https://easings.net/#easeInQuad
  78053. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78054. */
  78055. export class PowerEase extends EasingFunction implements IEasingFunction {
  78056. /** Defines the power of the function */
  78057. power: number;
  78058. /**
  78059. * Instantiates an power base easing function
  78060. * @see https://easings.net/#easeInQuad
  78061. * @param power Defines the power of the function
  78062. */
  78063. constructor(
  78064. /** Defines the power of the function */
  78065. power?: number);
  78066. /** @hidden */
  78067. easeInCore(gradient: number): number;
  78068. }
  78069. /**
  78070. * Easing function with a power of 2 shape (see link below).
  78071. * @see https://easings.net/#easeInQuad
  78072. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78073. */
  78074. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  78075. /** @hidden */
  78076. easeInCore(gradient: number): number;
  78077. }
  78078. /**
  78079. * Easing function with a power of 4 shape (see link below).
  78080. * @see https://easings.net/#easeInQuart
  78081. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78082. */
  78083. export class QuarticEase extends EasingFunction implements IEasingFunction {
  78084. /** @hidden */
  78085. easeInCore(gradient: number): number;
  78086. }
  78087. /**
  78088. * Easing function with a power of 5 shape (see link below).
  78089. * @see https://easings.net/#easeInQuint
  78090. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78091. */
  78092. export class QuinticEase extends EasingFunction implements IEasingFunction {
  78093. /** @hidden */
  78094. easeInCore(gradient: number): number;
  78095. }
  78096. /**
  78097. * Easing function with a sin shape (see link below).
  78098. * @see https://easings.net/#easeInSine
  78099. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78100. */
  78101. export class SineEase extends EasingFunction implements IEasingFunction {
  78102. /** @hidden */
  78103. easeInCore(gradient: number): number;
  78104. }
  78105. /**
  78106. * Easing function with a bezier shape (see link below).
  78107. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78108. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78109. */
  78110. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  78111. /** Defines the x component of the start tangent in the bezier curve */
  78112. x1: number;
  78113. /** Defines the y component of the start tangent in the bezier curve */
  78114. y1: number;
  78115. /** Defines the x component of the end tangent in the bezier curve */
  78116. x2: number;
  78117. /** Defines the y component of the end tangent in the bezier curve */
  78118. y2: number;
  78119. /**
  78120. * Instantiates a bezier function
  78121. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78122. * @param x1 Defines the x component of the start tangent in the bezier curve
  78123. * @param y1 Defines the y component of the start tangent in the bezier curve
  78124. * @param x2 Defines the x component of the end tangent in the bezier curve
  78125. * @param y2 Defines the y component of the end tangent in the bezier curve
  78126. */
  78127. constructor(
  78128. /** Defines the x component of the start tangent in the bezier curve */
  78129. x1?: number,
  78130. /** Defines the y component of the start tangent in the bezier curve */
  78131. y1?: number,
  78132. /** Defines the x component of the end tangent in the bezier curve */
  78133. x2?: number,
  78134. /** Defines the y component of the end tangent in the bezier curve */
  78135. y2?: number);
  78136. /** @hidden */
  78137. easeInCore(gradient: number): number;
  78138. }
  78139. }
  78140. declare module BABYLON {
  78141. /**
  78142. * Class used to hold a RBG color
  78143. */
  78144. export class Color3 {
  78145. /**
  78146. * Defines the red component (between 0 and 1, default is 0)
  78147. */
  78148. r: number;
  78149. /**
  78150. * Defines the green component (between 0 and 1, default is 0)
  78151. */
  78152. g: number;
  78153. /**
  78154. * Defines the blue component (between 0 and 1, default is 0)
  78155. */
  78156. b: number;
  78157. /**
  78158. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  78159. * @param r defines the red component (between 0 and 1, default is 0)
  78160. * @param g defines the green component (between 0 and 1, default is 0)
  78161. * @param b defines the blue component (between 0 and 1, default is 0)
  78162. */
  78163. constructor(
  78164. /**
  78165. * Defines the red component (between 0 and 1, default is 0)
  78166. */
  78167. r?: number,
  78168. /**
  78169. * Defines the green component (between 0 and 1, default is 0)
  78170. */
  78171. g?: number,
  78172. /**
  78173. * Defines the blue component (between 0 and 1, default is 0)
  78174. */
  78175. b?: number);
  78176. /**
  78177. * Creates a string with the Color3 current values
  78178. * @returns the string representation of the Color3 object
  78179. */
  78180. toString(): string;
  78181. /**
  78182. * Returns the string "Color3"
  78183. * @returns "Color3"
  78184. */
  78185. getClassName(): string;
  78186. /**
  78187. * Compute the Color3 hash code
  78188. * @returns an unique number that can be used to hash Color3 objects
  78189. */
  78190. getHashCode(): number;
  78191. /**
  78192. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  78193. * @param array defines the array where to store the r,g,b components
  78194. * @param index defines an optional index in the target array to define where to start storing values
  78195. * @returns the current Color3 object
  78196. */
  78197. toArray(array: FloatArray, index?: number): Color3;
  78198. /**
  78199. * Returns a new Color4 object from the current Color3 and the given alpha
  78200. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  78201. * @returns a new Color4 object
  78202. */
  78203. toColor4(alpha?: number): Color4;
  78204. /**
  78205. * Returns a new array populated with 3 numeric elements : red, green and blue values
  78206. * @returns the new array
  78207. */
  78208. asArray(): number[];
  78209. /**
  78210. * Returns the luminance value
  78211. * @returns a float value
  78212. */
  78213. toLuminance(): number;
  78214. /**
  78215. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  78216. * @param otherColor defines the second operand
  78217. * @returns the new Color3 object
  78218. */
  78219. multiply(otherColor: DeepImmutable<Color3>): Color3;
  78220. /**
  78221. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  78222. * @param otherColor defines the second operand
  78223. * @param result defines the Color3 object where to store the result
  78224. * @returns the current Color3
  78225. */
  78226. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78227. /**
  78228. * Determines equality between Color3 objects
  78229. * @param otherColor defines the second operand
  78230. * @returns true if the rgb values are equal to the given ones
  78231. */
  78232. equals(otherColor: DeepImmutable<Color3>): boolean;
  78233. /**
  78234. * Determines equality between the current Color3 object and a set of r,b,g values
  78235. * @param r defines the red component to check
  78236. * @param g defines the green component to check
  78237. * @param b defines the blue component to check
  78238. * @returns true if the rgb values are equal to the given ones
  78239. */
  78240. equalsFloats(r: number, g: number, b: number): boolean;
  78241. /**
  78242. * Multiplies in place each rgb value by scale
  78243. * @param scale defines the scaling factor
  78244. * @returns the updated Color3
  78245. */
  78246. scale(scale: number): Color3;
  78247. /**
  78248. * Multiplies the rgb values by scale and stores the result into "result"
  78249. * @param scale defines the scaling factor
  78250. * @param result defines the Color3 object where to store the result
  78251. * @returns the unmodified current Color3
  78252. */
  78253. scaleToRef(scale: number, result: Color3): Color3;
  78254. /**
  78255. * Scale the current Color3 values by a factor and add the result to a given Color3
  78256. * @param scale defines the scale factor
  78257. * @param result defines color to store the result into
  78258. * @returns the unmodified current Color3
  78259. */
  78260. scaleAndAddToRef(scale: number, result: Color3): Color3;
  78261. /**
  78262. * Clamps the rgb values by the min and max values and stores the result into "result"
  78263. * @param min defines minimum clamping value (default is 0)
  78264. * @param max defines maximum clamping value (default is 1)
  78265. * @param result defines color to store the result into
  78266. * @returns the original Color3
  78267. */
  78268. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  78269. /**
  78270. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  78271. * @param otherColor defines the second operand
  78272. * @returns the new Color3
  78273. */
  78274. add(otherColor: DeepImmutable<Color3>): Color3;
  78275. /**
  78276. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  78277. * @param otherColor defines the second operand
  78278. * @param result defines Color3 object to store the result into
  78279. * @returns the unmodified current Color3
  78280. */
  78281. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78282. /**
  78283. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  78284. * @param otherColor defines the second operand
  78285. * @returns the new Color3
  78286. */
  78287. subtract(otherColor: DeepImmutable<Color3>): Color3;
  78288. /**
  78289. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  78290. * @param otherColor defines the second operand
  78291. * @param result defines Color3 object to store the result into
  78292. * @returns the unmodified current Color3
  78293. */
  78294. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78295. /**
  78296. * Copy the current object
  78297. * @returns a new Color3 copied the current one
  78298. */
  78299. clone(): Color3;
  78300. /**
  78301. * Copies the rgb values from the source in the current Color3
  78302. * @param source defines the source Color3 object
  78303. * @returns the updated Color3 object
  78304. */
  78305. copyFrom(source: DeepImmutable<Color3>): Color3;
  78306. /**
  78307. * Updates the Color3 rgb values from the given floats
  78308. * @param r defines the red component to read from
  78309. * @param g defines the green component to read from
  78310. * @param b defines the blue component to read from
  78311. * @returns the current Color3 object
  78312. */
  78313. copyFromFloats(r: number, g: number, b: number): Color3;
  78314. /**
  78315. * Updates the Color3 rgb values from the given floats
  78316. * @param r defines the red component to read from
  78317. * @param g defines the green component to read from
  78318. * @param b defines the blue component to read from
  78319. * @returns the current Color3 object
  78320. */
  78321. set(r: number, g: number, b: number): Color3;
  78322. /**
  78323. * Compute the Color3 hexadecimal code as a string
  78324. * @returns a string containing the hexadecimal representation of the Color3 object
  78325. */
  78326. toHexString(): string;
  78327. /**
  78328. * Computes a new Color3 converted from the current one to linear space
  78329. * @returns a new Color3 object
  78330. */
  78331. toLinearSpace(): Color3;
  78332. /**
  78333. * Converts current color in rgb space to HSV values
  78334. * @returns a new color3 representing the HSV values
  78335. */
  78336. toHSV(): Color3;
  78337. /**
  78338. * Converts current color in rgb space to HSV values
  78339. * @param result defines the Color3 where to store the HSV values
  78340. */
  78341. toHSVToRef(result: Color3): void;
  78342. /**
  78343. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  78344. * @param convertedColor defines the Color3 object where to store the linear space version
  78345. * @returns the unmodified Color3
  78346. */
  78347. toLinearSpaceToRef(convertedColor: Color3): Color3;
  78348. /**
  78349. * Computes a new Color3 converted from the current one to gamma space
  78350. * @returns a new Color3 object
  78351. */
  78352. toGammaSpace(): Color3;
  78353. /**
  78354. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  78355. * @param convertedColor defines the Color3 object where to store the gamma space version
  78356. * @returns the unmodified Color3
  78357. */
  78358. toGammaSpaceToRef(convertedColor: Color3): Color3;
  78359. private static _BlackReadOnly;
  78360. /**
  78361. * Convert Hue, saturation and value to a Color3 (RGB)
  78362. * @param hue defines the hue
  78363. * @param saturation defines the saturation
  78364. * @param value defines the value
  78365. * @param result defines the Color3 where to store the RGB values
  78366. */
  78367. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  78368. /**
  78369. * Creates a new Color3 from the string containing valid hexadecimal values
  78370. * @param hex defines a string containing valid hexadecimal values
  78371. * @returns a new Color3 object
  78372. */
  78373. static FromHexString(hex: string): Color3;
  78374. /**
  78375. * Creates a new Color3 from the starting index of the given array
  78376. * @param array defines the source array
  78377. * @param offset defines an offset in the source array
  78378. * @returns a new Color3 object
  78379. */
  78380. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  78381. /**
  78382. * Creates a new Color3 from integer values (< 256)
  78383. * @param r defines the red component to read from (value between 0 and 255)
  78384. * @param g defines the green component to read from (value between 0 and 255)
  78385. * @param b defines the blue component to read from (value between 0 and 255)
  78386. * @returns a new Color3 object
  78387. */
  78388. static FromInts(r: number, g: number, b: number): Color3;
  78389. /**
  78390. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78391. * @param start defines the start Color3 value
  78392. * @param end defines the end Color3 value
  78393. * @param amount defines the gradient value between start and end
  78394. * @returns a new Color3 object
  78395. */
  78396. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  78397. /**
  78398. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78399. * @param left defines the start value
  78400. * @param right defines the end value
  78401. * @param amount defines the gradient factor
  78402. * @param result defines the Color3 object where to store the result
  78403. */
  78404. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  78405. /**
  78406. * Returns a Color3 value containing a red color
  78407. * @returns a new Color3 object
  78408. */
  78409. static Red(): Color3;
  78410. /**
  78411. * Returns a Color3 value containing a green color
  78412. * @returns a new Color3 object
  78413. */
  78414. static Green(): Color3;
  78415. /**
  78416. * Returns a Color3 value containing a blue color
  78417. * @returns a new Color3 object
  78418. */
  78419. static Blue(): Color3;
  78420. /**
  78421. * Returns a Color3 value containing a black color
  78422. * @returns a new Color3 object
  78423. */
  78424. static Black(): Color3;
  78425. /**
  78426. * Gets a Color3 value containing a black color that must not be updated
  78427. */
  78428. static get BlackReadOnly(): DeepImmutable<Color3>;
  78429. /**
  78430. * Returns a Color3 value containing a white color
  78431. * @returns a new Color3 object
  78432. */
  78433. static White(): Color3;
  78434. /**
  78435. * Returns a Color3 value containing a purple color
  78436. * @returns a new Color3 object
  78437. */
  78438. static Purple(): Color3;
  78439. /**
  78440. * Returns a Color3 value containing a magenta color
  78441. * @returns a new Color3 object
  78442. */
  78443. static Magenta(): Color3;
  78444. /**
  78445. * Returns a Color3 value containing a yellow color
  78446. * @returns a new Color3 object
  78447. */
  78448. static Yellow(): Color3;
  78449. /**
  78450. * Returns a Color3 value containing a gray color
  78451. * @returns a new Color3 object
  78452. */
  78453. static Gray(): Color3;
  78454. /**
  78455. * Returns a Color3 value containing a teal color
  78456. * @returns a new Color3 object
  78457. */
  78458. static Teal(): Color3;
  78459. /**
  78460. * Returns a Color3 value containing a random color
  78461. * @returns a new Color3 object
  78462. */
  78463. static Random(): Color3;
  78464. }
  78465. /**
  78466. * Class used to hold a RBGA color
  78467. */
  78468. export class Color4 {
  78469. /**
  78470. * Defines the red component (between 0 and 1, default is 0)
  78471. */
  78472. r: number;
  78473. /**
  78474. * Defines the green component (between 0 and 1, default is 0)
  78475. */
  78476. g: number;
  78477. /**
  78478. * Defines the blue component (between 0 and 1, default is 0)
  78479. */
  78480. b: number;
  78481. /**
  78482. * Defines the alpha component (between 0 and 1, default is 1)
  78483. */
  78484. a: number;
  78485. /**
  78486. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  78487. * @param r defines the red component (between 0 and 1, default is 0)
  78488. * @param g defines the green component (between 0 and 1, default is 0)
  78489. * @param b defines the blue component (between 0 and 1, default is 0)
  78490. * @param a defines the alpha component (between 0 and 1, default is 1)
  78491. */
  78492. constructor(
  78493. /**
  78494. * Defines the red component (between 0 and 1, default is 0)
  78495. */
  78496. r?: number,
  78497. /**
  78498. * Defines the green component (between 0 and 1, default is 0)
  78499. */
  78500. g?: number,
  78501. /**
  78502. * Defines the blue component (between 0 and 1, default is 0)
  78503. */
  78504. b?: number,
  78505. /**
  78506. * Defines the alpha component (between 0 and 1, default is 1)
  78507. */
  78508. a?: number);
  78509. /**
  78510. * Adds in place the given Color4 values to the current Color4 object
  78511. * @param right defines the second operand
  78512. * @returns the current updated Color4 object
  78513. */
  78514. addInPlace(right: DeepImmutable<Color4>): Color4;
  78515. /**
  78516. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  78517. * @returns the new array
  78518. */
  78519. asArray(): number[];
  78520. /**
  78521. * Stores from the starting index in the given array the Color4 successive values
  78522. * @param array defines the array where to store the r,g,b components
  78523. * @param index defines an optional index in the target array to define where to start storing values
  78524. * @returns the current Color4 object
  78525. */
  78526. toArray(array: number[], index?: number): Color4;
  78527. /**
  78528. * Determines equality between Color4 objects
  78529. * @param otherColor defines the second operand
  78530. * @returns true if the rgba values are equal to the given ones
  78531. */
  78532. equals(otherColor: DeepImmutable<Color4>): boolean;
  78533. /**
  78534. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  78535. * @param right defines the second operand
  78536. * @returns a new Color4 object
  78537. */
  78538. add(right: DeepImmutable<Color4>): Color4;
  78539. /**
  78540. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  78541. * @param right defines the second operand
  78542. * @returns a new Color4 object
  78543. */
  78544. subtract(right: DeepImmutable<Color4>): Color4;
  78545. /**
  78546. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  78547. * @param right defines the second operand
  78548. * @param result defines the Color4 object where to store the result
  78549. * @returns the current Color4 object
  78550. */
  78551. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  78552. /**
  78553. * Creates a new Color4 with the current Color4 values multiplied by scale
  78554. * @param scale defines the scaling factor to apply
  78555. * @returns a new Color4 object
  78556. */
  78557. scale(scale: number): Color4;
  78558. /**
  78559. * Multiplies the current Color4 values by scale and stores the result in "result"
  78560. * @param scale defines the scaling factor to apply
  78561. * @param result defines the Color4 object where to store the result
  78562. * @returns the current unmodified Color4
  78563. */
  78564. scaleToRef(scale: number, result: Color4): Color4;
  78565. /**
  78566. * Scale the current Color4 values by a factor and add the result to a given Color4
  78567. * @param scale defines the scale factor
  78568. * @param result defines the Color4 object where to store the result
  78569. * @returns the unmodified current Color4
  78570. */
  78571. scaleAndAddToRef(scale: number, result: Color4): Color4;
  78572. /**
  78573. * Clamps the rgb values by the min and max values and stores the result into "result"
  78574. * @param min defines minimum clamping value (default is 0)
  78575. * @param max defines maximum clamping value (default is 1)
  78576. * @param result defines color to store the result into.
  78577. * @returns the cuurent Color4
  78578. */
  78579. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  78580. /**
  78581. * Multipy an Color4 value by another and return a new Color4 object
  78582. * @param color defines the Color4 value to multiply by
  78583. * @returns a new Color4 object
  78584. */
  78585. multiply(color: Color4): Color4;
  78586. /**
  78587. * Multipy a Color4 value by another and push the result in a reference value
  78588. * @param color defines the Color4 value to multiply by
  78589. * @param result defines the Color4 to fill the result in
  78590. * @returns the result Color4
  78591. */
  78592. multiplyToRef(color: Color4, result: Color4): Color4;
  78593. /**
  78594. * Creates a string with the Color4 current values
  78595. * @returns the string representation of the Color4 object
  78596. */
  78597. toString(): string;
  78598. /**
  78599. * Returns the string "Color4"
  78600. * @returns "Color4"
  78601. */
  78602. getClassName(): string;
  78603. /**
  78604. * Compute the Color4 hash code
  78605. * @returns an unique number that can be used to hash Color4 objects
  78606. */
  78607. getHashCode(): number;
  78608. /**
  78609. * Creates a new Color4 copied from the current one
  78610. * @returns a new Color4 object
  78611. */
  78612. clone(): Color4;
  78613. /**
  78614. * Copies the given Color4 values into the current one
  78615. * @param source defines the source Color4 object
  78616. * @returns the current updated Color4 object
  78617. */
  78618. copyFrom(source: Color4): Color4;
  78619. /**
  78620. * Copies the given float values into the current one
  78621. * @param r defines the red component to read from
  78622. * @param g defines the green component to read from
  78623. * @param b defines the blue component to read from
  78624. * @param a defines the alpha component to read from
  78625. * @returns the current updated Color4 object
  78626. */
  78627. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  78628. /**
  78629. * Copies the given float values into the current one
  78630. * @param r defines the red component to read from
  78631. * @param g defines the green component to read from
  78632. * @param b defines the blue component to read from
  78633. * @param a defines the alpha component to read from
  78634. * @returns the current updated Color4 object
  78635. */
  78636. set(r: number, g: number, b: number, a: number): Color4;
  78637. /**
  78638. * Compute the Color4 hexadecimal code as a string
  78639. * @returns a string containing the hexadecimal representation of the Color4 object
  78640. */
  78641. toHexString(): string;
  78642. /**
  78643. * Computes a new Color4 converted from the current one to linear space
  78644. * @returns a new Color4 object
  78645. */
  78646. toLinearSpace(): Color4;
  78647. /**
  78648. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  78649. * @param convertedColor defines the Color4 object where to store the linear space version
  78650. * @returns the unmodified Color4
  78651. */
  78652. toLinearSpaceToRef(convertedColor: Color4): Color4;
  78653. /**
  78654. * Computes a new Color4 converted from the current one to gamma space
  78655. * @returns a new Color4 object
  78656. */
  78657. toGammaSpace(): Color4;
  78658. /**
  78659. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  78660. * @param convertedColor defines the Color4 object where to store the gamma space version
  78661. * @returns the unmodified Color4
  78662. */
  78663. toGammaSpaceToRef(convertedColor: Color4): Color4;
  78664. /**
  78665. * Creates a new Color4 from the string containing valid hexadecimal values
  78666. * @param hex defines a string containing valid hexadecimal values
  78667. * @returns a new Color4 object
  78668. */
  78669. static FromHexString(hex: string): Color4;
  78670. /**
  78671. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  78672. * @param left defines the start value
  78673. * @param right defines the end value
  78674. * @param amount defines the gradient factor
  78675. * @returns a new Color4 object
  78676. */
  78677. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  78678. /**
  78679. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  78680. * @param left defines the start value
  78681. * @param right defines the end value
  78682. * @param amount defines the gradient factor
  78683. * @param result defines the Color4 object where to store data
  78684. */
  78685. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  78686. /**
  78687. * Creates a new Color4 from a Color3 and an alpha value
  78688. * @param color3 defines the source Color3 to read from
  78689. * @param alpha defines the alpha component (1.0 by default)
  78690. * @returns a new Color4 object
  78691. */
  78692. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  78693. /**
  78694. * Creates a new Color4 from the starting index element of the given array
  78695. * @param array defines the source array to read from
  78696. * @param offset defines the offset in the source array
  78697. * @returns a new Color4 object
  78698. */
  78699. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  78700. /**
  78701. * Creates a new Color3 from integer values (< 256)
  78702. * @param r defines the red component to read from (value between 0 and 255)
  78703. * @param g defines the green component to read from (value between 0 and 255)
  78704. * @param b defines the blue component to read from (value between 0 and 255)
  78705. * @param a defines the alpha component to read from (value between 0 and 255)
  78706. * @returns a new Color3 object
  78707. */
  78708. static FromInts(r: number, g: number, b: number, a: number): Color4;
  78709. /**
  78710. * Check the content of a given array and convert it to an array containing RGBA data
  78711. * If the original array was already containing count * 4 values then it is returned directly
  78712. * @param colors defines the array to check
  78713. * @param count defines the number of RGBA data to expect
  78714. * @returns an array containing count * 4 values (RGBA)
  78715. */
  78716. static CheckColors4(colors: number[], count: number): number[];
  78717. }
  78718. /**
  78719. * @hidden
  78720. */
  78721. export class TmpColors {
  78722. static Color3: Color3[];
  78723. static Color4: Color4[];
  78724. }
  78725. }
  78726. declare module BABYLON {
  78727. /**
  78728. * Defines an interface which represents an animation key frame
  78729. */
  78730. export interface IAnimationKey {
  78731. /**
  78732. * Frame of the key frame
  78733. */
  78734. frame: number;
  78735. /**
  78736. * Value at the specifies key frame
  78737. */
  78738. value: any;
  78739. /**
  78740. * The input tangent for the cubic hermite spline
  78741. */
  78742. inTangent?: any;
  78743. /**
  78744. * The output tangent for the cubic hermite spline
  78745. */
  78746. outTangent?: any;
  78747. /**
  78748. * The animation interpolation type
  78749. */
  78750. interpolation?: AnimationKeyInterpolation;
  78751. }
  78752. /**
  78753. * Enum for the animation key frame interpolation type
  78754. */
  78755. export enum AnimationKeyInterpolation {
  78756. /**
  78757. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  78758. */
  78759. STEP = 1
  78760. }
  78761. }
  78762. declare module BABYLON {
  78763. /**
  78764. * Represents the range of an animation
  78765. */
  78766. export class AnimationRange {
  78767. /**The name of the animation range**/
  78768. name: string;
  78769. /**The starting frame of the animation */
  78770. from: number;
  78771. /**The ending frame of the animation*/
  78772. to: number;
  78773. /**
  78774. * Initializes the range of an animation
  78775. * @param name The name of the animation range
  78776. * @param from The starting frame of the animation
  78777. * @param to The ending frame of the animation
  78778. */
  78779. constructor(
  78780. /**The name of the animation range**/
  78781. name: string,
  78782. /**The starting frame of the animation */
  78783. from: number,
  78784. /**The ending frame of the animation*/
  78785. to: number);
  78786. /**
  78787. * Makes a copy of the animation range
  78788. * @returns A copy of the animation range
  78789. */
  78790. clone(): AnimationRange;
  78791. }
  78792. }
  78793. declare module BABYLON {
  78794. /**
  78795. * Composed of a frame, and an action function
  78796. */
  78797. export class AnimationEvent {
  78798. /** The frame for which the event is triggered **/
  78799. frame: number;
  78800. /** The event to perform when triggered **/
  78801. action: (currentFrame: number) => void;
  78802. /** Specifies if the event should be triggered only once**/
  78803. onlyOnce?: boolean | undefined;
  78804. /**
  78805. * Specifies if the animation event is done
  78806. */
  78807. isDone: boolean;
  78808. /**
  78809. * Initializes the animation event
  78810. * @param frame The frame for which the event is triggered
  78811. * @param action The event to perform when triggered
  78812. * @param onlyOnce Specifies if the event should be triggered only once
  78813. */
  78814. constructor(
  78815. /** The frame for which the event is triggered **/
  78816. frame: number,
  78817. /** The event to perform when triggered **/
  78818. action: (currentFrame: number) => void,
  78819. /** Specifies if the event should be triggered only once**/
  78820. onlyOnce?: boolean | undefined);
  78821. /** @hidden */
  78822. _clone(): AnimationEvent;
  78823. }
  78824. }
  78825. declare module BABYLON {
  78826. /**
  78827. * Interface used to define a behavior
  78828. */
  78829. export interface Behavior<T> {
  78830. /** gets or sets behavior's name */
  78831. name: string;
  78832. /**
  78833. * Function called when the behavior needs to be initialized (after attaching it to a target)
  78834. */
  78835. init(): void;
  78836. /**
  78837. * Called when the behavior is attached to a target
  78838. * @param target defines the target where the behavior is attached to
  78839. */
  78840. attach(target: T): void;
  78841. /**
  78842. * Called when the behavior is detached from its target
  78843. */
  78844. detach(): void;
  78845. }
  78846. /**
  78847. * Interface implemented by classes supporting behaviors
  78848. */
  78849. export interface IBehaviorAware<T> {
  78850. /**
  78851. * Attach a behavior
  78852. * @param behavior defines the behavior to attach
  78853. * @returns the current host
  78854. */
  78855. addBehavior(behavior: Behavior<T>): T;
  78856. /**
  78857. * Remove a behavior from the current object
  78858. * @param behavior defines the behavior to detach
  78859. * @returns the current host
  78860. */
  78861. removeBehavior(behavior: Behavior<T>): T;
  78862. /**
  78863. * Gets a behavior using its name to search
  78864. * @param name defines the name to search
  78865. * @returns the behavior or null if not found
  78866. */
  78867. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  78868. }
  78869. }
  78870. declare module BABYLON {
  78871. /**
  78872. * Defines an array and its length.
  78873. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  78874. */
  78875. export interface ISmartArrayLike<T> {
  78876. /**
  78877. * The data of the array.
  78878. */
  78879. data: Array<T>;
  78880. /**
  78881. * The active length of the array.
  78882. */
  78883. length: number;
  78884. }
  78885. /**
  78886. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  78887. */
  78888. export class SmartArray<T> implements ISmartArrayLike<T> {
  78889. /**
  78890. * The full set of data from the array.
  78891. */
  78892. data: Array<T>;
  78893. /**
  78894. * The active length of the array.
  78895. */
  78896. length: number;
  78897. protected _id: number;
  78898. /**
  78899. * Instantiates a Smart Array.
  78900. * @param capacity defines the default capacity of the array.
  78901. */
  78902. constructor(capacity: number);
  78903. /**
  78904. * Pushes a value at the end of the active data.
  78905. * @param value defines the object to push in the array.
  78906. */
  78907. push(value: T): void;
  78908. /**
  78909. * Iterates over the active data and apply the lambda to them.
  78910. * @param func defines the action to apply on each value.
  78911. */
  78912. forEach(func: (content: T) => void): void;
  78913. /**
  78914. * Sorts the full sets of data.
  78915. * @param compareFn defines the comparison function to apply.
  78916. */
  78917. sort(compareFn: (a: T, b: T) => number): void;
  78918. /**
  78919. * Resets the active data to an empty array.
  78920. */
  78921. reset(): void;
  78922. /**
  78923. * Releases all the data from the array as well as the array.
  78924. */
  78925. dispose(): void;
  78926. /**
  78927. * Concats the active data with a given array.
  78928. * @param array defines the data to concatenate with.
  78929. */
  78930. concat(array: any): void;
  78931. /**
  78932. * Returns the position of a value in the active data.
  78933. * @param value defines the value to find the index for
  78934. * @returns the index if found in the active data otherwise -1
  78935. */
  78936. indexOf(value: T): number;
  78937. /**
  78938. * Returns whether an element is part of the active data.
  78939. * @param value defines the value to look for
  78940. * @returns true if found in the active data otherwise false
  78941. */
  78942. contains(value: T): boolean;
  78943. private static _GlobalId;
  78944. }
  78945. /**
  78946. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  78947. * The data in this array can only be present once
  78948. */
  78949. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  78950. private _duplicateId;
  78951. /**
  78952. * Pushes a value at the end of the active data.
  78953. * THIS DOES NOT PREVENT DUPPLICATE DATA
  78954. * @param value defines the object to push in the array.
  78955. */
  78956. push(value: T): void;
  78957. /**
  78958. * Pushes a value at the end of the active data.
  78959. * If the data is already present, it won t be added again
  78960. * @param value defines the object to push in the array.
  78961. * @returns true if added false if it was already present
  78962. */
  78963. pushNoDuplicate(value: T): boolean;
  78964. /**
  78965. * Resets the active data to an empty array.
  78966. */
  78967. reset(): void;
  78968. /**
  78969. * Concats the active data with a given array.
  78970. * This ensures no dupplicate will be present in the result.
  78971. * @param array defines the data to concatenate with.
  78972. */
  78973. concatWithNoDuplicate(array: any): void;
  78974. }
  78975. }
  78976. declare module BABYLON {
  78977. /**
  78978. * @ignore
  78979. * This is a list of all the different input types that are available in the application.
  78980. * Fo instance: ArcRotateCameraGamepadInput...
  78981. */
  78982. export var CameraInputTypes: {};
  78983. /**
  78984. * This is the contract to implement in order to create a new input class.
  78985. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  78986. */
  78987. export interface ICameraInput<TCamera extends Camera> {
  78988. /**
  78989. * Defines the camera the input is attached to.
  78990. */
  78991. camera: Nullable<TCamera>;
  78992. /**
  78993. * Gets the class name of the current intput.
  78994. * @returns the class name
  78995. */
  78996. getClassName(): string;
  78997. /**
  78998. * Get the friendly name associated with the input class.
  78999. * @returns the input friendly name
  79000. */
  79001. getSimpleName(): string;
  79002. /**
  79003. * Attach the input controls to a specific dom element to get the input from.
  79004. * @param element Defines the element the controls should be listened from
  79005. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79006. */
  79007. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79008. /**
  79009. * Detach the current controls from the specified dom element.
  79010. * @param element Defines the element to stop listening the inputs from
  79011. */
  79012. detachControl(element: Nullable<HTMLElement>): void;
  79013. /**
  79014. * Update the current camera state depending on the inputs that have been used this frame.
  79015. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79016. */
  79017. checkInputs?: () => void;
  79018. }
  79019. /**
  79020. * Represents a map of input types to input instance or input index to input instance.
  79021. */
  79022. export interface CameraInputsMap<TCamera extends Camera> {
  79023. /**
  79024. * Accessor to the input by input type.
  79025. */
  79026. [name: string]: ICameraInput<TCamera>;
  79027. /**
  79028. * Accessor to the input by input index.
  79029. */
  79030. [idx: number]: ICameraInput<TCamera>;
  79031. }
  79032. /**
  79033. * This represents the input manager used within a camera.
  79034. * It helps dealing with all the different kind of input attached to a camera.
  79035. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79036. */
  79037. export class CameraInputsManager<TCamera extends Camera> {
  79038. /**
  79039. * Defines the list of inputs attahed to the camera.
  79040. */
  79041. attached: CameraInputsMap<TCamera>;
  79042. /**
  79043. * Defines the dom element the camera is collecting inputs from.
  79044. * This is null if the controls have not been attached.
  79045. */
  79046. attachedElement: Nullable<HTMLElement>;
  79047. /**
  79048. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79049. */
  79050. noPreventDefault: boolean;
  79051. /**
  79052. * Defined the camera the input manager belongs to.
  79053. */
  79054. camera: TCamera;
  79055. /**
  79056. * Update the current camera state depending on the inputs that have been used this frame.
  79057. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79058. */
  79059. checkInputs: () => void;
  79060. /**
  79061. * Instantiate a new Camera Input Manager.
  79062. * @param camera Defines the camera the input manager blongs to
  79063. */
  79064. constructor(camera: TCamera);
  79065. /**
  79066. * Add an input method to a camera
  79067. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79068. * @param input camera input method
  79069. */
  79070. add(input: ICameraInput<TCamera>): void;
  79071. /**
  79072. * Remove a specific input method from a camera
  79073. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  79074. * @param inputToRemove camera input method
  79075. */
  79076. remove(inputToRemove: ICameraInput<TCamera>): void;
  79077. /**
  79078. * Remove a specific input type from a camera
  79079. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  79080. * @param inputType the type of the input to remove
  79081. */
  79082. removeByType(inputType: string): void;
  79083. private _addCheckInputs;
  79084. /**
  79085. * Attach the input controls to the currently attached dom element to listen the events from.
  79086. * @param input Defines the input to attach
  79087. */
  79088. attachInput(input: ICameraInput<TCamera>): void;
  79089. /**
  79090. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  79091. * @param element Defines the dom element to collect the events from
  79092. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79093. */
  79094. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  79095. /**
  79096. * Detach the current manager inputs controls from a specific dom element.
  79097. * @param element Defines the dom element to collect the events from
  79098. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  79099. */
  79100. detachElement(element: HTMLElement, disconnect?: boolean): void;
  79101. /**
  79102. * Rebuild the dynamic inputCheck function from the current list of
  79103. * defined inputs in the manager.
  79104. */
  79105. rebuildInputCheck(): void;
  79106. /**
  79107. * Remove all attached input methods from a camera
  79108. */
  79109. clear(): void;
  79110. /**
  79111. * Serialize the current input manager attached to a camera.
  79112. * This ensures than once parsed,
  79113. * the input associated to the camera will be identical to the current ones
  79114. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  79115. */
  79116. serialize(serializedCamera: any): void;
  79117. /**
  79118. * Parses an input manager serialized JSON to restore the previous list of inputs
  79119. * and states associated to a camera.
  79120. * @param parsedCamera Defines the JSON to parse
  79121. */
  79122. parse(parsedCamera: any): void;
  79123. }
  79124. }
  79125. declare module BABYLON {
  79126. /**
  79127. * Class used to store data that will be store in GPU memory
  79128. */
  79129. export class Buffer {
  79130. private _engine;
  79131. private _buffer;
  79132. /** @hidden */
  79133. _data: Nullable<DataArray>;
  79134. private _updatable;
  79135. private _instanced;
  79136. private _divisor;
  79137. /**
  79138. * Gets the byte stride.
  79139. */
  79140. readonly byteStride: number;
  79141. /**
  79142. * Constructor
  79143. * @param engine the engine
  79144. * @param data the data to use for this buffer
  79145. * @param updatable whether the data is updatable
  79146. * @param stride the stride (optional)
  79147. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79148. * @param instanced whether the buffer is instanced (optional)
  79149. * @param useBytes set to true if the stride in in bytes (optional)
  79150. * @param divisor sets an optional divisor for instances (1 by default)
  79151. */
  79152. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  79153. /**
  79154. * Create a new VertexBuffer based on the current buffer
  79155. * @param kind defines the vertex buffer kind (position, normal, etc.)
  79156. * @param offset defines offset in the buffer (0 by default)
  79157. * @param size defines the size in floats of attributes (position is 3 for instance)
  79158. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  79159. * @param instanced defines if the vertex buffer contains indexed data
  79160. * @param useBytes defines if the offset and stride are in bytes *
  79161. * @param divisor sets an optional divisor for instances (1 by default)
  79162. * @returns the new vertex buffer
  79163. */
  79164. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  79165. /**
  79166. * Gets a boolean indicating if the Buffer is updatable?
  79167. * @returns true if the buffer is updatable
  79168. */
  79169. isUpdatable(): boolean;
  79170. /**
  79171. * Gets current buffer's data
  79172. * @returns a DataArray or null
  79173. */
  79174. getData(): Nullable<DataArray>;
  79175. /**
  79176. * Gets underlying native buffer
  79177. * @returns underlying native buffer
  79178. */
  79179. getBuffer(): Nullable<DataBuffer>;
  79180. /**
  79181. * Gets the stride in float32 units (i.e. byte stride / 4).
  79182. * May not be an integer if the byte stride is not divisible by 4.
  79183. * @returns the stride in float32 units
  79184. * @deprecated Please use byteStride instead.
  79185. */
  79186. getStrideSize(): number;
  79187. /**
  79188. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79189. * @param data defines the data to store
  79190. */
  79191. create(data?: Nullable<DataArray>): void;
  79192. /** @hidden */
  79193. _rebuild(): void;
  79194. /**
  79195. * Update current buffer data
  79196. * @param data defines the data to store
  79197. */
  79198. update(data: DataArray): void;
  79199. /**
  79200. * Updates the data directly.
  79201. * @param data the new data
  79202. * @param offset the new offset
  79203. * @param vertexCount the vertex count (optional)
  79204. * @param useBytes set to true if the offset is in bytes
  79205. */
  79206. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  79207. /**
  79208. * Release all resources
  79209. */
  79210. dispose(): void;
  79211. }
  79212. /**
  79213. * Specialized buffer used to store vertex data
  79214. */
  79215. export class VertexBuffer {
  79216. /** @hidden */
  79217. _buffer: Buffer;
  79218. private _kind;
  79219. private _size;
  79220. private _ownsBuffer;
  79221. private _instanced;
  79222. private _instanceDivisor;
  79223. /**
  79224. * The byte type.
  79225. */
  79226. static readonly BYTE: number;
  79227. /**
  79228. * The unsigned byte type.
  79229. */
  79230. static readonly UNSIGNED_BYTE: number;
  79231. /**
  79232. * The short type.
  79233. */
  79234. static readonly SHORT: number;
  79235. /**
  79236. * The unsigned short type.
  79237. */
  79238. static readonly UNSIGNED_SHORT: number;
  79239. /**
  79240. * The integer type.
  79241. */
  79242. static readonly INT: number;
  79243. /**
  79244. * The unsigned integer type.
  79245. */
  79246. static readonly UNSIGNED_INT: number;
  79247. /**
  79248. * The float type.
  79249. */
  79250. static readonly FLOAT: number;
  79251. /**
  79252. * Gets or sets the instance divisor when in instanced mode
  79253. */
  79254. get instanceDivisor(): number;
  79255. set instanceDivisor(value: number);
  79256. /**
  79257. * Gets the byte stride.
  79258. */
  79259. readonly byteStride: number;
  79260. /**
  79261. * Gets the byte offset.
  79262. */
  79263. readonly byteOffset: number;
  79264. /**
  79265. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  79266. */
  79267. readonly normalized: boolean;
  79268. /**
  79269. * Gets the data type of each component in the array.
  79270. */
  79271. readonly type: number;
  79272. /**
  79273. * Constructor
  79274. * @param engine the engine
  79275. * @param data the data to use for this vertex buffer
  79276. * @param kind the vertex buffer kind
  79277. * @param updatable whether the data is updatable
  79278. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79279. * @param stride the stride (optional)
  79280. * @param instanced whether the buffer is instanced (optional)
  79281. * @param offset the offset of the data (optional)
  79282. * @param size the number of components (optional)
  79283. * @param type the type of the component (optional)
  79284. * @param normalized whether the data contains normalized data (optional)
  79285. * @param useBytes set to true if stride and offset are in bytes (optional)
  79286. * @param divisor defines the instance divisor to use (1 by default)
  79287. */
  79288. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  79289. /** @hidden */
  79290. _rebuild(): void;
  79291. /**
  79292. * Returns the kind of the VertexBuffer (string)
  79293. * @returns a string
  79294. */
  79295. getKind(): string;
  79296. /**
  79297. * Gets a boolean indicating if the VertexBuffer is updatable?
  79298. * @returns true if the buffer is updatable
  79299. */
  79300. isUpdatable(): boolean;
  79301. /**
  79302. * Gets current buffer's data
  79303. * @returns a DataArray or null
  79304. */
  79305. getData(): Nullable<DataArray>;
  79306. /**
  79307. * Gets underlying native buffer
  79308. * @returns underlying native buffer
  79309. */
  79310. getBuffer(): Nullable<DataBuffer>;
  79311. /**
  79312. * Gets the stride in float32 units (i.e. byte stride / 4).
  79313. * May not be an integer if the byte stride is not divisible by 4.
  79314. * @returns the stride in float32 units
  79315. * @deprecated Please use byteStride instead.
  79316. */
  79317. getStrideSize(): number;
  79318. /**
  79319. * Returns the offset as a multiple of the type byte length.
  79320. * @returns the offset in bytes
  79321. * @deprecated Please use byteOffset instead.
  79322. */
  79323. getOffset(): number;
  79324. /**
  79325. * Returns the number of components per vertex attribute (integer)
  79326. * @returns the size in float
  79327. */
  79328. getSize(): number;
  79329. /**
  79330. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  79331. * @returns true if this buffer is instanced
  79332. */
  79333. getIsInstanced(): boolean;
  79334. /**
  79335. * Returns the instancing divisor, zero for non-instanced (integer).
  79336. * @returns a number
  79337. */
  79338. getInstanceDivisor(): number;
  79339. /**
  79340. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79341. * @param data defines the data to store
  79342. */
  79343. create(data?: DataArray): void;
  79344. /**
  79345. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  79346. * This function will create a new buffer if the current one is not updatable
  79347. * @param data defines the data to store
  79348. */
  79349. update(data: DataArray): void;
  79350. /**
  79351. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  79352. * Returns the directly updated WebGLBuffer.
  79353. * @param data the new data
  79354. * @param offset the new offset
  79355. * @param useBytes set to true if the offset is in bytes
  79356. */
  79357. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  79358. /**
  79359. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  79360. */
  79361. dispose(): void;
  79362. /**
  79363. * Enumerates each value of this vertex buffer as numbers.
  79364. * @param count the number of values to enumerate
  79365. * @param callback the callback function called for each value
  79366. */
  79367. forEach(count: number, callback: (value: number, index: number) => void): void;
  79368. /**
  79369. * Positions
  79370. */
  79371. static readonly PositionKind: string;
  79372. /**
  79373. * Normals
  79374. */
  79375. static readonly NormalKind: string;
  79376. /**
  79377. * Tangents
  79378. */
  79379. static readonly TangentKind: string;
  79380. /**
  79381. * Texture coordinates
  79382. */
  79383. static readonly UVKind: string;
  79384. /**
  79385. * Texture coordinates 2
  79386. */
  79387. static readonly UV2Kind: string;
  79388. /**
  79389. * Texture coordinates 3
  79390. */
  79391. static readonly UV3Kind: string;
  79392. /**
  79393. * Texture coordinates 4
  79394. */
  79395. static readonly UV4Kind: string;
  79396. /**
  79397. * Texture coordinates 5
  79398. */
  79399. static readonly UV5Kind: string;
  79400. /**
  79401. * Texture coordinates 6
  79402. */
  79403. static readonly UV6Kind: string;
  79404. /**
  79405. * Colors
  79406. */
  79407. static readonly ColorKind: string;
  79408. /**
  79409. * Matrix indices (for bones)
  79410. */
  79411. static readonly MatricesIndicesKind: string;
  79412. /**
  79413. * Matrix weights (for bones)
  79414. */
  79415. static readonly MatricesWeightsKind: string;
  79416. /**
  79417. * Additional matrix indices (for bones)
  79418. */
  79419. static readonly MatricesIndicesExtraKind: string;
  79420. /**
  79421. * Additional matrix weights (for bones)
  79422. */
  79423. static readonly MatricesWeightsExtraKind: string;
  79424. /**
  79425. * Deduces the stride given a kind.
  79426. * @param kind The kind string to deduce
  79427. * @returns The deduced stride
  79428. */
  79429. static DeduceStride(kind: string): number;
  79430. /**
  79431. * Gets the byte length of the given type.
  79432. * @param type the type
  79433. * @returns the number of bytes
  79434. */
  79435. static GetTypeByteLength(type: number): number;
  79436. /**
  79437. * Enumerates each value of the given parameters as numbers.
  79438. * @param data the data to enumerate
  79439. * @param byteOffset the byte offset of the data
  79440. * @param byteStride the byte stride of the data
  79441. * @param componentCount the number of components per element
  79442. * @param componentType the type of the component
  79443. * @param count the number of values to enumerate
  79444. * @param normalized whether the data is normalized
  79445. * @param callback the callback function called for each value
  79446. */
  79447. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  79448. private static _GetFloatValue;
  79449. }
  79450. }
  79451. declare module BABYLON {
  79452. /**
  79453. * @hidden
  79454. */
  79455. export class IntersectionInfo {
  79456. bu: Nullable<number>;
  79457. bv: Nullable<number>;
  79458. distance: number;
  79459. faceId: number;
  79460. subMeshId: number;
  79461. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  79462. }
  79463. }
  79464. declare module BABYLON {
  79465. /**
  79466. * Represens a plane by the equation ax + by + cz + d = 0
  79467. */
  79468. export class Plane {
  79469. private static _TmpMatrix;
  79470. /**
  79471. * Normal of the plane (a,b,c)
  79472. */
  79473. normal: Vector3;
  79474. /**
  79475. * d component of the plane
  79476. */
  79477. d: number;
  79478. /**
  79479. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  79480. * @param a a component of the plane
  79481. * @param b b component of the plane
  79482. * @param c c component of the plane
  79483. * @param d d component of the plane
  79484. */
  79485. constructor(a: number, b: number, c: number, d: number);
  79486. /**
  79487. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  79488. */
  79489. asArray(): number[];
  79490. /**
  79491. * @returns a new plane copied from the current Plane.
  79492. */
  79493. clone(): Plane;
  79494. /**
  79495. * @returns the string "Plane".
  79496. */
  79497. getClassName(): string;
  79498. /**
  79499. * @returns the Plane hash code.
  79500. */
  79501. getHashCode(): number;
  79502. /**
  79503. * Normalize the current Plane in place.
  79504. * @returns the updated Plane.
  79505. */
  79506. normalize(): Plane;
  79507. /**
  79508. * Applies a transformation the plane and returns the result
  79509. * @param transformation the transformation matrix to be applied to the plane
  79510. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  79511. */
  79512. transform(transformation: DeepImmutable<Matrix>): Plane;
  79513. /**
  79514. * Calcualtte the dot product between the point and the plane normal
  79515. * @param point point to calculate the dot product with
  79516. * @returns the dot product (float) of the point coordinates and the plane normal.
  79517. */
  79518. dotCoordinate(point: DeepImmutable<Vector3>): number;
  79519. /**
  79520. * Updates the current Plane from the plane defined by the three given points.
  79521. * @param point1 one of the points used to contruct the plane
  79522. * @param point2 one of the points used to contruct the plane
  79523. * @param point3 one of the points used to contruct the plane
  79524. * @returns the updated Plane.
  79525. */
  79526. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79527. /**
  79528. * Checks if the plane is facing a given direction
  79529. * @param direction the direction to check if the plane is facing
  79530. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  79531. * @returns True is the vector "direction" is the same side than the plane normal.
  79532. */
  79533. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  79534. /**
  79535. * Calculates the distance to a point
  79536. * @param point point to calculate distance to
  79537. * @returns the signed distance (float) from the given point to the Plane.
  79538. */
  79539. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  79540. /**
  79541. * Creates a plane from an array
  79542. * @param array the array to create a plane from
  79543. * @returns a new Plane from the given array.
  79544. */
  79545. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  79546. /**
  79547. * Creates a plane from three points
  79548. * @param point1 point used to create the plane
  79549. * @param point2 point used to create the plane
  79550. * @param point3 point used to create the plane
  79551. * @returns a new Plane defined by the three given points.
  79552. */
  79553. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79554. /**
  79555. * Creates a plane from an origin point and a normal
  79556. * @param origin origin of the plane to be constructed
  79557. * @param normal normal of the plane to be constructed
  79558. * @returns a new Plane the normal vector to this plane at the given origin point.
  79559. * Note : the vector "normal" is updated because normalized.
  79560. */
  79561. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  79562. /**
  79563. * Calculates the distance from a plane and a point
  79564. * @param origin origin of the plane to be constructed
  79565. * @param normal normal of the plane to be constructed
  79566. * @param point point to calculate distance to
  79567. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  79568. */
  79569. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  79570. }
  79571. }
  79572. declare module BABYLON {
  79573. /**
  79574. * Class used to store bounding sphere information
  79575. */
  79576. export class BoundingSphere {
  79577. /**
  79578. * Gets the center of the bounding sphere in local space
  79579. */
  79580. readonly center: Vector3;
  79581. /**
  79582. * Radius of the bounding sphere in local space
  79583. */
  79584. radius: number;
  79585. /**
  79586. * Gets the center of the bounding sphere in world space
  79587. */
  79588. readonly centerWorld: Vector3;
  79589. /**
  79590. * Radius of the bounding sphere in world space
  79591. */
  79592. radiusWorld: number;
  79593. /**
  79594. * Gets the minimum vector in local space
  79595. */
  79596. readonly minimum: Vector3;
  79597. /**
  79598. * Gets the maximum vector in local space
  79599. */
  79600. readonly maximum: Vector3;
  79601. private _worldMatrix;
  79602. private static readonly TmpVector3;
  79603. /**
  79604. * Creates a new bounding sphere
  79605. * @param min defines the minimum vector (in local space)
  79606. * @param max defines the maximum vector (in local space)
  79607. * @param worldMatrix defines the new world matrix
  79608. */
  79609. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  79610. /**
  79611. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  79612. * @param min defines the new minimum vector (in local space)
  79613. * @param max defines the new maximum vector (in local space)
  79614. * @param worldMatrix defines the new world matrix
  79615. */
  79616. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  79617. /**
  79618. * Scale the current bounding sphere by applying a scale factor
  79619. * @param factor defines the scale factor to apply
  79620. * @returns the current bounding box
  79621. */
  79622. scale(factor: number): BoundingSphere;
  79623. /**
  79624. * Gets the world matrix of the bounding box
  79625. * @returns a matrix
  79626. */
  79627. getWorldMatrix(): DeepImmutable<Matrix>;
  79628. /** @hidden */
  79629. _update(worldMatrix: DeepImmutable<Matrix>): void;
  79630. /**
  79631. * Tests if the bounding sphere is intersecting the frustum planes
  79632. * @param frustumPlanes defines the frustum planes to test
  79633. * @returns true if there is an intersection
  79634. */
  79635. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79636. /**
  79637. * Tests if the bounding sphere center is in between the frustum planes.
  79638. * Used for optimistic fast inclusion.
  79639. * @param frustumPlanes defines the frustum planes to test
  79640. * @returns true if the sphere center is in between the frustum planes
  79641. */
  79642. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79643. /**
  79644. * Tests if a point is inside the bounding sphere
  79645. * @param point defines the point to test
  79646. * @returns true if the point is inside the bounding sphere
  79647. */
  79648. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  79649. /**
  79650. * Checks if two sphere intersct
  79651. * @param sphere0 sphere 0
  79652. * @param sphere1 sphere 1
  79653. * @returns true if the speres intersect
  79654. */
  79655. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  79656. }
  79657. }
  79658. declare module BABYLON {
  79659. /**
  79660. * Class used to store bounding box information
  79661. */
  79662. export class BoundingBox implements ICullable {
  79663. /**
  79664. * Gets the 8 vectors representing the bounding box in local space
  79665. */
  79666. readonly vectors: Vector3[];
  79667. /**
  79668. * Gets the center of the bounding box in local space
  79669. */
  79670. readonly center: Vector3;
  79671. /**
  79672. * Gets the center of the bounding box in world space
  79673. */
  79674. readonly centerWorld: Vector3;
  79675. /**
  79676. * Gets the extend size in local space
  79677. */
  79678. readonly extendSize: Vector3;
  79679. /**
  79680. * Gets the extend size in world space
  79681. */
  79682. readonly extendSizeWorld: Vector3;
  79683. /**
  79684. * Gets the OBB (object bounding box) directions
  79685. */
  79686. readonly directions: Vector3[];
  79687. /**
  79688. * Gets the 8 vectors representing the bounding box in world space
  79689. */
  79690. readonly vectorsWorld: Vector3[];
  79691. /**
  79692. * Gets the minimum vector in world space
  79693. */
  79694. readonly minimumWorld: Vector3;
  79695. /**
  79696. * Gets the maximum vector in world space
  79697. */
  79698. readonly maximumWorld: Vector3;
  79699. /**
  79700. * Gets the minimum vector in local space
  79701. */
  79702. readonly minimum: Vector3;
  79703. /**
  79704. * Gets the maximum vector in local space
  79705. */
  79706. readonly maximum: Vector3;
  79707. private _worldMatrix;
  79708. private static readonly TmpVector3;
  79709. /**
  79710. * @hidden
  79711. */
  79712. _tag: number;
  79713. /**
  79714. * Creates a new bounding box
  79715. * @param min defines the minimum vector (in local space)
  79716. * @param max defines the maximum vector (in local space)
  79717. * @param worldMatrix defines the new world matrix
  79718. */
  79719. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  79720. /**
  79721. * Recreates the entire bounding box from scratch as if we call the constructor in place
  79722. * @param min defines the new minimum vector (in local space)
  79723. * @param max defines the new maximum vector (in local space)
  79724. * @param worldMatrix defines the new world matrix
  79725. */
  79726. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  79727. /**
  79728. * Scale the current bounding box by applying a scale factor
  79729. * @param factor defines the scale factor to apply
  79730. * @returns the current bounding box
  79731. */
  79732. scale(factor: number): BoundingBox;
  79733. /**
  79734. * Gets the world matrix of the bounding box
  79735. * @returns a matrix
  79736. */
  79737. getWorldMatrix(): DeepImmutable<Matrix>;
  79738. /** @hidden */
  79739. _update(world: DeepImmutable<Matrix>): void;
  79740. /**
  79741. * Tests if the bounding box is intersecting the frustum planes
  79742. * @param frustumPlanes defines the frustum planes to test
  79743. * @returns true if there is an intersection
  79744. */
  79745. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79746. /**
  79747. * Tests if the bounding box is entirely inside the frustum planes
  79748. * @param frustumPlanes defines the frustum planes to test
  79749. * @returns true if there is an inclusion
  79750. */
  79751. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79752. /**
  79753. * Tests if a point is inside the bounding box
  79754. * @param point defines the point to test
  79755. * @returns true if the point is inside the bounding box
  79756. */
  79757. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  79758. /**
  79759. * Tests if the bounding box intersects with a bounding sphere
  79760. * @param sphere defines the sphere to test
  79761. * @returns true if there is an intersection
  79762. */
  79763. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  79764. /**
  79765. * Tests if the bounding box intersects with a box defined by a min and max vectors
  79766. * @param min defines the min vector to use
  79767. * @param max defines the max vector to use
  79768. * @returns true if there is an intersection
  79769. */
  79770. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  79771. /**
  79772. * Tests if two bounding boxes are intersections
  79773. * @param box0 defines the first box to test
  79774. * @param box1 defines the second box to test
  79775. * @returns true if there is an intersection
  79776. */
  79777. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  79778. /**
  79779. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  79780. * @param minPoint defines the minimum vector of the bounding box
  79781. * @param maxPoint defines the maximum vector of the bounding box
  79782. * @param sphereCenter defines the sphere center
  79783. * @param sphereRadius defines the sphere radius
  79784. * @returns true if there is an intersection
  79785. */
  79786. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  79787. /**
  79788. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  79789. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  79790. * @param frustumPlanes defines the frustum planes to test
  79791. * @return true if there is an inclusion
  79792. */
  79793. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79794. /**
  79795. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  79796. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  79797. * @param frustumPlanes defines the frustum planes to test
  79798. * @return true if there is an intersection
  79799. */
  79800. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79801. }
  79802. }
  79803. declare module BABYLON {
  79804. /** @hidden */
  79805. export class Collider {
  79806. /** Define if a collision was found */
  79807. collisionFound: boolean;
  79808. /**
  79809. * Define last intersection point in local space
  79810. */
  79811. intersectionPoint: Vector3;
  79812. /**
  79813. * Define last collided mesh
  79814. */
  79815. collidedMesh: Nullable<AbstractMesh>;
  79816. private _collisionPoint;
  79817. private _planeIntersectionPoint;
  79818. private _tempVector;
  79819. private _tempVector2;
  79820. private _tempVector3;
  79821. private _tempVector4;
  79822. private _edge;
  79823. private _baseToVertex;
  79824. private _destinationPoint;
  79825. private _slidePlaneNormal;
  79826. private _displacementVector;
  79827. /** @hidden */
  79828. _radius: Vector3;
  79829. /** @hidden */
  79830. _retry: number;
  79831. private _velocity;
  79832. private _basePoint;
  79833. private _epsilon;
  79834. /** @hidden */
  79835. _velocityWorldLength: number;
  79836. /** @hidden */
  79837. _basePointWorld: Vector3;
  79838. private _velocityWorld;
  79839. private _normalizedVelocity;
  79840. /** @hidden */
  79841. _initialVelocity: Vector3;
  79842. /** @hidden */
  79843. _initialPosition: Vector3;
  79844. private _nearestDistance;
  79845. private _collisionMask;
  79846. get collisionMask(): number;
  79847. set collisionMask(mask: number);
  79848. /**
  79849. * Gets the plane normal used to compute the sliding response (in local space)
  79850. */
  79851. get slidePlaneNormal(): Vector3;
  79852. /** @hidden */
  79853. _initialize(source: Vector3, dir: Vector3, e: number): void;
  79854. /** @hidden */
  79855. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  79856. /** @hidden */
  79857. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  79858. /** @hidden */
  79859. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  79860. /** @hidden */
  79861. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  79862. /** @hidden */
  79863. _getResponse(pos: Vector3, vel: Vector3): void;
  79864. }
  79865. }
  79866. declare module BABYLON {
  79867. /**
  79868. * Interface for cullable objects
  79869. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  79870. */
  79871. export interface ICullable {
  79872. /**
  79873. * Checks if the object or part of the object is in the frustum
  79874. * @param frustumPlanes Camera near/planes
  79875. * @returns true if the object is in frustum otherwise false
  79876. */
  79877. isInFrustum(frustumPlanes: Plane[]): boolean;
  79878. /**
  79879. * Checks if a cullable object (mesh...) is in the camera frustum
  79880. * Unlike isInFrustum this cheks the full bounding box
  79881. * @param frustumPlanes Camera near/planes
  79882. * @returns true if the object is in frustum otherwise false
  79883. */
  79884. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  79885. }
  79886. /**
  79887. * Info for a bounding data of a mesh
  79888. */
  79889. export class BoundingInfo implements ICullable {
  79890. /**
  79891. * Bounding box for the mesh
  79892. */
  79893. readonly boundingBox: BoundingBox;
  79894. /**
  79895. * Bounding sphere for the mesh
  79896. */
  79897. readonly boundingSphere: BoundingSphere;
  79898. private _isLocked;
  79899. private static readonly TmpVector3;
  79900. /**
  79901. * Constructs bounding info
  79902. * @param minimum min vector of the bounding box/sphere
  79903. * @param maximum max vector of the bounding box/sphere
  79904. * @param worldMatrix defines the new world matrix
  79905. */
  79906. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  79907. /**
  79908. * Recreates the entire bounding info from scratch as if we call the constructor in place
  79909. * @param min defines the new minimum vector (in local space)
  79910. * @param max defines the new maximum vector (in local space)
  79911. * @param worldMatrix defines the new world matrix
  79912. */
  79913. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  79914. /**
  79915. * min vector of the bounding box/sphere
  79916. */
  79917. get minimum(): Vector3;
  79918. /**
  79919. * max vector of the bounding box/sphere
  79920. */
  79921. get maximum(): Vector3;
  79922. /**
  79923. * If the info is locked and won't be updated to avoid perf overhead
  79924. */
  79925. get isLocked(): boolean;
  79926. set isLocked(value: boolean);
  79927. /**
  79928. * Updates the bounding sphere and box
  79929. * @param world world matrix to be used to update
  79930. */
  79931. update(world: DeepImmutable<Matrix>): void;
  79932. /**
  79933. * Recreate the bounding info to be centered around a specific point given a specific extend.
  79934. * @param center New center of the bounding info
  79935. * @param extend New extend of the bounding info
  79936. * @returns the current bounding info
  79937. */
  79938. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  79939. /**
  79940. * Scale the current bounding info by applying a scale factor
  79941. * @param factor defines the scale factor to apply
  79942. * @returns the current bounding info
  79943. */
  79944. scale(factor: number): BoundingInfo;
  79945. /**
  79946. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  79947. * @param frustumPlanes defines the frustum to test
  79948. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  79949. * @returns true if the bounding info is in the frustum planes
  79950. */
  79951. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  79952. /**
  79953. * Gets the world distance between the min and max points of the bounding box
  79954. */
  79955. get diagonalLength(): number;
  79956. /**
  79957. * Checks if a cullable object (mesh...) is in the camera frustum
  79958. * Unlike isInFrustum this cheks the full bounding box
  79959. * @param frustumPlanes Camera near/planes
  79960. * @returns true if the object is in frustum otherwise false
  79961. */
  79962. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79963. /** @hidden */
  79964. _checkCollision(collider: Collider): boolean;
  79965. /**
  79966. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  79967. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  79968. * @param point the point to check intersection with
  79969. * @returns if the point intersects
  79970. */
  79971. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  79972. /**
  79973. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  79974. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  79975. * @param boundingInfo the bounding info to check intersection with
  79976. * @param precise if the intersection should be done using OBB
  79977. * @returns if the bounding info intersects
  79978. */
  79979. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  79980. }
  79981. }
  79982. declare module BABYLON {
  79983. /**
  79984. * Extracts minimum and maximum values from a list of indexed positions
  79985. * @param positions defines the positions to use
  79986. * @param indices defines the indices to the positions
  79987. * @param indexStart defines the start index
  79988. * @param indexCount defines the end index
  79989. * @param bias defines bias value to add to the result
  79990. * @return minimum and maximum values
  79991. */
  79992. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  79993. minimum: Vector3;
  79994. maximum: Vector3;
  79995. };
  79996. /**
  79997. * Extracts minimum and maximum values from a list of positions
  79998. * @param positions defines the positions to use
  79999. * @param start defines the start index in the positions array
  80000. * @param count defines the number of positions to handle
  80001. * @param bias defines bias value to add to the result
  80002. * @param stride defines the stride size to use (distance between two positions in the positions array)
  80003. * @return minimum and maximum values
  80004. */
  80005. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  80006. minimum: Vector3;
  80007. maximum: Vector3;
  80008. };
  80009. }
  80010. declare module BABYLON {
  80011. /** @hidden */
  80012. export class WebGLDataBuffer extends DataBuffer {
  80013. private _buffer;
  80014. constructor(resource: WebGLBuffer);
  80015. get underlyingResource(): any;
  80016. }
  80017. }
  80018. declare module BABYLON {
  80019. /** @hidden */
  80020. export class WebGLPipelineContext implements IPipelineContext {
  80021. engine: ThinEngine;
  80022. program: Nullable<WebGLProgram>;
  80023. context?: WebGLRenderingContext;
  80024. vertexShader?: WebGLShader;
  80025. fragmentShader?: WebGLShader;
  80026. isParallelCompiled: boolean;
  80027. onCompiled?: () => void;
  80028. transformFeedback?: WebGLTransformFeedback | null;
  80029. vertexCompilationError: Nullable<string>;
  80030. fragmentCompilationError: Nullable<string>;
  80031. programLinkError: Nullable<string>;
  80032. programValidationError: Nullable<string>;
  80033. get isAsync(): boolean;
  80034. get isReady(): boolean;
  80035. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  80036. }
  80037. }
  80038. declare module BABYLON {
  80039. interface ThinEngine {
  80040. /**
  80041. * Create an uniform buffer
  80042. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80043. * @param elements defines the content of the uniform buffer
  80044. * @returns the webGL uniform buffer
  80045. */
  80046. createUniformBuffer(elements: FloatArray): DataBuffer;
  80047. /**
  80048. * Create a dynamic uniform buffer
  80049. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80050. * @param elements defines the content of the uniform buffer
  80051. * @returns the webGL uniform buffer
  80052. */
  80053. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  80054. /**
  80055. * Update an existing uniform buffer
  80056. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80057. * @param uniformBuffer defines the target uniform buffer
  80058. * @param elements defines the content to update
  80059. * @param offset defines the offset in the uniform buffer where update should start
  80060. * @param count defines the size of the data to update
  80061. */
  80062. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  80063. /**
  80064. * Bind an uniform buffer to the current webGL context
  80065. * @param buffer defines the buffer to bind
  80066. */
  80067. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  80068. /**
  80069. * Bind a buffer to the current webGL context at a given location
  80070. * @param buffer defines the buffer to bind
  80071. * @param location defines the index where to bind the buffer
  80072. */
  80073. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  80074. /**
  80075. * Bind a specific block at a given index in a specific shader program
  80076. * @param pipelineContext defines the pipeline context to use
  80077. * @param blockName defines the block name
  80078. * @param index defines the index where to bind the block
  80079. */
  80080. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  80081. }
  80082. }
  80083. declare module BABYLON {
  80084. /**
  80085. * Uniform buffer objects.
  80086. *
  80087. * Handles blocks of uniform on the GPU.
  80088. *
  80089. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80090. *
  80091. * For more information, please refer to :
  80092. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80093. */
  80094. export class UniformBuffer {
  80095. private _engine;
  80096. private _buffer;
  80097. private _data;
  80098. private _bufferData;
  80099. private _dynamic?;
  80100. private _uniformLocations;
  80101. private _uniformSizes;
  80102. private _uniformLocationPointer;
  80103. private _needSync;
  80104. private _noUBO;
  80105. private _currentEffect;
  80106. /** @hidden */
  80107. _alreadyBound: boolean;
  80108. private static _MAX_UNIFORM_SIZE;
  80109. private static _tempBuffer;
  80110. /**
  80111. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  80112. * This is dynamic to allow compat with webgl 1 and 2.
  80113. * You will need to pass the name of the uniform as well as the value.
  80114. */
  80115. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  80116. /**
  80117. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  80118. * This is dynamic to allow compat with webgl 1 and 2.
  80119. * You will need to pass the name of the uniform as well as the value.
  80120. */
  80121. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  80122. /**
  80123. * Lambda to Update a single float in a uniform buffer.
  80124. * This is dynamic to allow compat with webgl 1 and 2.
  80125. * You will need to pass the name of the uniform as well as the value.
  80126. */
  80127. updateFloat: (name: string, x: number) => void;
  80128. /**
  80129. * Lambda to Update a vec2 of float in a uniform buffer.
  80130. * This is dynamic to allow compat with webgl 1 and 2.
  80131. * You will need to pass the name of the uniform as well as the value.
  80132. */
  80133. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  80134. /**
  80135. * Lambda to Update a vec3 of float in a uniform buffer.
  80136. * This is dynamic to allow compat with webgl 1 and 2.
  80137. * You will need to pass the name of the uniform as well as the value.
  80138. */
  80139. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  80140. /**
  80141. * Lambda to Update a vec4 of float in a uniform buffer.
  80142. * This is dynamic to allow compat with webgl 1 and 2.
  80143. * You will need to pass the name of the uniform as well as the value.
  80144. */
  80145. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  80146. /**
  80147. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  80148. * This is dynamic to allow compat with webgl 1 and 2.
  80149. * You will need to pass the name of the uniform as well as the value.
  80150. */
  80151. updateMatrix: (name: string, mat: Matrix) => void;
  80152. /**
  80153. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  80154. * This is dynamic to allow compat with webgl 1 and 2.
  80155. * You will need to pass the name of the uniform as well as the value.
  80156. */
  80157. updateVector3: (name: string, vector: Vector3) => void;
  80158. /**
  80159. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  80160. * This is dynamic to allow compat with webgl 1 and 2.
  80161. * You will need to pass the name of the uniform as well as the value.
  80162. */
  80163. updateVector4: (name: string, vector: Vector4) => void;
  80164. /**
  80165. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  80166. * This is dynamic to allow compat with webgl 1 and 2.
  80167. * You will need to pass the name of the uniform as well as the value.
  80168. */
  80169. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  80170. /**
  80171. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  80172. * This is dynamic to allow compat with webgl 1 and 2.
  80173. * You will need to pass the name of the uniform as well as the value.
  80174. */
  80175. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  80176. /**
  80177. * Instantiates a new Uniform buffer objects.
  80178. *
  80179. * Handles blocks of uniform on the GPU.
  80180. *
  80181. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80182. *
  80183. * For more information, please refer to :
  80184. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80185. * @param engine Define the engine the buffer is associated with
  80186. * @param data Define the data contained in the buffer
  80187. * @param dynamic Define if the buffer is updatable
  80188. */
  80189. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  80190. /**
  80191. * Indicates if the buffer is using the WebGL2 UBO implementation,
  80192. * or just falling back on setUniformXXX calls.
  80193. */
  80194. get useUbo(): boolean;
  80195. /**
  80196. * Indicates if the WebGL underlying uniform buffer is in sync
  80197. * with the javascript cache data.
  80198. */
  80199. get isSync(): boolean;
  80200. /**
  80201. * Indicates if the WebGL underlying uniform buffer is dynamic.
  80202. * Also, a dynamic UniformBuffer will disable cache verification and always
  80203. * update the underlying WebGL uniform buffer to the GPU.
  80204. * @returns if Dynamic, otherwise false
  80205. */
  80206. isDynamic(): boolean;
  80207. /**
  80208. * The data cache on JS side.
  80209. * @returns the underlying data as a float array
  80210. */
  80211. getData(): Float32Array;
  80212. /**
  80213. * The underlying WebGL Uniform buffer.
  80214. * @returns the webgl buffer
  80215. */
  80216. getBuffer(): Nullable<DataBuffer>;
  80217. /**
  80218. * std140 layout specifies how to align data within an UBO structure.
  80219. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  80220. * for specs.
  80221. */
  80222. private _fillAlignment;
  80223. /**
  80224. * Adds an uniform in the buffer.
  80225. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  80226. * for the layout to be correct !
  80227. * @param name Name of the uniform, as used in the uniform block in the shader.
  80228. * @param size Data size, or data directly.
  80229. */
  80230. addUniform(name: string, size: number | number[]): void;
  80231. /**
  80232. * Adds a Matrix 4x4 to the uniform buffer.
  80233. * @param name Name of the uniform, as used in the uniform block in the shader.
  80234. * @param mat A 4x4 matrix.
  80235. */
  80236. addMatrix(name: string, mat: Matrix): void;
  80237. /**
  80238. * Adds a vec2 to the uniform buffer.
  80239. * @param name Name of the uniform, as used in the uniform block in the shader.
  80240. * @param x Define the x component value of the vec2
  80241. * @param y Define the y component value of the vec2
  80242. */
  80243. addFloat2(name: string, x: number, y: number): void;
  80244. /**
  80245. * Adds a vec3 to the uniform buffer.
  80246. * @param name Name of the uniform, as used in the uniform block in the shader.
  80247. * @param x Define the x component value of the vec3
  80248. * @param y Define the y component value of the vec3
  80249. * @param z Define the z component value of the vec3
  80250. */
  80251. addFloat3(name: string, x: number, y: number, z: number): void;
  80252. /**
  80253. * Adds a vec3 to the uniform buffer.
  80254. * @param name Name of the uniform, as used in the uniform block in the shader.
  80255. * @param color Define the vec3 from a Color
  80256. */
  80257. addColor3(name: string, color: Color3): void;
  80258. /**
  80259. * Adds a vec4 to the uniform buffer.
  80260. * @param name Name of the uniform, as used in the uniform block in the shader.
  80261. * @param color Define the rgb components from a Color
  80262. * @param alpha Define the a component of the vec4
  80263. */
  80264. addColor4(name: string, color: Color3, alpha: number): void;
  80265. /**
  80266. * Adds a vec3 to the uniform buffer.
  80267. * @param name Name of the uniform, as used in the uniform block in the shader.
  80268. * @param vector Define the vec3 components from a Vector
  80269. */
  80270. addVector3(name: string, vector: Vector3): void;
  80271. /**
  80272. * Adds a Matrix 3x3 to the uniform buffer.
  80273. * @param name Name of the uniform, as used in the uniform block in the shader.
  80274. */
  80275. addMatrix3x3(name: string): void;
  80276. /**
  80277. * Adds a Matrix 2x2 to the uniform buffer.
  80278. * @param name Name of the uniform, as used in the uniform block in the shader.
  80279. */
  80280. addMatrix2x2(name: string): void;
  80281. /**
  80282. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  80283. */
  80284. create(): void;
  80285. /** @hidden */
  80286. _rebuild(): void;
  80287. /**
  80288. * Updates the WebGL Uniform Buffer on the GPU.
  80289. * If the `dynamic` flag is set to true, no cache comparison is done.
  80290. * Otherwise, the buffer will be updated only if the cache differs.
  80291. */
  80292. update(): void;
  80293. /**
  80294. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  80295. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80296. * @param data Define the flattened data
  80297. * @param size Define the size of the data.
  80298. */
  80299. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  80300. private _valueCache;
  80301. private _cacheMatrix;
  80302. private _updateMatrix3x3ForUniform;
  80303. private _updateMatrix3x3ForEffect;
  80304. private _updateMatrix2x2ForEffect;
  80305. private _updateMatrix2x2ForUniform;
  80306. private _updateFloatForEffect;
  80307. private _updateFloatForUniform;
  80308. private _updateFloat2ForEffect;
  80309. private _updateFloat2ForUniform;
  80310. private _updateFloat3ForEffect;
  80311. private _updateFloat3ForUniform;
  80312. private _updateFloat4ForEffect;
  80313. private _updateFloat4ForUniform;
  80314. private _updateMatrixForEffect;
  80315. private _updateMatrixForUniform;
  80316. private _updateVector3ForEffect;
  80317. private _updateVector3ForUniform;
  80318. private _updateVector4ForEffect;
  80319. private _updateVector4ForUniform;
  80320. private _updateColor3ForEffect;
  80321. private _updateColor3ForUniform;
  80322. private _updateColor4ForEffect;
  80323. private _updateColor4ForUniform;
  80324. /**
  80325. * Sets a sampler uniform on the effect.
  80326. * @param name Define the name of the sampler.
  80327. * @param texture Define the texture to set in the sampler
  80328. */
  80329. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  80330. /**
  80331. * Directly updates the value of the uniform in the cache AND on the GPU.
  80332. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80333. * @param data Define the flattened data
  80334. */
  80335. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  80336. /**
  80337. * Binds this uniform buffer to an effect.
  80338. * @param effect Define the effect to bind the buffer to
  80339. * @param name Name of the uniform block in the shader.
  80340. */
  80341. bindToEffect(effect: Effect, name: string): void;
  80342. /**
  80343. * Disposes the uniform buffer.
  80344. */
  80345. dispose(): void;
  80346. }
  80347. }
  80348. declare module BABYLON {
  80349. /**
  80350. * Enum that determines the text-wrapping mode to use.
  80351. */
  80352. export enum InspectableType {
  80353. /**
  80354. * Checkbox for booleans
  80355. */
  80356. Checkbox = 0,
  80357. /**
  80358. * Sliders for numbers
  80359. */
  80360. Slider = 1,
  80361. /**
  80362. * Vector3
  80363. */
  80364. Vector3 = 2,
  80365. /**
  80366. * Quaternions
  80367. */
  80368. Quaternion = 3,
  80369. /**
  80370. * Color3
  80371. */
  80372. Color3 = 4,
  80373. /**
  80374. * String
  80375. */
  80376. String = 5
  80377. }
  80378. /**
  80379. * Interface used to define custom inspectable properties.
  80380. * This interface is used by the inspector to display custom property grids
  80381. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80382. */
  80383. export interface IInspectable {
  80384. /**
  80385. * Gets the label to display
  80386. */
  80387. label: string;
  80388. /**
  80389. * Gets the name of the property to edit
  80390. */
  80391. propertyName: string;
  80392. /**
  80393. * Gets the type of the editor to use
  80394. */
  80395. type: InspectableType;
  80396. /**
  80397. * Gets the minimum value of the property when using in "slider" mode
  80398. */
  80399. min?: number;
  80400. /**
  80401. * Gets the maximum value of the property when using in "slider" mode
  80402. */
  80403. max?: number;
  80404. /**
  80405. * Gets the setp to use when using in "slider" mode
  80406. */
  80407. step?: number;
  80408. }
  80409. }
  80410. declare module BABYLON {
  80411. /**
  80412. * Class used to provide helper for timing
  80413. */
  80414. export class TimingTools {
  80415. /**
  80416. * Polyfill for setImmediate
  80417. * @param action defines the action to execute after the current execution block
  80418. */
  80419. static SetImmediate(action: () => void): void;
  80420. }
  80421. }
  80422. declare module BABYLON {
  80423. /**
  80424. * Class used to enable instatition of objects by class name
  80425. */
  80426. export class InstantiationTools {
  80427. /**
  80428. * Use this object to register external classes like custom textures or material
  80429. * to allow the laoders to instantiate them
  80430. */
  80431. static RegisteredExternalClasses: {
  80432. [key: string]: Object;
  80433. };
  80434. /**
  80435. * Tries to instantiate a new object from a given class name
  80436. * @param className defines the class name to instantiate
  80437. * @returns the new object or null if the system was not able to do the instantiation
  80438. */
  80439. static Instantiate(className: string): any;
  80440. }
  80441. }
  80442. declare module BABYLON {
  80443. /**
  80444. * Define options used to create a depth texture
  80445. */
  80446. export class DepthTextureCreationOptions {
  80447. /** Specifies whether or not a stencil should be allocated in the texture */
  80448. generateStencil?: boolean;
  80449. /** Specifies whether or not bilinear filtering is enable on the texture */
  80450. bilinearFiltering?: boolean;
  80451. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  80452. comparisonFunction?: number;
  80453. /** Specifies if the created texture is a cube texture */
  80454. isCube?: boolean;
  80455. }
  80456. }
  80457. declare module BABYLON {
  80458. interface ThinEngine {
  80459. /**
  80460. * Creates a depth stencil cube texture.
  80461. * This is only available in WebGL 2.
  80462. * @param size The size of face edge in the cube texture.
  80463. * @param options The options defining the cube texture.
  80464. * @returns The cube texture
  80465. */
  80466. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  80467. /**
  80468. * Creates a cube texture
  80469. * @param rootUrl defines the url where the files to load is located
  80470. * @param scene defines the current scene
  80471. * @param files defines the list of files to load (1 per face)
  80472. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80473. * @param onLoad defines an optional callback raised when the texture is loaded
  80474. * @param onError defines an optional callback raised if there is an issue to load the texture
  80475. * @param format defines the format of the data
  80476. * @param forcedExtension defines the extension to use to pick the right loader
  80477. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80478. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80479. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80480. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  80481. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  80482. * @returns the cube texture as an InternalTexture
  80483. */
  80484. 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;
  80485. /**
  80486. * Creates a cube texture
  80487. * @param rootUrl defines the url where the files to load is located
  80488. * @param scene defines the current scene
  80489. * @param files defines the list of files to load (1 per face)
  80490. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80491. * @param onLoad defines an optional callback raised when the texture is loaded
  80492. * @param onError defines an optional callback raised if there is an issue to load the texture
  80493. * @param format defines the format of the data
  80494. * @param forcedExtension defines the extension to use to pick the right loader
  80495. * @returns the cube texture as an InternalTexture
  80496. */
  80497. 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;
  80498. /**
  80499. * Creates a cube texture
  80500. * @param rootUrl defines the url where the files to load is located
  80501. * @param scene defines the current scene
  80502. * @param files defines the list of files to load (1 per face)
  80503. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80504. * @param onLoad defines an optional callback raised when the texture is loaded
  80505. * @param onError defines an optional callback raised if there is an issue to load the texture
  80506. * @param format defines the format of the data
  80507. * @param forcedExtension defines the extension to use to pick the right loader
  80508. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80509. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80510. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80511. * @returns the cube texture as an InternalTexture
  80512. */
  80513. 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;
  80514. /** @hidden */
  80515. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  80516. /** @hidden */
  80517. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  80518. /** @hidden */
  80519. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80520. /** @hidden */
  80521. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80522. /**
  80523. * @hidden
  80524. */
  80525. _setCubeMapTextureParams(loadMipmap: boolean): void;
  80526. }
  80527. }
  80528. declare module BABYLON {
  80529. /**
  80530. * Class for creating a cube texture
  80531. */
  80532. export class CubeTexture extends BaseTexture {
  80533. private _delayedOnLoad;
  80534. /**
  80535. * The url of the texture
  80536. */
  80537. url: string;
  80538. /**
  80539. * Gets or sets the center of the bounding box associated with the cube texture.
  80540. * It must define where the camera used to render the texture was set
  80541. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  80542. */
  80543. boundingBoxPosition: Vector3;
  80544. private _boundingBoxSize;
  80545. /**
  80546. * Gets or sets the size of the bounding box associated with the cube texture
  80547. * When defined, the cubemap will switch to local mode
  80548. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  80549. * @example https://www.babylonjs-playground.com/#RNASML
  80550. */
  80551. set boundingBoxSize(value: Vector3);
  80552. /**
  80553. * Returns the bounding box size
  80554. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  80555. */
  80556. get boundingBoxSize(): Vector3;
  80557. protected _rotationY: number;
  80558. /**
  80559. * Sets texture matrix rotation angle around Y axis in radians.
  80560. */
  80561. set rotationY(value: number);
  80562. /**
  80563. * Gets texture matrix rotation angle around Y axis radians.
  80564. */
  80565. get rotationY(): number;
  80566. /**
  80567. * Are mip maps generated for this texture or not.
  80568. */
  80569. get noMipmap(): boolean;
  80570. private _noMipmap;
  80571. private _files;
  80572. protected _forcedExtension: Nullable<string>;
  80573. private _extensions;
  80574. private _textureMatrix;
  80575. private _format;
  80576. private _createPolynomials;
  80577. /** @hidden */
  80578. _prefiltered: boolean;
  80579. /**
  80580. * Creates a cube texture from an array of image urls
  80581. * @param files defines an array of image urls
  80582. * @param scene defines the hosting scene
  80583. * @param noMipmap specifies if mip maps are not used
  80584. * @returns a cube texture
  80585. */
  80586. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  80587. /**
  80588. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  80589. * @param url defines the url of the prefiltered texture
  80590. * @param scene defines the scene the texture is attached to
  80591. * @param forcedExtension defines the extension of the file if different from the url
  80592. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  80593. * @return the prefiltered texture
  80594. */
  80595. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  80596. /**
  80597. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  80598. * as prefiltered data.
  80599. * @param rootUrl defines the url of the texture or the root name of the six images
  80600. * @param scene defines the scene the texture is attached to
  80601. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  80602. * @param noMipmap defines if mipmaps should be created or not
  80603. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  80604. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  80605. * @param onError defines a callback triggered in case of error during load
  80606. * @param format defines the internal format to use for the texture once loaded
  80607. * @param prefiltered defines whether or not the texture is created from prefiltered data
  80608. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  80609. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  80610. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80611. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80612. * @return the cube texture
  80613. */
  80614. 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);
  80615. /**
  80616. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  80617. */
  80618. get isPrefiltered(): boolean;
  80619. /**
  80620. * Get the current class name of the texture useful for serialization or dynamic coding.
  80621. * @returns "CubeTexture"
  80622. */
  80623. getClassName(): string;
  80624. /**
  80625. * Update the url (and optional buffer) of this texture if url was null during construction.
  80626. * @param url the url of the texture
  80627. * @param forcedExtension defines the extension to use
  80628. * @param onLoad callback called when the texture is loaded (defaults to null)
  80629. * @param prefiltered Defines whether the updated texture is prefiltered or not
  80630. */
  80631. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  80632. /**
  80633. * Delays loading of the cube texture
  80634. * @param forcedExtension defines the extension to use
  80635. */
  80636. delayLoad(forcedExtension?: string): void;
  80637. /**
  80638. * Returns the reflection texture matrix
  80639. * @returns the reflection texture matrix
  80640. */
  80641. getReflectionTextureMatrix(): Matrix;
  80642. /**
  80643. * Sets the reflection texture matrix
  80644. * @param value Reflection texture matrix
  80645. */
  80646. setReflectionTextureMatrix(value: Matrix): void;
  80647. /**
  80648. * Parses text to create a cube texture
  80649. * @param parsedTexture define the serialized text to read from
  80650. * @param scene defines the hosting scene
  80651. * @param rootUrl defines the root url of the cube texture
  80652. * @returns a cube texture
  80653. */
  80654. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  80655. /**
  80656. * Makes a clone, or deep copy, of the cube texture
  80657. * @returns a new cube texture
  80658. */
  80659. clone(): CubeTexture;
  80660. }
  80661. }
  80662. declare module BABYLON {
  80663. /**
  80664. * Manages the defines for the Material
  80665. */
  80666. export class MaterialDefines {
  80667. /** @hidden */
  80668. protected _keys: string[];
  80669. private _isDirty;
  80670. /** @hidden */
  80671. _renderId: number;
  80672. /** @hidden */
  80673. _areLightsDirty: boolean;
  80674. /** @hidden */
  80675. _areLightsDisposed: boolean;
  80676. /** @hidden */
  80677. _areAttributesDirty: boolean;
  80678. /** @hidden */
  80679. _areTexturesDirty: boolean;
  80680. /** @hidden */
  80681. _areFresnelDirty: boolean;
  80682. /** @hidden */
  80683. _areMiscDirty: boolean;
  80684. /** @hidden */
  80685. _areImageProcessingDirty: boolean;
  80686. /** @hidden */
  80687. _normals: boolean;
  80688. /** @hidden */
  80689. _uvs: boolean;
  80690. /** @hidden */
  80691. _needNormals: boolean;
  80692. /** @hidden */
  80693. _needUVs: boolean;
  80694. [id: string]: any;
  80695. /**
  80696. * Specifies if the material needs to be re-calculated
  80697. */
  80698. get isDirty(): boolean;
  80699. /**
  80700. * Marks the material to indicate that it has been re-calculated
  80701. */
  80702. markAsProcessed(): void;
  80703. /**
  80704. * Marks the material to indicate that it needs to be re-calculated
  80705. */
  80706. markAsUnprocessed(): void;
  80707. /**
  80708. * Marks the material to indicate all of its defines need to be re-calculated
  80709. */
  80710. markAllAsDirty(): void;
  80711. /**
  80712. * Marks the material to indicate that image processing needs to be re-calculated
  80713. */
  80714. markAsImageProcessingDirty(): void;
  80715. /**
  80716. * Marks the material to indicate the lights need to be re-calculated
  80717. * @param disposed Defines whether the light is dirty due to dispose or not
  80718. */
  80719. markAsLightDirty(disposed?: boolean): void;
  80720. /**
  80721. * Marks the attribute state as changed
  80722. */
  80723. markAsAttributesDirty(): void;
  80724. /**
  80725. * Marks the texture state as changed
  80726. */
  80727. markAsTexturesDirty(): void;
  80728. /**
  80729. * Marks the fresnel state as changed
  80730. */
  80731. markAsFresnelDirty(): void;
  80732. /**
  80733. * Marks the misc state as changed
  80734. */
  80735. markAsMiscDirty(): void;
  80736. /**
  80737. * Rebuilds the material defines
  80738. */
  80739. rebuild(): void;
  80740. /**
  80741. * Specifies if two material defines are equal
  80742. * @param other - A material define instance to compare to
  80743. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  80744. */
  80745. isEqual(other: MaterialDefines): boolean;
  80746. /**
  80747. * Clones this instance's defines to another instance
  80748. * @param other - material defines to clone values to
  80749. */
  80750. cloneTo(other: MaterialDefines): void;
  80751. /**
  80752. * Resets the material define values
  80753. */
  80754. reset(): void;
  80755. /**
  80756. * Converts the material define values to a string
  80757. * @returns - String of material define information
  80758. */
  80759. toString(): string;
  80760. }
  80761. }
  80762. declare module BABYLON {
  80763. /**
  80764. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  80765. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  80766. * 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;
  80767. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  80768. */
  80769. export class ColorCurves {
  80770. private _dirty;
  80771. private _tempColor;
  80772. private _globalCurve;
  80773. private _highlightsCurve;
  80774. private _midtonesCurve;
  80775. private _shadowsCurve;
  80776. private _positiveCurve;
  80777. private _negativeCurve;
  80778. private _globalHue;
  80779. private _globalDensity;
  80780. private _globalSaturation;
  80781. private _globalExposure;
  80782. /**
  80783. * Gets the global Hue value.
  80784. * 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).
  80785. */
  80786. get globalHue(): number;
  80787. /**
  80788. * Sets the global Hue value.
  80789. * 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).
  80790. */
  80791. set globalHue(value: number);
  80792. /**
  80793. * Gets the global Density value.
  80794. * 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.
  80795. * Values less than zero provide a filter of opposite hue.
  80796. */
  80797. get globalDensity(): number;
  80798. /**
  80799. * Sets the global Density value.
  80800. * 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.
  80801. * Values less than zero provide a filter of opposite hue.
  80802. */
  80803. set globalDensity(value: number);
  80804. /**
  80805. * Gets the global Saturation value.
  80806. * 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.
  80807. */
  80808. get globalSaturation(): number;
  80809. /**
  80810. * Sets the global Saturation value.
  80811. * 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.
  80812. */
  80813. set globalSaturation(value: number);
  80814. /**
  80815. * Gets the global Exposure value.
  80816. * 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.
  80817. */
  80818. get globalExposure(): number;
  80819. /**
  80820. * Sets the global Exposure value.
  80821. * 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.
  80822. */
  80823. set globalExposure(value: number);
  80824. private _highlightsHue;
  80825. private _highlightsDensity;
  80826. private _highlightsSaturation;
  80827. private _highlightsExposure;
  80828. /**
  80829. * Gets the highlights Hue value.
  80830. * 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).
  80831. */
  80832. get highlightsHue(): number;
  80833. /**
  80834. * Sets the highlights Hue value.
  80835. * 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).
  80836. */
  80837. set highlightsHue(value: number);
  80838. /**
  80839. * Gets the highlights Density value.
  80840. * 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.
  80841. * Values less than zero provide a filter of opposite hue.
  80842. */
  80843. get highlightsDensity(): number;
  80844. /**
  80845. * Sets the highlights Density value.
  80846. * 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.
  80847. * Values less than zero provide a filter of opposite hue.
  80848. */
  80849. set highlightsDensity(value: number);
  80850. /**
  80851. * Gets the highlights Saturation value.
  80852. * 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.
  80853. */
  80854. get highlightsSaturation(): number;
  80855. /**
  80856. * Sets the highlights Saturation value.
  80857. * 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.
  80858. */
  80859. set highlightsSaturation(value: number);
  80860. /**
  80861. * Gets the highlights Exposure value.
  80862. * 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.
  80863. */
  80864. get highlightsExposure(): number;
  80865. /**
  80866. * Sets the highlights Exposure value.
  80867. * 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.
  80868. */
  80869. set highlightsExposure(value: number);
  80870. private _midtonesHue;
  80871. private _midtonesDensity;
  80872. private _midtonesSaturation;
  80873. private _midtonesExposure;
  80874. /**
  80875. * Gets the midtones Hue value.
  80876. * 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).
  80877. */
  80878. get midtonesHue(): number;
  80879. /**
  80880. * Sets the midtones Hue value.
  80881. * 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).
  80882. */
  80883. set midtonesHue(value: number);
  80884. /**
  80885. * Gets the midtones Density value.
  80886. * 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.
  80887. * Values less than zero provide a filter of opposite hue.
  80888. */
  80889. get midtonesDensity(): number;
  80890. /**
  80891. * Sets the midtones Density value.
  80892. * 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.
  80893. * Values less than zero provide a filter of opposite hue.
  80894. */
  80895. set midtonesDensity(value: number);
  80896. /**
  80897. * Gets the midtones Saturation value.
  80898. * 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.
  80899. */
  80900. get midtonesSaturation(): number;
  80901. /**
  80902. * Sets the midtones Saturation value.
  80903. * 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.
  80904. */
  80905. set midtonesSaturation(value: number);
  80906. /**
  80907. * Gets the midtones Exposure value.
  80908. * 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.
  80909. */
  80910. get midtonesExposure(): number;
  80911. /**
  80912. * Sets the midtones Exposure value.
  80913. * 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.
  80914. */
  80915. set midtonesExposure(value: number);
  80916. private _shadowsHue;
  80917. private _shadowsDensity;
  80918. private _shadowsSaturation;
  80919. private _shadowsExposure;
  80920. /**
  80921. * Gets the shadows Hue value.
  80922. * 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).
  80923. */
  80924. get shadowsHue(): number;
  80925. /**
  80926. * Sets the shadows Hue value.
  80927. * 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).
  80928. */
  80929. set shadowsHue(value: number);
  80930. /**
  80931. * Gets the shadows Density value.
  80932. * 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.
  80933. * Values less than zero provide a filter of opposite hue.
  80934. */
  80935. get shadowsDensity(): number;
  80936. /**
  80937. * Sets the shadows Density value.
  80938. * 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.
  80939. * Values less than zero provide a filter of opposite hue.
  80940. */
  80941. set shadowsDensity(value: number);
  80942. /**
  80943. * Gets the shadows Saturation value.
  80944. * 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.
  80945. */
  80946. get shadowsSaturation(): number;
  80947. /**
  80948. * Sets the shadows Saturation value.
  80949. * 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.
  80950. */
  80951. set shadowsSaturation(value: number);
  80952. /**
  80953. * Gets the shadows Exposure value.
  80954. * 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.
  80955. */
  80956. get shadowsExposure(): number;
  80957. /**
  80958. * Sets the shadows Exposure value.
  80959. * 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.
  80960. */
  80961. set shadowsExposure(value: number);
  80962. /**
  80963. * Returns the class name
  80964. * @returns The class name
  80965. */
  80966. getClassName(): string;
  80967. /**
  80968. * Binds the color curves to the shader.
  80969. * @param colorCurves The color curve to bind
  80970. * @param effect The effect to bind to
  80971. * @param positiveUniform The positive uniform shader parameter
  80972. * @param neutralUniform The neutral uniform shader parameter
  80973. * @param negativeUniform The negative uniform shader parameter
  80974. */
  80975. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  80976. /**
  80977. * Prepare the list of uniforms associated with the ColorCurves effects.
  80978. * @param uniformsList The list of uniforms used in the effect
  80979. */
  80980. static PrepareUniforms(uniformsList: string[]): void;
  80981. /**
  80982. * Returns color grading data based on a hue, density, saturation and exposure value.
  80983. * @param filterHue The hue of the color filter.
  80984. * @param filterDensity The density of the color filter.
  80985. * @param saturation The saturation.
  80986. * @param exposure The exposure.
  80987. * @param result The result data container.
  80988. */
  80989. private getColorGradingDataToRef;
  80990. /**
  80991. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  80992. * @param value The input slider value in range [-100,100].
  80993. * @returns Adjusted value.
  80994. */
  80995. private static applyColorGradingSliderNonlinear;
  80996. /**
  80997. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  80998. * @param hue The hue (H) input.
  80999. * @param saturation The saturation (S) input.
  81000. * @param brightness The brightness (B) input.
  81001. * @result An RGBA color represented as Vector4.
  81002. */
  81003. private static fromHSBToRef;
  81004. /**
  81005. * Returns a value clamped between min and max
  81006. * @param value The value to clamp
  81007. * @param min The minimum of value
  81008. * @param max The maximum of value
  81009. * @returns The clamped value.
  81010. */
  81011. private static clamp;
  81012. /**
  81013. * Clones the current color curve instance.
  81014. * @return The cloned curves
  81015. */
  81016. clone(): ColorCurves;
  81017. /**
  81018. * Serializes the current color curve instance to a json representation.
  81019. * @return a JSON representation
  81020. */
  81021. serialize(): any;
  81022. /**
  81023. * Parses the color curve from a json representation.
  81024. * @param source the JSON source to parse
  81025. * @return The parsed curves
  81026. */
  81027. static Parse(source: any): ColorCurves;
  81028. }
  81029. }
  81030. declare module BABYLON {
  81031. /**
  81032. * Interface to follow in your material defines to integrate easily the
  81033. * Image proccessing functions.
  81034. * @hidden
  81035. */
  81036. export interface IImageProcessingConfigurationDefines {
  81037. IMAGEPROCESSING: boolean;
  81038. VIGNETTE: boolean;
  81039. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81040. VIGNETTEBLENDMODEOPAQUE: boolean;
  81041. TONEMAPPING: boolean;
  81042. TONEMAPPING_ACES: boolean;
  81043. CONTRAST: boolean;
  81044. EXPOSURE: boolean;
  81045. COLORCURVES: boolean;
  81046. COLORGRADING: boolean;
  81047. COLORGRADING3D: boolean;
  81048. SAMPLER3DGREENDEPTH: boolean;
  81049. SAMPLER3DBGRMAP: boolean;
  81050. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81051. }
  81052. /**
  81053. * @hidden
  81054. */
  81055. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  81056. IMAGEPROCESSING: boolean;
  81057. VIGNETTE: boolean;
  81058. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81059. VIGNETTEBLENDMODEOPAQUE: boolean;
  81060. TONEMAPPING: boolean;
  81061. TONEMAPPING_ACES: boolean;
  81062. CONTRAST: boolean;
  81063. COLORCURVES: boolean;
  81064. COLORGRADING: boolean;
  81065. COLORGRADING3D: boolean;
  81066. SAMPLER3DGREENDEPTH: boolean;
  81067. SAMPLER3DBGRMAP: boolean;
  81068. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81069. EXPOSURE: boolean;
  81070. constructor();
  81071. }
  81072. /**
  81073. * This groups together the common properties used for image processing either in direct forward pass
  81074. * or through post processing effect depending on the use of the image processing pipeline in your scene
  81075. * or not.
  81076. */
  81077. export class ImageProcessingConfiguration {
  81078. /**
  81079. * Default tone mapping applied in BabylonJS.
  81080. */
  81081. static readonly TONEMAPPING_STANDARD: number;
  81082. /**
  81083. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  81084. * to other engines rendering to increase portability.
  81085. */
  81086. static readonly TONEMAPPING_ACES: number;
  81087. /**
  81088. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  81089. */
  81090. colorCurves: Nullable<ColorCurves>;
  81091. private _colorCurvesEnabled;
  81092. /**
  81093. * Gets wether the color curves effect is enabled.
  81094. */
  81095. get colorCurvesEnabled(): boolean;
  81096. /**
  81097. * Sets wether the color curves effect is enabled.
  81098. */
  81099. set colorCurvesEnabled(value: boolean);
  81100. private _colorGradingTexture;
  81101. /**
  81102. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81103. */
  81104. get colorGradingTexture(): Nullable<BaseTexture>;
  81105. /**
  81106. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81107. */
  81108. set colorGradingTexture(value: Nullable<BaseTexture>);
  81109. private _colorGradingEnabled;
  81110. /**
  81111. * Gets wether the color grading effect is enabled.
  81112. */
  81113. get colorGradingEnabled(): boolean;
  81114. /**
  81115. * Sets wether the color grading effect is enabled.
  81116. */
  81117. set colorGradingEnabled(value: boolean);
  81118. private _colorGradingWithGreenDepth;
  81119. /**
  81120. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  81121. */
  81122. get colorGradingWithGreenDepth(): boolean;
  81123. /**
  81124. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  81125. */
  81126. set colorGradingWithGreenDepth(value: boolean);
  81127. private _colorGradingBGR;
  81128. /**
  81129. * Gets wether the color grading texture contains BGR values.
  81130. */
  81131. get colorGradingBGR(): boolean;
  81132. /**
  81133. * Sets wether the color grading texture contains BGR values.
  81134. */
  81135. set colorGradingBGR(value: boolean);
  81136. /** @hidden */
  81137. _exposure: number;
  81138. /**
  81139. * Gets the Exposure used in the effect.
  81140. */
  81141. get exposure(): number;
  81142. /**
  81143. * Sets the Exposure used in the effect.
  81144. */
  81145. set exposure(value: number);
  81146. private _toneMappingEnabled;
  81147. /**
  81148. * Gets wether the tone mapping effect is enabled.
  81149. */
  81150. get toneMappingEnabled(): boolean;
  81151. /**
  81152. * Sets wether the tone mapping effect is enabled.
  81153. */
  81154. set toneMappingEnabled(value: boolean);
  81155. private _toneMappingType;
  81156. /**
  81157. * Gets the type of tone mapping effect.
  81158. */
  81159. get toneMappingType(): number;
  81160. /**
  81161. * Sets the type of tone mapping effect used in BabylonJS.
  81162. */
  81163. set toneMappingType(value: number);
  81164. protected _contrast: number;
  81165. /**
  81166. * Gets the contrast used in the effect.
  81167. */
  81168. get contrast(): number;
  81169. /**
  81170. * Sets the contrast used in the effect.
  81171. */
  81172. set contrast(value: number);
  81173. /**
  81174. * Vignette stretch size.
  81175. */
  81176. vignetteStretch: number;
  81177. /**
  81178. * Vignette centre X Offset.
  81179. */
  81180. vignetteCentreX: number;
  81181. /**
  81182. * Vignette centre Y Offset.
  81183. */
  81184. vignetteCentreY: number;
  81185. /**
  81186. * Vignette weight or intensity of the vignette effect.
  81187. */
  81188. vignetteWeight: number;
  81189. /**
  81190. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  81191. * if vignetteEnabled is set to true.
  81192. */
  81193. vignetteColor: Color4;
  81194. /**
  81195. * Camera field of view used by the Vignette effect.
  81196. */
  81197. vignetteCameraFov: number;
  81198. private _vignetteBlendMode;
  81199. /**
  81200. * Gets the vignette blend mode allowing different kind of effect.
  81201. */
  81202. get vignetteBlendMode(): number;
  81203. /**
  81204. * Sets the vignette blend mode allowing different kind of effect.
  81205. */
  81206. set vignetteBlendMode(value: number);
  81207. private _vignetteEnabled;
  81208. /**
  81209. * Gets wether the vignette effect is enabled.
  81210. */
  81211. get vignetteEnabled(): boolean;
  81212. /**
  81213. * Sets wether the vignette effect is enabled.
  81214. */
  81215. set vignetteEnabled(value: boolean);
  81216. private _applyByPostProcess;
  81217. /**
  81218. * Gets wether the image processing is applied through a post process or not.
  81219. */
  81220. get applyByPostProcess(): boolean;
  81221. /**
  81222. * Sets wether the image processing is applied through a post process or not.
  81223. */
  81224. set applyByPostProcess(value: boolean);
  81225. private _isEnabled;
  81226. /**
  81227. * Gets wether the image processing is enabled or not.
  81228. */
  81229. get isEnabled(): boolean;
  81230. /**
  81231. * Sets wether the image processing is enabled or not.
  81232. */
  81233. set isEnabled(value: boolean);
  81234. /**
  81235. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  81236. */
  81237. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  81238. /**
  81239. * Method called each time the image processing information changes requires to recompile the effect.
  81240. */
  81241. protected _updateParameters(): void;
  81242. /**
  81243. * Gets the current class name.
  81244. * @return "ImageProcessingConfiguration"
  81245. */
  81246. getClassName(): string;
  81247. /**
  81248. * Prepare the list of uniforms associated with the Image Processing effects.
  81249. * @param uniforms The list of uniforms used in the effect
  81250. * @param defines the list of defines currently in use
  81251. */
  81252. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  81253. /**
  81254. * Prepare the list of samplers associated with the Image Processing effects.
  81255. * @param samplersList The list of uniforms used in the effect
  81256. * @param defines the list of defines currently in use
  81257. */
  81258. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  81259. /**
  81260. * Prepare the list of defines associated to the shader.
  81261. * @param defines the list of defines to complete
  81262. * @param forPostProcess Define if we are currently in post process mode or not
  81263. */
  81264. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  81265. /**
  81266. * Returns true if all the image processing information are ready.
  81267. * @returns True if ready, otherwise, false
  81268. */
  81269. isReady(): boolean;
  81270. /**
  81271. * Binds the image processing to the shader.
  81272. * @param effect The effect to bind to
  81273. * @param overrideAspectRatio Override the aspect ratio of the effect
  81274. */
  81275. bind(effect: Effect, overrideAspectRatio?: number): void;
  81276. /**
  81277. * Clones the current image processing instance.
  81278. * @return The cloned image processing
  81279. */
  81280. clone(): ImageProcessingConfiguration;
  81281. /**
  81282. * Serializes the current image processing instance to a json representation.
  81283. * @return a JSON representation
  81284. */
  81285. serialize(): any;
  81286. /**
  81287. * Parses the image processing from a json representation.
  81288. * @param source the JSON source to parse
  81289. * @return The parsed image processing
  81290. */
  81291. static Parse(source: any): ImageProcessingConfiguration;
  81292. private static _VIGNETTEMODE_MULTIPLY;
  81293. private static _VIGNETTEMODE_OPAQUE;
  81294. /**
  81295. * Used to apply the vignette as a mix with the pixel color.
  81296. */
  81297. static get VIGNETTEMODE_MULTIPLY(): number;
  81298. /**
  81299. * Used to apply the vignette as a replacement of the pixel color.
  81300. */
  81301. static get VIGNETTEMODE_OPAQUE(): number;
  81302. }
  81303. }
  81304. declare module BABYLON {
  81305. /** @hidden */
  81306. export var postprocessVertexShader: {
  81307. name: string;
  81308. shader: string;
  81309. };
  81310. }
  81311. declare module BABYLON {
  81312. interface ThinEngine {
  81313. /**
  81314. * Creates a new render target texture
  81315. * @param size defines the size of the texture
  81316. * @param options defines the options used to create the texture
  81317. * @returns a new render target texture stored in an InternalTexture
  81318. */
  81319. createRenderTargetTexture(size: number | {
  81320. width: number;
  81321. height: number;
  81322. layers?: number;
  81323. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  81324. /**
  81325. * Creates a depth stencil texture.
  81326. * This is only available in WebGL 2 or with the depth texture extension available.
  81327. * @param size The size of face edge in the texture.
  81328. * @param options The options defining the texture.
  81329. * @returns The texture
  81330. */
  81331. createDepthStencilTexture(size: number | {
  81332. width: number;
  81333. height: number;
  81334. layers?: number;
  81335. }, options: DepthTextureCreationOptions): InternalTexture;
  81336. /** @hidden */
  81337. _createDepthStencilTexture(size: number | {
  81338. width: number;
  81339. height: number;
  81340. layers?: number;
  81341. }, options: DepthTextureCreationOptions): InternalTexture;
  81342. }
  81343. }
  81344. declare module BABYLON {
  81345. /** Defines supported spaces */
  81346. export enum Space {
  81347. /** Local (object) space */
  81348. LOCAL = 0,
  81349. /** World space */
  81350. WORLD = 1,
  81351. /** Bone space */
  81352. BONE = 2
  81353. }
  81354. /** Defines the 3 main axes */
  81355. export class Axis {
  81356. /** X axis */
  81357. static X: Vector3;
  81358. /** Y axis */
  81359. static Y: Vector3;
  81360. /** Z axis */
  81361. static Z: Vector3;
  81362. }
  81363. }
  81364. declare module BABYLON {
  81365. /**
  81366. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  81367. * This is the base of the follow, arc rotate cameras and Free camera
  81368. * @see http://doc.babylonjs.com/features/cameras
  81369. */
  81370. export class TargetCamera extends Camera {
  81371. private static _RigCamTransformMatrix;
  81372. private static _TargetTransformMatrix;
  81373. private static _TargetFocalPoint;
  81374. /**
  81375. * Define the current direction the camera is moving to
  81376. */
  81377. cameraDirection: Vector3;
  81378. /**
  81379. * Define the current rotation the camera is rotating to
  81380. */
  81381. cameraRotation: Vector2;
  81382. /**
  81383. * When set, the up vector of the camera will be updated by the rotation of the camera
  81384. */
  81385. updateUpVectorFromRotation: boolean;
  81386. private _tmpQuaternion;
  81387. /**
  81388. * Define the current rotation of the camera
  81389. */
  81390. rotation: Vector3;
  81391. /**
  81392. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  81393. */
  81394. rotationQuaternion: Quaternion;
  81395. /**
  81396. * Define the current speed of the camera
  81397. */
  81398. speed: number;
  81399. /**
  81400. * Add constraint to the camera to prevent it to move freely in all directions and
  81401. * around all axis.
  81402. */
  81403. noRotationConstraint: boolean;
  81404. /**
  81405. * Define the current target of the camera as an object or a position.
  81406. */
  81407. lockedTarget: any;
  81408. /** @hidden */
  81409. _currentTarget: Vector3;
  81410. /** @hidden */
  81411. _initialFocalDistance: number;
  81412. /** @hidden */
  81413. _viewMatrix: Matrix;
  81414. /** @hidden */
  81415. _camMatrix: Matrix;
  81416. /** @hidden */
  81417. _cameraTransformMatrix: Matrix;
  81418. /** @hidden */
  81419. _cameraRotationMatrix: Matrix;
  81420. /** @hidden */
  81421. _referencePoint: Vector3;
  81422. /** @hidden */
  81423. _transformedReferencePoint: Vector3;
  81424. protected _globalCurrentTarget: Vector3;
  81425. protected _globalCurrentUpVector: Vector3;
  81426. /** @hidden */
  81427. _reset: () => void;
  81428. private _defaultUp;
  81429. /**
  81430. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  81431. * This is the base of the follow, arc rotate cameras and Free camera
  81432. * @see http://doc.babylonjs.com/features/cameras
  81433. * @param name Defines the name of the camera in the scene
  81434. * @param position Defines the start position of the camera in the scene
  81435. * @param scene Defines the scene the camera belongs to
  81436. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  81437. */
  81438. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  81439. /**
  81440. * Gets the position in front of the camera at a given distance.
  81441. * @param distance The distance from the camera we want the position to be
  81442. * @returns the position
  81443. */
  81444. getFrontPosition(distance: number): Vector3;
  81445. /** @hidden */
  81446. _getLockedTargetPosition(): Nullable<Vector3>;
  81447. private _storedPosition;
  81448. private _storedRotation;
  81449. private _storedRotationQuaternion;
  81450. /**
  81451. * Store current camera state of the camera (fov, position, rotation, etc..)
  81452. * @returns the camera
  81453. */
  81454. storeState(): Camera;
  81455. /**
  81456. * Restored camera state. You must call storeState() first
  81457. * @returns whether it was successful or not
  81458. * @hidden
  81459. */
  81460. _restoreStateValues(): boolean;
  81461. /** @hidden */
  81462. _initCache(): void;
  81463. /** @hidden */
  81464. _updateCache(ignoreParentClass?: boolean): void;
  81465. /** @hidden */
  81466. _isSynchronizedViewMatrix(): boolean;
  81467. /** @hidden */
  81468. _computeLocalCameraSpeed(): number;
  81469. /**
  81470. * Defines the target the camera should look at.
  81471. * @param target Defines the new target as a Vector or a mesh
  81472. */
  81473. setTarget(target: Vector3): void;
  81474. /**
  81475. * Return the current target position of the camera. This value is expressed in local space.
  81476. * @returns the target position
  81477. */
  81478. getTarget(): Vector3;
  81479. /** @hidden */
  81480. _decideIfNeedsToMove(): boolean;
  81481. /** @hidden */
  81482. _updatePosition(): void;
  81483. /** @hidden */
  81484. _checkInputs(): void;
  81485. protected _updateCameraRotationMatrix(): void;
  81486. /**
  81487. * 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)
  81488. * @returns the current camera
  81489. */
  81490. private _rotateUpVectorWithCameraRotationMatrix;
  81491. private _cachedRotationZ;
  81492. private _cachedQuaternionRotationZ;
  81493. /** @hidden */
  81494. _getViewMatrix(): Matrix;
  81495. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  81496. /**
  81497. * @hidden
  81498. */
  81499. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  81500. /**
  81501. * @hidden
  81502. */
  81503. _updateRigCameras(): void;
  81504. private _getRigCamPositionAndTarget;
  81505. /**
  81506. * Gets the current object class name.
  81507. * @return the class name
  81508. */
  81509. getClassName(): string;
  81510. }
  81511. }
  81512. declare module BABYLON {
  81513. /**
  81514. * Gather the list of keyboard event types as constants.
  81515. */
  81516. export class KeyboardEventTypes {
  81517. /**
  81518. * The keydown event is fired when a key becomes active (pressed).
  81519. */
  81520. static readonly KEYDOWN: number;
  81521. /**
  81522. * The keyup event is fired when a key has been released.
  81523. */
  81524. static readonly KEYUP: number;
  81525. }
  81526. /**
  81527. * This class is used to store keyboard related info for the onKeyboardObservable event.
  81528. */
  81529. export class KeyboardInfo {
  81530. /**
  81531. * Defines the type of event (KeyboardEventTypes)
  81532. */
  81533. type: number;
  81534. /**
  81535. * Defines the related dom event
  81536. */
  81537. event: KeyboardEvent;
  81538. /**
  81539. * Instantiates a new keyboard info.
  81540. * This class is used to store keyboard related info for the onKeyboardObservable event.
  81541. * @param type Defines the type of event (KeyboardEventTypes)
  81542. * @param event Defines the related dom event
  81543. */
  81544. constructor(
  81545. /**
  81546. * Defines the type of event (KeyboardEventTypes)
  81547. */
  81548. type: number,
  81549. /**
  81550. * Defines the related dom event
  81551. */
  81552. event: KeyboardEvent);
  81553. }
  81554. /**
  81555. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  81556. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  81557. */
  81558. export class KeyboardInfoPre extends KeyboardInfo {
  81559. /**
  81560. * Defines the type of event (KeyboardEventTypes)
  81561. */
  81562. type: number;
  81563. /**
  81564. * Defines the related dom event
  81565. */
  81566. event: KeyboardEvent;
  81567. /**
  81568. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  81569. */
  81570. skipOnPointerObservable: boolean;
  81571. /**
  81572. * Instantiates a new keyboard pre info.
  81573. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  81574. * @param type Defines the type of event (KeyboardEventTypes)
  81575. * @param event Defines the related dom event
  81576. */
  81577. constructor(
  81578. /**
  81579. * Defines the type of event (KeyboardEventTypes)
  81580. */
  81581. type: number,
  81582. /**
  81583. * Defines the related dom event
  81584. */
  81585. event: KeyboardEvent);
  81586. }
  81587. }
  81588. declare module BABYLON {
  81589. /**
  81590. * Manage the keyboard inputs to control the movement of a free camera.
  81591. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  81592. */
  81593. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  81594. /**
  81595. * Defines the camera the input is attached to.
  81596. */
  81597. camera: FreeCamera;
  81598. /**
  81599. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  81600. */
  81601. keysUp: number[];
  81602. /**
  81603. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  81604. */
  81605. keysDown: number[];
  81606. /**
  81607. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  81608. */
  81609. keysLeft: number[];
  81610. /**
  81611. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  81612. */
  81613. keysRight: number[];
  81614. private _keys;
  81615. private _onCanvasBlurObserver;
  81616. private _onKeyboardObserver;
  81617. private _engine;
  81618. private _scene;
  81619. /**
  81620. * Attach the input controls to a specific dom element to get the input from.
  81621. * @param element Defines the element the controls should be listened from
  81622. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  81623. */
  81624. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81625. /**
  81626. * Detach the current controls from the specified dom element.
  81627. * @param element Defines the element to stop listening the inputs from
  81628. */
  81629. detachControl(element: Nullable<HTMLElement>): void;
  81630. /**
  81631. * Update the current camera state depending on the inputs that have been used this frame.
  81632. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  81633. */
  81634. checkInputs(): void;
  81635. /**
  81636. * Gets the class name of the current intput.
  81637. * @returns the class name
  81638. */
  81639. getClassName(): string;
  81640. /** @hidden */
  81641. _onLostFocus(): void;
  81642. /**
  81643. * Get the friendly name associated with the input class.
  81644. * @returns the input friendly name
  81645. */
  81646. getSimpleName(): string;
  81647. }
  81648. }
  81649. declare module BABYLON {
  81650. /**
  81651. * Interface describing all the common properties and methods a shadow light needs to implement.
  81652. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  81653. * as well as binding the different shadow properties to the effects.
  81654. */
  81655. export interface IShadowLight extends Light {
  81656. /**
  81657. * The light id in the scene (used in scene.findLighById for instance)
  81658. */
  81659. id: string;
  81660. /**
  81661. * The position the shdow will be casted from.
  81662. */
  81663. position: Vector3;
  81664. /**
  81665. * In 2d mode (needCube being false), the direction used to cast the shadow.
  81666. */
  81667. direction: Vector3;
  81668. /**
  81669. * The transformed position. Position of the light in world space taking parenting in account.
  81670. */
  81671. transformedPosition: Vector3;
  81672. /**
  81673. * The transformed direction. Direction of the light in world space taking parenting in account.
  81674. */
  81675. transformedDirection: Vector3;
  81676. /**
  81677. * The friendly name of the light in the scene.
  81678. */
  81679. name: string;
  81680. /**
  81681. * Defines the shadow projection clipping minimum z value.
  81682. */
  81683. shadowMinZ: number;
  81684. /**
  81685. * Defines the shadow projection clipping maximum z value.
  81686. */
  81687. shadowMaxZ: number;
  81688. /**
  81689. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  81690. * @returns true if the information has been computed, false if it does not need to (no parenting)
  81691. */
  81692. computeTransformedInformation(): boolean;
  81693. /**
  81694. * Gets the scene the light belongs to.
  81695. * @returns The scene
  81696. */
  81697. getScene(): Scene;
  81698. /**
  81699. * Callback defining a custom Projection Matrix Builder.
  81700. * This can be used to override the default projection matrix computation.
  81701. */
  81702. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  81703. /**
  81704. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  81705. * @param matrix The materix to updated with the projection information
  81706. * @param viewMatrix The transform matrix of the light
  81707. * @param renderList The list of mesh to render in the map
  81708. * @returns The current light
  81709. */
  81710. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  81711. /**
  81712. * Gets the current depth scale used in ESM.
  81713. * @returns The scale
  81714. */
  81715. getDepthScale(): number;
  81716. /**
  81717. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  81718. * @returns true if a cube texture needs to be use
  81719. */
  81720. needCube(): boolean;
  81721. /**
  81722. * Detects if the projection matrix requires to be recomputed this frame.
  81723. * @returns true if it requires to be recomputed otherwise, false.
  81724. */
  81725. needProjectionMatrixCompute(): boolean;
  81726. /**
  81727. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  81728. */
  81729. forceProjectionMatrixCompute(): void;
  81730. /**
  81731. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  81732. * @param faceIndex The index of the face we are computed the direction to generate shadow
  81733. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  81734. */
  81735. getShadowDirection(faceIndex?: number): Vector3;
  81736. /**
  81737. * Gets the minZ used for shadow according to both the scene and the light.
  81738. * @param activeCamera The camera we are returning the min for
  81739. * @returns the depth min z
  81740. */
  81741. getDepthMinZ(activeCamera: Camera): number;
  81742. /**
  81743. * Gets the maxZ used for shadow according to both the scene and the light.
  81744. * @param activeCamera The camera we are returning the max for
  81745. * @returns the depth max z
  81746. */
  81747. getDepthMaxZ(activeCamera: Camera): number;
  81748. }
  81749. /**
  81750. * Base implementation IShadowLight
  81751. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  81752. */
  81753. export abstract class ShadowLight extends Light implements IShadowLight {
  81754. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  81755. protected _position: Vector3;
  81756. protected _setPosition(value: Vector3): void;
  81757. /**
  81758. * Sets the position the shadow will be casted from. Also use as the light position for both
  81759. * point and spot lights.
  81760. */
  81761. get position(): Vector3;
  81762. /**
  81763. * Sets the position the shadow will be casted from. Also use as the light position for both
  81764. * point and spot lights.
  81765. */
  81766. set position(value: Vector3);
  81767. protected _direction: Vector3;
  81768. protected _setDirection(value: Vector3): void;
  81769. /**
  81770. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  81771. * Also use as the light direction on spot and directional lights.
  81772. */
  81773. get direction(): Vector3;
  81774. /**
  81775. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  81776. * Also use as the light direction on spot and directional lights.
  81777. */
  81778. set direction(value: Vector3);
  81779. protected _shadowMinZ: number;
  81780. /**
  81781. * Gets the shadow projection clipping minimum z value.
  81782. */
  81783. get shadowMinZ(): number;
  81784. /**
  81785. * Sets the shadow projection clipping minimum z value.
  81786. */
  81787. set shadowMinZ(value: number);
  81788. protected _shadowMaxZ: number;
  81789. /**
  81790. * Sets the shadow projection clipping maximum z value.
  81791. */
  81792. get shadowMaxZ(): number;
  81793. /**
  81794. * Gets the shadow projection clipping maximum z value.
  81795. */
  81796. set shadowMaxZ(value: number);
  81797. /**
  81798. * Callback defining a custom Projection Matrix Builder.
  81799. * This can be used to override the default projection matrix computation.
  81800. */
  81801. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  81802. /**
  81803. * The transformed position. Position of the light in world space taking parenting in account.
  81804. */
  81805. transformedPosition: Vector3;
  81806. /**
  81807. * The transformed direction. Direction of the light in world space taking parenting in account.
  81808. */
  81809. transformedDirection: Vector3;
  81810. private _needProjectionMatrixCompute;
  81811. /**
  81812. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  81813. * @returns true if the information has been computed, false if it does not need to (no parenting)
  81814. */
  81815. computeTransformedInformation(): boolean;
  81816. /**
  81817. * Return the depth scale used for the shadow map.
  81818. * @returns the depth scale.
  81819. */
  81820. getDepthScale(): number;
  81821. /**
  81822. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  81823. * @param faceIndex The index of the face we are computed the direction to generate shadow
  81824. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  81825. */
  81826. getShadowDirection(faceIndex?: number): Vector3;
  81827. /**
  81828. * Returns the ShadowLight absolute position in the World.
  81829. * @returns the position vector in world space
  81830. */
  81831. getAbsolutePosition(): Vector3;
  81832. /**
  81833. * Sets the ShadowLight direction toward the passed target.
  81834. * @param target The point to target in local space
  81835. * @returns the updated ShadowLight direction
  81836. */
  81837. setDirectionToTarget(target: Vector3): Vector3;
  81838. /**
  81839. * Returns the light rotation in euler definition.
  81840. * @returns the x y z rotation in local space.
  81841. */
  81842. getRotation(): Vector3;
  81843. /**
  81844. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  81845. * @returns true if a cube texture needs to be use
  81846. */
  81847. needCube(): boolean;
  81848. /**
  81849. * Detects if the projection matrix requires to be recomputed this frame.
  81850. * @returns true if it requires to be recomputed otherwise, false.
  81851. */
  81852. needProjectionMatrixCompute(): boolean;
  81853. /**
  81854. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  81855. */
  81856. forceProjectionMatrixCompute(): void;
  81857. /** @hidden */
  81858. _initCache(): void;
  81859. /** @hidden */
  81860. _isSynchronized(): boolean;
  81861. /**
  81862. * Computes the world matrix of the node
  81863. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81864. * @returns the world matrix
  81865. */
  81866. computeWorldMatrix(force?: boolean): Matrix;
  81867. /**
  81868. * Gets the minZ used for shadow according to both the scene and the light.
  81869. * @param activeCamera The camera we are returning the min for
  81870. * @returns the depth min z
  81871. */
  81872. getDepthMinZ(activeCamera: Camera): number;
  81873. /**
  81874. * Gets the maxZ used for shadow according to both the scene and the light.
  81875. * @param activeCamera The camera we are returning the max for
  81876. * @returns the depth max z
  81877. */
  81878. getDepthMaxZ(activeCamera: Camera): number;
  81879. /**
  81880. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  81881. * @param matrix The materix to updated with the projection information
  81882. * @param viewMatrix The transform matrix of the light
  81883. * @param renderList The list of mesh to render in the map
  81884. * @returns The current light
  81885. */
  81886. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  81887. }
  81888. }
  81889. declare module BABYLON {
  81890. /**
  81891. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  81892. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  81893. */
  81894. export class EffectFallbacks implements IEffectFallbacks {
  81895. private _defines;
  81896. private _currentRank;
  81897. private _maxRank;
  81898. private _mesh;
  81899. /**
  81900. * Removes the fallback from the bound mesh.
  81901. */
  81902. unBindMesh(): void;
  81903. /**
  81904. * Adds a fallback on the specified property.
  81905. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  81906. * @param define The name of the define in the shader
  81907. */
  81908. addFallback(rank: number, define: string): void;
  81909. /**
  81910. * Sets the mesh to use CPU skinning when needing to fallback.
  81911. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  81912. * @param mesh The mesh to use the fallbacks.
  81913. */
  81914. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  81915. /**
  81916. * Checks to see if more fallbacks are still availible.
  81917. */
  81918. get hasMoreFallbacks(): boolean;
  81919. /**
  81920. * Removes the defines that should be removed when falling back.
  81921. * @param currentDefines defines the current define statements for the shader.
  81922. * @param effect defines the current effect we try to compile
  81923. * @returns The resulting defines with defines of the current rank removed.
  81924. */
  81925. reduce(currentDefines: string, effect: Effect): string;
  81926. }
  81927. }
  81928. declare module BABYLON {
  81929. /**
  81930. * "Static Class" containing the most commonly used helper while dealing with material for
  81931. * rendering purpose.
  81932. *
  81933. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  81934. *
  81935. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  81936. */
  81937. export class MaterialHelper {
  81938. /**
  81939. * Bind the current view position to an effect.
  81940. * @param effect The effect to be bound
  81941. * @param scene The scene the eyes position is used from
  81942. */
  81943. static BindEyePosition(effect: Effect, scene: Scene): void;
  81944. /**
  81945. * Helps preparing the defines values about the UVs in used in the effect.
  81946. * UVs are shared as much as we can accross channels in the shaders.
  81947. * @param texture The texture we are preparing the UVs for
  81948. * @param defines The defines to update
  81949. * @param key The channel key "diffuse", "specular"... used in the shader
  81950. */
  81951. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  81952. /**
  81953. * Binds a texture matrix value to its corrsponding uniform
  81954. * @param texture The texture to bind the matrix for
  81955. * @param uniformBuffer The uniform buffer receivin the data
  81956. * @param key The channel key "diffuse", "specular"... used in the shader
  81957. */
  81958. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  81959. /**
  81960. * Gets the current status of the fog (should it be enabled?)
  81961. * @param mesh defines the mesh to evaluate for fog support
  81962. * @param scene defines the hosting scene
  81963. * @returns true if fog must be enabled
  81964. */
  81965. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  81966. /**
  81967. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  81968. * @param mesh defines the current mesh
  81969. * @param scene defines the current scene
  81970. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  81971. * @param pointsCloud defines if point cloud rendering has to be turned on
  81972. * @param fogEnabled defines if fog has to be turned on
  81973. * @param alphaTest defines if alpha testing has to be turned on
  81974. * @param defines defines the current list of defines
  81975. */
  81976. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  81977. /**
  81978. * Helper used to prepare the list of defines associated with frame values for shader compilation
  81979. * @param scene defines the current scene
  81980. * @param engine defines the current engine
  81981. * @param defines specifies the list of active defines
  81982. * @param useInstances defines if instances have to be turned on
  81983. * @param useClipPlane defines if clip plane have to be turned on
  81984. */
  81985. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  81986. /**
  81987. * Prepares the defines for bones
  81988. * @param mesh The mesh containing the geometry data we will draw
  81989. * @param defines The defines to update
  81990. */
  81991. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  81992. /**
  81993. * Prepares the defines for morph targets
  81994. * @param mesh The mesh containing the geometry data we will draw
  81995. * @param defines The defines to update
  81996. */
  81997. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  81998. /**
  81999. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  82000. * @param mesh The mesh containing the geometry data we will draw
  82001. * @param defines The defines to update
  82002. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  82003. * @param useBones Precise whether bones should be used or not (override mesh info)
  82004. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  82005. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  82006. * @returns false if defines are considered not dirty and have not been checked
  82007. */
  82008. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  82009. /**
  82010. * Prepares the defines related to multiview
  82011. * @param scene The scene we are intending to draw
  82012. * @param defines The defines to update
  82013. */
  82014. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  82015. /**
  82016. * Prepares the defines related to the light information passed in parameter
  82017. * @param scene The scene we are intending to draw
  82018. * @param mesh The mesh the effect is compiling for
  82019. * @param light The light the effect is compiling for
  82020. * @param lightIndex The index of the light
  82021. * @param defines The defines to update
  82022. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82023. * @param state Defines the current state regarding what is needed (normals, etc...)
  82024. */
  82025. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  82026. needNormals: boolean;
  82027. needRebuild: boolean;
  82028. shadowEnabled: boolean;
  82029. specularEnabled: boolean;
  82030. lightmapMode: boolean;
  82031. }): void;
  82032. /**
  82033. * Prepares the defines related to the light information passed in parameter
  82034. * @param scene The scene we are intending to draw
  82035. * @param mesh The mesh the effect is compiling for
  82036. * @param defines The defines to update
  82037. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82038. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  82039. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  82040. * @returns true if normals will be required for the rest of the effect
  82041. */
  82042. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  82043. /**
  82044. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  82045. * @param lightIndex defines the light index
  82046. * @param uniformsList The uniform list
  82047. * @param samplersList The sampler list
  82048. * @param projectedLightTexture defines if projected texture must be used
  82049. * @param uniformBuffersList defines an optional list of uniform buffers
  82050. */
  82051. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  82052. /**
  82053. * Prepares the uniforms and samplers list to be used in the effect
  82054. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  82055. * @param samplersList The sampler list
  82056. * @param defines The defines helping in the list generation
  82057. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  82058. */
  82059. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  82060. /**
  82061. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  82062. * @param defines The defines to update while falling back
  82063. * @param fallbacks The authorized effect fallbacks
  82064. * @param maxSimultaneousLights The maximum number of lights allowed
  82065. * @param rank the current rank of the Effect
  82066. * @returns The newly affected rank
  82067. */
  82068. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  82069. private static _TmpMorphInfluencers;
  82070. /**
  82071. * Prepares the list of attributes required for morph targets according to the effect defines.
  82072. * @param attribs The current list of supported attribs
  82073. * @param mesh The mesh to prepare the morph targets attributes for
  82074. * @param influencers The number of influencers
  82075. */
  82076. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  82077. /**
  82078. * Prepares the list of attributes required for morph targets according to the effect defines.
  82079. * @param attribs The current list of supported attribs
  82080. * @param mesh The mesh to prepare the morph targets attributes for
  82081. * @param defines The current Defines of the effect
  82082. */
  82083. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  82084. /**
  82085. * Prepares the list of attributes required for bones according to the effect defines.
  82086. * @param attribs The current list of supported attribs
  82087. * @param mesh The mesh to prepare the bones attributes for
  82088. * @param defines The current Defines of the effect
  82089. * @param fallbacks The current efffect fallback strategy
  82090. */
  82091. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  82092. /**
  82093. * Check and prepare the list of attributes required for instances according to the effect defines.
  82094. * @param attribs The current list of supported attribs
  82095. * @param defines The current MaterialDefines of the effect
  82096. */
  82097. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  82098. /**
  82099. * Add the list of attributes required for instances to the attribs array.
  82100. * @param attribs The current list of supported attribs
  82101. */
  82102. static PushAttributesForInstances(attribs: string[]): void;
  82103. /**
  82104. * Binds the light information to the effect.
  82105. * @param light The light containing the generator
  82106. * @param effect The effect we are binding the data to
  82107. * @param lightIndex The light index in the effect used to render
  82108. */
  82109. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  82110. /**
  82111. * Binds the lights information from the scene to the effect for the given mesh.
  82112. * @param light Light to bind
  82113. * @param lightIndex Light index
  82114. * @param scene The scene where the light belongs to
  82115. * @param effect The effect we are binding the data to
  82116. * @param useSpecular Defines if specular is supported
  82117. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82118. */
  82119. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  82120. /**
  82121. * Binds the lights information from the scene to the effect for the given mesh.
  82122. * @param scene The scene the lights belongs to
  82123. * @param mesh The mesh we are binding the information to render
  82124. * @param effect The effect we are binding the data to
  82125. * @param defines The generated defines for the effect
  82126. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  82127. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82128. */
  82129. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  82130. private static _tempFogColor;
  82131. /**
  82132. * Binds the fog information from the scene to the effect for the given mesh.
  82133. * @param scene The scene the lights belongs to
  82134. * @param mesh The mesh we are binding the information to render
  82135. * @param effect The effect we are binding the data to
  82136. * @param linearSpace Defines if the fog effect is applied in linear space
  82137. */
  82138. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  82139. /**
  82140. * Binds the bones information from the mesh to the effect.
  82141. * @param mesh The mesh we are binding the information to render
  82142. * @param effect The effect we are binding the data to
  82143. */
  82144. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  82145. /**
  82146. * Binds the morph targets information from the mesh to the effect.
  82147. * @param abstractMesh The mesh we are binding the information to render
  82148. * @param effect The effect we are binding the data to
  82149. */
  82150. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  82151. /**
  82152. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  82153. * @param defines The generated defines used in the effect
  82154. * @param effect The effect we are binding the data to
  82155. * @param scene The scene we are willing to render with logarithmic scale for
  82156. */
  82157. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  82158. /**
  82159. * Binds the clip plane information from the scene to the effect.
  82160. * @param scene The scene the clip plane information are extracted from
  82161. * @param effect The effect we are binding the data to
  82162. */
  82163. static BindClipPlane(effect: Effect, scene: Scene): void;
  82164. }
  82165. }
  82166. declare module BABYLON {
  82167. /** @hidden */
  82168. export var packingFunctions: {
  82169. name: string;
  82170. shader: string;
  82171. };
  82172. }
  82173. declare module BABYLON {
  82174. /** @hidden */
  82175. export var clipPlaneFragmentDeclaration: {
  82176. name: string;
  82177. shader: string;
  82178. };
  82179. }
  82180. declare module BABYLON {
  82181. /** @hidden */
  82182. export var clipPlaneFragment: {
  82183. name: string;
  82184. shader: string;
  82185. };
  82186. }
  82187. declare module BABYLON {
  82188. /** @hidden */
  82189. export var shadowMapPixelShader: {
  82190. name: string;
  82191. shader: string;
  82192. };
  82193. }
  82194. declare module BABYLON {
  82195. /** @hidden */
  82196. export var bonesDeclaration: {
  82197. name: string;
  82198. shader: string;
  82199. };
  82200. }
  82201. declare module BABYLON {
  82202. /** @hidden */
  82203. export var morphTargetsVertexGlobalDeclaration: {
  82204. name: string;
  82205. shader: string;
  82206. };
  82207. }
  82208. declare module BABYLON {
  82209. /** @hidden */
  82210. export var morphTargetsVertexDeclaration: {
  82211. name: string;
  82212. shader: string;
  82213. };
  82214. }
  82215. declare module BABYLON {
  82216. /** @hidden */
  82217. export var instancesDeclaration: {
  82218. name: string;
  82219. shader: string;
  82220. };
  82221. }
  82222. declare module BABYLON {
  82223. /** @hidden */
  82224. export var helperFunctions: {
  82225. name: string;
  82226. shader: string;
  82227. };
  82228. }
  82229. declare module BABYLON {
  82230. /** @hidden */
  82231. export var clipPlaneVertexDeclaration: {
  82232. name: string;
  82233. shader: string;
  82234. };
  82235. }
  82236. declare module BABYLON {
  82237. /** @hidden */
  82238. export var morphTargetsVertex: {
  82239. name: string;
  82240. shader: string;
  82241. };
  82242. }
  82243. declare module BABYLON {
  82244. /** @hidden */
  82245. export var instancesVertex: {
  82246. name: string;
  82247. shader: string;
  82248. };
  82249. }
  82250. declare module BABYLON {
  82251. /** @hidden */
  82252. export var bonesVertex: {
  82253. name: string;
  82254. shader: string;
  82255. };
  82256. }
  82257. declare module BABYLON {
  82258. /** @hidden */
  82259. export var clipPlaneVertex: {
  82260. name: string;
  82261. shader: string;
  82262. };
  82263. }
  82264. declare module BABYLON {
  82265. /** @hidden */
  82266. export var shadowMapVertexShader: {
  82267. name: string;
  82268. shader: string;
  82269. };
  82270. }
  82271. declare module BABYLON {
  82272. /** @hidden */
  82273. export var depthBoxBlurPixelShader: {
  82274. name: string;
  82275. shader: string;
  82276. };
  82277. }
  82278. declare module BABYLON {
  82279. /**
  82280. * Defines the options associated with the creation of a custom shader for a shadow generator.
  82281. */
  82282. export interface ICustomShaderOptions {
  82283. /**
  82284. * Gets or sets the custom shader name to use
  82285. */
  82286. shaderName: string;
  82287. /**
  82288. * The list of attribute names used in the shader
  82289. */
  82290. attributes?: string[];
  82291. /**
  82292. * The list of unifrom names used in the shader
  82293. */
  82294. uniforms?: string[];
  82295. /**
  82296. * The list of sampler names used in the shader
  82297. */
  82298. samplers?: string[];
  82299. /**
  82300. * The list of defines used in the shader
  82301. */
  82302. defines?: string[];
  82303. }
  82304. /**
  82305. * Interface to implement to create a shadow generator compatible with BJS.
  82306. */
  82307. export interface IShadowGenerator {
  82308. /**
  82309. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  82310. * @returns The render target texture if present otherwise, null
  82311. */
  82312. getShadowMap(): Nullable<RenderTargetTexture>;
  82313. /**
  82314. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  82315. * @param subMesh The submesh we want to render in the shadow map
  82316. * @param useInstances Defines wether will draw in the map using instances
  82317. * @returns true if ready otherwise, false
  82318. */
  82319. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  82320. /**
  82321. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  82322. * @param defines Defines of the material we want to update
  82323. * @param lightIndex Index of the light in the enabled light list of the material
  82324. */
  82325. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  82326. /**
  82327. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  82328. * defined in the generator but impacting the effect).
  82329. * It implies the unifroms available on the materials are the standard BJS ones.
  82330. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  82331. * @param effect The effect we are binfing the information for
  82332. */
  82333. bindShadowLight(lightIndex: string, effect: Effect): void;
  82334. /**
  82335. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  82336. * (eq to shadow prjection matrix * light transform matrix)
  82337. * @returns The transform matrix used to create the shadow map
  82338. */
  82339. getTransformMatrix(): Matrix;
  82340. /**
  82341. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  82342. * Cube and 2D textures for instance.
  82343. */
  82344. recreateShadowMap(): void;
  82345. /**
  82346. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  82347. * @param onCompiled Callback triggered at the and of the effects compilation
  82348. * @param options Sets of optional options forcing the compilation with different modes
  82349. */
  82350. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  82351. useInstances: boolean;
  82352. }>): void;
  82353. /**
  82354. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  82355. * @param options Sets of optional options forcing the compilation with different modes
  82356. * @returns A promise that resolves when the compilation completes
  82357. */
  82358. forceCompilationAsync(options?: Partial<{
  82359. useInstances: boolean;
  82360. }>): Promise<void>;
  82361. /**
  82362. * Serializes the shadow generator setup to a json object.
  82363. * @returns The serialized JSON object
  82364. */
  82365. serialize(): any;
  82366. /**
  82367. * Disposes the Shadow map and related Textures and effects.
  82368. */
  82369. dispose(): void;
  82370. }
  82371. /**
  82372. * Default implementation IShadowGenerator.
  82373. * This is the main object responsible of generating shadows in the framework.
  82374. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  82375. */
  82376. export class ShadowGenerator implements IShadowGenerator {
  82377. /**
  82378. * Name of the shadow generator class
  82379. */
  82380. static CLASSNAME: string;
  82381. /**
  82382. * Shadow generator mode None: no filtering applied.
  82383. */
  82384. static readonly FILTER_NONE: number;
  82385. /**
  82386. * Shadow generator mode ESM: Exponential Shadow Mapping.
  82387. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  82388. */
  82389. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  82390. /**
  82391. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  82392. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  82393. */
  82394. static readonly FILTER_POISSONSAMPLING: number;
  82395. /**
  82396. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  82397. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  82398. */
  82399. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  82400. /**
  82401. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  82402. * edge artifacts on steep falloff.
  82403. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  82404. */
  82405. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  82406. /**
  82407. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  82408. * edge artifacts on steep falloff.
  82409. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  82410. */
  82411. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  82412. /**
  82413. * Shadow generator mode PCF: Percentage Closer Filtering
  82414. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  82415. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  82416. */
  82417. static readonly FILTER_PCF: number;
  82418. /**
  82419. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  82420. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  82421. * Contact Hardening
  82422. */
  82423. static readonly FILTER_PCSS: number;
  82424. /**
  82425. * Reserved for PCF and PCSS
  82426. * Highest Quality.
  82427. *
  82428. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  82429. *
  82430. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  82431. */
  82432. static readonly QUALITY_HIGH: number;
  82433. /**
  82434. * Reserved for PCF and PCSS
  82435. * Good tradeoff for quality/perf cross devices
  82436. *
  82437. * Execute PCF on a 3*3 kernel.
  82438. *
  82439. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  82440. */
  82441. static readonly QUALITY_MEDIUM: number;
  82442. /**
  82443. * Reserved for PCF and PCSS
  82444. * The lowest quality but the fastest.
  82445. *
  82446. * Execute PCF on a 1*1 kernel.
  82447. *
  82448. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  82449. */
  82450. static readonly QUALITY_LOW: number;
  82451. /** Gets or sets the custom shader name to use */
  82452. customShaderOptions: ICustomShaderOptions;
  82453. /**
  82454. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  82455. */
  82456. onBeforeShadowMapRenderObservable: Observable<Effect>;
  82457. /**
  82458. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  82459. */
  82460. onAfterShadowMapRenderObservable: Observable<Effect>;
  82461. /**
  82462. * Observable triggered before a mesh is rendered in the shadow map.
  82463. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  82464. */
  82465. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  82466. /**
  82467. * Observable triggered after a mesh is rendered in the shadow map.
  82468. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  82469. */
  82470. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  82471. protected _bias: number;
  82472. /**
  82473. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  82474. */
  82475. get bias(): number;
  82476. /**
  82477. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  82478. */
  82479. set bias(bias: number);
  82480. protected _normalBias: number;
  82481. /**
  82482. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  82483. */
  82484. get normalBias(): number;
  82485. /**
  82486. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  82487. */
  82488. set normalBias(normalBias: number);
  82489. protected _blurBoxOffset: number;
  82490. /**
  82491. * Gets the blur box offset: offset applied during the blur pass.
  82492. * Only useful if useKernelBlur = false
  82493. */
  82494. get blurBoxOffset(): number;
  82495. /**
  82496. * Sets the blur box offset: offset applied during the blur pass.
  82497. * Only useful if useKernelBlur = false
  82498. */
  82499. set blurBoxOffset(value: number);
  82500. protected _blurScale: number;
  82501. /**
  82502. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  82503. * 2 means half of the size.
  82504. */
  82505. get blurScale(): number;
  82506. /**
  82507. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  82508. * 2 means half of the size.
  82509. */
  82510. set blurScale(value: number);
  82511. protected _blurKernel: number;
  82512. /**
  82513. * Gets the blur kernel: kernel size of the blur pass.
  82514. * Only useful if useKernelBlur = true
  82515. */
  82516. get blurKernel(): number;
  82517. /**
  82518. * Sets the blur kernel: kernel size of the blur pass.
  82519. * Only useful if useKernelBlur = true
  82520. */
  82521. set blurKernel(value: number);
  82522. protected _useKernelBlur: boolean;
  82523. /**
  82524. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  82525. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  82526. */
  82527. get useKernelBlur(): boolean;
  82528. /**
  82529. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  82530. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  82531. */
  82532. set useKernelBlur(value: boolean);
  82533. protected _depthScale: number;
  82534. /**
  82535. * Gets the depth scale used in ESM mode.
  82536. */
  82537. get depthScale(): number;
  82538. /**
  82539. * Sets the depth scale used in ESM mode.
  82540. * This can override the scale stored on the light.
  82541. */
  82542. set depthScale(value: number);
  82543. protected _validateFilter(filter: number): number;
  82544. protected _filter: number;
  82545. /**
  82546. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  82547. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  82548. */
  82549. get filter(): number;
  82550. /**
  82551. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  82552. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  82553. */
  82554. set filter(value: number);
  82555. /**
  82556. * Gets if the current filter is set to Poisson Sampling.
  82557. */
  82558. get usePoissonSampling(): boolean;
  82559. /**
  82560. * Sets the current filter to Poisson Sampling.
  82561. */
  82562. set usePoissonSampling(value: boolean);
  82563. /**
  82564. * Gets if the current filter is set to ESM.
  82565. */
  82566. get useExponentialShadowMap(): boolean;
  82567. /**
  82568. * Sets the current filter is to ESM.
  82569. */
  82570. set useExponentialShadowMap(value: boolean);
  82571. /**
  82572. * Gets if the current filter is set to filtered ESM.
  82573. */
  82574. get useBlurExponentialShadowMap(): boolean;
  82575. /**
  82576. * Gets if the current filter is set to filtered ESM.
  82577. */
  82578. set useBlurExponentialShadowMap(value: boolean);
  82579. /**
  82580. * Gets if the current filter is set to "close ESM" (using the inverse of the
  82581. * exponential to prevent steep falloff artifacts).
  82582. */
  82583. get useCloseExponentialShadowMap(): boolean;
  82584. /**
  82585. * Sets the current filter to "close ESM" (using the inverse of the
  82586. * exponential to prevent steep falloff artifacts).
  82587. */
  82588. set useCloseExponentialShadowMap(value: boolean);
  82589. /**
  82590. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  82591. * exponential to prevent steep falloff artifacts).
  82592. */
  82593. get useBlurCloseExponentialShadowMap(): boolean;
  82594. /**
  82595. * Sets the current filter to filtered "close ESM" (using the inverse of the
  82596. * exponential to prevent steep falloff artifacts).
  82597. */
  82598. set useBlurCloseExponentialShadowMap(value: boolean);
  82599. /**
  82600. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  82601. */
  82602. get usePercentageCloserFiltering(): boolean;
  82603. /**
  82604. * Sets the current filter to "PCF" (percentage closer filtering).
  82605. */
  82606. set usePercentageCloserFiltering(value: boolean);
  82607. protected _filteringQuality: number;
  82608. /**
  82609. * Gets the PCF or PCSS Quality.
  82610. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  82611. */
  82612. get filteringQuality(): number;
  82613. /**
  82614. * Sets the PCF or PCSS Quality.
  82615. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  82616. */
  82617. set filteringQuality(filteringQuality: number);
  82618. /**
  82619. * Gets if the current filter is set to "PCSS" (contact hardening).
  82620. */
  82621. get useContactHardeningShadow(): boolean;
  82622. /**
  82623. * Sets the current filter to "PCSS" (contact hardening).
  82624. */
  82625. set useContactHardeningShadow(value: boolean);
  82626. protected _contactHardeningLightSizeUVRatio: number;
  82627. /**
  82628. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  82629. * Using a ratio helps keeping shape stability independently of the map size.
  82630. *
  82631. * It does not account for the light projection as it was having too much
  82632. * instability during the light setup or during light position changes.
  82633. *
  82634. * Only valid if useContactHardeningShadow is true.
  82635. */
  82636. get contactHardeningLightSizeUVRatio(): number;
  82637. /**
  82638. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  82639. * Using a ratio helps keeping shape stability independently of the map size.
  82640. *
  82641. * It does not account for the light projection as it was having too much
  82642. * instability during the light setup or during light position changes.
  82643. *
  82644. * Only valid if useContactHardeningShadow is true.
  82645. */
  82646. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  82647. protected _darkness: number;
  82648. /** Gets or sets the actual darkness of a shadow */
  82649. get darkness(): number;
  82650. set darkness(value: number);
  82651. /**
  82652. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  82653. * 0 means strongest and 1 would means no shadow.
  82654. * @returns the darkness.
  82655. */
  82656. getDarkness(): number;
  82657. /**
  82658. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  82659. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  82660. * @returns the shadow generator allowing fluent coding.
  82661. */
  82662. setDarkness(darkness: number): ShadowGenerator;
  82663. protected _transparencyShadow: boolean;
  82664. /** Gets or sets the ability to have transparent shadow */
  82665. get transparencyShadow(): boolean;
  82666. set transparencyShadow(value: boolean);
  82667. /**
  82668. * Sets the ability to have transparent shadow (boolean).
  82669. * @param transparent True if transparent else False
  82670. * @returns the shadow generator allowing fluent coding
  82671. */
  82672. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  82673. protected _shadowMap: Nullable<RenderTargetTexture>;
  82674. protected _shadowMap2: Nullable<RenderTargetTexture>;
  82675. /**
  82676. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  82677. * @returns The render target texture if present otherwise, null
  82678. */
  82679. getShadowMap(): Nullable<RenderTargetTexture>;
  82680. /**
  82681. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  82682. * @returns The render target texture if the shadow map is present otherwise, null
  82683. */
  82684. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  82685. /**
  82686. * Gets the class name of that object
  82687. * @returns "ShadowGenerator"
  82688. */
  82689. getClassName(): string;
  82690. /**
  82691. * Helper function to add a mesh and its descendants to the list of shadow casters.
  82692. * @param mesh Mesh to add
  82693. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  82694. * @returns the Shadow Generator itself
  82695. */
  82696. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  82697. /**
  82698. * Helper function to remove a mesh and its descendants from the list of shadow casters
  82699. * @param mesh Mesh to remove
  82700. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  82701. * @returns the Shadow Generator itself
  82702. */
  82703. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  82704. /**
  82705. * Controls the extent to which the shadows fade out at the edge of the frustum
  82706. */
  82707. frustumEdgeFalloff: number;
  82708. protected _light: IShadowLight;
  82709. /**
  82710. * Returns the associated light object.
  82711. * @returns the light generating the shadow
  82712. */
  82713. getLight(): IShadowLight;
  82714. /**
  82715. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  82716. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  82717. * It might on the other hand introduce peter panning.
  82718. */
  82719. forceBackFacesOnly: boolean;
  82720. protected _scene: Scene;
  82721. protected _lightDirection: Vector3;
  82722. protected _effect: Effect;
  82723. protected _viewMatrix: Matrix;
  82724. protected _projectionMatrix: Matrix;
  82725. protected _transformMatrix: Matrix;
  82726. protected _cachedPosition: Vector3;
  82727. protected _cachedDirection: Vector3;
  82728. protected _cachedDefines: string;
  82729. protected _currentRenderID: number;
  82730. protected _boxBlurPostprocess: Nullable<PostProcess>;
  82731. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  82732. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  82733. protected _blurPostProcesses: PostProcess[];
  82734. protected _mapSize: number;
  82735. protected _currentFaceIndex: number;
  82736. protected _currentFaceIndexCache: number;
  82737. protected _textureType: number;
  82738. protected _defaultTextureMatrix: Matrix;
  82739. protected _storedUniqueId: Nullable<number>;
  82740. /** @hidden */
  82741. static _SceneComponentInitialization: (scene: Scene) => void;
  82742. /**
  82743. * Creates a ShadowGenerator object.
  82744. * A ShadowGenerator is the required tool to use the shadows.
  82745. * Each light casting shadows needs to use its own ShadowGenerator.
  82746. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  82747. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  82748. * @param light The light object generating the shadows.
  82749. * @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.
  82750. */
  82751. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  82752. protected _initializeGenerator(): void;
  82753. protected _createTargetRenderTexture(): void;
  82754. protected _initializeShadowMap(): void;
  82755. protected _initializeBlurRTTAndPostProcesses(): void;
  82756. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  82757. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  82758. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  82759. protected _applyFilterValues(): void;
  82760. /**
  82761. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  82762. * @param onCompiled Callback triggered at the and of the effects compilation
  82763. * @param options Sets of optional options forcing the compilation with different modes
  82764. */
  82765. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  82766. useInstances: boolean;
  82767. }>): void;
  82768. /**
  82769. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  82770. * @param options Sets of optional options forcing the compilation with different modes
  82771. * @returns A promise that resolves when the compilation completes
  82772. */
  82773. forceCompilationAsync(options?: Partial<{
  82774. useInstances: boolean;
  82775. }>): Promise<void>;
  82776. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  82777. /**
  82778. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  82779. * @param subMesh The submesh we want to render in the shadow map
  82780. * @param useInstances Defines wether will draw in the map using instances
  82781. * @returns true if ready otherwise, false
  82782. */
  82783. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  82784. /**
  82785. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  82786. * @param defines Defines of the material we want to update
  82787. * @param lightIndex Index of the light in the enabled light list of the material
  82788. */
  82789. prepareDefines(defines: any, lightIndex: number): void;
  82790. /**
  82791. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  82792. * defined in the generator but impacting the effect).
  82793. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  82794. * @param effect The effect we are binfing the information for
  82795. */
  82796. bindShadowLight(lightIndex: string, effect: Effect): void;
  82797. /**
  82798. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  82799. * (eq to shadow prjection matrix * light transform matrix)
  82800. * @returns The transform matrix used to create the shadow map
  82801. */
  82802. getTransformMatrix(): Matrix;
  82803. /**
  82804. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  82805. * Cube and 2D textures for instance.
  82806. */
  82807. recreateShadowMap(): void;
  82808. protected _disposeBlurPostProcesses(): void;
  82809. protected _disposeRTTandPostProcesses(): void;
  82810. /**
  82811. * Disposes the ShadowGenerator.
  82812. * Returns nothing.
  82813. */
  82814. dispose(): void;
  82815. /**
  82816. * Serializes the shadow generator setup to a json object.
  82817. * @returns The serialized JSON object
  82818. */
  82819. serialize(): any;
  82820. /**
  82821. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  82822. * @param parsedShadowGenerator The JSON object to parse
  82823. * @param scene The scene to create the shadow map for
  82824. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  82825. * @returns The parsed shadow generator
  82826. */
  82827. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  82828. }
  82829. }
  82830. declare module BABYLON {
  82831. /**
  82832. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  82833. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  82834. * 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.
  82835. */
  82836. export abstract class Light extends Node {
  82837. /**
  82838. * Falloff Default: light is falling off following the material specification:
  82839. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  82840. */
  82841. static readonly FALLOFF_DEFAULT: number;
  82842. /**
  82843. * Falloff Physical: light is falling off following the inverse squared distance law.
  82844. */
  82845. static readonly FALLOFF_PHYSICAL: number;
  82846. /**
  82847. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  82848. * to enhance interoperability with other engines.
  82849. */
  82850. static readonly FALLOFF_GLTF: number;
  82851. /**
  82852. * Falloff Standard: light is falling off like in the standard material
  82853. * to enhance interoperability with other materials.
  82854. */
  82855. static readonly FALLOFF_STANDARD: number;
  82856. /**
  82857. * If every light affecting the material is in this lightmapMode,
  82858. * material.lightmapTexture adds or multiplies
  82859. * (depends on material.useLightmapAsShadowmap)
  82860. * after every other light calculations.
  82861. */
  82862. static readonly LIGHTMAP_DEFAULT: number;
  82863. /**
  82864. * material.lightmapTexture as only diffuse lighting from this light
  82865. * adds only specular lighting from this light
  82866. * adds dynamic shadows
  82867. */
  82868. static readonly LIGHTMAP_SPECULAR: number;
  82869. /**
  82870. * material.lightmapTexture as only lighting
  82871. * no light calculation from this light
  82872. * only adds dynamic shadows from this light
  82873. */
  82874. static readonly LIGHTMAP_SHADOWSONLY: number;
  82875. /**
  82876. * Each light type uses the default quantity according to its type:
  82877. * point/spot lights use luminous intensity
  82878. * directional lights use illuminance
  82879. */
  82880. static readonly INTENSITYMODE_AUTOMATIC: number;
  82881. /**
  82882. * lumen (lm)
  82883. */
  82884. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  82885. /**
  82886. * candela (lm/sr)
  82887. */
  82888. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  82889. /**
  82890. * lux (lm/m^2)
  82891. */
  82892. static readonly INTENSITYMODE_ILLUMINANCE: number;
  82893. /**
  82894. * nit (cd/m^2)
  82895. */
  82896. static readonly INTENSITYMODE_LUMINANCE: number;
  82897. /**
  82898. * Light type const id of the point light.
  82899. */
  82900. static readonly LIGHTTYPEID_POINTLIGHT: number;
  82901. /**
  82902. * Light type const id of the directional light.
  82903. */
  82904. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  82905. /**
  82906. * Light type const id of the spot light.
  82907. */
  82908. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  82909. /**
  82910. * Light type const id of the hemispheric light.
  82911. */
  82912. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  82913. /**
  82914. * Diffuse gives the basic color to an object.
  82915. */
  82916. diffuse: Color3;
  82917. /**
  82918. * Specular produces a highlight color on an object.
  82919. * Note: This is note affecting PBR materials.
  82920. */
  82921. specular: Color3;
  82922. /**
  82923. * Defines the falloff type for this light. This lets overrriding how punctual light are
  82924. * falling off base on range or angle.
  82925. * This can be set to any values in Light.FALLOFF_x.
  82926. *
  82927. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  82928. * other types of materials.
  82929. */
  82930. falloffType: number;
  82931. /**
  82932. * Strength of the light.
  82933. * Note: By default it is define in the framework own unit.
  82934. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  82935. */
  82936. intensity: number;
  82937. private _range;
  82938. protected _inverseSquaredRange: number;
  82939. /**
  82940. * Defines how far from the source the light is impacting in scene units.
  82941. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  82942. */
  82943. get range(): number;
  82944. /**
  82945. * Defines how far from the source the light is impacting in scene units.
  82946. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  82947. */
  82948. set range(value: number);
  82949. /**
  82950. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  82951. * of light.
  82952. */
  82953. private _photometricScale;
  82954. private _intensityMode;
  82955. /**
  82956. * Gets the photometric scale used to interpret the intensity.
  82957. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  82958. */
  82959. get intensityMode(): number;
  82960. /**
  82961. * Sets the photometric scale used to interpret the intensity.
  82962. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  82963. */
  82964. set intensityMode(value: number);
  82965. private _radius;
  82966. /**
  82967. * Gets the light radius used by PBR Materials to simulate soft area lights.
  82968. */
  82969. get radius(): number;
  82970. /**
  82971. * sets the light radius used by PBR Materials to simulate soft area lights.
  82972. */
  82973. set radius(value: number);
  82974. private _renderPriority;
  82975. /**
  82976. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  82977. * exceeding the number allowed of the materials.
  82978. */
  82979. renderPriority: number;
  82980. private _shadowEnabled;
  82981. /**
  82982. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  82983. * the current shadow generator.
  82984. */
  82985. get shadowEnabled(): boolean;
  82986. /**
  82987. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  82988. * the current shadow generator.
  82989. */
  82990. set shadowEnabled(value: boolean);
  82991. private _includedOnlyMeshes;
  82992. /**
  82993. * Gets the only meshes impacted by this light.
  82994. */
  82995. get includedOnlyMeshes(): AbstractMesh[];
  82996. /**
  82997. * Sets the only meshes impacted by this light.
  82998. */
  82999. set includedOnlyMeshes(value: AbstractMesh[]);
  83000. private _excludedMeshes;
  83001. /**
  83002. * Gets the meshes not impacted by this light.
  83003. */
  83004. get excludedMeshes(): AbstractMesh[];
  83005. /**
  83006. * Sets the meshes not impacted by this light.
  83007. */
  83008. set excludedMeshes(value: AbstractMesh[]);
  83009. private _excludeWithLayerMask;
  83010. /**
  83011. * Gets the layer id use to find what meshes are not impacted by the light.
  83012. * Inactive if 0
  83013. */
  83014. get excludeWithLayerMask(): number;
  83015. /**
  83016. * Sets the layer id use to find what meshes are not impacted by the light.
  83017. * Inactive if 0
  83018. */
  83019. set excludeWithLayerMask(value: number);
  83020. private _includeOnlyWithLayerMask;
  83021. /**
  83022. * Gets the layer id use to find what meshes are impacted by the light.
  83023. * Inactive if 0
  83024. */
  83025. get includeOnlyWithLayerMask(): number;
  83026. /**
  83027. * Sets the layer id use to find what meshes are impacted by the light.
  83028. * Inactive if 0
  83029. */
  83030. set includeOnlyWithLayerMask(value: number);
  83031. private _lightmapMode;
  83032. /**
  83033. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  83034. */
  83035. get lightmapMode(): number;
  83036. /**
  83037. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  83038. */
  83039. set lightmapMode(value: number);
  83040. /**
  83041. * Shadow generator associted to the light.
  83042. * @hidden Internal use only.
  83043. */
  83044. _shadowGenerator: Nullable<IShadowGenerator>;
  83045. /**
  83046. * @hidden Internal use only.
  83047. */
  83048. _excludedMeshesIds: string[];
  83049. /**
  83050. * @hidden Internal use only.
  83051. */
  83052. _includedOnlyMeshesIds: string[];
  83053. /**
  83054. * The current light unifom buffer.
  83055. * @hidden Internal use only.
  83056. */
  83057. _uniformBuffer: UniformBuffer;
  83058. /** @hidden */
  83059. _renderId: number;
  83060. /**
  83061. * Creates a Light object in the scene.
  83062. * Documentation : https://doc.babylonjs.com/babylon101/lights
  83063. * @param name The firendly name of the light
  83064. * @param scene The scene the light belongs too
  83065. */
  83066. constructor(name: string, scene: Scene);
  83067. protected abstract _buildUniformLayout(): void;
  83068. /**
  83069. * Sets the passed Effect "effect" with the Light information.
  83070. * @param effect The effect to update
  83071. * @param lightIndex The index of the light in the effect to update
  83072. * @returns The light
  83073. */
  83074. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  83075. /**
  83076. * Sets the passed Effect "effect" with the Light textures.
  83077. * @param effect The effect to update
  83078. * @param lightIndex The index of the light in the effect to update
  83079. * @returns The light
  83080. */
  83081. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  83082. /**
  83083. * Binds the lights information from the scene to the effect for the given mesh.
  83084. * @param lightIndex Light index
  83085. * @param scene The scene where the light belongs to
  83086. * @param effect The effect we are binding the data to
  83087. * @param useSpecular Defines if specular is supported
  83088. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  83089. */
  83090. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  83091. /**
  83092. * Sets the passed Effect "effect" with the Light information.
  83093. * @param effect The effect to update
  83094. * @param lightDataUniformName The uniform used to store light data (position or direction)
  83095. * @returns The light
  83096. */
  83097. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  83098. /**
  83099. * Returns the string "Light".
  83100. * @returns the class name
  83101. */
  83102. getClassName(): string;
  83103. /** @hidden */
  83104. readonly _isLight: boolean;
  83105. /**
  83106. * Converts the light information to a readable string for debug purpose.
  83107. * @param fullDetails Supports for multiple levels of logging within scene loading
  83108. * @returns the human readable light info
  83109. */
  83110. toString(fullDetails?: boolean): string;
  83111. /** @hidden */
  83112. protected _syncParentEnabledState(): void;
  83113. /**
  83114. * Set the enabled state of this node.
  83115. * @param value - the new enabled state
  83116. */
  83117. setEnabled(value: boolean): void;
  83118. /**
  83119. * Returns the Light associated shadow generator if any.
  83120. * @return the associated shadow generator.
  83121. */
  83122. getShadowGenerator(): Nullable<IShadowGenerator>;
  83123. /**
  83124. * Returns a Vector3, the absolute light position in the World.
  83125. * @returns the world space position of the light
  83126. */
  83127. getAbsolutePosition(): Vector3;
  83128. /**
  83129. * Specifies if the light will affect the passed mesh.
  83130. * @param mesh The mesh to test against the light
  83131. * @return true the mesh is affected otherwise, false.
  83132. */
  83133. canAffectMesh(mesh: AbstractMesh): boolean;
  83134. /**
  83135. * Sort function to order lights for rendering.
  83136. * @param a First Light object to compare to second.
  83137. * @param b Second Light object to compare first.
  83138. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  83139. */
  83140. static CompareLightsPriority(a: Light, b: Light): number;
  83141. /**
  83142. * Releases resources associated with this node.
  83143. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83144. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83145. */
  83146. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83147. /**
  83148. * Returns the light type ID (integer).
  83149. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  83150. */
  83151. getTypeID(): number;
  83152. /**
  83153. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  83154. * @returns the scaled intensity in intensity mode unit
  83155. */
  83156. getScaledIntensity(): number;
  83157. /**
  83158. * Returns a new Light object, named "name", from the current one.
  83159. * @param name The name of the cloned light
  83160. * @returns the new created light
  83161. */
  83162. clone(name: string): Nullable<Light>;
  83163. /**
  83164. * Serializes the current light into a Serialization object.
  83165. * @returns the serialized object.
  83166. */
  83167. serialize(): any;
  83168. /**
  83169. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  83170. * This new light is named "name" and added to the passed scene.
  83171. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  83172. * @param name The friendly name of the light
  83173. * @param scene The scene the new light will belong to
  83174. * @returns the constructor function
  83175. */
  83176. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  83177. /**
  83178. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  83179. * @param parsedLight The JSON representation of the light
  83180. * @param scene The scene to create the parsed light in
  83181. * @returns the created light after parsing
  83182. */
  83183. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  83184. private _hookArrayForExcluded;
  83185. private _hookArrayForIncludedOnly;
  83186. private _resyncMeshes;
  83187. /**
  83188. * Forces the meshes to update their light related information in their rendering used effects
  83189. * @hidden Internal Use Only
  83190. */
  83191. _markMeshesAsLightDirty(): void;
  83192. /**
  83193. * Recomputes the cached photometric scale if needed.
  83194. */
  83195. private _computePhotometricScale;
  83196. /**
  83197. * Returns the Photometric Scale according to the light type and intensity mode.
  83198. */
  83199. private _getPhotometricScale;
  83200. /**
  83201. * Reorder the light in the scene according to their defined priority.
  83202. * @hidden Internal Use Only
  83203. */
  83204. _reorderLightsInScene(): void;
  83205. /**
  83206. * Prepares the list of defines specific to the light type.
  83207. * @param defines the list of defines
  83208. * @param lightIndex defines the index of the light for the effect
  83209. */
  83210. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  83211. }
  83212. }
  83213. declare module BABYLON {
  83214. /**
  83215. * Interface used to define Action
  83216. */
  83217. export interface IAction {
  83218. /**
  83219. * Trigger for the action
  83220. */
  83221. trigger: number;
  83222. /** Options of the trigger */
  83223. triggerOptions: any;
  83224. /**
  83225. * Gets the trigger parameters
  83226. * @returns the trigger parameters
  83227. */
  83228. getTriggerParameter(): any;
  83229. /**
  83230. * Internal only - executes current action event
  83231. * @hidden
  83232. */
  83233. _executeCurrent(evt?: ActionEvent): void;
  83234. /**
  83235. * Serialize placeholder for child classes
  83236. * @param parent of child
  83237. * @returns the serialized object
  83238. */
  83239. serialize(parent: any): any;
  83240. /**
  83241. * Internal only
  83242. * @hidden
  83243. */
  83244. _prepare(): void;
  83245. /**
  83246. * Internal only - manager for action
  83247. * @hidden
  83248. */
  83249. _actionManager: AbstractActionManager;
  83250. /**
  83251. * Adds action to chain of actions, may be a DoNothingAction
  83252. * @param action defines the next action to execute
  83253. * @returns The action passed in
  83254. * @see https://www.babylonjs-playground.com/#1T30HR#0
  83255. */
  83256. then(action: IAction): IAction;
  83257. }
  83258. /**
  83259. * The action to be carried out following a trigger
  83260. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  83261. */
  83262. export class Action implements IAction {
  83263. /** the trigger, with or without parameters, for the action */
  83264. triggerOptions: any;
  83265. /**
  83266. * Trigger for the action
  83267. */
  83268. trigger: number;
  83269. /**
  83270. * Internal only - manager for action
  83271. * @hidden
  83272. */
  83273. _actionManager: ActionManager;
  83274. private _nextActiveAction;
  83275. private _child;
  83276. private _condition?;
  83277. private _triggerParameter;
  83278. /**
  83279. * An event triggered prior to action being executed.
  83280. */
  83281. onBeforeExecuteObservable: Observable<Action>;
  83282. /**
  83283. * Creates a new Action
  83284. * @param triggerOptions the trigger, with or without parameters, for the action
  83285. * @param condition an optional determinant of action
  83286. */
  83287. constructor(
  83288. /** the trigger, with or without parameters, for the action */
  83289. triggerOptions: any, condition?: Condition);
  83290. /**
  83291. * Internal only
  83292. * @hidden
  83293. */
  83294. _prepare(): void;
  83295. /**
  83296. * Gets the trigger parameters
  83297. * @returns the trigger parameters
  83298. */
  83299. getTriggerParameter(): any;
  83300. /**
  83301. * Internal only - executes current action event
  83302. * @hidden
  83303. */
  83304. _executeCurrent(evt?: ActionEvent): void;
  83305. /**
  83306. * Execute placeholder for child classes
  83307. * @param evt optional action event
  83308. */
  83309. execute(evt?: ActionEvent): void;
  83310. /**
  83311. * Skips to next active action
  83312. */
  83313. skipToNextActiveAction(): void;
  83314. /**
  83315. * Adds action to chain of actions, may be a DoNothingAction
  83316. * @param action defines the next action to execute
  83317. * @returns The action passed in
  83318. * @see https://www.babylonjs-playground.com/#1T30HR#0
  83319. */
  83320. then(action: Action): Action;
  83321. /**
  83322. * Internal only
  83323. * @hidden
  83324. */
  83325. _getProperty(propertyPath: string): string;
  83326. /**
  83327. * Internal only
  83328. * @hidden
  83329. */
  83330. _getEffectiveTarget(target: any, propertyPath: string): any;
  83331. /**
  83332. * Serialize placeholder for child classes
  83333. * @param parent of child
  83334. * @returns the serialized object
  83335. */
  83336. serialize(parent: any): any;
  83337. /**
  83338. * Internal only called by serialize
  83339. * @hidden
  83340. */
  83341. protected _serialize(serializedAction: any, parent?: any): any;
  83342. /**
  83343. * Internal only
  83344. * @hidden
  83345. */
  83346. static _SerializeValueAsString: (value: any) => string;
  83347. /**
  83348. * Internal only
  83349. * @hidden
  83350. */
  83351. static _GetTargetProperty: (target: Node | Scene) => {
  83352. name: string;
  83353. targetType: string;
  83354. value: string;
  83355. };
  83356. }
  83357. }
  83358. declare module BABYLON {
  83359. /**
  83360. * A Condition applied to an Action
  83361. */
  83362. export class Condition {
  83363. /**
  83364. * Internal only - manager for action
  83365. * @hidden
  83366. */
  83367. _actionManager: ActionManager;
  83368. /**
  83369. * Internal only
  83370. * @hidden
  83371. */
  83372. _evaluationId: number;
  83373. /**
  83374. * Internal only
  83375. * @hidden
  83376. */
  83377. _currentResult: boolean;
  83378. /**
  83379. * Creates a new Condition
  83380. * @param actionManager the manager of the action the condition is applied to
  83381. */
  83382. constructor(actionManager: ActionManager);
  83383. /**
  83384. * Check if the current condition is valid
  83385. * @returns a boolean
  83386. */
  83387. isValid(): boolean;
  83388. /**
  83389. * Internal only
  83390. * @hidden
  83391. */
  83392. _getProperty(propertyPath: string): string;
  83393. /**
  83394. * Internal only
  83395. * @hidden
  83396. */
  83397. _getEffectiveTarget(target: any, propertyPath: string): any;
  83398. /**
  83399. * Serialize placeholder for child classes
  83400. * @returns the serialized object
  83401. */
  83402. serialize(): any;
  83403. /**
  83404. * Internal only
  83405. * @hidden
  83406. */
  83407. protected _serialize(serializedCondition: any): any;
  83408. }
  83409. /**
  83410. * Defines specific conditional operators as extensions of Condition
  83411. */
  83412. export class ValueCondition extends Condition {
  83413. /** path to specify the property of the target the conditional operator uses */
  83414. propertyPath: string;
  83415. /** the value compared by the conditional operator against the current value of the property */
  83416. value: any;
  83417. /** the conditional operator, default ValueCondition.IsEqual */
  83418. operator: number;
  83419. /**
  83420. * Internal only
  83421. * @hidden
  83422. */
  83423. private static _IsEqual;
  83424. /**
  83425. * Internal only
  83426. * @hidden
  83427. */
  83428. private static _IsDifferent;
  83429. /**
  83430. * Internal only
  83431. * @hidden
  83432. */
  83433. private static _IsGreater;
  83434. /**
  83435. * Internal only
  83436. * @hidden
  83437. */
  83438. private static _IsLesser;
  83439. /**
  83440. * returns the number for IsEqual
  83441. */
  83442. static get IsEqual(): number;
  83443. /**
  83444. * Returns the number for IsDifferent
  83445. */
  83446. static get IsDifferent(): number;
  83447. /**
  83448. * Returns the number for IsGreater
  83449. */
  83450. static get IsGreater(): number;
  83451. /**
  83452. * Returns the number for IsLesser
  83453. */
  83454. static get IsLesser(): number;
  83455. /**
  83456. * Internal only The action manager for the condition
  83457. * @hidden
  83458. */
  83459. _actionManager: ActionManager;
  83460. /**
  83461. * Internal only
  83462. * @hidden
  83463. */
  83464. private _target;
  83465. /**
  83466. * Internal only
  83467. * @hidden
  83468. */
  83469. private _effectiveTarget;
  83470. /**
  83471. * Internal only
  83472. * @hidden
  83473. */
  83474. private _property;
  83475. /**
  83476. * Creates a new ValueCondition
  83477. * @param actionManager manager for the action the condition applies to
  83478. * @param target for the action
  83479. * @param propertyPath path to specify the property of the target the conditional operator uses
  83480. * @param value the value compared by the conditional operator against the current value of the property
  83481. * @param operator the conditional operator, default ValueCondition.IsEqual
  83482. */
  83483. constructor(actionManager: ActionManager, target: any,
  83484. /** path to specify the property of the target the conditional operator uses */
  83485. propertyPath: string,
  83486. /** the value compared by the conditional operator against the current value of the property */
  83487. value: any,
  83488. /** the conditional operator, default ValueCondition.IsEqual */
  83489. operator?: number);
  83490. /**
  83491. * Compares the given value with the property value for the specified conditional operator
  83492. * @returns the result of the comparison
  83493. */
  83494. isValid(): boolean;
  83495. /**
  83496. * Serialize the ValueCondition into a JSON compatible object
  83497. * @returns serialization object
  83498. */
  83499. serialize(): any;
  83500. /**
  83501. * Gets the name of the conditional operator for the ValueCondition
  83502. * @param operator the conditional operator
  83503. * @returns the name
  83504. */
  83505. static GetOperatorName(operator: number): string;
  83506. }
  83507. /**
  83508. * Defines a predicate condition as an extension of Condition
  83509. */
  83510. export class PredicateCondition extends Condition {
  83511. /** defines the predicate function used to validate the condition */
  83512. predicate: () => boolean;
  83513. /**
  83514. * Internal only - manager for action
  83515. * @hidden
  83516. */
  83517. _actionManager: ActionManager;
  83518. /**
  83519. * Creates a new PredicateCondition
  83520. * @param actionManager manager for the action the condition applies to
  83521. * @param predicate defines the predicate function used to validate the condition
  83522. */
  83523. constructor(actionManager: ActionManager,
  83524. /** defines the predicate function used to validate the condition */
  83525. predicate: () => boolean);
  83526. /**
  83527. * @returns the validity of the predicate condition
  83528. */
  83529. isValid(): boolean;
  83530. }
  83531. /**
  83532. * Defines a state condition as an extension of Condition
  83533. */
  83534. export class StateCondition extends Condition {
  83535. /** Value to compare with target state */
  83536. value: string;
  83537. /**
  83538. * Internal only - manager for action
  83539. * @hidden
  83540. */
  83541. _actionManager: ActionManager;
  83542. /**
  83543. * Internal only
  83544. * @hidden
  83545. */
  83546. private _target;
  83547. /**
  83548. * Creates a new StateCondition
  83549. * @param actionManager manager for the action the condition applies to
  83550. * @param target of the condition
  83551. * @param value to compare with target state
  83552. */
  83553. constructor(actionManager: ActionManager, target: any,
  83554. /** Value to compare with target state */
  83555. value: string);
  83556. /**
  83557. * Gets a boolean indicating if the current condition is met
  83558. * @returns the validity of the state
  83559. */
  83560. isValid(): boolean;
  83561. /**
  83562. * Serialize the StateCondition into a JSON compatible object
  83563. * @returns serialization object
  83564. */
  83565. serialize(): any;
  83566. }
  83567. }
  83568. declare module BABYLON {
  83569. /**
  83570. * This defines an action responsible to toggle a boolean once triggered.
  83571. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83572. */
  83573. export class SwitchBooleanAction extends Action {
  83574. /**
  83575. * The path to the boolean property in the target object
  83576. */
  83577. propertyPath: string;
  83578. private _target;
  83579. private _effectiveTarget;
  83580. private _property;
  83581. /**
  83582. * Instantiate the action
  83583. * @param triggerOptions defines the trigger options
  83584. * @param target defines the object containing the boolean
  83585. * @param propertyPath defines the path to the boolean property in the target object
  83586. * @param condition defines the trigger related conditions
  83587. */
  83588. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  83589. /** @hidden */
  83590. _prepare(): void;
  83591. /**
  83592. * Execute the action toggle the boolean value.
  83593. */
  83594. execute(): void;
  83595. /**
  83596. * Serializes the actions and its related information.
  83597. * @param parent defines the object to serialize in
  83598. * @returns the serialized object
  83599. */
  83600. serialize(parent: any): any;
  83601. }
  83602. /**
  83603. * This defines an action responsible to set a the state field of the target
  83604. * to a desired value once triggered.
  83605. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83606. */
  83607. export class SetStateAction extends Action {
  83608. /**
  83609. * The value to store in the state field.
  83610. */
  83611. value: string;
  83612. private _target;
  83613. /**
  83614. * Instantiate the action
  83615. * @param triggerOptions defines the trigger options
  83616. * @param target defines the object containing the state property
  83617. * @param value defines the value to store in the state field
  83618. * @param condition defines the trigger related conditions
  83619. */
  83620. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  83621. /**
  83622. * Execute the action and store the value on the target state property.
  83623. */
  83624. execute(): void;
  83625. /**
  83626. * Serializes the actions and its related information.
  83627. * @param parent defines the object to serialize in
  83628. * @returns the serialized object
  83629. */
  83630. serialize(parent: any): any;
  83631. }
  83632. /**
  83633. * This defines an action responsible to set a property of the target
  83634. * to a desired value once triggered.
  83635. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83636. */
  83637. export class SetValueAction extends Action {
  83638. /**
  83639. * The path of the property to set in the target.
  83640. */
  83641. propertyPath: string;
  83642. /**
  83643. * The value to set in the property
  83644. */
  83645. value: any;
  83646. private _target;
  83647. private _effectiveTarget;
  83648. private _property;
  83649. /**
  83650. * Instantiate the action
  83651. * @param triggerOptions defines the trigger options
  83652. * @param target defines the object containing the property
  83653. * @param propertyPath defines the path of the property to set in the target
  83654. * @param value defines the value to set in the property
  83655. * @param condition defines the trigger related conditions
  83656. */
  83657. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  83658. /** @hidden */
  83659. _prepare(): void;
  83660. /**
  83661. * Execute the action and set the targetted property to the desired value.
  83662. */
  83663. execute(): void;
  83664. /**
  83665. * Serializes the actions and its related information.
  83666. * @param parent defines the object to serialize in
  83667. * @returns the serialized object
  83668. */
  83669. serialize(parent: any): any;
  83670. }
  83671. /**
  83672. * This defines an action responsible to increment the target value
  83673. * to a desired value once triggered.
  83674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83675. */
  83676. export class IncrementValueAction extends Action {
  83677. /**
  83678. * The path of the property to increment in the target.
  83679. */
  83680. propertyPath: string;
  83681. /**
  83682. * The value we should increment the property by.
  83683. */
  83684. value: any;
  83685. private _target;
  83686. private _effectiveTarget;
  83687. private _property;
  83688. /**
  83689. * Instantiate the action
  83690. * @param triggerOptions defines the trigger options
  83691. * @param target defines the object containing the property
  83692. * @param propertyPath defines the path of the property to increment in the target
  83693. * @param value defines the value value we should increment the property by
  83694. * @param condition defines the trigger related conditions
  83695. */
  83696. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  83697. /** @hidden */
  83698. _prepare(): void;
  83699. /**
  83700. * Execute the action and increment the target of the value amount.
  83701. */
  83702. execute(): void;
  83703. /**
  83704. * Serializes the actions and its related information.
  83705. * @param parent defines the object to serialize in
  83706. * @returns the serialized object
  83707. */
  83708. serialize(parent: any): any;
  83709. }
  83710. /**
  83711. * This defines an action responsible to start an animation once triggered.
  83712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83713. */
  83714. export class PlayAnimationAction extends Action {
  83715. /**
  83716. * Where the animation should start (animation frame)
  83717. */
  83718. from: number;
  83719. /**
  83720. * Where the animation should stop (animation frame)
  83721. */
  83722. to: number;
  83723. /**
  83724. * Define if the animation should loop or stop after the first play.
  83725. */
  83726. loop?: boolean;
  83727. private _target;
  83728. /**
  83729. * Instantiate the action
  83730. * @param triggerOptions defines the trigger options
  83731. * @param target defines the target animation or animation name
  83732. * @param from defines from where the animation should start (animation frame)
  83733. * @param end defines where the animation should stop (animation frame)
  83734. * @param loop defines if the animation should loop or stop after the first play
  83735. * @param condition defines the trigger related conditions
  83736. */
  83737. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  83738. /** @hidden */
  83739. _prepare(): void;
  83740. /**
  83741. * Execute the action and play the animation.
  83742. */
  83743. execute(): void;
  83744. /**
  83745. * Serializes the actions and its related information.
  83746. * @param parent defines the object to serialize in
  83747. * @returns the serialized object
  83748. */
  83749. serialize(parent: any): any;
  83750. }
  83751. /**
  83752. * This defines an action responsible to stop an animation once triggered.
  83753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83754. */
  83755. export class StopAnimationAction extends Action {
  83756. private _target;
  83757. /**
  83758. * Instantiate the action
  83759. * @param triggerOptions defines the trigger options
  83760. * @param target defines the target animation or animation name
  83761. * @param condition defines the trigger related conditions
  83762. */
  83763. constructor(triggerOptions: any, target: any, condition?: Condition);
  83764. /** @hidden */
  83765. _prepare(): void;
  83766. /**
  83767. * Execute the action and stop the animation.
  83768. */
  83769. execute(): void;
  83770. /**
  83771. * Serializes the actions and its related information.
  83772. * @param parent defines the object to serialize in
  83773. * @returns the serialized object
  83774. */
  83775. serialize(parent: any): any;
  83776. }
  83777. /**
  83778. * This defines an action responsible that does nothing once triggered.
  83779. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83780. */
  83781. export class DoNothingAction extends Action {
  83782. /**
  83783. * Instantiate the action
  83784. * @param triggerOptions defines the trigger options
  83785. * @param condition defines the trigger related conditions
  83786. */
  83787. constructor(triggerOptions?: any, condition?: Condition);
  83788. /**
  83789. * Execute the action and do nothing.
  83790. */
  83791. execute(): void;
  83792. /**
  83793. * Serializes the actions and its related information.
  83794. * @param parent defines the object to serialize in
  83795. * @returns the serialized object
  83796. */
  83797. serialize(parent: any): any;
  83798. }
  83799. /**
  83800. * This defines an action responsible to trigger several actions once triggered.
  83801. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83802. */
  83803. export class CombineAction extends Action {
  83804. /**
  83805. * The list of aggregated animations to run.
  83806. */
  83807. children: Action[];
  83808. /**
  83809. * Instantiate the action
  83810. * @param triggerOptions defines the trigger options
  83811. * @param children defines the list of aggregated animations to run
  83812. * @param condition defines the trigger related conditions
  83813. */
  83814. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  83815. /** @hidden */
  83816. _prepare(): void;
  83817. /**
  83818. * Execute the action and executes all the aggregated actions.
  83819. */
  83820. execute(evt: ActionEvent): void;
  83821. /**
  83822. * Serializes the actions and its related information.
  83823. * @param parent defines the object to serialize in
  83824. * @returns the serialized object
  83825. */
  83826. serialize(parent: any): any;
  83827. }
  83828. /**
  83829. * This defines an action responsible to run code (external event) once triggered.
  83830. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83831. */
  83832. export class ExecuteCodeAction extends Action {
  83833. /**
  83834. * The callback function to run.
  83835. */
  83836. func: (evt: ActionEvent) => void;
  83837. /**
  83838. * Instantiate the action
  83839. * @param triggerOptions defines the trigger options
  83840. * @param func defines the callback function to run
  83841. * @param condition defines the trigger related conditions
  83842. */
  83843. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  83844. /**
  83845. * Execute the action and run the attached code.
  83846. */
  83847. execute(evt: ActionEvent): void;
  83848. }
  83849. /**
  83850. * This defines an action responsible to set the parent property of the target once triggered.
  83851. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83852. */
  83853. export class SetParentAction extends Action {
  83854. private _parent;
  83855. private _target;
  83856. /**
  83857. * Instantiate the action
  83858. * @param triggerOptions defines the trigger options
  83859. * @param target defines the target containing the parent property
  83860. * @param parent defines from where the animation should start (animation frame)
  83861. * @param condition defines the trigger related conditions
  83862. */
  83863. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  83864. /** @hidden */
  83865. _prepare(): void;
  83866. /**
  83867. * Execute the action and set the parent property.
  83868. */
  83869. execute(): void;
  83870. /**
  83871. * Serializes the actions and its related information.
  83872. * @param parent defines the object to serialize in
  83873. * @returns the serialized object
  83874. */
  83875. serialize(parent: any): any;
  83876. }
  83877. }
  83878. declare module BABYLON {
  83879. /**
  83880. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  83881. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  83882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83883. */
  83884. export class ActionManager extends AbstractActionManager {
  83885. /**
  83886. * Nothing
  83887. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83888. */
  83889. static readonly NothingTrigger: number;
  83890. /**
  83891. * On pick
  83892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83893. */
  83894. static readonly OnPickTrigger: number;
  83895. /**
  83896. * On left pick
  83897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83898. */
  83899. static readonly OnLeftPickTrigger: number;
  83900. /**
  83901. * On right pick
  83902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83903. */
  83904. static readonly OnRightPickTrigger: number;
  83905. /**
  83906. * On center pick
  83907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83908. */
  83909. static readonly OnCenterPickTrigger: number;
  83910. /**
  83911. * On pick down
  83912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83913. */
  83914. static readonly OnPickDownTrigger: number;
  83915. /**
  83916. * On double pick
  83917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83918. */
  83919. static readonly OnDoublePickTrigger: number;
  83920. /**
  83921. * On pick up
  83922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83923. */
  83924. static readonly OnPickUpTrigger: number;
  83925. /**
  83926. * On pick out.
  83927. * This trigger will only be raised if you also declared a OnPickDown
  83928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83929. */
  83930. static readonly OnPickOutTrigger: number;
  83931. /**
  83932. * On long press
  83933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83934. */
  83935. static readonly OnLongPressTrigger: number;
  83936. /**
  83937. * On pointer over
  83938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83939. */
  83940. static readonly OnPointerOverTrigger: number;
  83941. /**
  83942. * On pointer out
  83943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83944. */
  83945. static readonly OnPointerOutTrigger: number;
  83946. /**
  83947. * On every frame
  83948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83949. */
  83950. static readonly OnEveryFrameTrigger: number;
  83951. /**
  83952. * On intersection enter
  83953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83954. */
  83955. static readonly OnIntersectionEnterTrigger: number;
  83956. /**
  83957. * On intersection exit
  83958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83959. */
  83960. static readonly OnIntersectionExitTrigger: number;
  83961. /**
  83962. * On key down
  83963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83964. */
  83965. static readonly OnKeyDownTrigger: number;
  83966. /**
  83967. * On key up
  83968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  83969. */
  83970. static readonly OnKeyUpTrigger: number;
  83971. private _scene;
  83972. /**
  83973. * Creates a new action manager
  83974. * @param scene defines the hosting scene
  83975. */
  83976. constructor(scene: Scene);
  83977. /**
  83978. * Releases all associated resources
  83979. */
  83980. dispose(): void;
  83981. /**
  83982. * Gets hosting scene
  83983. * @returns the hosting scene
  83984. */
  83985. getScene(): Scene;
  83986. /**
  83987. * Does this action manager handles actions of any of the given triggers
  83988. * @param triggers defines the triggers to be tested
  83989. * @return a boolean indicating whether one (or more) of the triggers is handled
  83990. */
  83991. hasSpecificTriggers(triggers: number[]): boolean;
  83992. /**
  83993. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  83994. * speed.
  83995. * @param triggerA defines the trigger to be tested
  83996. * @param triggerB defines the trigger to be tested
  83997. * @return a boolean indicating whether one (or more) of the triggers is handled
  83998. */
  83999. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  84000. /**
  84001. * Does this action manager handles actions of a given trigger
  84002. * @param trigger defines the trigger to be tested
  84003. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  84004. * @return whether the trigger is handled
  84005. */
  84006. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  84007. /**
  84008. * Does this action manager has pointer triggers
  84009. */
  84010. get hasPointerTriggers(): boolean;
  84011. /**
  84012. * Does this action manager has pick triggers
  84013. */
  84014. get hasPickTriggers(): boolean;
  84015. /**
  84016. * Registers an action to this action manager
  84017. * @param action defines the action to be registered
  84018. * @return the action amended (prepared) after registration
  84019. */
  84020. registerAction(action: IAction): Nullable<IAction>;
  84021. /**
  84022. * Unregisters an action to this action manager
  84023. * @param action defines the action to be unregistered
  84024. * @return a boolean indicating whether the action has been unregistered
  84025. */
  84026. unregisterAction(action: IAction): Boolean;
  84027. /**
  84028. * Process a specific trigger
  84029. * @param trigger defines the trigger to process
  84030. * @param evt defines the event details to be processed
  84031. */
  84032. processTrigger(trigger: number, evt?: IActionEvent): void;
  84033. /** @hidden */
  84034. _getEffectiveTarget(target: any, propertyPath: string): any;
  84035. /** @hidden */
  84036. _getProperty(propertyPath: string): string;
  84037. /**
  84038. * Serialize this manager to a JSON object
  84039. * @param name defines the property name to store this manager
  84040. * @returns a JSON representation of this manager
  84041. */
  84042. serialize(name: string): any;
  84043. /**
  84044. * Creates a new ActionManager from a JSON data
  84045. * @param parsedActions defines the JSON data to read from
  84046. * @param object defines the hosting mesh
  84047. * @param scene defines the hosting scene
  84048. */
  84049. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  84050. /**
  84051. * Get a trigger name by index
  84052. * @param trigger defines the trigger index
  84053. * @returns a trigger name
  84054. */
  84055. static GetTriggerName(trigger: number): string;
  84056. }
  84057. }
  84058. declare module BABYLON {
  84059. /**
  84060. * Class representing a ray with position and direction
  84061. */
  84062. export class Ray {
  84063. /** origin point */
  84064. origin: Vector3;
  84065. /** direction */
  84066. direction: Vector3;
  84067. /** length of the ray */
  84068. length: number;
  84069. private static readonly TmpVector3;
  84070. private _tmpRay;
  84071. /**
  84072. * Creates a new ray
  84073. * @param origin origin point
  84074. * @param direction direction
  84075. * @param length length of the ray
  84076. */
  84077. constructor(
  84078. /** origin point */
  84079. origin: Vector3,
  84080. /** direction */
  84081. direction: Vector3,
  84082. /** length of the ray */
  84083. length?: number);
  84084. /**
  84085. * Checks if the ray intersects a box
  84086. * @param minimum bound of the box
  84087. * @param maximum bound of the box
  84088. * @param intersectionTreshold extra extend to be added to the box in all direction
  84089. * @returns if the box was hit
  84090. */
  84091. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  84092. /**
  84093. * Checks if the ray intersects a box
  84094. * @param box the bounding box to check
  84095. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  84096. * @returns if the box was hit
  84097. */
  84098. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  84099. /**
  84100. * If the ray hits a sphere
  84101. * @param sphere the bounding sphere to check
  84102. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  84103. * @returns true if it hits the sphere
  84104. */
  84105. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  84106. /**
  84107. * If the ray hits a triange
  84108. * @param vertex0 triangle vertex
  84109. * @param vertex1 triangle vertex
  84110. * @param vertex2 triangle vertex
  84111. * @returns intersection information if hit
  84112. */
  84113. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  84114. /**
  84115. * Checks if ray intersects a plane
  84116. * @param plane the plane to check
  84117. * @returns the distance away it was hit
  84118. */
  84119. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  84120. /**
  84121. * Calculate the intercept of a ray on a given axis
  84122. * @param axis to check 'x' | 'y' | 'z'
  84123. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  84124. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  84125. */
  84126. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  84127. /**
  84128. * Checks if ray intersects a mesh
  84129. * @param mesh the mesh to check
  84130. * @param fastCheck if only the bounding box should checked
  84131. * @returns picking info of the intersecton
  84132. */
  84133. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  84134. /**
  84135. * Checks if ray intersects a mesh
  84136. * @param meshes the meshes to check
  84137. * @param fastCheck if only the bounding box should checked
  84138. * @param results array to store result in
  84139. * @returns Array of picking infos
  84140. */
  84141. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  84142. private _comparePickingInfo;
  84143. private static smallnum;
  84144. private static rayl;
  84145. /**
  84146. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  84147. * @param sega the first point of the segment to test the intersection against
  84148. * @param segb the second point of the segment to test the intersection against
  84149. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  84150. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  84151. */
  84152. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  84153. /**
  84154. * Update the ray from viewport position
  84155. * @param x position
  84156. * @param y y position
  84157. * @param viewportWidth viewport width
  84158. * @param viewportHeight viewport height
  84159. * @param world world matrix
  84160. * @param view view matrix
  84161. * @param projection projection matrix
  84162. * @returns this ray updated
  84163. */
  84164. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  84165. /**
  84166. * Creates a ray with origin and direction of 0,0,0
  84167. * @returns the new ray
  84168. */
  84169. static Zero(): Ray;
  84170. /**
  84171. * Creates a new ray from screen space and viewport
  84172. * @param x position
  84173. * @param y y position
  84174. * @param viewportWidth viewport width
  84175. * @param viewportHeight viewport height
  84176. * @param world world matrix
  84177. * @param view view matrix
  84178. * @param projection projection matrix
  84179. * @returns new ray
  84180. */
  84181. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  84182. /**
  84183. * 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
  84184. * transformed to the given world matrix.
  84185. * @param origin The origin point
  84186. * @param end The end point
  84187. * @param world a matrix to transform the ray to. Default is the identity matrix.
  84188. * @returns the new ray
  84189. */
  84190. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  84191. /**
  84192. * Transforms a ray by a matrix
  84193. * @param ray ray to transform
  84194. * @param matrix matrix to apply
  84195. * @returns the resulting new ray
  84196. */
  84197. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  84198. /**
  84199. * Transforms a ray by a matrix
  84200. * @param ray ray to transform
  84201. * @param matrix matrix to apply
  84202. * @param result ray to store result in
  84203. */
  84204. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  84205. /**
  84206. * Unproject a ray from screen space to object space
  84207. * @param sourceX defines the screen space x coordinate to use
  84208. * @param sourceY defines the screen space y coordinate to use
  84209. * @param viewportWidth defines the current width of the viewport
  84210. * @param viewportHeight defines the current height of the viewport
  84211. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  84212. * @param view defines the view matrix to use
  84213. * @param projection defines the projection matrix to use
  84214. */
  84215. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  84216. }
  84217. /**
  84218. * Type used to define predicate used to select faces when a mesh intersection is detected
  84219. */
  84220. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  84221. interface Scene {
  84222. /** @hidden */
  84223. _tempPickingRay: Nullable<Ray>;
  84224. /** @hidden */
  84225. _cachedRayForTransform: Ray;
  84226. /** @hidden */
  84227. _pickWithRayInverseMatrix: Matrix;
  84228. /** @hidden */
  84229. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  84230. /** @hidden */
  84231. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  84232. }
  84233. }
  84234. declare module BABYLON {
  84235. /**
  84236. * Groups all the scene component constants in one place to ease maintenance.
  84237. * @hidden
  84238. */
  84239. export class SceneComponentConstants {
  84240. static readonly NAME_EFFECTLAYER: string;
  84241. static readonly NAME_LAYER: string;
  84242. static readonly NAME_LENSFLARESYSTEM: string;
  84243. static readonly NAME_BOUNDINGBOXRENDERER: string;
  84244. static readonly NAME_PARTICLESYSTEM: string;
  84245. static readonly NAME_GAMEPAD: string;
  84246. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  84247. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  84248. static readonly NAME_DEPTHRENDERER: string;
  84249. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  84250. static readonly NAME_SPRITE: string;
  84251. static readonly NAME_OUTLINERENDERER: string;
  84252. static readonly NAME_PROCEDURALTEXTURE: string;
  84253. static readonly NAME_SHADOWGENERATOR: string;
  84254. static readonly NAME_OCTREE: string;
  84255. static readonly NAME_PHYSICSENGINE: string;
  84256. static readonly NAME_AUDIO: string;
  84257. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  84258. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  84259. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  84260. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  84261. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  84262. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  84263. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  84264. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  84265. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  84266. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  84267. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  84268. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  84269. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  84270. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  84271. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  84272. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  84273. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  84274. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  84275. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  84276. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  84277. static readonly STEP_AFTERRENDER_AUDIO: number;
  84278. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  84279. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  84280. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  84281. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  84282. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  84283. static readonly STEP_POINTERMOVE_SPRITE: number;
  84284. static readonly STEP_POINTERDOWN_SPRITE: number;
  84285. static readonly STEP_POINTERUP_SPRITE: number;
  84286. }
  84287. /**
  84288. * This represents a scene component.
  84289. *
  84290. * This is used to decouple the dependency the scene is having on the different workloads like
  84291. * layers, post processes...
  84292. */
  84293. export interface ISceneComponent {
  84294. /**
  84295. * The name of the component. Each component must have a unique name.
  84296. */
  84297. name: string;
  84298. /**
  84299. * The scene the component belongs to.
  84300. */
  84301. scene: Scene;
  84302. /**
  84303. * Register the component to one instance of a scene.
  84304. */
  84305. register(): void;
  84306. /**
  84307. * Rebuilds the elements related to this component in case of
  84308. * context lost for instance.
  84309. */
  84310. rebuild(): void;
  84311. /**
  84312. * Disposes the component and the associated ressources.
  84313. */
  84314. dispose(): void;
  84315. }
  84316. /**
  84317. * This represents a SERIALIZABLE scene component.
  84318. *
  84319. * This extends Scene Component to add Serialization methods on top.
  84320. */
  84321. export interface ISceneSerializableComponent extends ISceneComponent {
  84322. /**
  84323. * Adds all the elements from the container to the scene
  84324. * @param container the container holding the elements
  84325. */
  84326. addFromContainer(container: AbstractScene): void;
  84327. /**
  84328. * Removes all the elements in the container from the scene
  84329. * @param container contains the elements to remove
  84330. * @param dispose if the removed element should be disposed (default: false)
  84331. */
  84332. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  84333. /**
  84334. * Serializes the component data to the specified json object
  84335. * @param serializationObject The object to serialize to
  84336. */
  84337. serialize(serializationObject: any): void;
  84338. }
  84339. /**
  84340. * Strong typing of a Mesh related stage step action
  84341. */
  84342. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  84343. /**
  84344. * Strong typing of a Evaluate Sub Mesh related stage step action
  84345. */
  84346. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  84347. /**
  84348. * Strong typing of a Active Mesh related stage step action
  84349. */
  84350. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  84351. /**
  84352. * Strong typing of a Camera related stage step action
  84353. */
  84354. export type CameraStageAction = (camera: Camera) => void;
  84355. /**
  84356. * Strong typing of a Camera Frame buffer related stage step action
  84357. */
  84358. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  84359. /**
  84360. * Strong typing of a Render Target related stage step action
  84361. */
  84362. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  84363. /**
  84364. * Strong typing of a RenderingGroup related stage step action
  84365. */
  84366. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  84367. /**
  84368. * Strong typing of a Mesh Render related stage step action
  84369. */
  84370. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  84371. /**
  84372. * Strong typing of a simple stage step action
  84373. */
  84374. export type SimpleStageAction = () => void;
  84375. /**
  84376. * Strong typing of a render target action.
  84377. */
  84378. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  84379. /**
  84380. * Strong typing of a pointer move action.
  84381. */
  84382. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  84383. /**
  84384. * Strong typing of a pointer up/down action.
  84385. */
  84386. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  84387. /**
  84388. * Representation of a stage in the scene (Basically a list of ordered steps)
  84389. * @hidden
  84390. */
  84391. export class Stage<T extends Function> extends Array<{
  84392. index: number;
  84393. component: ISceneComponent;
  84394. action: T;
  84395. }> {
  84396. /**
  84397. * Hide ctor from the rest of the world.
  84398. * @param items The items to add.
  84399. */
  84400. private constructor();
  84401. /**
  84402. * Creates a new Stage.
  84403. * @returns A new instance of a Stage
  84404. */
  84405. static Create<T extends Function>(): Stage<T>;
  84406. /**
  84407. * Registers a step in an ordered way in the targeted stage.
  84408. * @param index Defines the position to register the step in
  84409. * @param component Defines the component attached to the step
  84410. * @param action Defines the action to launch during the step
  84411. */
  84412. registerStep(index: number, component: ISceneComponent, action: T): void;
  84413. /**
  84414. * Clears all the steps from the stage.
  84415. */
  84416. clear(): void;
  84417. }
  84418. }
  84419. declare module BABYLON {
  84420. interface Scene {
  84421. /** @hidden */
  84422. _pointerOverSprite: Nullable<Sprite>;
  84423. /** @hidden */
  84424. _pickedDownSprite: Nullable<Sprite>;
  84425. /** @hidden */
  84426. _tempSpritePickingRay: Nullable<Ray>;
  84427. /**
  84428. * All of the sprite managers added to this scene
  84429. * @see http://doc.babylonjs.com/babylon101/sprites
  84430. */
  84431. spriteManagers: Array<ISpriteManager>;
  84432. /**
  84433. * An event triggered when sprites rendering is about to start
  84434. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  84435. */
  84436. onBeforeSpritesRenderingObservable: Observable<Scene>;
  84437. /**
  84438. * An event triggered when sprites rendering is done
  84439. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  84440. */
  84441. onAfterSpritesRenderingObservable: Observable<Scene>;
  84442. /** @hidden */
  84443. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84444. /** Launch a ray to try to pick a sprite in the scene
  84445. * @param x position on screen
  84446. * @param y position on screen
  84447. * @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
  84448. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  84449. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  84450. * @returns a PickingInfo
  84451. */
  84452. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84453. /** Use the given ray to pick a sprite in the scene
  84454. * @param ray The ray (in world space) to use to pick meshes
  84455. * @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
  84456. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  84457. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  84458. * @returns a PickingInfo
  84459. */
  84460. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84461. /** @hidden */
  84462. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84463. /** Launch a ray to try to pick sprites in the scene
  84464. * @param x position on screen
  84465. * @param y position on screen
  84466. * @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
  84467. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  84468. * @returns a PickingInfo array
  84469. */
  84470. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84471. /** Use the given ray to pick sprites in the scene
  84472. * @param ray The ray (in world space) to use to pick meshes
  84473. * @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
  84474. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  84475. * @returns a PickingInfo array
  84476. */
  84477. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84478. /**
  84479. * Force the sprite under the pointer
  84480. * @param sprite defines the sprite to use
  84481. */
  84482. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  84483. /**
  84484. * Gets the sprite under the pointer
  84485. * @returns a Sprite or null if no sprite is under the pointer
  84486. */
  84487. getPointerOverSprite(): Nullable<Sprite>;
  84488. }
  84489. /**
  84490. * Defines the sprite scene component responsible to manage sprites
  84491. * in a given scene.
  84492. */
  84493. export class SpriteSceneComponent implements ISceneComponent {
  84494. /**
  84495. * The component name helpfull to identify the component in the list of scene components.
  84496. */
  84497. readonly name: string;
  84498. /**
  84499. * The scene the component belongs to.
  84500. */
  84501. scene: Scene;
  84502. /** @hidden */
  84503. private _spritePredicate;
  84504. /**
  84505. * Creates a new instance of the component for the given scene
  84506. * @param scene Defines the scene to register the component in
  84507. */
  84508. constructor(scene: Scene);
  84509. /**
  84510. * Registers the component in a given scene
  84511. */
  84512. register(): void;
  84513. /**
  84514. * Rebuilds the elements related to this component in case of
  84515. * context lost for instance.
  84516. */
  84517. rebuild(): void;
  84518. /**
  84519. * Disposes the component and the associated ressources.
  84520. */
  84521. dispose(): void;
  84522. private _pickSpriteButKeepRay;
  84523. private _pointerMove;
  84524. private _pointerDown;
  84525. private _pointerUp;
  84526. }
  84527. }
  84528. declare module BABYLON {
  84529. /** @hidden */
  84530. export var fogFragmentDeclaration: {
  84531. name: string;
  84532. shader: string;
  84533. };
  84534. }
  84535. declare module BABYLON {
  84536. /** @hidden */
  84537. export var fogFragment: {
  84538. name: string;
  84539. shader: string;
  84540. };
  84541. }
  84542. declare module BABYLON {
  84543. /** @hidden */
  84544. export var spritesPixelShader: {
  84545. name: string;
  84546. shader: string;
  84547. };
  84548. }
  84549. declare module BABYLON {
  84550. /** @hidden */
  84551. export var fogVertexDeclaration: {
  84552. name: string;
  84553. shader: string;
  84554. };
  84555. }
  84556. declare module BABYLON {
  84557. /** @hidden */
  84558. export var spritesVertexShader: {
  84559. name: string;
  84560. shader: string;
  84561. };
  84562. }
  84563. declare module BABYLON {
  84564. /**
  84565. * Defines the minimum interface to fullfil in order to be a sprite manager.
  84566. */
  84567. export interface ISpriteManager extends IDisposable {
  84568. /**
  84569. * Restricts the camera to viewing objects with the same layerMask.
  84570. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  84571. */
  84572. layerMask: number;
  84573. /**
  84574. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  84575. */
  84576. isPickable: boolean;
  84577. /**
  84578. * Specifies the rendering group id for this mesh (0 by default)
  84579. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  84580. */
  84581. renderingGroupId: number;
  84582. /**
  84583. * Defines the list of sprites managed by the manager.
  84584. */
  84585. sprites: Array<Sprite>;
  84586. /**
  84587. * Tests the intersection of a sprite with a specific ray.
  84588. * @param ray The ray we are sending to test the collision
  84589. * @param camera The camera space we are sending rays in
  84590. * @param predicate A predicate allowing excluding sprites from the list of object to test
  84591. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  84592. * @returns picking info or null.
  84593. */
  84594. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  84595. /**
  84596. * Intersects the sprites with a ray
  84597. * @param ray defines the ray to intersect with
  84598. * @param camera defines the current active camera
  84599. * @param predicate defines a predicate used to select candidate sprites
  84600. * @returns null if no hit or a PickingInfo array
  84601. */
  84602. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  84603. /**
  84604. * Renders the list of sprites on screen.
  84605. */
  84606. render(): void;
  84607. }
  84608. /**
  84609. * Class used to manage multiple sprites on the same spritesheet
  84610. * @see http://doc.babylonjs.com/babylon101/sprites
  84611. */
  84612. export class SpriteManager implements ISpriteManager {
  84613. /** defines the manager's name */
  84614. name: string;
  84615. /** Gets the list of sprites */
  84616. sprites: Sprite[];
  84617. /** Gets or sets the rendering group id (0 by default) */
  84618. renderingGroupId: number;
  84619. /** Gets or sets camera layer mask */
  84620. layerMask: number;
  84621. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  84622. fogEnabled: boolean;
  84623. /** Gets or sets a boolean indicating if the sprites are pickable */
  84624. isPickable: boolean;
  84625. /** Defines the default width of a cell in the spritesheet */
  84626. cellWidth: number;
  84627. /** Defines the default height of a cell in the spritesheet */
  84628. cellHeight: number;
  84629. /** Associative array from JSON sprite data file */
  84630. private _cellData;
  84631. /** Array of sprite names from JSON sprite data file */
  84632. private _spriteMap;
  84633. /** True when packed cell data from JSON file is ready*/
  84634. private _packedAndReady;
  84635. /**
  84636. * An event triggered when the manager is disposed.
  84637. */
  84638. onDisposeObservable: Observable<SpriteManager>;
  84639. private _onDisposeObserver;
  84640. /**
  84641. * Callback called when the manager is disposed
  84642. */
  84643. set onDispose(callback: () => void);
  84644. private _capacity;
  84645. private _fromPacked;
  84646. private _spriteTexture;
  84647. private _epsilon;
  84648. private _scene;
  84649. private _vertexData;
  84650. private _buffer;
  84651. private _vertexBuffers;
  84652. private _indexBuffer;
  84653. private _effectBase;
  84654. private _effectFog;
  84655. /**
  84656. * Gets or sets the spritesheet texture
  84657. */
  84658. get texture(): Texture;
  84659. set texture(value: Texture);
  84660. /**
  84661. * Creates a new sprite manager
  84662. * @param name defines the manager's name
  84663. * @param imgUrl defines the sprite sheet url
  84664. * @param capacity defines the maximum allowed number of sprites
  84665. * @param cellSize defines the size of a sprite cell
  84666. * @param scene defines the hosting scene
  84667. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  84668. * @param samplingMode defines the smapling mode to use with spritesheet
  84669. * @param fromPacked set to false; do not alter
  84670. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  84671. */
  84672. constructor(
  84673. /** defines the manager's name */
  84674. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  84675. private _makePacked;
  84676. private _appendSpriteVertex;
  84677. /**
  84678. * Intersects the sprites with a ray
  84679. * @param ray defines the ray to intersect with
  84680. * @param camera defines the current active camera
  84681. * @param predicate defines a predicate used to select candidate sprites
  84682. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  84683. * @returns null if no hit or a PickingInfo
  84684. */
  84685. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  84686. /**
  84687. * Intersects the sprites with a ray
  84688. * @param ray defines the ray to intersect with
  84689. * @param camera defines the current active camera
  84690. * @param predicate defines a predicate used to select candidate sprites
  84691. * @returns null if no hit or a PickingInfo array
  84692. */
  84693. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  84694. /**
  84695. * Render all child sprites
  84696. */
  84697. render(): void;
  84698. /**
  84699. * Release associated resources
  84700. */
  84701. dispose(): void;
  84702. }
  84703. }
  84704. declare module BABYLON {
  84705. /**
  84706. * Class used to represent a sprite
  84707. * @see http://doc.babylonjs.com/babylon101/sprites
  84708. */
  84709. export class Sprite {
  84710. /** defines the name */
  84711. name: string;
  84712. /** Gets or sets the current world position */
  84713. position: Vector3;
  84714. /** Gets or sets the main color */
  84715. color: Color4;
  84716. /** Gets or sets the width */
  84717. width: number;
  84718. /** Gets or sets the height */
  84719. height: number;
  84720. /** Gets or sets rotation angle */
  84721. angle: number;
  84722. /** Gets or sets the cell index in the sprite sheet */
  84723. cellIndex: number;
  84724. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  84725. cellRef: string;
  84726. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  84727. invertU: number;
  84728. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  84729. invertV: number;
  84730. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  84731. disposeWhenFinishedAnimating: boolean;
  84732. /** Gets the list of attached animations */
  84733. animations: Animation[];
  84734. /** Gets or sets a boolean indicating if the sprite can be picked */
  84735. isPickable: boolean;
  84736. /**
  84737. * Gets or sets the associated action manager
  84738. */
  84739. actionManager: Nullable<ActionManager>;
  84740. private _animationStarted;
  84741. private _loopAnimation;
  84742. private _fromIndex;
  84743. private _toIndex;
  84744. private _delay;
  84745. private _direction;
  84746. private _manager;
  84747. private _time;
  84748. private _onAnimationEnd;
  84749. /**
  84750. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  84751. */
  84752. isVisible: boolean;
  84753. /**
  84754. * Gets or sets the sprite size
  84755. */
  84756. get size(): number;
  84757. set size(value: number);
  84758. /**
  84759. * Creates a new Sprite
  84760. * @param name defines the name
  84761. * @param manager defines the manager
  84762. */
  84763. constructor(
  84764. /** defines the name */
  84765. name: string, manager: ISpriteManager);
  84766. /**
  84767. * Starts an animation
  84768. * @param from defines the initial key
  84769. * @param to defines the end key
  84770. * @param loop defines if the animation must loop
  84771. * @param delay defines the start delay (in ms)
  84772. * @param onAnimationEnd defines a callback to call when animation ends
  84773. */
  84774. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  84775. /** Stops current animation (if any) */
  84776. stopAnimation(): void;
  84777. /** @hidden */
  84778. _animate(deltaTime: number): void;
  84779. /** Release associated resources */
  84780. dispose(): void;
  84781. }
  84782. }
  84783. declare module BABYLON {
  84784. /**
  84785. * Information about the result of picking within a scene
  84786. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  84787. */
  84788. export class PickingInfo {
  84789. /** @hidden */
  84790. _pickingUnavailable: boolean;
  84791. /**
  84792. * If the pick collided with an object
  84793. */
  84794. hit: boolean;
  84795. /**
  84796. * Distance away where the pick collided
  84797. */
  84798. distance: number;
  84799. /**
  84800. * The location of pick collision
  84801. */
  84802. pickedPoint: Nullable<Vector3>;
  84803. /**
  84804. * The mesh corresponding the the pick collision
  84805. */
  84806. pickedMesh: Nullable<AbstractMesh>;
  84807. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  84808. bu: number;
  84809. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  84810. bv: number;
  84811. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  84812. faceId: number;
  84813. /** Id of the the submesh that was picked */
  84814. subMeshId: number;
  84815. /** If a sprite was picked, this will be the sprite the pick collided with */
  84816. pickedSprite: Nullable<Sprite>;
  84817. /**
  84818. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  84819. */
  84820. originMesh: Nullable<AbstractMesh>;
  84821. /**
  84822. * The ray that was used to perform the picking.
  84823. */
  84824. ray: Nullable<Ray>;
  84825. /**
  84826. * Gets the normal correspodning to the face the pick collided with
  84827. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  84828. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  84829. * @returns The normal correspodning to the face the pick collided with
  84830. */
  84831. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  84832. /**
  84833. * Gets the texture coordinates of where the pick occured
  84834. * @returns the vector containing the coordnates of the texture
  84835. */
  84836. getTextureCoordinates(): Nullable<Vector2>;
  84837. }
  84838. }
  84839. declare module BABYLON {
  84840. /**
  84841. * Gather the list of pointer event types as constants.
  84842. */
  84843. export class PointerEventTypes {
  84844. /**
  84845. * 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.
  84846. */
  84847. static readonly POINTERDOWN: number;
  84848. /**
  84849. * The pointerup event is fired when a pointer is no longer active.
  84850. */
  84851. static readonly POINTERUP: number;
  84852. /**
  84853. * The pointermove event is fired when a pointer changes coordinates.
  84854. */
  84855. static readonly POINTERMOVE: number;
  84856. /**
  84857. * The pointerwheel event is fired when a mouse wheel has been rotated.
  84858. */
  84859. static readonly POINTERWHEEL: number;
  84860. /**
  84861. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  84862. */
  84863. static readonly POINTERPICK: number;
  84864. /**
  84865. * The pointertap event is fired when a the object has been touched and released without drag.
  84866. */
  84867. static readonly POINTERTAP: number;
  84868. /**
  84869. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  84870. */
  84871. static readonly POINTERDOUBLETAP: number;
  84872. }
  84873. /**
  84874. * Base class of pointer info types.
  84875. */
  84876. export class PointerInfoBase {
  84877. /**
  84878. * Defines the type of event (PointerEventTypes)
  84879. */
  84880. type: number;
  84881. /**
  84882. * Defines the related dom event
  84883. */
  84884. event: PointerEvent | MouseWheelEvent;
  84885. /**
  84886. * Instantiates the base class of pointers info.
  84887. * @param type Defines the type of event (PointerEventTypes)
  84888. * @param event Defines the related dom event
  84889. */
  84890. constructor(
  84891. /**
  84892. * Defines the type of event (PointerEventTypes)
  84893. */
  84894. type: number,
  84895. /**
  84896. * Defines the related dom event
  84897. */
  84898. event: PointerEvent | MouseWheelEvent);
  84899. }
  84900. /**
  84901. * This class is used to store pointer related info for the onPrePointerObservable event.
  84902. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  84903. */
  84904. export class PointerInfoPre extends PointerInfoBase {
  84905. /**
  84906. * Ray from a pointer if availible (eg. 6dof controller)
  84907. */
  84908. ray: Nullable<Ray>;
  84909. /**
  84910. * Defines the local position of the pointer on the canvas.
  84911. */
  84912. localPosition: Vector2;
  84913. /**
  84914. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  84915. */
  84916. skipOnPointerObservable: boolean;
  84917. /**
  84918. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  84919. * @param type Defines the type of event (PointerEventTypes)
  84920. * @param event Defines the related dom event
  84921. * @param localX Defines the local x coordinates of the pointer when the event occured
  84922. * @param localY Defines the local y coordinates of the pointer when the event occured
  84923. */
  84924. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  84925. }
  84926. /**
  84927. * This type contains all the data related to a pointer event in Babylon.js.
  84928. * 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.
  84929. */
  84930. export class PointerInfo extends PointerInfoBase {
  84931. /**
  84932. * Defines the picking info associated to the info (if any)\
  84933. */
  84934. pickInfo: Nullable<PickingInfo>;
  84935. /**
  84936. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  84937. * @param type Defines the type of event (PointerEventTypes)
  84938. * @param event Defines the related dom event
  84939. * @param pickInfo Defines the picking info associated to the info (if any)\
  84940. */
  84941. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  84942. /**
  84943. * Defines the picking info associated to the info (if any)\
  84944. */
  84945. pickInfo: Nullable<PickingInfo>);
  84946. }
  84947. /**
  84948. * Data relating to a touch event on the screen.
  84949. */
  84950. export interface PointerTouch {
  84951. /**
  84952. * X coordinate of touch.
  84953. */
  84954. x: number;
  84955. /**
  84956. * Y coordinate of touch.
  84957. */
  84958. y: number;
  84959. /**
  84960. * Id of touch. Unique for each finger.
  84961. */
  84962. pointerId: number;
  84963. /**
  84964. * Event type passed from DOM.
  84965. */
  84966. type: any;
  84967. }
  84968. }
  84969. declare module BABYLON {
  84970. /**
  84971. * Manage the mouse inputs to control the movement of a free camera.
  84972. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  84973. */
  84974. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  84975. /**
  84976. * Define if touch is enabled in the mouse input
  84977. */
  84978. touchEnabled: boolean;
  84979. /**
  84980. * Defines the camera the input is attached to.
  84981. */
  84982. camera: FreeCamera;
  84983. /**
  84984. * Defines the buttons associated with the input to handle camera move.
  84985. */
  84986. buttons: number[];
  84987. /**
  84988. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  84989. */
  84990. angularSensibility: number;
  84991. private _pointerInput;
  84992. private _onMouseMove;
  84993. private _observer;
  84994. private previousPosition;
  84995. /**
  84996. * Observable for when a pointer move event occurs containing the move offset
  84997. */
  84998. onPointerMovedObservable: Observable<{
  84999. offsetX: number;
  85000. offsetY: number;
  85001. }>;
  85002. /**
  85003. * @hidden
  85004. * If the camera should be rotated automatically based on pointer movement
  85005. */
  85006. _allowCameraRotation: boolean;
  85007. /**
  85008. * Manage the mouse inputs to control the movement of a free camera.
  85009. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  85010. * @param touchEnabled Defines if touch is enabled or not
  85011. */
  85012. constructor(
  85013. /**
  85014. * Define if touch is enabled in the mouse input
  85015. */
  85016. touchEnabled?: boolean);
  85017. /**
  85018. * Attach the input controls to a specific dom element to get the input from.
  85019. * @param element Defines the element the controls should be listened from
  85020. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85021. */
  85022. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  85023. /**
  85024. * Called on JS contextmenu event.
  85025. * Override this method to provide functionality.
  85026. */
  85027. protected onContextMenu(evt: PointerEvent): void;
  85028. /**
  85029. * Detach the current controls from the specified dom element.
  85030. * @param element Defines the element to stop listening the inputs from
  85031. */
  85032. detachControl(element: Nullable<HTMLElement>): void;
  85033. /**
  85034. * Gets the class name of the current intput.
  85035. * @returns the class name
  85036. */
  85037. getClassName(): string;
  85038. /**
  85039. * Get the friendly name associated with the input class.
  85040. * @returns the input friendly name
  85041. */
  85042. getSimpleName(): string;
  85043. }
  85044. }
  85045. declare module BABYLON {
  85046. /**
  85047. * Manage the touch inputs to control the movement of a free camera.
  85048. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  85049. */
  85050. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  85051. /**
  85052. * Defines the camera the input is attached to.
  85053. */
  85054. camera: FreeCamera;
  85055. /**
  85056. * Defines the touch sensibility for rotation.
  85057. * The higher the faster.
  85058. */
  85059. touchAngularSensibility: number;
  85060. /**
  85061. * Defines the touch sensibility for move.
  85062. * The higher the faster.
  85063. */
  85064. touchMoveSensibility: number;
  85065. private _offsetX;
  85066. private _offsetY;
  85067. private _pointerPressed;
  85068. private _pointerInput;
  85069. private _observer;
  85070. private _onLostFocus;
  85071. /**
  85072. * Attach the input controls to a specific dom element to get the input from.
  85073. * @param element Defines the element the controls should be listened from
  85074. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85075. */
  85076. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  85077. /**
  85078. * Detach the current controls from the specified dom element.
  85079. * @param element Defines the element to stop listening the inputs from
  85080. */
  85081. detachControl(element: Nullable<HTMLElement>): void;
  85082. /**
  85083. * Update the current camera state depending on the inputs that have been used this frame.
  85084. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  85085. */
  85086. checkInputs(): void;
  85087. /**
  85088. * Gets the class name of the current intput.
  85089. * @returns the class name
  85090. */
  85091. getClassName(): string;
  85092. /**
  85093. * Get the friendly name associated with the input class.
  85094. * @returns the input friendly name
  85095. */
  85096. getSimpleName(): string;
  85097. }
  85098. }
  85099. declare module BABYLON {
  85100. /**
  85101. * Default Inputs manager for the FreeCamera.
  85102. * It groups all the default supported inputs for ease of use.
  85103. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  85104. */
  85105. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  85106. /**
  85107. * @hidden
  85108. */
  85109. _mouseInput: Nullable<FreeCameraMouseInput>;
  85110. /**
  85111. * Instantiates a new FreeCameraInputsManager.
  85112. * @param camera Defines the camera the inputs belong to
  85113. */
  85114. constructor(camera: FreeCamera);
  85115. /**
  85116. * Add keyboard input support to the input manager.
  85117. * @returns the current input manager
  85118. */
  85119. addKeyboard(): FreeCameraInputsManager;
  85120. /**
  85121. * Add mouse input support to the input manager.
  85122. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  85123. * @returns the current input manager
  85124. */
  85125. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  85126. /**
  85127. * Removes the mouse input support from the manager
  85128. * @returns the current input manager
  85129. */
  85130. removeMouse(): FreeCameraInputsManager;
  85131. /**
  85132. * Add touch input support to the input manager.
  85133. * @returns the current input manager
  85134. */
  85135. addTouch(): FreeCameraInputsManager;
  85136. /**
  85137. * Remove all attached input methods from a camera
  85138. */
  85139. clear(): void;
  85140. }
  85141. }
  85142. declare module BABYLON {
  85143. /**
  85144. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  85145. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  85146. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  85147. */
  85148. export class FreeCamera extends TargetCamera {
  85149. /**
  85150. * Define the collision ellipsoid of the camera.
  85151. * This is helpful to simulate a camera body like the player body around the camera
  85152. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  85153. */
  85154. ellipsoid: Vector3;
  85155. /**
  85156. * Define an offset for the position of the ellipsoid around the camera.
  85157. * This can be helpful to determine the center of the body near the gravity center of the body
  85158. * instead of its head.
  85159. */
  85160. ellipsoidOffset: Vector3;
  85161. /**
  85162. * Enable or disable collisions of the camera with the rest of the scene objects.
  85163. */
  85164. checkCollisions: boolean;
  85165. /**
  85166. * Enable or disable gravity on the camera.
  85167. */
  85168. applyGravity: boolean;
  85169. /**
  85170. * Define the input manager associated to the camera.
  85171. */
  85172. inputs: FreeCameraInputsManager;
  85173. /**
  85174. * Gets the input sensibility for a mouse input. (default is 2000.0)
  85175. * Higher values reduce sensitivity.
  85176. */
  85177. get angularSensibility(): number;
  85178. /**
  85179. * Sets the input sensibility for a mouse input. (default is 2000.0)
  85180. * Higher values reduce sensitivity.
  85181. */
  85182. set angularSensibility(value: number);
  85183. /**
  85184. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  85185. */
  85186. get keysUp(): number[];
  85187. set keysUp(value: number[]);
  85188. /**
  85189. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  85190. */
  85191. get keysDown(): number[];
  85192. set keysDown(value: number[]);
  85193. /**
  85194. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  85195. */
  85196. get keysLeft(): number[];
  85197. set keysLeft(value: number[]);
  85198. /**
  85199. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  85200. */
  85201. get keysRight(): number[];
  85202. set keysRight(value: number[]);
  85203. /**
  85204. * Event raised when the camera collide with a mesh in the scene.
  85205. */
  85206. onCollide: (collidedMesh: AbstractMesh) => void;
  85207. private _collider;
  85208. private _needMoveForGravity;
  85209. private _oldPosition;
  85210. private _diffPosition;
  85211. private _newPosition;
  85212. /** @hidden */
  85213. _localDirection: Vector3;
  85214. /** @hidden */
  85215. _transformedDirection: Vector3;
  85216. /**
  85217. * Instantiates a Free Camera.
  85218. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  85219. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  85220. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  85221. * @param name Define the name of the camera in the scene
  85222. * @param position Define the start position of the camera in the scene
  85223. * @param scene Define the scene the camera belongs to
  85224. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  85225. */
  85226. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  85227. /**
  85228. * Attached controls to the current camera.
  85229. * @param element Defines the element the controls should be listened from
  85230. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85231. */
  85232. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  85233. /**
  85234. * Detach the current controls from the camera.
  85235. * The camera will stop reacting to inputs.
  85236. * @param element Defines the element to stop listening the inputs from
  85237. */
  85238. detachControl(element: HTMLElement): void;
  85239. private _collisionMask;
  85240. /**
  85241. * Define a collision mask to limit the list of object the camera can collide with
  85242. */
  85243. get collisionMask(): number;
  85244. set collisionMask(mask: number);
  85245. /** @hidden */
  85246. _collideWithWorld(displacement: Vector3): void;
  85247. private _onCollisionPositionChange;
  85248. /** @hidden */
  85249. _checkInputs(): void;
  85250. /** @hidden */
  85251. _decideIfNeedsToMove(): boolean;
  85252. /** @hidden */
  85253. _updatePosition(): void;
  85254. /**
  85255. * Destroy the camera and release the current resources hold by it.
  85256. */
  85257. dispose(): void;
  85258. /**
  85259. * Gets the current object class name.
  85260. * @return the class name
  85261. */
  85262. getClassName(): string;
  85263. }
  85264. }
  85265. declare module BABYLON {
  85266. /**
  85267. * Represents a gamepad control stick position
  85268. */
  85269. export class StickValues {
  85270. /**
  85271. * The x component of the control stick
  85272. */
  85273. x: number;
  85274. /**
  85275. * The y component of the control stick
  85276. */
  85277. y: number;
  85278. /**
  85279. * Initializes the gamepad x and y control stick values
  85280. * @param x The x component of the gamepad control stick value
  85281. * @param y The y component of the gamepad control stick value
  85282. */
  85283. constructor(
  85284. /**
  85285. * The x component of the control stick
  85286. */
  85287. x: number,
  85288. /**
  85289. * The y component of the control stick
  85290. */
  85291. y: number);
  85292. }
  85293. /**
  85294. * An interface which manages callbacks for gamepad button changes
  85295. */
  85296. export interface GamepadButtonChanges {
  85297. /**
  85298. * Called when a gamepad has been changed
  85299. */
  85300. changed: boolean;
  85301. /**
  85302. * Called when a gamepad press event has been triggered
  85303. */
  85304. pressChanged: boolean;
  85305. /**
  85306. * Called when a touch event has been triggered
  85307. */
  85308. touchChanged: boolean;
  85309. /**
  85310. * Called when a value has changed
  85311. */
  85312. valueChanged: boolean;
  85313. }
  85314. /**
  85315. * Represents a gamepad
  85316. */
  85317. export class Gamepad {
  85318. /**
  85319. * The id of the gamepad
  85320. */
  85321. id: string;
  85322. /**
  85323. * The index of the gamepad
  85324. */
  85325. index: number;
  85326. /**
  85327. * The browser gamepad
  85328. */
  85329. browserGamepad: any;
  85330. /**
  85331. * Specifies what type of gamepad this represents
  85332. */
  85333. type: number;
  85334. private _leftStick;
  85335. private _rightStick;
  85336. /** @hidden */
  85337. _isConnected: boolean;
  85338. private _leftStickAxisX;
  85339. private _leftStickAxisY;
  85340. private _rightStickAxisX;
  85341. private _rightStickAxisY;
  85342. /**
  85343. * Triggered when the left control stick has been changed
  85344. */
  85345. private _onleftstickchanged;
  85346. /**
  85347. * Triggered when the right control stick has been changed
  85348. */
  85349. private _onrightstickchanged;
  85350. /**
  85351. * Represents a gamepad controller
  85352. */
  85353. static GAMEPAD: number;
  85354. /**
  85355. * Represents a generic controller
  85356. */
  85357. static GENERIC: number;
  85358. /**
  85359. * Represents an XBox controller
  85360. */
  85361. static XBOX: number;
  85362. /**
  85363. * Represents a pose-enabled controller
  85364. */
  85365. static POSE_ENABLED: number;
  85366. /**
  85367. * Represents an Dual Shock controller
  85368. */
  85369. static DUALSHOCK: number;
  85370. /**
  85371. * Specifies whether the left control stick should be Y-inverted
  85372. */
  85373. protected _invertLeftStickY: boolean;
  85374. /**
  85375. * Specifies if the gamepad has been connected
  85376. */
  85377. get isConnected(): boolean;
  85378. /**
  85379. * Initializes the gamepad
  85380. * @param id The id of the gamepad
  85381. * @param index The index of the gamepad
  85382. * @param browserGamepad The browser gamepad
  85383. * @param leftStickX The x component of the left joystick
  85384. * @param leftStickY The y component of the left joystick
  85385. * @param rightStickX The x component of the right joystick
  85386. * @param rightStickY The y component of the right joystick
  85387. */
  85388. constructor(
  85389. /**
  85390. * The id of the gamepad
  85391. */
  85392. id: string,
  85393. /**
  85394. * The index of the gamepad
  85395. */
  85396. index: number,
  85397. /**
  85398. * The browser gamepad
  85399. */
  85400. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  85401. /**
  85402. * Callback triggered when the left joystick has changed
  85403. * @param callback
  85404. */
  85405. onleftstickchanged(callback: (values: StickValues) => void): void;
  85406. /**
  85407. * Callback triggered when the right joystick has changed
  85408. * @param callback
  85409. */
  85410. onrightstickchanged(callback: (values: StickValues) => void): void;
  85411. /**
  85412. * Gets the left joystick
  85413. */
  85414. get leftStick(): StickValues;
  85415. /**
  85416. * Sets the left joystick values
  85417. */
  85418. set leftStick(newValues: StickValues);
  85419. /**
  85420. * Gets the right joystick
  85421. */
  85422. get rightStick(): StickValues;
  85423. /**
  85424. * Sets the right joystick value
  85425. */
  85426. set rightStick(newValues: StickValues);
  85427. /**
  85428. * Updates the gamepad joystick positions
  85429. */
  85430. update(): void;
  85431. /**
  85432. * Disposes the gamepad
  85433. */
  85434. dispose(): void;
  85435. }
  85436. /**
  85437. * Represents a generic gamepad
  85438. */
  85439. export class GenericPad extends Gamepad {
  85440. private _buttons;
  85441. private _onbuttondown;
  85442. private _onbuttonup;
  85443. /**
  85444. * Observable triggered when a button has been pressed
  85445. */
  85446. onButtonDownObservable: Observable<number>;
  85447. /**
  85448. * Observable triggered when a button has been released
  85449. */
  85450. onButtonUpObservable: Observable<number>;
  85451. /**
  85452. * Callback triggered when a button has been pressed
  85453. * @param callback Called when a button has been pressed
  85454. */
  85455. onbuttondown(callback: (buttonPressed: number) => void): void;
  85456. /**
  85457. * Callback triggered when a button has been released
  85458. * @param callback Called when a button has been released
  85459. */
  85460. onbuttonup(callback: (buttonReleased: number) => void): void;
  85461. /**
  85462. * Initializes the generic gamepad
  85463. * @param id The id of the generic gamepad
  85464. * @param index The index of the generic gamepad
  85465. * @param browserGamepad The browser gamepad
  85466. */
  85467. constructor(id: string, index: number, browserGamepad: any);
  85468. private _setButtonValue;
  85469. /**
  85470. * Updates the generic gamepad
  85471. */
  85472. update(): void;
  85473. /**
  85474. * Disposes the generic gamepad
  85475. */
  85476. dispose(): void;
  85477. }
  85478. }
  85479. declare module BABYLON {
  85480. interface Engine {
  85481. /**
  85482. * Creates a raw texture
  85483. * @param data defines the data to store in the texture
  85484. * @param width defines the width of the texture
  85485. * @param height defines the height of the texture
  85486. * @param format defines the format of the data
  85487. * @param generateMipMaps defines if the engine should generate the mip levels
  85488. * @param invertY defines if data must be stored with Y axis inverted
  85489. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85490. * @param compression defines the compression used (null by default)
  85491. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85492. * @returns the raw texture inside an InternalTexture
  85493. */
  85494. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  85495. /**
  85496. * Update a raw texture
  85497. * @param texture defines the texture to update
  85498. * @param data defines the data to store in the texture
  85499. * @param format defines the format of the data
  85500. * @param invertY defines if data must be stored with Y axis inverted
  85501. */
  85502. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  85503. /**
  85504. * Update a raw texture
  85505. * @param texture defines the texture to update
  85506. * @param data defines the data to store in the texture
  85507. * @param format defines the format of the data
  85508. * @param invertY defines if data must be stored with Y axis inverted
  85509. * @param compression defines the compression used (null by default)
  85510. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85511. */
  85512. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  85513. /**
  85514. * Creates a new raw cube texture
  85515. * @param data defines the array of data to use to create each face
  85516. * @param size defines the size of the textures
  85517. * @param format defines the format of the data
  85518. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85519. * @param generateMipMaps defines if the engine should generate the mip levels
  85520. * @param invertY defines if data must be stored with Y axis inverted
  85521. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85522. * @param compression defines the compression used (null by default)
  85523. * @returns the cube texture as an InternalTexture
  85524. */
  85525. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  85526. /**
  85527. * Update a raw cube texture
  85528. * @param texture defines the texture to udpdate
  85529. * @param data defines the data to store
  85530. * @param format defines the data format
  85531. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85532. * @param invertY defines if data must be stored with Y axis inverted
  85533. */
  85534. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  85535. /**
  85536. * Update a raw cube texture
  85537. * @param texture defines the texture to udpdate
  85538. * @param data defines the data to store
  85539. * @param format defines the data format
  85540. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85541. * @param invertY defines if data must be stored with Y axis inverted
  85542. * @param compression defines the compression used (null by default)
  85543. */
  85544. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  85545. /**
  85546. * Update a raw cube texture
  85547. * @param texture defines the texture to udpdate
  85548. * @param data defines the data to store
  85549. * @param format defines the data format
  85550. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85551. * @param invertY defines if data must be stored with Y axis inverted
  85552. * @param compression defines the compression used (null by default)
  85553. * @param level defines which level of the texture to update
  85554. */
  85555. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  85556. /**
  85557. * Creates a new raw cube texture from a specified url
  85558. * @param url defines the url where the data is located
  85559. * @param scene defines the current scene
  85560. * @param size defines the size of the textures
  85561. * @param format defines the format of the data
  85562. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85563. * @param noMipmap defines if the engine should avoid generating the mip levels
  85564. * @param callback defines a callback used to extract texture data from loaded data
  85565. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  85566. * @param onLoad defines a callback called when texture is loaded
  85567. * @param onError defines a callback called if there is an error
  85568. * @returns the cube texture as an InternalTexture
  85569. */
  85570. 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;
  85571. /**
  85572. * Creates a new raw cube texture from a specified url
  85573. * @param url defines the url where the data is located
  85574. * @param scene defines the current scene
  85575. * @param size defines the size of the textures
  85576. * @param format defines the format of the data
  85577. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85578. * @param noMipmap defines if the engine should avoid generating the mip levels
  85579. * @param callback defines a callback used to extract texture data from loaded data
  85580. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  85581. * @param onLoad defines a callback called when texture is loaded
  85582. * @param onError defines a callback called if there is an error
  85583. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85584. * @param invertY defines if data must be stored with Y axis inverted
  85585. * @returns the cube texture as an InternalTexture
  85586. */
  85587. 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;
  85588. /**
  85589. * Creates a new raw 3D texture
  85590. * @param data defines the data used to create the texture
  85591. * @param width defines the width of the texture
  85592. * @param height defines the height of the texture
  85593. * @param depth defines the depth of the texture
  85594. * @param format defines the format of the texture
  85595. * @param generateMipMaps defines if the engine must generate mip levels
  85596. * @param invertY defines if data must be stored with Y axis inverted
  85597. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85598. * @param compression defines the compressed used (can be null)
  85599. * @param textureType defines the compressed used (can be null)
  85600. * @returns a new raw 3D texture (stored in an InternalTexture)
  85601. */
  85602. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  85603. /**
  85604. * Update a raw 3D texture
  85605. * @param texture defines the texture to update
  85606. * @param data defines the data to store
  85607. * @param format defines the data format
  85608. * @param invertY defines if data must be stored with Y axis inverted
  85609. */
  85610. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  85611. /**
  85612. * Update a raw 3D texture
  85613. * @param texture defines the texture to update
  85614. * @param data defines the data to store
  85615. * @param format defines the data format
  85616. * @param invertY defines if data must be stored with Y axis inverted
  85617. * @param compression defines the used compression (can be null)
  85618. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  85619. */
  85620. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  85621. /**
  85622. * Creates a new raw 2D array texture
  85623. * @param data defines the data used to create the texture
  85624. * @param width defines the width of the texture
  85625. * @param height defines the height of the texture
  85626. * @param depth defines the number of layers of the texture
  85627. * @param format defines the format of the texture
  85628. * @param generateMipMaps defines if the engine must generate mip levels
  85629. * @param invertY defines if data must be stored with Y axis inverted
  85630. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85631. * @param compression defines the compressed used (can be null)
  85632. * @param textureType defines the compressed used (can be null)
  85633. * @returns a new raw 2D array texture (stored in an InternalTexture)
  85634. */
  85635. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  85636. /**
  85637. * Update a raw 2D array texture
  85638. * @param texture defines the texture to update
  85639. * @param data defines the data to store
  85640. * @param format defines the data format
  85641. * @param invertY defines if data must be stored with Y axis inverted
  85642. */
  85643. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  85644. /**
  85645. * Update a raw 2D array texture
  85646. * @param texture defines the texture to update
  85647. * @param data defines the data to store
  85648. * @param format defines the data format
  85649. * @param invertY defines if data must be stored with Y axis inverted
  85650. * @param compression defines the used compression (can be null)
  85651. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  85652. */
  85653. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  85654. }
  85655. }
  85656. declare module BABYLON {
  85657. /**
  85658. * Raw texture can help creating a texture directly from an array of data.
  85659. * This can be super useful if you either get the data from an uncompressed source or
  85660. * if you wish to create your texture pixel by pixel.
  85661. */
  85662. export class RawTexture extends Texture {
  85663. /**
  85664. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  85665. */
  85666. format: number;
  85667. private _engine;
  85668. /**
  85669. * Instantiates a new RawTexture.
  85670. * Raw texture can help creating a texture directly from an array of data.
  85671. * This can be super useful if you either get the data from an uncompressed source or
  85672. * if you wish to create your texture pixel by pixel.
  85673. * @param data define the array of data to use to create the texture
  85674. * @param width define the width of the texture
  85675. * @param height define the height of the texture
  85676. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  85677. * @param scene define the scene the texture belongs to
  85678. * @param generateMipMaps define whether mip maps should be generated or not
  85679. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85680. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85681. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85682. */
  85683. constructor(data: ArrayBufferView, width: number, height: number,
  85684. /**
  85685. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  85686. */
  85687. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  85688. /**
  85689. * Updates the texture underlying data.
  85690. * @param data Define the new data of the texture
  85691. */
  85692. update(data: ArrayBufferView): void;
  85693. /**
  85694. * Creates a luminance texture from some data.
  85695. * @param data Define the texture data
  85696. * @param width Define the width of the texture
  85697. * @param height Define the height of the texture
  85698. * @param scene Define the scene the texture belongs to
  85699. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85700. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85701. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85702. * @returns the luminance texture
  85703. */
  85704. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  85705. /**
  85706. * Creates a luminance alpha texture from some data.
  85707. * @param data Define the texture data
  85708. * @param width Define the width of the texture
  85709. * @param height Define the height of the texture
  85710. * @param scene Define the scene the texture belongs to
  85711. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85712. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85713. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85714. * @returns the luminance alpha texture
  85715. */
  85716. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  85717. /**
  85718. * Creates an alpha texture from some data.
  85719. * @param data Define the texture data
  85720. * @param width Define the width of the texture
  85721. * @param height Define the height of the texture
  85722. * @param scene Define the scene the texture belongs to
  85723. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85724. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85725. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85726. * @returns the alpha texture
  85727. */
  85728. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  85729. /**
  85730. * Creates a RGB texture from some data.
  85731. * @param data Define the texture data
  85732. * @param width Define the width of the texture
  85733. * @param height Define the height of the texture
  85734. * @param scene Define the scene the texture belongs to
  85735. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85736. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85737. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85738. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85739. * @returns the RGB alpha texture
  85740. */
  85741. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85742. /**
  85743. * Creates a RGBA texture from some data.
  85744. * @param data Define the texture data
  85745. * @param width Define the width of the texture
  85746. * @param height Define the height of the texture
  85747. * @param scene Define the scene the texture belongs to
  85748. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85749. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85750. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85751. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85752. * @returns the RGBA texture
  85753. */
  85754. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85755. /**
  85756. * Creates a R texture from some data.
  85757. * @param data Define the texture data
  85758. * @param width Define the width of the texture
  85759. * @param height Define the height of the texture
  85760. * @param scene Define the scene the texture belongs to
  85761. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85762. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85763. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85764. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85765. * @returns the R texture
  85766. */
  85767. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85768. }
  85769. }
  85770. declare module BABYLON {
  85771. /**
  85772. * Interface for the size containing width and height
  85773. */
  85774. export interface ISize {
  85775. /**
  85776. * Width
  85777. */
  85778. width: number;
  85779. /**
  85780. * Heighht
  85781. */
  85782. height: number;
  85783. }
  85784. /**
  85785. * Size containing widht and height
  85786. */
  85787. export class Size implements ISize {
  85788. /**
  85789. * Width
  85790. */
  85791. width: number;
  85792. /**
  85793. * Height
  85794. */
  85795. height: number;
  85796. /**
  85797. * Creates a Size object from the given width and height (floats).
  85798. * @param width width of the new size
  85799. * @param height height of the new size
  85800. */
  85801. constructor(width: number, height: number);
  85802. /**
  85803. * Returns a string with the Size width and height
  85804. * @returns a string with the Size width and height
  85805. */
  85806. toString(): string;
  85807. /**
  85808. * "Size"
  85809. * @returns the string "Size"
  85810. */
  85811. getClassName(): string;
  85812. /**
  85813. * Returns the Size hash code.
  85814. * @returns a hash code for a unique width and height
  85815. */
  85816. getHashCode(): number;
  85817. /**
  85818. * Updates the current size from the given one.
  85819. * @param src the given size
  85820. */
  85821. copyFrom(src: Size): void;
  85822. /**
  85823. * Updates in place the current Size from the given floats.
  85824. * @param width width of the new size
  85825. * @param height height of the new size
  85826. * @returns the updated Size.
  85827. */
  85828. copyFromFloats(width: number, height: number): Size;
  85829. /**
  85830. * Updates in place the current Size from the given floats.
  85831. * @param width width to set
  85832. * @param height height to set
  85833. * @returns the updated Size.
  85834. */
  85835. set(width: number, height: number): Size;
  85836. /**
  85837. * Multiplies the width and height by numbers
  85838. * @param w factor to multiple the width by
  85839. * @param h factor to multiple the height by
  85840. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  85841. */
  85842. multiplyByFloats(w: number, h: number): Size;
  85843. /**
  85844. * Clones the size
  85845. * @returns a new Size copied from the given one.
  85846. */
  85847. clone(): Size;
  85848. /**
  85849. * True if the current Size and the given one width and height are strictly equal.
  85850. * @param other the other size to compare against
  85851. * @returns True if the current Size and the given one width and height are strictly equal.
  85852. */
  85853. equals(other: Size): boolean;
  85854. /**
  85855. * The surface of the Size : width * height (float).
  85856. */
  85857. get surface(): number;
  85858. /**
  85859. * Create a new size of zero
  85860. * @returns a new Size set to (0.0, 0.0)
  85861. */
  85862. static Zero(): Size;
  85863. /**
  85864. * Sums the width and height of two sizes
  85865. * @param otherSize size to add to this size
  85866. * @returns a new Size set as the addition result of the current Size and the given one.
  85867. */
  85868. add(otherSize: Size): Size;
  85869. /**
  85870. * Subtracts the width and height of two
  85871. * @param otherSize size to subtract to this size
  85872. * @returns a new Size set as the subtraction result of the given one from the current Size.
  85873. */
  85874. subtract(otherSize: Size): Size;
  85875. /**
  85876. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  85877. * @param start starting size to lerp between
  85878. * @param end end size to lerp between
  85879. * @param amount amount to lerp between the start and end values
  85880. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  85881. */
  85882. static Lerp(start: Size, end: Size, amount: number): Size;
  85883. }
  85884. }
  85885. declare module BABYLON {
  85886. /**
  85887. * Defines a runtime animation
  85888. */
  85889. export class RuntimeAnimation {
  85890. private _events;
  85891. /**
  85892. * The current frame of the runtime animation
  85893. */
  85894. private _currentFrame;
  85895. /**
  85896. * The animation used by the runtime animation
  85897. */
  85898. private _animation;
  85899. /**
  85900. * The target of the runtime animation
  85901. */
  85902. private _target;
  85903. /**
  85904. * The initiating animatable
  85905. */
  85906. private _host;
  85907. /**
  85908. * The original value of the runtime animation
  85909. */
  85910. private _originalValue;
  85911. /**
  85912. * The original blend value of the runtime animation
  85913. */
  85914. private _originalBlendValue;
  85915. /**
  85916. * The offsets cache of the runtime animation
  85917. */
  85918. private _offsetsCache;
  85919. /**
  85920. * The high limits cache of the runtime animation
  85921. */
  85922. private _highLimitsCache;
  85923. /**
  85924. * Specifies if the runtime animation has been stopped
  85925. */
  85926. private _stopped;
  85927. /**
  85928. * The blending factor of the runtime animation
  85929. */
  85930. private _blendingFactor;
  85931. /**
  85932. * The BabylonJS scene
  85933. */
  85934. private _scene;
  85935. /**
  85936. * The current value of the runtime animation
  85937. */
  85938. private _currentValue;
  85939. /** @hidden */
  85940. _animationState: _IAnimationState;
  85941. /**
  85942. * The active target of the runtime animation
  85943. */
  85944. private _activeTargets;
  85945. private _currentActiveTarget;
  85946. private _directTarget;
  85947. /**
  85948. * The target path of the runtime animation
  85949. */
  85950. private _targetPath;
  85951. /**
  85952. * The weight of the runtime animation
  85953. */
  85954. private _weight;
  85955. /**
  85956. * The ratio offset of the runtime animation
  85957. */
  85958. private _ratioOffset;
  85959. /**
  85960. * The previous delay of the runtime animation
  85961. */
  85962. private _previousDelay;
  85963. /**
  85964. * The previous ratio of the runtime animation
  85965. */
  85966. private _previousRatio;
  85967. private _enableBlending;
  85968. private _keys;
  85969. private _minFrame;
  85970. private _maxFrame;
  85971. private _minValue;
  85972. private _maxValue;
  85973. private _targetIsArray;
  85974. /**
  85975. * Gets the current frame of the runtime animation
  85976. */
  85977. get currentFrame(): number;
  85978. /**
  85979. * Gets the weight of the runtime animation
  85980. */
  85981. get weight(): number;
  85982. /**
  85983. * Gets the current value of the runtime animation
  85984. */
  85985. get currentValue(): any;
  85986. /**
  85987. * Gets the target path of the runtime animation
  85988. */
  85989. get targetPath(): string;
  85990. /**
  85991. * Gets the actual target of the runtime animation
  85992. */
  85993. get target(): any;
  85994. /** @hidden */
  85995. _onLoop: () => void;
  85996. /**
  85997. * Create a new RuntimeAnimation object
  85998. * @param target defines the target of the animation
  85999. * @param animation defines the source animation object
  86000. * @param scene defines the hosting scene
  86001. * @param host defines the initiating Animatable
  86002. */
  86003. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  86004. private _preparePath;
  86005. /**
  86006. * Gets the animation from the runtime animation
  86007. */
  86008. get animation(): Animation;
  86009. /**
  86010. * Resets the runtime animation to the beginning
  86011. * @param restoreOriginal defines whether to restore the target property to the original value
  86012. */
  86013. reset(restoreOriginal?: boolean): void;
  86014. /**
  86015. * Specifies if the runtime animation is stopped
  86016. * @returns Boolean specifying if the runtime animation is stopped
  86017. */
  86018. isStopped(): boolean;
  86019. /**
  86020. * Disposes of the runtime animation
  86021. */
  86022. dispose(): void;
  86023. /**
  86024. * Apply the interpolated value to the target
  86025. * @param currentValue defines the value computed by the animation
  86026. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  86027. */
  86028. setValue(currentValue: any, weight: number): void;
  86029. private _getOriginalValues;
  86030. private _setValue;
  86031. /**
  86032. * Gets the loop pmode of the runtime animation
  86033. * @returns Loop Mode
  86034. */
  86035. private _getCorrectLoopMode;
  86036. /**
  86037. * Move the current animation to a given frame
  86038. * @param frame defines the frame to move to
  86039. */
  86040. goToFrame(frame: number): void;
  86041. /**
  86042. * @hidden Internal use only
  86043. */
  86044. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  86045. /**
  86046. * Execute the current animation
  86047. * @param delay defines the delay to add to the current frame
  86048. * @param from defines the lower bound of the animation range
  86049. * @param to defines the upper bound of the animation range
  86050. * @param loop defines if the current animation must loop
  86051. * @param speedRatio defines the current speed ratio
  86052. * @param weight defines the weight of the animation (default is -1 so no weight)
  86053. * @param onLoop optional callback called when animation loops
  86054. * @returns a boolean indicating if the animation is running
  86055. */
  86056. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  86057. }
  86058. }
  86059. declare module BABYLON {
  86060. /**
  86061. * Class used to store an actual running animation
  86062. */
  86063. export class Animatable {
  86064. /** defines the target object */
  86065. target: any;
  86066. /** defines the starting frame number (default is 0) */
  86067. fromFrame: number;
  86068. /** defines the ending frame number (default is 100) */
  86069. toFrame: number;
  86070. /** defines if the animation must loop (default is false) */
  86071. loopAnimation: boolean;
  86072. /** defines a callback to call when animation ends if it is not looping */
  86073. onAnimationEnd?: (() => void) | null | undefined;
  86074. /** defines a callback to call when animation loops */
  86075. onAnimationLoop?: (() => void) | null | undefined;
  86076. private _localDelayOffset;
  86077. private _pausedDelay;
  86078. private _runtimeAnimations;
  86079. private _paused;
  86080. private _scene;
  86081. private _speedRatio;
  86082. private _weight;
  86083. private _syncRoot;
  86084. /**
  86085. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  86086. * This will only apply for non looping animation (default is true)
  86087. */
  86088. disposeOnEnd: boolean;
  86089. /**
  86090. * Gets a boolean indicating if the animation has started
  86091. */
  86092. animationStarted: boolean;
  86093. /**
  86094. * Observer raised when the animation ends
  86095. */
  86096. onAnimationEndObservable: Observable<Animatable>;
  86097. /**
  86098. * Observer raised when the animation loops
  86099. */
  86100. onAnimationLoopObservable: Observable<Animatable>;
  86101. /**
  86102. * Gets the root Animatable used to synchronize and normalize animations
  86103. */
  86104. get syncRoot(): Nullable<Animatable>;
  86105. /**
  86106. * Gets the current frame of the first RuntimeAnimation
  86107. * Used to synchronize Animatables
  86108. */
  86109. get masterFrame(): number;
  86110. /**
  86111. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  86112. */
  86113. get weight(): number;
  86114. set weight(value: number);
  86115. /**
  86116. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  86117. */
  86118. get speedRatio(): number;
  86119. set speedRatio(value: number);
  86120. /**
  86121. * Creates a new Animatable
  86122. * @param scene defines the hosting scene
  86123. * @param target defines the target object
  86124. * @param fromFrame defines the starting frame number (default is 0)
  86125. * @param toFrame defines the ending frame number (default is 100)
  86126. * @param loopAnimation defines if the animation must loop (default is false)
  86127. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  86128. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  86129. * @param animations defines a group of animation to add to the new Animatable
  86130. * @param onAnimationLoop defines a callback to call when animation loops
  86131. */
  86132. constructor(scene: Scene,
  86133. /** defines the target object */
  86134. target: any,
  86135. /** defines the starting frame number (default is 0) */
  86136. fromFrame?: number,
  86137. /** defines the ending frame number (default is 100) */
  86138. toFrame?: number,
  86139. /** defines if the animation must loop (default is false) */
  86140. loopAnimation?: boolean, speedRatio?: number,
  86141. /** defines a callback to call when animation ends if it is not looping */
  86142. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  86143. /** defines a callback to call when animation loops */
  86144. onAnimationLoop?: (() => void) | null | undefined);
  86145. /**
  86146. * Synchronize and normalize current Animatable with a source Animatable
  86147. * This is useful when using animation weights and when animations are not of the same length
  86148. * @param root defines the root Animatable to synchronize with
  86149. * @returns the current Animatable
  86150. */
  86151. syncWith(root: Animatable): Animatable;
  86152. /**
  86153. * Gets the list of runtime animations
  86154. * @returns an array of RuntimeAnimation
  86155. */
  86156. getAnimations(): RuntimeAnimation[];
  86157. /**
  86158. * Adds more animations to the current animatable
  86159. * @param target defines the target of the animations
  86160. * @param animations defines the new animations to add
  86161. */
  86162. appendAnimations(target: any, animations: Animation[]): void;
  86163. /**
  86164. * Gets the source animation for a specific property
  86165. * @param property defines the propertyu to look for
  86166. * @returns null or the source animation for the given property
  86167. */
  86168. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  86169. /**
  86170. * Gets the runtime animation for a specific property
  86171. * @param property defines the propertyu to look for
  86172. * @returns null or the runtime animation for the given property
  86173. */
  86174. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  86175. /**
  86176. * Resets the animatable to its original state
  86177. */
  86178. reset(): void;
  86179. /**
  86180. * Allows the animatable to blend with current running animations
  86181. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  86182. * @param blendingSpeed defines the blending speed to use
  86183. */
  86184. enableBlending(blendingSpeed: number): void;
  86185. /**
  86186. * Disable animation blending
  86187. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  86188. */
  86189. disableBlending(): void;
  86190. /**
  86191. * Jump directly to a given frame
  86192. * @param frame defines the frame to jump to
  86193. */
  86194. goToFrame(frame: number): void;
  86195. /**
  86196. * Pause the animation
  86197. */
  86198. pause(): void;
  86199. /**
  86200. * Restart the animation
  86201. */
  86202. restart(): void;
  86203. private _raiseOnAnimationEnd;
  86204. /**
  86205. * Stop and delete the current animation
  86206. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  86207. * @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)
  86208. */
  86209. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  86210. /**
  86211. * Wait asynchronously for the animation to end
  86212. * @returns a promise which will be fullfilled when the animation ends
  86213. */
  86214. waitAsync(): Promise<Animatable>;
  86215. /** @hidden */
  86216. _animate(delay: number): boolean;
  86217. }
  86218. interface Scene {
  86219. /** @hidden */
  86220. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  86221. /** @hidden */
  86222. _processLateAnimationBindingsForMatrices(holder: {
  86223. totalWeight: number;
  86224. animations: RuntimeAnimation[];
  86225. originalValue: Matrix;
  86226. }): any;
  86227. /** @hidden */
  86228. _processLateAnimationBindingsForQuaternions(holder: {
  86229. totalWeight: number;
  86230. animations: RuntimeAnimation[];
  86231. originalValue: Quaternion;
  86232. }, refQuaternion: Quaternion): Quaternion;
  86233. /** @hidden */
  86234. _processLateAnimationBindings(): void;
  86235. /**
  86236. * Will start the animation sequence of a given target
  86237. * @param target defines the target
  86238. * @param from defines from which frame should animation start
  86239. * @param to defines until which frame should animation run.
  86240. * @param weight defines the weight to apply to the animation (1.0 by default)
  86241. * @param loop defines if the animation loops
  86242. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  86243. * @param onAnimationEnd defines the function to be executed when the animation ends
  86244. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  86245. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  86246. * @param onAnimationLoop defines the callback to call when an animation loops
  86247. * @returns the animatable object created for this animation
  86248. */
  86249. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  86250. /**
  86251. * Will start the animation sequence of a given target
  86252. * @param target defines the target
  86253. * @param from defines from which frame should animation start
  86254. * @param to defines until which frame should animation run.
  86255. * @param loop defines if the animation loops
  86256. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  86257. * @param onAnimationEnd defines the function to be executed when the animation ends
  86258. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  86259. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  86260. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  86261. * @param onAnimationLoop defines the callback to call when an animation loops
  86262. * @returns the animatable object created for this animation
  86263. */
  86264. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  86265. /**
  86266. * Will start the animation sequence of a given target and its hierarchy
  86267. * @param target defines the target
  86268. * @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.
  86269. * @param from defines from which frame should animation start
  86270. * @param to defines until which frame should animation run.
  86271. * @param loop defines if the animation loops
  86272. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  86273. * @param onAnimationEnd defines the function to be executed when the animation ends
  86274. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  86275. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  86276. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  86277. * @param onAnimationLoop defines the callback to call when an animation loops
  86278. * @returns the list of created animatables
  86279. */
  86280. 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[];
  86281. /**
  86282. * Begin a new animation on a given node
  86283. * @param target defines the target where the animation will take place
  86284. * @param animations defines the list of animations to start
  86285. * @param from defines the initial value
  86286. * @param to defines the final value
  86287. * @param loop defines if you want animation to loop (off by default)
  86288. * @param speedRatio defines the speed ratio to apply to all animations
  86289. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  86290. * @param onAnimationLoop defines the callback to call when an animation loops
  86291. * @returns the list of created animatables
  86292. */
  86293. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  86294. /**
  86295. * Begin a new animation on a given node and its hierarchy
  86296. * @param target defines the root node where the animation will take place
  86297. * @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.
  86298. * @param animations defines the list of animations to start
  86299. * @param from defines the initial value
  86300. * @param to defines the final value
  86301. * @param loop defines if you want animation to loop (off by default)
  86302. * @param speedRatio defines the speed ratio to apply to all animations
  86303. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  86304. * @param onAnimationLoop defines the callback to call when an animation loops
  86305. * @returns the list of animatables created for all nodes
  86306. */
  86307. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  86308. /**
  86309. * Gets the animatable associated with a specific target
  86310. * @param target defines the target of the animatable
  86311. * @returns the required animatable if found
  86312. */
  86313. getAnimatableByTarget(target: any): Nullable<Animatable>;
  86314. /**
  86315. * Gets all animatables associated with a given target
  86316. * @param target defines the target to look animatables for
  86317. * @returns an array of Animatables
  86318. */
  86319. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  86320. /**
  86321. * Stops and removes all animations that have been applied to the scene
  86322. */
  86323. stopAllAnimations(): void;
  86324. /**
  86325. * Gets the current delta time used by animation engine
  86326. */
  86327. deltaTime: number;
  86328. }
  86329. interface Bone {
  86330. /**
  86331. * Copy an animation range from another bone
  86332. * @param source defines the source bone
  86333. * @param rangeName defines the range name to copy
  86334. * @param frameOffset defines the frame offset
  86335. * @param rescaleAsRequired defines if rescaling must be applied if required
  86336. * @param skelDimensionsRatio defines the scaling ratio
  86337. * @returns true if operation was successful
  86338. */
  86339. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  86340. }
  86341. }
  86342. declare module BABYLON {
  86343. /**
  86344. * Class used to override all child animations of a given target
  86345. */
  86346. export class AnimationPropertiesOverride {
  86347. /**
  86348. * Gets or sets a value indicating if animation blending must be used
  86349. */
  86350. enableBlending: boolean;
  86351. /**
  86352. * Gets or sets the blending speed to use when enableBlending is true
  86353. */
  86354. blendingSpeed: number;
  86355. /**
  86356. * Gets or sets the default loop mode to use
  86357. */
  86358. loopMode: number;
  86359. }
  86360. }
  86361. declare module BABYLON {
  86362. /**
  86363. * Class used to handle skinning animations
  86364. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  86365. */
  86366. export class Skeleton implements IAnimatable {
  86367. /** defines the skeleton name */
  86368. name: string;
  86369. /** defines the skeleton Id */
  86370. id: string;
  86371. /**
  86372. * Defines the list of child bones
  86373. */
  86374. bones: Bone[];
  86375. /**
  86376. * Defines an estimate of the dimension of the skeleton at rest
  86377. */
  86378. dimensionsAtRest: Vector3;
  86379. /**
  86380. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  86381. */
  86382. needInitialSkinMatrix: boolean;
  86383. /**
  86384. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  86385. */
  86386. overrideMesh: Nullable<AbstractMesh>;
  86387. /**
  86388. * Gets the list of animations attached to this skeleton
  86389. */
  86390. animations: Array<Animation>;
  86391. private _scene;
  86392. private _isDirty;
  86393. private _transformMatrices;
  86394. private _transformMatrixTexture;
  86395. private _meshesWithPoseMatrix;
  86396. private _animatables;
  86397. private _identity;
  86398. private _synchronizedWithMesh;
  86399. private _ranges;
  86400. private _lastAbsoluteTransformsUpdateId;
  86401. private _canUseTextureForBones;
  86402. private _uniqueId;
  86403. /** @hidden */
  86404. _numBonesWithLinkedTransformNode: number;
  86405. /** @hidden */
  86406. _hasWaitingData: Nullable<boolean>;
  86407. /**
  86408. * Specifies if the skeleton should be serialized
  86409. */
  86410. doNotSerialize: boolean;
  86411. private _useTextureToStoreBoneMatrices;
  86412. /**
  86413. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  86414. * Please note that this option is not available if the hardware does not support it
  86415. */
  86416. get useTextureToStoreBoneMatrices(): boolean;
  86417. set useTextureToStoreBoneMatrices(value: boolean);
  86418. private _animationPropertiesOverride;
  86419. /**
  86420. * Gets or sets the animation properties override
  86421. */
  86422. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  86423. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  86424. /**
  86425. * List of inspectable custom properties (used by the Inspector)
  86426. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86427. */
  86428. inspectableCustomProperties: IInspectable[];
  86429. /**
  86430. * An observable triggered before computing the skeleton's matrices
  86431. */
  86432. onBeforeComputeObservable: Observable<Skeleton>;
  86433. /**
  86434. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  86435. */
  86436. get isUsingTextureForMatrices(): boolean;
  86437. /**
  86438. * Gets the unique ID of this skeleton
  86439. */
  86440. get uniqueId(): number;
  86441. /**
  86442. * Creates a new skeleton
  86443. * @param name defines the skeleton name
  86444. * @param id defines the skeleton Id
  86445. * @param scene defines the hosting scene
  86446. */
  86447. constructor(
  86448. /** defines the skeleton name */
  86449. name: string,
  86450. /** defines the skeleton Id */
  86451. id: string, scene: Scene);
  86452. /**
  86453. * Gets the current object class name.
  86454. * @return the class name
  86455. */
  86456. getClassName(): string;
  86457. /**
  86458. * Returns an array containing the root bones
  86459. * @returns an array containing the root bones
  86460. */
  86461. getChildren(): Array<Bone>;
  86462. /**
  86463. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  86464. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  86465. * @returns a Float32Array containing matrices data
  86466. */
  86467. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  86468. /**
  86469. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  86470. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  86471. * @returns a raw texture containing the data
  86472. */
  86473. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  86474. /**
  86475. * Gets the current hosting scene
  86476. * @returns a scene object
  86477. */
  86478. getScene(): Scene;
  86479. /**
  86480. * Gets a string representing the current skeleton data
  86481. * @param fullDetails defines a boolean indicating if we want a verbose version
  86482. * @returns a string representing the current skeleton data
  86483. */
  86484. toString(fullDetails?: boolean): string;
  86485. /**
  86486. * Get bone's index searching by name
  86487. * @param name defines bone's name to search for
  86488. * @return the indice of the bone. Returns -1 if not found
  86489. */
  86490. getBoneIndexByName(name: string): number;
  86491. /**
  86492. * Creater a new animation range
  86493. * @param name defines the name of the range
  86494. * @param from defines the start key
  86495. * @param to defines the end key
  86496. */
  86497. createAnimationRange(name: string, from: number, to: number): void;
  86498. /**
  86499. * Delete a specific animation range
  86500. * @param name defines the name of the range
  86501. * @param deleteFrames defines if frames must be removed as well
  86502. */
  86503. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  86504. /**
  86505. * Gets a specific animation range
  86506. * @param name defines the name of the range to look for
  86507. * @returns the requested animation range or null if not found
  86508. */
  86509. getAnimationRange(name: string): Nullable<AnimationRange>;
  86510. /**
  86511. * Gets the list of all animation ranges defined on this skeleton
  86512. * @returns an array
  86513. */
  86514. getAnimationRanges(): Nullable<AnimationRange>[];
  86515. /**
  86516. * Copy animation range from a source skeleton.
  86517. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  86518. * @param source defines the source skeleton
  86519. * @param name defines the name of the range to copy
  86520. * @param rescaleAsRequired defines if rescaling must be applied if required
  86521. * @returns true if operation was successful
  86522. */
  86523. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  86524. /**
  86525. * Forces the skeleton to go to rest pose
  86526. */
  86527. returnToRest(): void;
  86528. private _getHighestAnimationFrame;
  86529. /**
  86530. * Begin a specific animation range
  86531. * @param name defines the name of the range to start
  86532. * @param loop defines if looping must be turned on (false by default)
  86533. * @param speedRatio defines the speed ratio to apply (1 by default)
  86534. * @param onAnimationEnd defines a callback which will be called when animation will end
  86535. * @returns a new animatable
  86536. */
  86537. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  86538. /** @hidden */
  86539. _markAsDirty(): void;
  86540. /** @hidden */
  86541. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  86542. /** @hidden */
  86543. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  86544. private _computeTransformMatrices;
  86545. /**
  86546. * Build all resources required to render a skeleton
  86547. */
  86548. prepare(): void;
  86549. /**
  86550. * Gets the list of animatables currently running for this skeleton
  86551. * @returns an array of animatables
  86552. */
  86553. getAnimatables(): IAnimatable[];
  86554. /**
  86555. * Clone the current skeleton
  86556. * @param name defines the name of the new skeleton
  86557. * @param id defines the id of the new skeleton
  86558. * @returns the new skeleton
  86559. */
  86560. clone(name: string, id?: string): Skeleton;
  86561. /**
  86562. * Enable animation blending for this skeleton
  86563. * @param blendingSpeed defines the blending speed to apply
  86564. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  86565. */
  86566. enableBlending(blendingSpeed?: number): void;
  86567. /**
  86568. * Releases all resources associated with the current skeleton
  86569. */
  86570. dispose(): void;
  86571. /**
  86572. * Serialize the skeleton in a JSON object
  86573. * @returns a JSON object
  86574. */
  86575. serialize(): any;
  86576. /**
  86577. * Creates a new skeleton from serialized data
  86578. * @param parsedSkeleton defines the serialized data
  86579. * @param scene defines the hosting scene
  86580. * @returns a new skeleton
  86581. */
  86582. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  86583. /**
  86584. * Compute all node absolute transforms
  86585. * @param forceUpdate defines if computation must be done even if cache is up to date
  86586. */
  86587. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  86588. /**
  86589. * Gets the root pose matrix
  86590. * @returns a matrix
  86591. */
  86592. getPoseMatrix(): Nullable<Matrix>;
  86593. /**
  86594. * Sorts bones per internal index
  86595. */
  86596. sortBones(): void;
  86597. private _sortBones;
  86598. }
  86599. }
  86600. declare module BABYLON {
  86601. /**
  86602. * Class used to store bone information
  86603. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  86604. */
  86605. export class Bone extends Node {
  86606. /**
  86607. * defines the bone name
  86608. */
  86609. name: string;
  86610. private static _tmpVecs;
  86611. private static _tmpQuat;
  86612. private static _tmpMats;
  86613. /**
  86614. * Gets the list of child bones
  86615. */
  86616. children: Bone[];
  86617. /** Gets the animations associated with this bone */
  86618. animations: Animation[];
  86619. /**
  86620. * Gets or sets bone length
  86621. */
  86622. length: number;
  86623. /**
  86624. * @hidden Internal only
  86625. * Set this value to map this bone to a different index in the transform matrices
  86626. * Set this value to -1 to exclude the bone from the transform matrices
  86627. */
  86628. _index: Nullable<number>;
  86629. private _skeleton;
  86630. private _localMatrix;
  86631. private _restPose;
  86632. private _baseMatrix;
  86633. private _absoluteTransform;
  86634. private _invertedAbsoluteTransform;
  86635. private _parent;
  86636. private _scalingDeterminant;
  86637. private _worldTransform;
  86638. private _localScaling;
  86639. private _localRotation;
  86640. private _localPosition;
  86641. private _needToDecompose;
  86642. private _needToCompose;
  86643. /** @hidden */
  86644. _linkedTransformNode: Nullable<TransformNode>;
  86645. /** @hidden */
  86646. _waitingTransformNodeId: Nullable<string>;
  86647. /** @hidden */
  86648. get _matrix(): Matrix;
  86649. /** @hidden */
  86650. set _matrix(value: Matrix);
  86651. /**
  86652. * Create a new bone
  86653. * @param name defines the bone name
  86654. * @param skeleton defines the parent skeleton
  86655. * @param parentBone defines the parent (can be null if the bone is the root)
  86656. * @param localMatrix defines the local matrix
  86657. * @param restPose defines the rest pose matrix
  86658. * @param baseMatrix defines the base matrix
  86659. * @param index defines index of the bone in the hiearchy
  86660. */
  86661. constructor(
  86662. /**
  86663. * defines the bone name
  86664. */
  86665. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  86666. /**
  86667. * Gets the current object class name.
  86668. * @return the class name
  86669. */
  86670. getClassName(): string;
  86671. /**
  86672. * Gets the parent skeleton
  86673. * @returns a skeleton
  86674. */
  86675. getSkeleton(): Skeleton;
  86676. /**
  86677. * Gets parent bone
  86678. * @returns a bone or null if the bone is the root of the bone hierarchy
  86679. */
  86680. getParent(): Nullable<Bone>;
  86681. /**
  86682. * Returns an array containing the root bones
  86683. * @returns an array containing the root bones
  86684. */
  86685. getChildren(): Array<Bone>;
  86686. /**
  86687. * Gets the node index in matrix array generated for rendering
  86688. * @returns the node index
  86689. */
  86690. getIndex(): number;
  86691. /**
  86692. * Sets the parent bone
  86693. * @param parent defines the parent (can be null if the bone is the root)
  86694. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  86695. */
  86696. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  86697. /**
  86698. * Gets the local matrix
  86699. * @returns a matrix
  86700. */
  86701. getLocalMatrix(): Matrix;
  86702. /**
  86703. * Gets the base matrix (initial matrix which remains unchanged)
  86704. * @returns a matrix
  86705. */
  86706. getBaseMatrix(): Matrix;
  86707. /**
  86708. * Gets the rest pose matrix
  86709. * @returns a matrix
  86710. */
  86711. getRestPose(): Matrix;
  86712. /**
  86713. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  86714. */
  86715. getWorldMatrix(): Matrix;
  86716. /**
  86717. * Sets the local matrix to rest pose matrix
  86718. */
  86719. returnToRest(): void;
  86720. /**
  86721. * Gets the inverse of the absolute transform matrix.
  86722. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  86723. * @returns a matrix
  86724. */
  86725. getInvertedAbsoluteTransform(): Matrix;
  86726. /**
  86727. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  86728. * @returns a matrix
  86729. */
  86730. getAbsoluteTransform(): Matrix;
  86731. /**
  86732. * Links with the given transform node.
  86733. * The local matrix of this bone is copied from the transform node every frame.
  86734. * @param transformNode defines the transform node to link to
  86735. */
  86736. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  86737. /**
  86738. * Gets the node used to drive the bone's transformation
  86739. * @returns a transform node or null
  86740. */
  86741. getTransformNode(): Nullable<TransformNode>;
  86742. /** Gets or sets current position (in local space) */
  86743. get position(): Vector3;
  86744. set position(newPosition: Vector3);
  86745. /** Gets or sets current rotation (in local space) */
  86746. get rotation(): Vector3;
  86747. set rotation(newRotation: Vector3);
  86748. /** Gets or sets current rotation quaternion (in local space) */
  86749. get rotationQuaternion(): Quaternion;
  86750. set rotationQuaternion(newRotation: Quaternion);
  86751. /** Gets or sets current scaling (in local space) */
  86752. get scaling(): Vector3;
  86753. set scaling(newScaling: Vector3);
  86754. /**
  86755. * Gets the animation properties override
  86756. */
  86757. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  86758. private _decompose;
  86759. private _compose;
  86760. /**
  86761. * Update the base and local matrices
  86762. * @param matrix defines the new base or local matrix
  86763. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  86764. * @param updateLocalMatrix defines if the local matrix should be updated
  86765. */
  86766. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  86767. /** @hidden */
  86768. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  86769. /**
  86770. * Flag the bone as dirty (Forcing it to update everything)
  86771. */
  86772. markAsDirty(): void;
  86773. /** @hidden */
  86774. _markAsDirtyAndCompose(): void;
  86775. private _markAsDirtyAndDecompose;
  86776. /**
  86777. * Translate the bone in local or world space
  86778. * @param vec The amount to translate the bone
  86779. * @param space The space that the translation is in
  86780. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86781. */
  86782. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  86783. /**
  86784. * Set the postion of the bone in local or world space
  86785. * @param position The position to set the bone
  86786. * @param space The space that the position is in
  86787. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86788. */
  86789. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  86790. /**
  86791. * Set the absolute position of the bone (world space)
  86792. * @param position The position to set the bone
  86793. * @param mesh The mesh that this bone is attached to
  86794. */
  86795. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  86796. /**
  86797. * Scale the bone on the x, y and z axes (in local space)
  86798. * @param x The amount to scale the bone on the x axis
  86799. * @param y The amount to scale the bone on the y axis
  86800. * @param z The amount to scale the bone on the z axis
  86801. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  86802. */
  86803. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  86804. /**
  86805. * Set the bone scaling in local space
  86806. * @param scale defines the scaling vector
  86807. */
  86808. setScale(scale: Vector3): void;
  86809. /**
  86810. * Gets the current scaling in local space
  86811. * @returns the current scaling vector
  86812. */
  86813. getScale(): Vector3;
  86814. /**
  86815. * Gets the current scaling in local space and stores it in a target vector
  86816. * @param result defines the target vector
  86817. */
  86818. getScaleToRef(result: Vector3): void;
  86819. /**
  86820. * Set the yaw, pitch, and roll of the bone in local or world space
  86821. * @param yaw The rotation of the bone on the y axis
  86822. * @param pitch The rotation of the bone on the x axis
  86823. * @param roll The rotation of the bone on the z axis
  86824. * @param space The space that the axes of rotation are in
  86825. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86826. */
  86827. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  86828. /**
  86829. * Add a rotation to the bone on an axis in local or world space
  86830. * @param axis The axis to rotate the bone on
  86831. * @param amount The amount to rotate the bone
  86832. * @param space The space that the axis is in
  86833. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86834. */
  86835. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  86836. /**
  86837. * Set the rotation of the bone to a particular axis angle in local or world space
  86838. * @param axis The axis to rotate the bone on
  86839. * @param angle The angle that the bone should be rotated to
  86840. * @param space The space that the axis is in
  86841. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86842. */
  86843. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  86844. /**
  86845. * Set the euler rotation of the bone in local of world space
  86846. * @param rotation The euler rotation that the bone should be set to
  86847. * @param space The space that the rotation is in
  86848. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86849. */
  86850. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  86851. /**
  86852. * Set the quaternion rotation of the bone in local of world space
  86853. * @param quat The quaternion rotation that the bone should be set to
  86854. * @param space The space that the rotation is in
  86855. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86856. */
  86857. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  86858. /**
  86859. * Set the rotation matrix of the bone in local of world space
  86860. * @param rotMat The rotation matrix that the bone should be set to
  86861. * @param space The space that the rotation is in
  86862. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86863. */
  86864. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  86865. private _rotateWithMatrix;
  86866. private _getNegativeRotationToRef;
  86867. /**
  86868. * Get the position of the bone in local or world space
  86869. * @param space The space that the returned position is in
  86870. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86871. * @returns The position of the bone
  86872. */
  86873. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  86874. /**
  86875. * Copy the position of the bone to a vector3 in local or world space
  86876. * @param space The space that the returned position is in
  86877. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86878. * @param result The vector3 to copy the position to
  86879. */
  86880. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  86881. /**
  86882. * Get the absolute position of the bone (world space)
  86883. * @param mesh The mesh that this bone is attached to
  86884. * @returns The absolute position of the bone
  86885. */
  86886. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  86887. /**
  86888. * Copy the absolute position of the bone (world space) to the result param
  86889. * @param mesh The mesh that this bone is attached to
  86890. * @param result The vector3 to copy the absolute position to
  86891. */
  86892. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  86893. /**
  86894. * Compute the absolute transforms of this bone and its children
  86895. */
  86896. computeAbsoluteTransforms(): void;
  86897. /**
  86898. * Get the world direction from an axis that is in the local space of the bone
  86899. * @param localAxis The local direction that is used to compute the world direction
  86900. * @param mesh The mesh that this bone is attached to
  86901. * @returns The world direction
  86902. */
  86903. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  86904. /**
  86905. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  86906. * @param localAxis The local direction that is used to compute the world direction
  86907. * @param mesh The mesh that this bone is attached to
  86908. * @param result The vector3 that the world direction will be copied to
  86909. */
  86910. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  86911. /**
  86912. * Get the euler rotation of the bone in local or world space
  86913. * @param space The space that the rotation should be in
  86914. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86915. * @returns The euler rotation
  86916. */
  86917. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  86918. /**
  86919. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  86920. * @param space The space that the rotation should be in
  86921. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86922. * @param result The vector3 that the rotation should be copied to
  86923. */
  86924. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  86925. /**
  86926. * Get the quaternion rotation of the bone in either local or world space
  86927. * @param space The space that the rotation should be in
  86928. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86929. * @returns The quaternion rotation
  86930. */
  86931. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  86932. /**
  86933. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  86934. * @param space The space that the rotation should be in
  86935. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86936. * @param result The quaternion that the rotation should be copied to
  86937. */
  86938. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  86939. /**
  86940. * Get the rotation matrix of the bone in local or world space
  86941. * @param space The space that the rotation should be in
  86942. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86943. * @returns The rotation matrix
  86944. */
  86945. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  86946. /**
  86947. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  86948. * @param space The space that the rotation should be in
  86949. * @param mesh The mesh that this bone is attached to. This is only used in world space
  86950. * @param result The quaternion that the rotation should be copied to
  86951. */
  86952. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  86953. /**
  86954. * Get the world position of a point that is in the local space of the bone
  86955. * @param position The local position
  86956. * @param mesh The mesh that this bone is attached to
  86957. * @returns The world position
  86958. */
  86959. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  86960. /**
  86961. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  86962. * @param position The local position
  86963. * @param mesh The mesh that this bone is attached to
  86964. * @param result The vector3 that the world position should be copied to
  86965. */
  86966. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  86967. /**
  86968. * Get the local position of a point that is in world space
  86969. * @param position The world position
  86970. * @param mesh The mesh that this bone is attached to
  86971. * @returns The local position
  86972. */
  86973. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  86974. /**
  86975. * Get the local position of a point that is in world space and copy it to the result param
  86976. * @param position The world position
  86977. * @param mesh The mesh that this bone is attached to
  86978. * @param result The vector3 that the local position should be copied to
  86979. */
  86980. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  86981. }
  86982. }
  86983. declare module BABYLON {
  86984. /**
  86985. * 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.
  86986. * @see https://doc.babylonjs.com/how_to/transformnode
  86987. */
  86988. export class TransformNode extends Node {
  86989. /**
  86990. * Object will not rotate to face the camera
  86991. */
  86992. static BILLBOARDMODE_NONE: number;
  86993. /**
  86994. * Object will rotate to face the camera but only on the x axis
  86995. */
  86996. static BILLBOARDMODE_X: number;
  86997. /**
  86998. * Object will rotate to face the camera but only on the y axis
  86999. */
  87000. static BILLBOARDMODE_Y: number;
  87001. /**
  87002. * Object will rotate to face the camera but only on the z axis
  87003. */
  87004. static BILLBOARDMODE_Z: number;
  87005. /**
  87006. * Object will rotate to face the camera
  87007. */
  87008. static BILLBOARDMODE_ALL: number;
  87009. /**
  87010. * Object will rotate to face the camera's position instead of orientation
  87011. */
  87012. static BILLBOARDMODE_USE_POSITION: number;
  87013. private _forward;
  87014. private _forwardInverted;
  87015. private _up;
  87016. private _right;
  87017. private _rightInverted;
  87018. private _position;
  87019. private _rotation;
  87020. private _rotationQuaternion;
  87021. protected _scaling: Vector3;
  87022. protected _isDirty: boolean;
  87023. private _transformToBoneReferal;
  87024. private _isAbsoluteSynced;
  87025. private _billboardMode;
  87026. /**
  87027. * Gets or sets the billboard mode. Default is 0.
  87028. *
  87029. * | Value | Type | Description |
  87030. * | --- | --- | --- |
  87031. * | 0 | BILLBOARDMODE_NONE | |
  87032. * | 1 | BILLBOARDMODE_X | |
  87033. * | 2 | BILLBOARDMODE_Y | |
  87034. * | 4 | BILLBOARDMODE_Z | |
  87035. * | 7 | BILLBOARDMODE_ALL | |
  87036. *
  87037. */
  87038. get billboardMode(): number;
  87039. set billboardMode(value: number);
  87040. private _preserveParentRotationForBillboard;
  87041. /**
  87042. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  87043. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  87044. */
  87045. get preserveParentRotationForBillboard(): boolean;
  87046. set preserveParentRotationForBillboard(value: boolean);
  87047. /**
  87048. * 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
  87049. */
  87050. scalingDeterminant: number;
  87051. private _infiniteDistance;
  87052. /**
  87053. * Gets or sets the distance of the object to max, often used by skybox
  87054. */
  87055. get infiniteDistance(): boolean;
  87056. set infiniteDistance(value: boolean);
  87057. /**
  87058. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  87059. * By default the system will update normals to compensate
  87060. */
  87061. ignoreNonUniformScaling: boolean;
  87062. /**
  87063. * 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
  87064. */
  87065. reIntegrateRotationIntoRotationQuaternion: boolean;
  87066. /** @hidden */
  87067. _poseMatrix: Nullable<Matrix>;
  87068. /** @hidden */
  87069. _localMatrix: Matrix;
  87070. private _usePivotMatrix;
  87071. private _absolutePosition;
  87072. private _absoluteScaling;
  87073. private _absoluteRotationQuaternion;
  87074. private _pivotMatrix;
  87075. private _pivotMatrixInverse;
  87076. protected _postMultiplyPivotMatrix: boolean;
  87077. protected _isWorldMatrixFrozen: boolean;
  87078. /** @hidden */
  87079. _indexInSceneTransformNodesArray: number;
  87080. /**
  87081. * An event triggered after the world matrix is updated
  87082. */
  87083. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  87084. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  87085. /**
  87086. * Gets a string identifying the name of the class
  87087. * @returns "TransformNode" string
  87088. */
  87089. getClassName(): string;
  87090. /**
  87091. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  87092. */
  87093. get position(): Vector3;
  87094. set position(newPosition: Vector3);
  87095. /**
  87096. * 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)).
  87097. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  87098. */
  87099. get rotation(): Vector3;
  87100. set rotation(newRotation: Vector3);
  87101. /**
  87102. * 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)).
  87103. */
  87104. get scaling(): Vector3;
  87105. set scaling(newScaling: Vector3);
  87106. /**
  87107. * 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).
  87108. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  87109. */
  87110. get rotationQuaternion(): Nullable<Quaternion>;
  87111. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  87112. /**
  87113. * The forward direction of that transform in world space.
  87114. */
  87115. get forward(): Vector3;
  87116. /**
  87117. * The up direction of that transform in world space.
  87118. */
  87119. get up(): Vector3;
  87120. /**
  87121. * The right direction of that transform in world space.
  87122. */
  87123. get right(): Vector3;
  87124. /**
  87125. * Copies the parameter passed Matrix into the mesh Pose matrix.
  87126. * @param matrix the matrix to copy the pose from
  87127. * @returns this TransformNode.
  87128. */
  87129. updatePoseMatrix(matrix: Matrix): TransformNode;
  87130. /**
  87131. * Returns the mesh Pose matrix.
  87132. * @returns the pose matrix
  87133. */
  87134. getPoseMatrix(): Matrix;
  87135. /** @hidden */
  87136. _isSynchronized(): boolean;
  87137. /** @hidden */
  87138. _initCache(): void;
  87139. /**
  87140. * Flag the transform node as dirty (Forcing it to update everything)
  87141. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  87142. * @returns this transform node
  87143. */
  87144. markAsDirty(property: string): TransformNode;
  87145. /**
  87146. * Returns the current mesh absolute position.
  87147. * Returns a Vector3.
  87148. */
  87149. get absolutePosition(): Vector3;
  87150. /**
  87151. * Returns the current mesh absolute scaling.
  87152. * Returns a Vector3.
  87153. */
  87154. get absoluteScaling(): Vector3;
  87155. /**
  87156. * Returns the current mesh absolute rotation.
  87157. * Returns a Quaternion.
  87158. */
  87159. get absoluteRotationQuaternion(): Quaternion;
  87160. /**
  87161. * Sets a new matrix to apply before all other transformation
  87162. * @param matrix defines the transform matrix
  87163. * @returns the current TransformNode
  87164. */
  87165. setPreTransformMatrix(matrix: Matrix): TransformNode;
  87166. /**
  87167. * Sets a new pivot matrix to the current node
  87168. * @param matrix defines the new pivot matrix to use
  87169. * @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
  87170. * @returns the current TransformNode
  87171. */
  87172. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  87173. /**
  87174. * Returns the mesh pivot matrix.
  87175. * Default : Identity.
  87176. * @returns the matrix
  87177. */
  87178. getPivotMatrix(): Matrix;
  87179. /**
  87180. * Instantiate (when possible) or clone that node with its hierarchy
  87181. * @param newParent defines the new parent to use for the instance (or clone)
  87182. * @param options defines options to configure how copy is done
  87183. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  87184. * @returns an instance (or a clone) of the current node with its hiearchy
  87185. */
  87186. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  87187. doNotInstantiate: boolean;
  87188. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  87189. /**
  87190. * Prevents the World matrix to be computed any longer
  87191. * @param newWorldMatrix defines an optional matrix to use as world matrix
  87192. * @returns the TransformNode.
  87193. */
  87194. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  87195. /**
  87196. * Allows back the World matrix computation.
  87197. * @returns the TransformNode.
  87198. */
  87199. unfreezeWorldMatrix(): this;
  87200. /**
  87201. * True if the World matrix has been frozen.
  87202. */
  87203. get isWorldMatrixFrozen(): boolean;
  87204. /**
  87205. * Retuns the mesh absolute position in the World.
  87206. * @returns a Vector3.
  87207. */
  87208. getAbsolutePosition(): Vector3;
  87209. /**
  87210. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  87211. * @param absolutePosition the absolute position to set
  87212. * @returns the TransformNode.
  87213. */
  87214. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  87215. /**
  87216. * Sets the mesh position in its local space.
  87217. * @param vector3 the position to set in localspace
  87218. * @returns the TransformNode.
  87219. */
  87220. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  87221. /**
  87222. * Returns the mesh position in the local space from the current World matrix values.
  87223. * @returns a new Vector3.
  87224. */
  87225. getPositionExpressedInLocalSpace(): Vector3;
  87226. /**
  87227. * Translates the mesh along the passed Vector3 in its local space.
  87228. * @param vector3 the distance to translate in localspace
  87229. * @returns the TransformNode.
  87230. */
  87231. locallyTranslate(vector3: Vector3): TransformNode;
  87232. private static _lookAtVectorCache;
  87233. /**
  87234. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  87235. * @param targetPoint the position (must be in same space as current mesh) to look at
  87236. * @param yawCor optional yaw (y-axis) correction in radians
  87237. * @param pitchCor optional pitch (x-axis) correction in radians
  87238. * @param rollCor optional roll (z-axis) correction in radians
  87239. * @param space the choosen space of the target
  87240. * @returns the TransformNode.
  87241. */
  87242. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  87243. /**
  87244. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  87245. * This Vector3 is expressed in the World space.
  87246. * @param localAxis axis to rotate
  87247. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  87248. */
  87249. getDirection(localAxis: Vector3): Vector3;
  87250. /**
  87251. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  87252. * localAxis is expressed in the mesh local space.
  87253. * result is computed in the Wordl space from the mesh World matrix.
  87254. * @param localAxis axis to rotate
  87255. * @param result the resulting transformnode
  87256. * @returns this TransformNode.
  87257. */
  87258. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  87259. /**
  87260. * Sets this transform node rotation to the given local axis.
  87261. * @param localAxis the axis in local space
  87262. * @param yawCor optional yaw (y-axis) correction in radians
  87263. * @param pitchCor optional pitch (x-axis) correction in radians
  87264. * @param rollCor optional roll (z-axis) correction in radians
  87265. * @returns this TransformNode
  87266. */
  87267. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  87268. /**
  87269. * Sets a new pivot point to the current node
  87270. * @param point defines the new pivot point to use
  87271. * @param space defines if the point is in world or local space (local by default)
  87272. * @returns the current TransformNode
  87273. */
  87274. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  87275. /**
  87276. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  87277. * @returns the pivot point
  87278. */
  87279. getPivotPoint(): Vector3;
  87280. /**
  87281. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  87282. * @param result the vector3 to store the result
  87283. * @returns this TransformNode.
  87284. */
  87285. getPivotPointToRef(result: Vector3): TransformNode;
  87286. /**
  87287. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  87288. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  87289. */
  87290. getAbsolutePivotPoint(): Vector3;
  87291. /**
  87292. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  87293. * @param result vector3 to store the result
  87294. * @returns this TransformNode.
  87295. */
  87296. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  87297. /**
  87298. * Defines the passed node as the parent of the current node.
  87299. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  87300. * @see https://doc.babylonjs.com/how_to/parenting
  87301. * @param node the node ot set as the parent
  87302. * @returns this TransformNode.
  87303. */
  87304. setParent(node: Nullable<Node>): TransformNode;
  87305. private _nonUniformScaling;
  87306. /**
  87307. * True if the scaling property of this object is non uniform eg. (1,2,1)
  87308. */
  87309. get nonUniformScaling(): boolean;
  87310. /** @hidden */
  87311. _updateNonUniformScalingState(value: boolean): boolean;
  87312. /**
  87313. * Attach the current TransformNode to another TransformNode associated with a bone
  87314. * @param bone Bone affecting the TransformNode
  87315. * @param affectedTransformNode TransformNode associated with the bone
  87316. * @returns this object
  87317. */
  87318. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  87319. /**
  87320. * Detach the transform node if its associated with a bone
  87321. * @returns this object
  87322. */
  87323. detachFromBone(): TransformNode;
  87324. private static _rotationAxisCache;
  87325. /**
  87326. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  87327. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87328. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87329. * The passed axis is also normalized.
  87330. * @param axis the axis to rotate around
  87331. * @param amount the amount to rotate in radians
  87332. * @param space Space to rotate in (Default: local)
  87333. * @returns the TransformNode.
  87334. */
  87335. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  87336. /**
  87337. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  87338. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87339. * The passed axis is also normalized. .
  87340. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  87341. * @param point the point to rotate around
  87342. * @param axis the axis to rotate around
  87343. * @param amount the amount to rotate in radians
  87344. * @returns the TransformNode
  87345. */
  87346. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  87347. /**
  87348. * Translates the mesh along the axis vector for the passed distance in the given space.
  87349. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87350. * @param axis the axis to translate in
  87351. * @param distance the distance to translate
  87352. * @param space Space to rotate in (Default: local)
  87353. * @returns the TransformNode.
  87354. */
  87355. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  87356. /**
  87357. * Adds a rotation step to the mesh current rotation.
  87358. * x, y, z are Euler angles expressed in radians.
  87359. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  87360. * This means this rotation is made in the mesh local space only.
  87361. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  87362. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  87363. * ```javascript
  87364. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  87365. * ```
  87366. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  87367. * 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.
  87368. * @param x Rotation to add
  87369. * @param y Rotation to add
  87370. * @param z Rotation to add
  87371. * @returns the TransformNode.
  87372. */
  87373. addRotation(x: number, y: number, z: number): TransformNode;
  87374. /**
  87375. * @hidden
  87376. */
  87377. protected _getEffectiveParent(): Nullable<Node>;
  87378. /**
  87379. * Computes the world matrix of the node
  87380. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87381. * @returns the world matrix
  87382. */
  87383. computeWorldMatrix(force?: boolean): Matrix;
  87384. /**
  87385. * Resets this nodeTransform's local matrix to Matrix.Identity().
  87386. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  87387. */
  87388. resetLocalMatrix(independentOfChildren?: boolean): void;
  87389. protected _afterComputeWorldMatrix(): void;
  87390. /**
  87391. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  87392. * @param func callback function to add
  87393. *
  87394. * @returns the TransformNode.
  87395. */
  87396. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87397. /**
  87398. * Removes a registered callback function.
  87399. * @param func callback function to remove
  87400. * @returns the TransformNode.
  87401. */
  87402. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87403. /**
  87404. * Gets the position of the current mesh in camera space
  87405. * @param camera defines the camera to use
  87406. * @returns a position
  87407. */
  87408. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  87409. /**
  87410. * Returns the distance from the mesh to the active camera
  87411. * @param camera defines the camera to use
  87412. * @returns the distance
  87413. */
  87414. getDistanceToCamera(camera?: Nullable<Camera>): number;
  87415. /**
  87416. * Clone the current transform node
  87417. * @param name Name of the new clone
  87418. * @param newParent New parent for the clone
  87419. * @param doNotCloneChildren Do not clone children hierarchy
  87420. * @returns the new transform node
  87421. */
  87422. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  87423. /**
  87424. * Serializes the objects information.
  87425. * @param currentSerializationObject defines the object to serialize in
  87426. * @returns the serialized object
  87427. */
  87428. serialize(currentSerializationObject?: any): any;
  87429. /**
  87430. * Returns a new TransformNode object parsed from the source provided.
  87431. * @param parsedTransformNode is the source.
  87432. * @param scene the scne the object belongs to
  87433. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  87434. * @returns a new TransformNode object parsed from the source provided.
  87435. */
  87436. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  87437. /**
  87438. * Get all child-transformNodes of this node
  87439. * @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
  87440. * @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
  87441. * @returns an array of TransformNode
  87442. */
  87443. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  87444. /**
  87445. * Releases resources associated with this transform node.
  87446. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87447. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87448. */
  87449. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87450. /**
  87451. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87452. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87453. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87454. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87455. * @returns the current mesh
  87456. */
  87457. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  87458. private _syncAbsoluteScalingAndRotation;
  87459. }
  87460. }
  87461. declare module BABYLON {
  87462. /**
  87463. * Defines the types of pose enabled controllers that are supported
  87464. */
  87465. export enum PoseEnabledControllerType {
  87466. /**
  87467. * HTC Vive
  87468. */
  87469. VIVE = 0,
  87470. /**
  87471. * Oculus Rift
  87472. */
  87473. OCULUS = 1,
  87474. /**
  87475. * Windows mixed reality
  87476. */
  87477. WINDOWS = 2,
  87478. /**
  87479. * Samsung gear VR
  87480. */
  87481. GEAR_VR = 3,
  87482. /**
  87483. * Google Daydream
  87484. */
  87485. DAYDREAM = 4,
  87486. /**
  87487. * Generic
  87488. */
  87489. GENERIC = 5
  87490. }
  87491. /**
  87492. * Defines the MutableGamepadButton interface for the state of a gamepad button
  87493. */
  87494. export interface MutableGamepadButton {
  87495. /**
  87496. * Value of the button/trigger
  87497. */
  87498. value: number;
  87499. /**
  87500. * If the button/trigger is currently touched
  87501. */
  87502. touched: boolean;
  87503. /**
  87504. * If the button/trigger is currently pressed
  87505. */
  87506. pressed: boolean;
  87507. }
  87508. /**
  87509. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  87510. * @hidden
  87511. */
  87512. export interface ExtendedGamepadButton extends GamepadButton {
  87513. /**
  87514. * If the button/trigger is currently pressed
  87515. */
  87516. readonly pressed: boolean;
  87517. /**
  87518. * If the button/trigger is currently touched
  87519. */
  87520. readonly touched: boolean;
  87521. /**
  87522. * Value of the button/trigger
  87523. */
  87524. readonly value: number;
  87525. }
  87526. /** @hidden */
  87527. export interface _GamePadFactory {
  87528. /**
  87529. * Returns whether or not the current gamepad can be created for this type of controller.
  87530. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  87531. * @returns true if it can be created, otherwise false
  87532. */
  87533. canCreate(gamepadInfo: any): boolean;
  87534. /**
  87535. * Creates a new instance of the Gamepad.
  87536. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  87537. * @returns the new gamepad instance
  87538. */
  87539. create(gamepadInfo: any): Gamepad;
  87540. }
  87541. /**
  87542. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  87543. */
  87544. export class PoseEnabledControllerHelper {
  87545. /** @hidden */
  87546. static _ControllerFactories: _GamePadFactory[];
  87547. /** @hidden */
  87548. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  87549. /**
  87550. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  87551. * @param vrGamepad the gamepad to initialized
  87552. * @returns a vr controller of the type the gamepad identified as
  87553. */
  87554. static InitiateController(vrGamepad: any): Gamepad;
  87555. }
  87556. /**
  87557. * Defines the PoseEnabledController object that contains state of a vr capable controller
  87558. */
  87559. export class PoseEnabledController extends Gamepad implements PoseControlled {
  87560. /**
  87561. * If the controller is used in a webXR session
  87562. */
  87563. isXR: boolean;
  87564. private _deviceRoomPosition;
  87565. private _deviceRoomRotationQuaternion;
  87566. /**
  87567. * The device position in babylon space
  87568. */
  87569. devicePosition: Vector3;
  87570. /**
  87571. * The device rotation in babylon space
  87572. */
  87573. deviceRotationQuaternion: Quaternion;
  87574. /**
  87575. * The scale factor of the device in babylon space
  87576. */
  87577. deviceScaleFactor: number;
  87578. /**
  87579. * (Likely devicePosition should be used instead) The device position in its room space
  87580. */
  87581. position: Vector3;
  87582. /**
  87583. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  87584. */
  87585. rotationQuaternion: Quaternion;
  87586. /**
  87587. * The type of controller (Eg. Windows mixed reality)
  87588. */
  87589. controllerType: PoseEnabledControllerType;
  87590. protected _calculatedPosition: Vector3;
  87591. private _calculatedRotation;
  87592. /**
  87593. * The raw pose from the device
  87594. */
  87595. rawPose: DevicePose;
  87596. private _trackPosition;
  87597. private _maxRotationDistFromHeadset;
  87598. private _draggedRoomRotation;
  87599. /**
  87600. * @hidden
  87601. */
  87602. _disableTrackPosition(fixedPosition: Vector3): void;
  87603. /**
  87604. * Internal, the mesh attached to the controller
  87605. * @hidden
  87606. */
  87607. _mesh: Nullable<AbstractMesh>;
  87608. private _poseControlledCamera;
  87609. private _leftHandSystemQuaternion;
  87610. /**
  87611. * Internal, matrix used to convert room space to babylon space
  87612. * @hidden
  87613. */
  87614. _deviceToWorld: Matrix;
  87615. /**
  87616. * Node to be used when casting a ray from the controller
  87617. * @hidden
  87618. */
  87619. _pointingPoseNode: Nullable<TransformNode>;
  87620. /**
  87621. * Name of the child mesh that can be used to cast a ray from the controller
  87622. */
  87623. static readonly POINTING_POSE: string;
  87624. /**
  87625. * Creates a new PoseEnabledController from a gamepad
  87626. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  87627. */
  87628. constructor(browserGamepad: any);
  87629. private _workingMatrix;
  87630. /**
  87631. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  87632. */
  87633. update(): void;
  87634. /**
  87635. * Updates only the pose device and mesh without doing any button event checking
  87636. */
  87637. protected _updatePoseAndMesh(): void;
  87638. /**
  87639. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  87640. * @param poseData raw pose fromthe device
  87641. */
  87642. updateFromDevice(poseData: DevicePose): void;
  87643. /**
  87644. * @hidden
  87645. */
  87646. _meshAttachedObservable: Observable<AbstractMesh>;
  87647. /**
  87648. * Attaches a mesh to the controller
  87649. * @param mesh the mesh to be attached
  87650. */
  87651. attachToMesh(mesh: AbstractMesh): void;
  87652. /**
  87653. * Attaches the controllers mesh to a camera
  87654. * @param camera the camera the mesh should be attached to
  87655. */
  87656. attachToPoseControlledCamera(camera: TargetCamera): void;
  87657. /**
  87658. * Disposes of the controller
  87659. */
  87660. dispose(): void;
  87661. /**
  87662. * The mesh that is attached to the controller
  87663. */
  87664. get mesh(): Nullable<AbstractMesh>;
  87665. /**
  87666. * Gets the ray of the controller in the direction the controller is pointing
  87667. * @param length the length the resulting ray should be
  87668. * @returns a ray in the direction the controller is pointing
  87669. */
  87670. getForwardRay(length?: number): Ray;
  87671. }
  87672. }
  87673. declare module BABYLON {
  87674. /**
  87675. * Defines the WebVRController object that represents controllers tracked in 3D space
  87676. */
  87677. export abstract class WebVRController extends PoseEnabledController {
  87678. /**
  87679. * Internal, the default controller model for the controller
  87680. */
  87681. protected _defaultModel: Nullable<AbstractMesh>;
  87682. /**
  87683. * Fired when the trigger state has changed
  87684. */
  87685. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  87686. /**
  87687. * Fired when the main button state has changed
  87688. */
  87689. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  87690. /**
  87691. * Fired when the secondary button state has changed
  87692. */
  87693. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  87694. /**
  87695. * Fired when the pad state has changed
  87696. */
  87697. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  87698. /**
  87699. * Fired when controllers stick values have changed
  87700. */
  87701. onPadValuesChangedObservable: Observable<StickValues>;
  87702. /**
  87703. * Array of button availible on the controller
  87704. */
  87705. protected _buttons: Array<MutableGamepadButton>;
  87706. private _onButtonStateChange;
  87707. /**
  87708. * Fired when a controller button's state has changed
  87709. * @param callback the callback containing the button that was modified
  87710. */
  87711. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  87712. /**
  87713. * X and Y axis corresponding to the controllers joystick
  87714. */
  87715. pad: StickValues;
  87716. /**
  87717. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  87718. */
  87719. hand: string;
  87720. /**
  87721. * The default controller model for the controller
  87722. */
  87723. get defaultModel(): Nullable<AbstractMesh>;
  87724. /**
  87725. * Creates a new WebVRController from a gamepad
  87726. * @param vrGamepad the gamepad that the WebVRController should be created from
  87727. */
  87728. constructor(vrGamepad: any);
  87729. /**
  87730. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  87731. */
  87732. update(): void;
  87733. /**
  87734. * Function to be called when a button is modified
  87735. */
  87736. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  87737. /**
  87738. * Loads a mesh and attaches it to the controller
  87739. * @param scene the scene the mesh should be added to
  87740. * @param meshLoaded callback for when the mesh has been loaded
  87741. */
  87742. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  87743. private _setButtonValue;
  87744. private _changes;
  87745. private _checkChanges;
  87746. /**
  87747. * Disposes of th webVRCOntroller
  87748. */
  87749. dispose(): void;
  87750. }
  87751. }
  87752. declare module BABYLON {
  87753. /**
  87754. * The HemisphericLight simulates the ambient environment light,
  87755. * so the passed direction is the light reflection direction, not the incoming direction.
  87756. */
  87757. export class HemisphericLight extends Light {
  87758. /**
  87759. * The groundColor is the light in the opposite direction to the one specified during creation.
  87760. * 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.
  87761. */
  87762. groundColor: Color3;
  87763. /**
  87764. * The light reflection direction, not the incoming direction.
  87765. */
  87766. direction: Vector3;
  87767. /**
  87768. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  87769. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  87770. * The HemisphericLight can't cast shadows.
  87771. * Documentation : https://doc.babylonjs.com/babylon101/lights
  87772. * @param name The friendly name of the light
  87773. * @param direction The direction of the light reflection
  87774. * @param scene The scene the light belongs to
  87775. */
  87776. constructor(name: string, direction: Vector3, scene: Scene);
  87777. protected _buildUniformLayout(): void;
  87778. /**
  87779. * Returns the string "HemisphericLight".
  87780. * @return The class name
  87781. */
  87782. getClassName(): string;
  87783. /**
  87784. * Sets the HemisphericLight direction towards the passed target (Vector3).
  87785. * Returns the updated direction.
  87786. * @param target The target the direction should point to
  87787. * @return The computed direction
  87788. */
  87789. setDirectionToTarget(target: Vector3): Vector3;
  87790. /**
  87791. * Returns the shadow generator associated to the light.
  87792. * @returns Always null for hemispheric lights because it does not support shadows.
  87793. */
  87794. getShadowGenerator(): Nullable<IShadowGenerator>;
  87795. /**
  87796. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  87797. * @param effect The effect to update
  87798. * @param lightIndex The index of the light in the effect to update
  87799. * @returns The hemispheric light
  87800. */
  87801. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  87802. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  87803. /**
  87804. * Computes the world matrix of the node
  87805. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87806. * @param useWasUpdatedFlag defines a reserved property
  87807. * @returns the world matrix
  87808. */
  87809. computeWorldMatrix(): Matrix;
  87810. /**
  87811. * Returns the integer 3.
  87812. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  87813. */
  87814. getTypeID(): number;
  87815. /**
  87816. * Prepares the list of defines specific to the light type.
  87817. * @param defines the list of defines
  87818. * @param lightIndex defines the index of the light for the effect
  87819. */
  87820. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  87821. }
  87822. }
  87823. declare module BABYLON {
  87824. /** @hidden */
  87825. export var vrMultiviewToSingleviewPixelShader: {
  87826. name: string;
  87827. shader: string;
  87828. };
  87829. }
  87830. declare module BABYLON {
  87831. /**
  87832. * Renders to multiple views with a single draw call
  87833. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  87834. */
  87835. export class MultiviewRenderTarget extends RenderTargetTexture {
  87836. /**
  87837. * Creates a multiview render target
  87838. * @param scene scene used with the render target
  87839. * @param size the size of the render target (used for each view)
  87840. */
  87841. constructor(scene: Scene, size?: number | {
  87842. width: number;
  87843. height: number;
  87844. } | {
  87845. ratio: number;
  87846. });
  87847. /**
  87848. * @hidden
  87849. * @param faceIndex the face index, if its a cube texture
  87850. */
  87851. _bindFrameBuffer(faceIndex?: number): void;
  87852. /**
  87853. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  87854. * @returns the view count
  87855. */
  87856. getViewCount(): number;
  87857. }
  87858. }
  87859. declare module BABYLON {
  87860. /**
  87861. * Represents a camera frustum
  87862. */
  87863. export class Frustum {
  87864. /**
  87865. * Gets the planes representing the frustum
  87866. * @param transform matrix to be applied to the returned planes
  87867. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  87868. */
  87869. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  87870. /**
  87871. * Gets the near frustum plane transformed by the transform matrix
  87872. * @param transform transformation matrix to be applied to the resulting frustum plane
  87873. * @param frustumPlane the resuling frustum plane
  87874. */
  87875. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87876. /**
  87877. * Gets the far frustum plane transformed by the transform matrix
  87878. * @param transform transformation matrix to be applied to the resulting frustum plane
  87879. * @param frustumPlane the resuling frustum plane
  87880. */
  87881. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87882. /**
  87883. * Gets the left frustum plane transformed by the transform matrix
  87884. * @param transform transformation matrix to be applied to the resulting frustum plane
  87885. * @param frustumPlane the resuling frustum plane
  87886. */
  87887. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87888. /**
  87889. * Gets the right frustum plane transformed by the transform matrix
  87890. * @param transform transformation matrix to be applied to the resulting frustum plane
  87891. * @param frustumPlane the resuling frustum plane
  87892. */
  87893. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87894. /**
  87895. * Gets the top frustum plane transformed by the transform matrix
  87896. * @param transform transformation matrix to be applied to the resulting frustum plane
  87897. * @param frustumPlane the resuling frustum plane
  87898. */
  87899. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87900. /**
  87901. * Gets the bottom frustum plane transformed by the transform matrix
  87902. * @param transform transformation matrix to be applied to the resulting frustum plane
  87903. * @param frustumPlane the resuling frustum plane
  87904. */
  87905. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87906. /**
  87907. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  87908. * @param transform transformation matrix to be applied to the resulting frustum planes
  87909. * @param frustumPlanes the resuling frustum planes
  87910. */
  87911. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  87912. }
  87913. }
  87914. declare module BABYLON {
  87915. interface Engine {
  87916. /**
  87917. * Creates a new multiview render target
  87918. * @param width defines the width of the texture
  87919. * @param height defines the height of the texture
  87920. * @returns the created multiview texture
  87921. */
  87922. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  87923. /**
  87924. * Binds a multiview framebuffer to be drawn to
  87925. * @param multiviewTexture texture to bind
  87926. */
  87927. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  87928. }
  87929. interface Camera {
  87930. /**
  87931. * @hidden
  87932. * 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)
  87933. */
  87934. _useMultiviewToSingleView: boolean;
  87935. /**
  87936. * @hidden
  87937. * 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)
  87938. */
  87939. _multiviewTexture: Nullable<RenderTargetTexture>;
  87940. /**
  87941. * @hidden
  87942. * ensures the multiview texture of the camera exists and has the specified width/height
  87943. * @param width height to set on the multiview texture
  87944. * @param height width to set on the multiview texture
  87945. */
  87946. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  87947. }
  87948. interface Scene {
  87949. /** @hidden */
  87950. _transformMatrixR: Matrix;
  87951. /** @hidden */
  87952. _multiviewSceneUbo: Nullable<UniformBuffer>;
  87953. /** @hidden */
  87954. _createMultiviewUbo(): void;
  87955. /** @hidden */
  87956. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  87957. /** @hidden */
  87958. _renderMultiviewToSingleView(camera: Camera): void;
  87959. }
  87960. }
  87961. declare module BABYLON {
  87962. /**
  87963. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  87964. * This will not be used for webXR as it supports displaying texture arrays directly
  87965. */
  87966. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  87967. /**
  87968. * Initializes a VRMultiviewToSingleview
  87969. * @param name name of the post process
  87970. * @param camera camera to be applied to
  87971. * @param scaleFactor scaling factor to the size of the output texture
  87972. */
  87973. constructor(name: string, camera: Camera, scaleFactor: number);
  87974. }
  87975. }
  87976. declare module BABYLON {
  87977. /**
  87978. * Interface used to define additional presentation attributes
  87979. */
  87980. export interface IVRPresentationAttributes {
  87981. /**
  87982. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  87983. */
  87984. highRefreshRate: boolean;
  87985. /**
  87986. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  87987. */
  87988. foveationLevel: number;
  87989. }
  87990. interface Engine {
  87991. /** @hidden */
  87992. _vrDisplay: any;
  87993. /** @hidden */
  87994. _vrSupported: boolean;
  87995. /** @hidden */
  87996. _oldSize: Size;
  87997. /** @hidden */
  87998. _oldHardwareScaleFactor: number;
  87999. /** @hidden */
  88000. _vrExclusivePointerMode: boolean;
  88001. /** @hidden */
  88002. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  88003. /** @hidden */
  88004. _onVRDisplayPointerRestricted: () => void;
  88005. /** @hidden */
  88006. _onVRDisplayPointerUnrestricted: () => void;
  88007. /** @hidden */
  88008. _onVrDisplayConnect: Nullable<(display: any) => void>;
  88009. /** @hidden */
  88010. _onVrDisplayDisconnect: Nullable<() => void>;
  88011. /** @hidden */
  88012. _onVrDisplayPresentChange: Nullable<() => void>;
  88013. /**
  88014. * Observable signaled when VR display mode changes
  88015. */
  88016. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  88017. /**
  88018. * Observable signaled when VR request present is complete
  88019. */
  88020. onVRRequestPresentComplete: Observable<boolean>;
  88021. /**
  88022. * Observable signaled when VR request present starts
  88023. */
  88024. onVRRequestPresentStart: Observable<Engine>;
  88025. /**
  88026. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  88027. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  88028. */
  88029. isInVRExclusivePointerMode: boolean;
  88030. /**
  88031. * Gets a boolean indicating if a webVR device was detected
  88032. * @returns true if a webVR device was detected
  88033. */
  88034. isVRDevicePresent(): boolean;
  88035. /**
  88036. * Gets the current webVR device
  88037. * @returns the current webVR device (or null)
  88038. */
  88039. getVRDevice(): any;
  88040. /**
  88041. * Initializes a webVR display and starts listening to display change events
  88042. * The onVRDisplayChangedObservable will be notified upon these changes
  88043. * @returns A promise containing a VRDisplay and if vr is supported
  88044. */
  88045. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  88046. /** @hidden */
  88047. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  88048. /**
  88049. * Gets or sets the presentation attributes used to configure VR rendering
  88050. */
  88051. vrPresentationAttributes?: IVRPresentationAttributes;
  88052. /**
  88053. * Call this function to switch to webVR mode
  88054. * Will do nothing if webVR is not supported or if there is no webVR device
  88055. * @param options the webvr options provided to the camera. mainly used for multiview
  88056. * @see http://doc.babylonjs.com/how_to/webvr_camera
  88057. */
  88058. enableVR(options: WebVROptions): void;
  88059. /** @hidden */
  88060. _onVRFullScreenTriggered(): void;
  88061. }
  88062. }
  88063. declare module BABYLON {
  88064. /**
  88065. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  88066. * IMPORTANT!! The data is right-hand data.
  88067. * @export
  88068. * @interface DevicePose
  88069. */
  88070. export interface DevicePose {
  88071. /**
  88072. * The position of the device, values in array are [x,y,z].
  88073. */
  88074. readonly position: Nullable<Float32Array>;
  88075. /**
  88076. * The linearVelocity of the device, values in array are [x,y,z].
  88077. */
  88078. readonly linearVelocity: Nullable<Float32Array>;
  88079. /**
  88080. * The linearAcceleration of the device, values in array are [x,y,z].
  88081. */
  88082. readonly linearAcceleration: Nullable<Float32Array>;
  88083. /**
  88084. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  88085. */
  88086. readonly orientation: Nullable<Float32Array>;
  88087. /**
  88088. * The angularVelocity of the device, values in array are [x,y,z].
  88089. */
  88090. readonly angularVelocity: Nullable<Float32Array>;
  88091. /**
  88092. * The angularAcceleration of the device, values in array are [x,y,z].
  88093. */
  88094. readonly angularAcceleration: Nullable<Float32Array>;
  88095. }
  88096. /**
  88097. * Interface representing a pose controlled object in Babylon.
  88098. * A pose controlled object has both regular pose values as well as pose values
  88099. * from an external device such as a VR head mounted display
  88100. */
  88101. export interface PoseControlled {
  88102. /**
  88103. * The position of the object in babylon space.
  88104. */
  88105. position: Vector3;
  88106. /**
  88107. * The rotation quaternion of the object in babylon space.
  88108. */
  88109. rotationQuaternion: Quaternion;
  88110. /**
  88111. * The position of the device in babylon space.
  88112. */
  88113. devicePosition?: Vector3;
  88114. /**
  88115. * The rotation quaternion of the device in babylon space.
  88116. */
  88117. deviceRotationQuaternion: Quaternion;
  88118. /**
  88119. * The raw pose coming from the device.
  88120. */
  88121. rawPose: Nullable<DevicePose>;
  88122. /**
  88123. * The scale of the device to be used when translating from device space to babylon space.
  88124. */
  88125. deviceScaleFactor: number;
  88126. /**
  88127. * Updates the poseControlled values based on the input device pose.
  88128. * @param poseData the pose data to update the object with
  88129. */
  88130. updateFromDevice(poseData: DevicePose): void;
  88131. }
  88132. /**
  88133. * Set of options to customize the webVRCamera
  88134. */
  88135. export interface WebVROptions {
  88136. /**
  88137. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  88138. */
  88139. trackPosition?: boolean;
  88140. /**
  88141. * Sets the scale of the vrDevice in babylon space. (default: 1)
  88142. */
  88143. positionScale?: number;
  88144. /**
  88145. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  88146. */
  88147. displayName?: string;
  88148. /**
  88149. * Should the native controller meshes be initialized. (default: true)
  88150. */
  88151. controllerMeshes?: boolean;
  88152. /**
  88153. * Creating a default HemiLight only on controllers. (default: true)
  88154. */
  88155. defaultLightingOnControllers?: boolean;
  88156. /**
  88157. * If you don't want to use the default VR button of the helper. (default: false)
  88158. */
  88159. useCustomVRButton?: boolean;
  88160. /**
  88161. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  88162. */
  88163. customVRButton?: HTMLButtonElement;
  88164. /**
  88165. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  88166. */
  88167. rayLength?: number;
  88168. /**
  88169. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  88170. */
  88171. defaultHeight?: number;
  88172. /**
  88173. * If multiview should be used if availible (default: false)
  88174. */
  88175. useMultiview?: boolean;
  88176. }
  88177. /**
  88178. * This represents a WebVR camera.
  88179. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  88180. * @example http://doc.babylonjs.com/how_to/webvr_camera
  88181. */
  88182. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  88183. private webVROptions;
  88184. /**
  88185. * @hidden
  88186. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  88187. */
  88188. _vrDevice: any;
  88189. /**
  88190. * The rawPose of the vrDevice.
  88191. */
  88192. rawPose: Nullable<DevicePose>;
  88193. private _onVREnabled;
  88194. private _specsVersion;
  88195. private _attached;
  88196. private _frameData;
  88197. protected _descendants: Array<Node>;
  88198. private _deviceRoomPosition;
  88199. /** @hidden */
  88200. _deviceRoomRotationQuaternion: Quaternion;
  88201. private _standingMatrix;
  88202. /**
  88203. * Represents device position in babylon space.
  88204. */
  88205. devicePosition: Vector3;
  88206. /**
  88207. * Represents device rotation in babylon space.
  88208. */
  88209. deviceRotationQuaternion: Quaternion;
  88210. /**
  88211. * The scale of the device to be used when translating from device space to babylon space.
  88212. */
  88213. deviceScaleFactor: number;
  88214. private _deviceToWorld;
  88215. private _worldToDevice;
  88216. /**
  88217. * References to the webVR controllers for the vrDevice.
  88218. */
  88219. controllers: Array<WebVRController>;
  88220. /**
  88221. * Emits an event when a controller is attached.
  88222. */
  88223. onControllersAttachedObservable: Observable<WebVRController[]>;
  88224. /**
  88225. * Emits an event when a controller's mesh has been loaded;
  88226. */
  88227. onControllerMeshLoadedObservable: Observable<WebVRController>;
  88228. /**
  88229. * Emits an event when the HMD's pose has been updated.
  88230. */
  88231. onPoseUpdatedFromDeviceObservable: Observable<any>;
  88232. private _poseSet;
  88233. /**
  88234. * If the rig cameras be used as parent instead of this camera.
  88235. */
  88236. rigParenting: boolean;
  88237. private _lightOnControllers;
  88238. private _defaultHeight?;
  88239. /**
  88240. * Instantiates a WebVRFreeCamera.
  88241. * @param name The name of the WebVRFreeCamera
  88242. * @param position The starting anchor position for the camera
  88243. * @param scene The scene the camera belongs to
  88244. * @param webVROptions a set of customizable options for the webVRCamera
  88245. */
  88246. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  88247. /**
  88248. * Gets the device distance from the ground in meters.
  88249. * @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.
  88250. */
  88251. deviceDistanceToRoomGround(): number;
  88252. /**
  88253. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  88254. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  88255. */
  88256. useStandingMatrix(callback?: (bool: boolean) => void): void;
  88257. /**
  88258. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  88259. * @returns A promise with a boolean set to if the standing matrix is supported.
  88260. */
  88261. useStandingMatrixAsync(): Promise<boolean>;
  88262. /**
  88263. * Disposes the camera
  88264. */
  88265. dispose(): void;
  88266. /**
  88267. * Gets a vrController by name.
  88268. * @param name The name of the controller to retreive
  88269. * @returns the controller matching the name specified or null if not found
  88270. */
  88271. getControllerByName(name: string): Nullable<WebVRController>;
  88272. private _leftController;
  88273. /**
  88274. * The controller corresponding to the users left hand.
  88275. */
  88276. get leftController(): Nullable<WebVRController>;
  88277. private _rightController;
  88278. /**
  88279. * The controller corresponding to the users right hand.
  88280. */
  88281. get rightController(): Nullable<WebVRController>;
  88282. /**
  88283. * Casts a ray forward from the vrCamera's gaze.
  88284. * @param length Length of the ray (default: 100)
  88285. * @returns the ray corresponding to the gaze
  88286. */
  88287. getForwardRay(length?: number): Ray;
  88288. /**
  88289. * @hidden
  88290. * Updates the camera based on device's frame data
  88291. */
  88292. _checkInputs(): void;
  88293. /**
  88294. * Updates the poseControlled values based on the input device pose.
  88295. * @param poseData Pose coming from the device
  88296. */
  88297. updateFromDevice(poseData: DevicePose): void;
  88298. private _htmlElementAttached;
  88299. private _detachIfAttached;
  88300. /**
  88301. * WebVR's attach control will start broadcasting frames to the device.
  88302. * Note that in certain browsers (chrome for example) this function must be called
  88303. * within a user-interaction callback. Example:
  88304. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  88305. *
  88306. * @param element html element to attach the vrDevice to
  88307. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  88308. */
  88309. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  88310. /**
  88311. * Detaches the camera from the html element and disables VR
  88312. *
  88313. * @param element html element to detach from
  88314. */
  88315. detachControl(element: HTMLElement): void;
  88316. /**
  88317. * @returns the name of this class
  88318. */
  88319. getClassName(): string;
  88320. /**
  88321. * Calls resetPose on the vrDisplay
  88322. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  88323. */
  88324. resetToCurrentRotation(): void;
  88325. /**
  88326. * @hidden
  88327. * Updates the rig cameras (left and right eye)
  88328. */
  88329. _updateRigCameras(): void;
  88330. private _workingVector;
  88331. private _oneVector;
  88332. private _workingMatrix;
  88333. private updateCacheCalled;
  88334. private _correctPositionIfNotTrackPosition;
  88335. /**
  88336. * @hidden
  88337. * Updates the cached values of the camera
  88338. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  88339. */
  88340. _updateCache(ignoreParentClass?: boolean): void;
  88341. /**
  88342. * @hidden
  88343. * Get current device position in babylon world
  88344. */
  88345. _computeDevicePosition(): void;
  88346. /**
  88347. * Updates the current device position and rotation in the babylon world
  88348. */
  88349. update(): void;
  88350. /**
  88351. * @hidden
  88352. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  88353. * @returns an identity matrix
  88354. */
  88355. _getViewMatrix(): Matrix;
  88356. private _tmpMatrix;
  88357. /**
  88358. * This function is called by the two RIG cameras.
  88359. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  88360. * @hidden
  88361. */
  88362. _getWebVRViewMatrix(): Matrix;
  88363. /** @hidden */
  88364. _getWebVRProjectionMatrix(): Matrix;
  88365. private _onGamepadConnectedObserver;
  88366. private _onGamepadDisconnectedObserver;
  88367. private _updateCacheWhenTrackingDisabledObserver;
  88368. /**
  88369. * Initializes the controllers and their meshes
  88370. */
  88371. initControllers(): void;
  88372. }
  88373. }
  88374. declare module BABYLON {
  88375. /**
  88376. * Size options for a post process
  88377. */
  88378. export type PostProcessOptions = {
  88379. width: number;
  88380. height: number;
  88381. };
  88382. /**
  88383. * PostProcess can be used to apply a shader to a texture after it has been rendered
  88384. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  88385. */
  88386. export class PostProcess {
  88387. /** Name of the PostProcess. */
  88388. name: string;
  88389. /**
  88390. * Gets or sets the unique id of the post process
  88391. */
  88392. uniqueId: number;
  88393. /**
  88394. * Width of the texture to apply the post process on
  88395. */
  88396. width: number;
  88397. /**
  88398. * Height of the texture to apply the post process on
  88399. */
  88400. height: number;
  88401. /**
  88402. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  88403. * @hidden
  88404. */
  88405. _outputTexture: Nullable<InternalTexture>;
  88406. /**
  88407. * Sampling mode used by the shader
  88408. * See https://doc.babylonjs.com/classes/3.1/texture
  88409. */
  88410. renderTargetSamplingMode: number;
  88411. /**
  88412. * Clear color to use when screen clearing
  88413. */
  88414. clearColor: Color4;
  88415. /**
  88416. * If the buffer needs to be cleared before applying the post process. (default: true)
  88417. * Should be set to false if shader will overwrite all previous pixels.
  88418. */
  88419. autoClear: boolean;
  88420. /**
  88421. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  88422. */
  88423. alphaMode: number;
  88424. /**
  88425. * Sets the setAlphaBlendConstants of the babylon engine
  88426. */
  88427. alphaConstants: Color4;
  88428. /**
  88429. * Animations to be used for the post processing
  88430. */
  88431. animations: Animation[];
  88432. /**
  88433. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  88434. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  88435. */
  88436. enablePixelPerfectMode: boolean;
  88437. /**
  88438. * Force the postprocess to be applied without taking in account viewport
  88439. */
  88440. forceFullscreenViewport: boolean;
  88441. /**
  88442. * List of inspectable custom properties (used by the Inspector)
  88443. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88444. */
  88445. inspectableCustomProperties: IInspectable[];
  88446. /**
  88447. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  88448. *
  88449. * | Value | Type | Description |
  88450. * | ----- | ----------------------------------- | ----------- |
  88451. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  88452. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  88453. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  88454. *
  88455. */
  88456. scaleMode: number;
  88457. /**
  88458. * Force textures to be a power of two (default: false)
  88459. */
  88460. alwaysForcePOT: boolean;
  88461. private _samples;
  88462. /**
  88463. * Number of sample textures (default: 1)
  88464. */
  88465. get samples(): number;
  88466. set samples(n: number);
  88467. /**
  88468. * Modify the scale of the post process to be the same as the viewport (default: false)
  88469. */
  88470. adaptScaleToCurrentViewport: boolean;
  88471. private _camera;
  88472. private _scene;
  88473. private _engine;
  88474. private _options;
  88475. private _reusable;
  88476. private _textureType;
  88477. private _textureFormat;
  88478. /**
  88479. * Smart array of input and output textures for the post process.
  88480. * @hidden
  88481. */
  88482. _textures: SmartArray<InternalTexture>;
  88483. /**
  88484. * The index in _textures that corresponds to the output texture.
  88485. * @hidden
  88486. */
  88487. _currentRenderTextureInd: number;
  88488. private _effect;
  88489. private _samplers;
  88490. private _fragmentUrl;
  88491. private _vertexUrl;
  88492. private _parameters;
  88493. private _scaleRatio;
  88494. protected _indexParameters: any;
  88495. private _shareOutputWithPostProcess;
  88496. private _texelSize;
  88497. private _forcedOutputTexture;
  88498. /**
  88499. * Returns the fragment url or shader name used in the post process.
  88500. * @returns the fragment url or name in the shader store.
  88501. */
  88502. getEffectName(): string;
  88503. /**
  88504. * An event triggered when the postprocess is activated.
  88505. */
  88506. onActivateObservable: Observable<Camera>;
  88507. private _onActivateObserver;
  88508. /**
  88509. * A function that is added to the onActivateObservable
  88510. */
  88511. set onActivate(callback: Nullable<(camera: Camera) => void>);
  88512. /**
  88513. * An event triggered when the postprocess changes its size.
  88514. */
  88515. onSizeChangedObservable: Observable<PostProcess>;
  88516. private _onSizeChangedObserver;
  88517. /**
  88518. * A function that is added to the onSizeChangedObservable
  88519. */
  88520. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  88521. /**
  88522. * An event triggered when the postprocess applies its effect.
  88523. */
  88524. onApplyObservable: Observable<Effect>;
  88525. private _onApplyObserver;
  88526. /**
  88527. * A function that is added to the onApplyObservable
  88528. */
  88529. set onApply(callback: (effect: Effect) => void);
  88530. /**
  88531. * An event triggered before rendering the postprocess
  88532. */
  88533. onBeforeRenderObservable: Observable<Effect>;
  88534. private _onBeforeRenderObserver;
  88535. /**
  88536. * A function that is added to the onBeforeRenderObservable
  88537. */
  88538. set onBeforeRender(callback: (effect: Effect) => void);
  88539. /**
  88540. * An event triggered after rendering the postprocess
  88541. */
  88542. onAfterRenderObservable: Observable<Effect>;
  88543. private _onAfterRenderObserver;
  88544. /**
  88545. * A function that is added to the onAfterRenderObservable
  88546. */
  88547. set onAfterRender(callback: (efect: Effect) => void);
  88548. /**
  88549. * 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
  88550. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  88551. */
  88552. get inputTexture(): InternalTexture;
  88553. set inputTexture(value: InternalTexture);
  88554. /**
  88555. * Gets the camera which post process is applied to.
  88556. * @returns The camera the post process is applied to.
  88557. */
  88558. getCamera(): Camera;
  88559. /**
  88560. * Gets the texel size of the postprocess.
  88561. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  88562. */
  88563. get texelSize(): Vector2;
  88564. /**
  88565. * Creates a new instance PostProcess
  88566. * @param name The name of the PostProcess.
  88567. * @param fragmentUrl The url of the fragment shader to be used.
  88568. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  88569. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  88570. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  88571. * @param camera The camera to apply the render pass to.
  88572. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  88573. * @param engine The engine which the post process will be applied. (default: current engine)
  88574. * @param reusable If the post process can be reused on the same frame. (default: false)
  88575. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  88576. * @param textureType Type of textures used when performing the post process. (default: 0)
  88577. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  88578. * @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
  88579. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  88580. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  88581. */
  88582. constructor(
  88583. /** Name of the PostProcess. */
  88584. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  88585. /**
  88586. * Gets a string idenfifying the name of the class
  88587. * @returns "PostProcess" string
  88588. */
  88589. getClassName(): string;
  88590. /**
  88591. * Gets the engine which this post process belongs to.
  88592. * @returns The engine the post process was enabled with.
  88593. */
  88594. getEngine(): Engine;
  88595. /**
  88596. * The effect that is created when initializing the post process.
  88597. * @returns The created effect corresponding the the postprocess.
  88598. */
  88599. getEffect(): Effect;
  88600. /**
  88601. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  88602. * @param postProcess The post process to share the output with.
  88603. * @returns This post process.
  88604. */
  88605. shareOutputWith(postProcess: PostProcess): PostProcess;
  88606. /**
  88607. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  88608. * This should be called if the post process that shares output with this post process is disabled/disposed.
  88609. */
  88610. useOwnOutput(): void;
  88611. /**
  88612. * Updates the effect with the current post process compile time values and recompiles the shader.
  88613. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  88614. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  88615. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  88616. * @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
  88617. * @param onCompiled Called when the shader has been compiled.
  88618. * @param onError Called if there is an error when compiling a shader.
  88619. */
  88620. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  88621. /**
  88622. * The post process is reusable if it can be used multiple times within one frame.
  88623. * @returns If the post process is reusable
  88624. */
  88625. isReusable(): boolean;
  88626. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  88627. markTextureDirty(): void;
  88628. /**
  88629. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  88630. * 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.
  88631. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  88632. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  88633. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  88634. * @returns The target texture that was bound to be written to.
  88635. */
  88636. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  88637. /**
  88638. * If the post process is supported.
  88639. */
  88640. get isSupported(): boolean;
  88641. /**
  88642. * The aspect ratio of the output texture.
  88643. */
  88644. get aspectRatio(): number;
  88645. /**
  88646. * Get a value indicating if the post-process is ready to be used
  88647. * @returns true if the post-process is ready (shader is compiled)
  88648. */
  88649. isReady(): boolean;
  88650. /**
  88651. * Binds all textures and uniforms to the shader, this will be run on every pass.
  88652. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  88653. */
  88654. apply(): Nullable<Effect>;
  88655. private _disposeTextures;
  88656. /**
  88657. * Disposes the post process.
  88658. * @param camera The camera to dispose the post process on.
  88659. */
  88660. dispose(camera?: Camera): void;
  88661. }
  88662. }
  88663. declare module BABYLON {
  88664. /** @hidden */
  88665. export var kernelBlurVaryingDeclaration: {
  88666. name: string;
  88667. shader: string;
  88668. };
  88669. }
  88670. declare module BABYLON {
  88671. /** @hidden */
  88672. export var kernelBlurFragment: {
  88673. name: string;
  88674. shader: string;
  88675. };
  88676. }
  88677. declare module BABYLON {
  88678. /** @hidden */
  88679. export var kernelBlurFragment2: {
  88680. name: string;
  88681. shader: string;
  88682. };
  88683. }
  88684. declare module BABYLON {
  88685. /** @hidden */
  88686. export var kernelBlurPixelShader: {
  88687. name: string;
  88688. shader: string;
  88689. };
  88690. }
  88691. declare module BABYLON {
  88692. /** @hidden */
  88693. export var kernelBlurVertex: {
  88694. name: string;
  88695. shader: string;
  88696. };
  88697. }
  88698. declare module BABYLON {
  88699. /** @hidden */
  88700. export var kernelBlurVertexShader: {
  88701. name: string;
  88702. shader: string;
  88703. };
  88704. }
  88705. declare module BABYLON {
  88706. /**
  88707. * The Blur Post Process which blurs an image based on a kernel and direction.
  88708. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  88709. */
  88710. export class BlurPostProcess extends PostProcess {
  88711. /** The direction in which to blur the image. */
  88712. direction: Vector2;
  88713. private blockCompilation;
  88714. protected _kernel: number;
  88715. protected _idealKernel: number;
  88716. protected _packedFloat: boolean;
  88717. private _staticDefines;
  88718. /**
  88719. * Sets the length in pixels of the blur sample region
  88720. */
  88721. set kernel(v: number);
  88722. /**
  88723. * Gets the length in pixels of the blur sample region
  88724. */
  88725. get kernel(): number;
  88726. /**
  88727. * Sets wether or not the blur needs to unpack/repack floats
  88728. */
  88729. set packedFloat(v: boolean);
  88730. /**
  88731. * Gets wether or not the blur is unpacking/repacking floats
  88732. */
  88733. get packedFloat(): boolean;
  88734. /**
  88735. * Creates a new instance BlurPostProcess
  88736. * @param name The name of the effect.
  88737. * @param direction The direction in which to blur the image.
  88738. * @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.
  88739. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  88740. * @param camera The camera to apply the render pass to.
  88741. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  88742. * @param engine The engine which the post process will be applied. (default: current engine)
  88743. * @param reusable If the post process can be reused on the same frame. (default: false)
  88744. * @param textureType Type of textures used when performing the post process. (default: 0)
  88745. * @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)
  88746. */
  88747. constructor(name: string,
  88748. /** The direction in which to blur the image. */
  88749. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  88750. /**
  88751. * Updates the effect with the current post process compile time values and recompiles the shader.
  88752. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  88753. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  88754. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  88755. * @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
  88756. * @param onCompiled Called when the shader has been compiled.
  88757. * @param onError Called if there is an error when compiling a shader.
  88758. */
  88759. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  88760. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  88761. /**
  88762. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  88763. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  88764. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  88765. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  88766. * The gaps between physical kernels are compensated for in the weighting of the samples
  88767. * @param idealKernel Ideal blur kernel.
  88768. * @return Nearest best kernel.
  88769. */
  88770. protected _nearestBestKernel(idealKernel: number): number;
  88771. /**
  88772. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  88773. * @param x The point on the Gaussian distribution to sample.
  88774. * @return the value of the Gaussian function at x.
  88775. */
  88776. protected _gaussianWeight(x: number): number;
  88777. /**
  88778. * Generates a string that can be used as a floating point number in GLSL.
  88779. * @param x Value to print.
  88780. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  88781. * @return GLSL float string.
  88782. */
  88783. protected _glslFloat(x: number, decimalFigures?: number): string;
  88784. }
  88785. }
  88786. declare module BABYLON {
  88787. /**
  88788. * Mirror texture can be used to simulate the view from a mirror in a scene.
  88789. * It will dynamically be rendered every frame to adapt to the camera point of view.
  88790. * You can then easily use it as a reflectionTexture on a flat surface.
  88791. * In case the surface is not a plane, please consider relying on reflection probes.
  88792. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  88793. */
  88794. export class MirrorTexture extends RenderTargetTexture {
  88795. private scene;
  88796. /**
  88797. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  88798. * 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.
  88799. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  88800. */
  88801. mirrorPlane: Plane;
  88802. /**
  88803. * Define the blur ratio used to blur the reflection if needed.
  88804. */
  88805. set blurRatio(value: number);
  88806. get blurRatio(): number;
  88807. /**
  88808. * Define the adaptive blur kernel used to blur the reflection if needed.
  88809. * This will autocompute the closest best match for the `blurKernel`
  88810. */
  88811. set adaptiveBlurKernel(value: number);
  88812. /**
  88813. * Define the blur kernel used to blur the reflection if needed.
  88814. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  88815. */
  88816. set blurKernel(value: number);
  88817. /**
  88818. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  88819. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  88820. */
  88821. set blurKernelX(value: number);
  88822. get blurKernelX(): number;
  88823. /**
  88824. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  88825. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  88826. */
  88827. set blurKernelY(value: number);
  88828. get blurKernelY(): number;
  88829. private _autoComputeBlurKernel;
  88830. protected _onRatioRescale(): void;
  88831. private _updateGammaSpace;
  88832. private _imageProcessingConfigChangeObserver;
  88833. private _transformMatrix;
  88834. private _mirrorMatrix;
  88835. private _savedViewMatrix;
  88836. private _blurX;
  88837. private _blurY;
  88838. private _adaptiveBlurKernel;
  88839. private _blurKernelX;
  88840. private _blurKernelY;
  88841. private _blurRatio;
  88842. /**
  88843. * Instantiates a Mirror Texture.
  88844. * Mirror texture can be used to simulate the view from a mirror in a scene.
  88845. * It will dynamically be rendered every frame to adapt to the camera point of view.
  88846. * You can then easily use it as a reflectionTexture on a flat surface.
  88847. * In case the surface is not a plane, please consider relying on reflection probes.
  88848. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  88849. * @param name
  88850. * @param size
  88851. * @param scene
  88852. * @param generateMipMaps
  88853. * @param type
  88854. * @param samplingMode
  88855. * @param generateDepthBuffer
  88856. */
  88857. constructor(name: string, size: number | {
  88858. width: number;
  88859. height: number;
  88860. } | {
  88861. ratio: number;
  88862. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  88863. private _preparePostProcesses;
  88864. /**
  88865. * Clone the mirror texture.
  88866. * @returns the cloned texture
  88867. */
  88868. clone(): MirrorTexture;
  88869. /**
  88870. * Serialize the texture to a JSON representation you could use in Parse later on
  88871. * @returns the serialized JSON representation
  88872. */
  88873. serialize(): any;
  88874. /**
  88875. * Dispose the texture and release its associated resources.
  88876. */
  88877. dispose(): void;
  88878. }
  88879. }
  88880. declare module BABYLON {
  88881. /**
  88882. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  88883. * @see http://doc.babylonjs.com/babylon101/materials#texture
  88884. */
  88885. export class Texture extends BaseTexture {
  88886. /**
  88887. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  88888. */
  88889. static SerializeBuffers: boolean;
  88890. /** @hidden */
  88891. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  88892. /** @hidden */
  88893. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  88894. /** @hidden */
  88895. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  88896. /** nearest is mag = nearest and min = nearest and mip = linear */
  88897. static readonly NEAREST_SAMPLINGMODE: number;
  88898. /** nearest is mag = nearest and min = nearest and mip = linear */
  88899. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  88900. /** Bilinear is mag = linear and min = linear and mip = nearest */
  88901. static readonly BILINEAR_SAMPLINGMODE: number;
  88902. /** Bilinear is mag = linear and min = linear and mip = nearest */
  88903. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  88904. /** Trilinear is mag = linear and min = linear and mip = linear */
  88905. static readonly TRILINEAR_SAMPLINGMODE: number;
  88906. /** Trilinear is mag = linear and min = linear and mip = linear */
  88907. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  88908. /** mag = nearest and min = nearest and mip = nearest */
  88909. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  88910. /** mag = nearest and min = linear and mip = nearest */
  88911. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  88912. /** mag = nearest and min = linear and mip = linear */
  88913. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  88914. /** mag = nearest and min = linear and mip = none */
  88915. static readonly NEAREST_LINEAR: number;
  88916. /** mag = nearest and min = nearest and mip = none */
  88917. static readonly NEAREST_NEAREST: number;
  88918. /** mag = linear and min = nearest and mip = nearest */
  88919. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  88920. /** mag = linear and min = nearest and mip = linear */
  88921. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  88922. /** mag = linear and min = linear and mip = none */
  88923. static readonly LINEAR_LINEAR: number;
  88924. /** mag = linear and min = nearest and mip = none */
  88925. static readonly LINEAR_NEAREST: number;
  88926. /** Explicit coordinates mode */
  88927. static readonly EXPLICIT_MODE: number;
  88928. /** Spherical coordinates mode */
  88929. static readonly SPHERICAL_MODE: number;
  88930. /** Planar coordinates mode */
  88931. static readonly PLANAR_MODE: number;
  88932. /** Cubic coordinates mode */
  88933. static readonly CUBIC_MODE: number;
  88934. /** Projection coordinates mode */
  88935. static readonly PROJECTION_MODE: number;
  88936. /** Inverse Cubic coordinates mode */
  88937. static readonly SKYBOX_MODE: number;
  88938. /** Inverse Cubic coordinates mode */
  88939. static readonly INVCUBIC_MODE: number;
  88940. /** Equirectangular coordinates mode */
  88941. static readonly EQUIRECTANGULAR_MODE: number;
  88942. /** Equirectangular Fixed coordinates mode */
  88943. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  88944. /** Equirectangular Fixed Mirrored coordinates mode */
  88945. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  88946. /** Texture is not repeating outside of 0..1 UVs */
  88947. static readonly CLAMP_ADDRESSMODE: number;
  88948. /** Texture is repeating outside of 0..1 UVs */
  88949. static readonly WRAP_ADDRESSMODE: number;
  88950. /** Texture is repeating and mirrored */
  88951. static readonly MIRROR_ADDRESSMODE: number;
  88952. /**
  88953. * 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
  88954. */
  88955. static UseSerializedUrlIfAny: boolean;
  88956. /**
  88957. * Define the url of the texture.
  88958. */
  88959. url: Nullable<string>;
  88960. /**
  88961. * Define an offset on the texture to offset the u coordinates of the UVs
  88962. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  88963. */
  88964. uOffset: number;
  88965. /**
  88966. * Define an offset on the texture to offset the v coordinates of the UVs
  88967. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  88968. */
  88969. vOffset: number;
  88970. /**
  88971. * Define an offset on the texture to scale the u coordinates of the UVs
  88972. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  88973. */
  88974. uScale: number;
  88975. /**
  88976. * Define an offset on the texture to scale the v coordinates of the UVs
  88977. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  88978. */
  88979. vScale: number;
  88980. /**
  88981. * Define an offset on the texture to rotate around the u coordinates of the UVs
  88982. * @see http://doc.babylonjs.com/how_to/more_materials
  88983. */
  88984. uAng: number;
  88985. /**
  88986. * Define an offset on the texture to rotate around the v coordinates of the UVs
  88987. * @see http://doc.babylonjs.com/how_to/more_materials
  88988. */
  88989. vAng: number;
  88990. /**
  88991. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  88992. * @see http://doc.babylonjs.com/how_to/more_materials
  88993. */
  88994. wAng: number;
  88995. /**
  88996. * Defines the center of rotation (U)
  88997. */
  88998. uRotationCenter: number;
  88999. /**
  89000. * Defines the center of rotation (V)
  89001. */
  89002. vRotationCenter: number;
  89003. /**
  89004. * Defines the center of rotation (W)
  89005. */
  89006. wRotationCenter: number;
  89007. /**
  89008. * Are mip maps generated for this texture or not.
  89009. */
  89010. get noMipmap(): boolean;
  89011. /**
  89012. * List of inspectable custom properties (used by the Inspector)
  89013. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  89014. */
  89015. inspectableCustomProperties: Nullable<IInspectable[]>;
  89016. private _noMipmap;
  89017. /** @hidden */
  89018. _invertY: boolean;
  89019. private _rowGenerationMatrix;
  89020. private _cachedTextureMatrix;
  89021. private _projectionModeMatrix;
  89022. private _t0;
  89023. private _t1;
  89024. private _t2;
  89025. private _cachedUOffset;
  89026. private _cachedVOffset;
  89027. private _cachedUScale;
  89028. private _cachedVScale;
  89029. private _cachedUAng;
  89030. private _cachedVAng;
  89031. private _cachedWAng;
  89032. private _cachedProjectionMatrixId;
  89033. private _cachedCoordinatesMode;
  89034. /** @hidden */
  89035. protected _initialSamplingMode: number;
  89036. /** @hidden */
  89037. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  89038. private _deleteBuffer;
  89039. protected _format: Nullable<number>;
  89040. private _delayedOnLoad;
  89041. private _delayedOnError;
  89042. private _mimeType?;
  89043. /**
  89044. * Observable triggered once the texture has been loaded.
  89045. */
  89046. onLoadObservable: Observable<Texture>;
  89047. protected _isBlocking: boolean;
  89048. /**
  89049. * Is the texture preventing material to render while loading.
  89050. * If false, a default texture will be used instead of the loading one during the preparation step.
  89051. */
  89052. set isBlocking(value: boolean);
  89053. get isBlocking(): boolean;
  89054. /**
  89055. * Get the current sampling mode associated with the texture.
  89056. */
  89057. get samplingMode(): number;
  89058. /**
  89059. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  89060. */
  89061. get invertY(): boolean;
  89062. /**
  89063. * Instantiates a new texture.
  89064. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  89065. * @see http://doc.babylonjs.com/babylon101/materials#texture
  89066. * @param url defines the url of the picture to load as a texture
  89067. * @param scene defines the scene or engine the texture will belong to
  89068. * @param noMipmap defines if the texture will require mip maps or not
  89069. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  89070. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  89071. * @param onLoad defines a callback triggered when the texture has been loaded
  89072. * @param onError defines a callback triggered when an error occurred during the loading session
  89073. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  89074. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  89075. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  89076. * @param mimeType defines an optional mime type information
  89077. */
  89078. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  89079. /**
  89080. * Update the url (and optional buffer) of this texture if url was null during construction.
  89081. * @param url the url of the texture
  89082. * @param buffer the buffer of the texture (defaults to null)
  89083. * @param onLoad callback called when the texture is loaded (defaults to null)
  89084. */
  89085. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  89086. /**
  89087. * Finish the loading sequence of a texture flagged as delayed load.
  89088. * @hidden
  89089. */
  89090. delayLoad(): void;
  89091. private _prepareRowForTextureGeneration;
  89092. /**
  89093. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  89094. * @returns the transform matrix of the texture.
  89095. */
  89096. getTextureMatrix(uBase?: number): Matrix;
  89097. /**
  89098. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  89099. * @returns The reflection texture transform
  89100. */
  89101. getReflectionTextureMatrix(): Matrix;
  89102. /**
  89103. * Clones the texture.
  89104. * @returns the cloned texture
  89105. */
  89106. clone(): Texture;
  89107. /**
  89108. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  89109. * @returns The JSON representation of the texture
  89110. */
  89111. serialize(): any;
  89112. /**
  89113. * Get the current class name of the texture useful for serialization or dynamic coding.
  89114. * @returns "Texture"
  89115. */
  89116. getClassName(): string;
  89117. /**
  89118. * Dispose the texture and release its associated resources.
  89119. */
  89120. dispose(): void;
  89121. /**
  89122. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  89123. * @param parsedTexture Define the JSON representation of the texture
  89124. * @param scene Define the scene the parsed texture should be instantiated in
  89125. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  89126. * @returns The parsed texture if successful
  89127. */
  89128. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  89129. /**
  89130. * Creates a texture from its base 64 representation.
  89131. * @param data Define the base64 payload without the data: prefix
  89132. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  89133. * @param scene Define the scene the texture should belong to
  89134. * @param noMipmap Forces the texture to not create mip map information if true
  89135. * @param invertY define if the texture needs to be inverted on the y axis during loading
  89136. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  89137. * @param onLoad define a callback triggered when the texture has been loaded
  89138. * @param onError define a callback triggered when an error occurred during the loading session
  89139. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  89140. * @returns the created texture
  89141. */
  89142. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  89143. /**
  89144. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  89145. * @param data Define the base64 payload without the data: prefix
  89146. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  89147. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  89148. * @param scene Define the scene the texture should belong to
  89149. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  89150. * @param noMipmap Forces the texture to not create mip map information if true
  89151. * @param invertY define if the texture needs to be inverted on the y axis during loading
  89152. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  89153. * @param onLoad define a callback triggered when the texture has been loaded
  89154. * @param onError define a callback triggered when an error occurred during the loading session
  89155. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  89156. * @returns the created texture
  89157. */
  89158. 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;
  89159. }
  89160. }
  89161. declare module BABYLON {
  89162. /**
  89163. * PostProcessManager is used to manage one or more post processes or post process pipelines
  89164. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  89165. */
  89166. export class PostProcessManager {
  89167. private _scene;
  89168. private _indexBuffer;
  89169. private _vertexBuffers;
  89170. /**
  89171. * Creates a new instance PostProcess
  89172. * @param scene The scene that the post process is associated with.
  89173. */
  89174. constructor(scene: Scene);
  89175. private _prepareBuffers;
  89176. private _buildIndexBuffer;
  89177. /**
  89178. * Rebuilds the vertex buffers of the manager.
  89179. * @hidden
  89180. */
  89181. _rebuild(): void;
  89182. /**
  89183. * Prepares a frame to be run through a post process.
  89184. * @param sourceTexture The input texture to the post procesess. (default: null)
  89185. * @param postProcesses An array of post processes to be run. (default: null)
  89186. * @returns True if the post processes were able to be run.
  89187. * @hidden
  89188. */
  89189. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  89190. /**
  89191. * Manually render a set of post processes to a texture.
  89192. * @param postProcesses An array of post processes to be run.
  89193. * @param targetTexture The target texture to render to.
  89194. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  89195. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  89196. * @param lodLevel defines which lod of the texture to render to
  89197. */
  89198. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  89199. /**
  89200. * Finalize the result of the output of the postprocesses.
  89201. * @param doNotPresent If true the result will not be displayed to the screen.
  89202. * @param targetTexture The target texture to render to.
  89203. * @param faceIndex The index of the face to bind the target texture to.
  89204. * @param postProcesses The array of post processes to render.
  89205. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  89206. * @hidden
  89207. */
  89208. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  89209. /**
  89210. * Disposes of the post process manager.
  89211. */
  89212. dispose(): void;
  89213. }
  89214. }
  89215. declare module BABYLON {
  89216. /** Interface used by value gradients (color, factor, ...) */
  89217. export interface IValueGradient {
  89218. /**
  89219. * Gets or sets the gradient value (between 0 and 1)
  89220. */
  89221. gradient: number;
  89222. }
  89223. /** Class used to store color4 gradient */
  89224. export class ColorGradient implements IValueGradient {
  89225. /**
  89226. * Gets or sets the gradient value (between 0 and 1)
  89227. */
  89228. gradient: number;
  89229. /**
  89230. * Gets or sets first associated color
  89231. */
  89232. color1: Color4;
  89233. /**
  89234. * Gets or sets second associated color
  89235. */
  89236. color2?: Color4;
  89237. /**
  89238. * Will get a color picked randomly between color1 and color2.
  89239. * If color2 is undefined then color1 will be used
  89240. * @param result defines the target Color4 to store the result in
  89241. */
  89242. getColorToRef(result: Color4): void;
  89243. }
  89244. /** Class used to store color 3 gradient */
  89245. export class Color3Gradient implements IValueGradient {
  89246. /**
  89247. * Gets or sets the gradient value (between 0 and 1)
  89248. */
  89249. gradient: number;
  89250. /**
  89251. * Gets or sets the associated color
  89252. */
  89253. color: Color3;
  89254. }
  89255. /** Class used to store factor gradient */
  89256. export class FactorGradient implements IValueGradient {
  89257. /**
  89258. * Gets or sets the gradient value (between 0 and 1)
  89259. */
  89260. gradient: number;
  89261. /**
  89262. * Gets or sets first associated factor
  89263. */
  89264. factor1: number;
  89265. /**
  89266. * Gets or sets second associated factor
  89267. */
  89268. factor2?: number;
  89269. /**
  89270. * Will get a number picked randomly between factor1 and factor2.
  89271. * If factor2 is undefined then factor1 will be used
  89272. * @returns the picked number
  89273. */
  89274. getFactor(): number;
  89275. }
  89276. /**
  89277. * Helper used to simplify some generic gradient tasks
  89278. */
  89279. export class GradientHelper {
  89280. /**
  89281. * Gets the current gradient from an array of IValueGradient
  89282. * @param ratio defines the current ratio to get
  89283. * @param gradients defines the array of IValueGradient
  89284. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  89285. */
  89286. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  89287. }
  89288. }
  89289. declare module BABYLON {
  89290. interface ThinEngine {
  89291. /**
  89292. * Creates a dynamic texture
  89293. * @param width defines the width of the texture
  89294. * @param height defines the height of the texture
  89295. * @param generateMipMaps defines if the engine should generate the mip levels
  89296. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  89297. * @returns the dynamic texture inside an InternalTexture
  89298. */
  89299. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  89300. /**
  89301. * Update the content of a dynamic texture
  89302. * @param texture defines the texture to update
  89303. * @param canvas defines the canvas containing the source
  89304. * @param invertY defines if data must be stored with Y axis inverted
  89305. * @param premulAlpha defines if alpha is stored as premultiplied
  89306. * @param format defines the format of the data
  89307. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  89308. */
  89309. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  89310. }
  89311. }
  89312. declare module BABYLON {
  89313. /**
  89314. * Helper class used to generate a canvas to manipulate images
  89315. */
  89316. export class CanvasGenerator {
  89317. /**
  89318. * Create a new canvas (or offscreen canvas depending on the context)
  89319. * @param width defines the expected width
  89320. * @param height defines the expected height
  89321. * @return a new canvas or offscreen canvas
  89322. */
  89323. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  89324. }
  89325. }
  89326. declare module BABYLON {
  89327. /**
  89328. * A class extending Texture allowing drawing on a texture
  89329. * @see http://doc.babylonjs.com/how_to/dynamictexture
  89330. */
  89331. export class DynamicTexture extends Texture {
  89332. private _generateMipMaps;
  89333. private _canvas;
  89334. private _context;
  89335. private _engine;
  89336. /**
  89337. * Creates a DynamicTexture
  89338. * @param name defines the name of the texture
  89339. * @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
  89340. * @param scene defines the scene where you want the texture
  89341. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  89342. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  89343. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  89344. */
  89345. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  89346. /**
  89347. * Get the current class name of the texture useful for serialization or dynamic coding.
  89348. * @returns "DynamicTexture"
  89349. */
  89350. getClassName(): string;
  89351. /**
  89352. * Gets the current state of canRescale
  89353. */
  89354. get canRescale(): boolean;
  89355. private _recreate;
  89356. /**
  89357. * Scales the texture
  89358. * @param ratio the scale factor to apply to both width and height
  89359. */
  89360. scale(ratio: number): void;
  89361. /**
  89362. * Resizes the texture
  89363. * @param width the new width
  89364. * @param height the new height
  89365. */
  89366. scaleTo(width: number, height: number): void;
  89367. /**
  89368. * Gets the context of the canvas used by the texture
  89369. * @returns the canvas context of the dynamic texture
  89370. */
  89371. getContext(): CanvasRenderingContext2D;
  89372. /**
  89373. * Clears the texture
  89374. */
  89375. clear(): void;
  89376. /**
  89377. * Updates the texture
  89378. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  89379. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  89380. */
  89381. update(invertY?: boolean, premulAlpha?: boolean): void;
  89382. /**
  89383. * Draws text onto the texture
  89384. * @param text defines the text to be drawn
  89385. * @param x defines the placement of the text from the left
  89386. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  89387. * @param font defines the font to be used with font-style, font-size, font-name
  89388. * @param color defines the color used for the text
  89389. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  89390. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  89391. * @param update defines whether texture is immediately update (default is true)
  89392. */
  89393. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  89394. /**
  89395. * Clones the texture
  89396. * @returns the clone of the texture.
  89397. */
  89398. clone(): DynamicTexture;
  89399. /**
  89400. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  89401. * @returns a serialized dynamic texture object
  89402. */
  89403. serialize(): any;
  89404. /** @hidden */
  89405. _rebuild(): void;
  89406. }
  89407. }
  89408. declare module BABYLON {
  89409. interface AbstractScene {
  89410. /**
  89411. * The list of procedural textures added to the scene
  89412. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89413. */
  89414. proceduralTextures: Array<ProceduralTexture>;
  89415. }
  89416. /**
  89417. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  89418. * in a given scene.
  89419. */
  89420. export class ProceduralTextureSceneComponent implements ISceneComponent {
  89421. /**
  89422. * The component name helpfull to identify the component in the list of scene components.
  89423. */
  89424. readonly name: string;
  89425. /**
  89426. * The scene the component belongs to.
  89427. */
  89428. scene: Scene;
  89429. /**
  89430. * Creates a new instance of the component for the given scene
  89431. * @param scene Defines the scene to register the component in
  89432. */
  89433. constructor(scene: Scene);
  89434. /**
  89435. * Registers the component in a given scene
  89436. */
  89437. register(): void;
  89438. /**
  89439. * Rebuilds the elements related to this component in case of
  89440. * context lost for instance.
  89441. */
  89442. rebuild(): void;
  89443. /**
  89444. * Disposes the component and the associated ressources.
  89445. */
  89446. dispose(): void;
  89447. private _beforeClear;
  89448. }
  89449. }
  89450. declare module BABYLON {
  89451. interface ThinEngine {
  89452. /**
  89453. * Creates a new render target cube texture
  89454. * @param size defines the size of the texture
  89455. * @param options defines the options used to create the texture
  89456. * @returns a new render target cube texture stored in an InternalTexture
  89457. */
  89458. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  89459. }
  89460. }
  89461. declare module BABYLON {
  89462. /** @hidden */
  89463. export var proceduralVertexShader: {
  89464. name: string;
  89465. shader: string;
  89466. };
  89467. }
  89468. declare module BABYLON {
  89469. /**
  89470. * 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.
  89471. * This is the base class of any Procedural texture and contains most of the shareable code.
  89472. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89473. */
  89474. export class ProceduralTexture extends Texture {
  89475. isCube: boolean;
  89476. /**
  89477. * Define if the texture is enabled or not (disabled texture will not render)
  89478. */
  89479. isEnabled: boolean;
  89480. /**
  89481. * Define if the texture must be cleared before rendering (default is true)
  89482. */
  89483. autoClear: boolean;
  89484. /**
  89485. * Callback called when the texture is generated
  89486. */
  89487. onGenerated: () => void;
  89488. /**
  89489. * Event raised when the texture is generated
  89490. */
  89491. onGeneratedObservable: Observable<ProceduralTexture>;
  89492. /** @hidden */
  89493. _generateMipMaps: boolean;
  89494. /** @hidden **/
  89495. _effect: Effect;
  89496. /** @hidden */
  89497. _textures: {
  89498. [key: string]: Texture;
  89499. };
  89500. private _size;
  89501. private _currentRefreshId;
  89502. private _frameId;
  89503. private _refreshRate;
  89504. private _vertexBuffers;
  89505. private _indexBuffer;
  89506. private _uniforms;
  89507. private _samplers;
  89508. private _fragment;
  89509. private _floats;
  89510. private _ints;
  89511. private _floatsArrays;
  89512. private _colors3;
  89513. private _colors4;
  89514. private _vectors2;
  89515. private _vectors3;
  89516. private _matrices;
  89517. private _fallbackTexture;
  89518. private _fallbackTextureUsed;
  89519. private _engine;
  89520. private _cachedDefines;
  89521. private _contentUpdateId;
  89522. private _contentData;
  89523. /**
  89524. * Instantiates a new procedural texture.
  89525. * 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.
  89526. * This is the base class of any Procedural texture and contains most of the shareable code.
  89527. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89528. * @param name Define the name of the texture
  89529. * @param size Define the size of the texture to create
  89530. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  89531. * @param scene Define the scene the texture belongs to
  89532. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  89533. * @param generateMipMaps Define if the texture should creates mip maps or not
  89534. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  89535. */
  89536. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  89537. /**
  89538. * The effect that is created when initializing the post process.
  89539. * @returns The created effect corresponding the the postprocess.
  89540. */
  89541. getEffect(): Effect;
  89542. /**
  89543. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  89544. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  89545. */
  89546. getContent(): Nullable<ArrayBufferView>;
  89547. private _createIndexBuffer;
  89548. /** @hidden */
  89549. _rebuild(): void;
  89550. /**
  89551. * Resets the texture in order to recreate its associated resources.
  89552. * This can be called in case of context loss
  89553. */
  89554. reset(): void;
  89555. protected _getDefines(): string;
  89556. /**
  89557. * Is the texture ready to be used ? (rendered at least once)
  89558. * @returns true if ready, otherwise, false.
  89559. */
  89560. isReady(): boolean;
  89561. /**
  89562. * Resets the refresh counter of the texture and start bak from scratch.
  89563. * Could be useful to regenerate the texture if it is setup to render only once.
  89564. */
  89565. resetRefreshCounter(): void;
  89566. /**
  89567. * Set the fragment shader to use in order to render the texture.
  89568. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  89569. */
  89570. setFragment(fragment: any): void;
  89571. /**
  89572. * Define the refresh rate of the texture or the rendering frequency.
  89573. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  89574. */
  89575. get refreshRate(): number;
  89576. set refreshRate(value: number);
  89577. /** @hidden */
  89578. _shouldRender(): boolean;
  89579. /**
  89580. * Get the size the texture is rendering at.
  89581. * @returns the size (texture is always squared)
  89582. */
  89583. getRenderSize(): number;
  89584. /**
  89585. * Resize the texture to new value.
  89586. * @param size Define the new size the texture should have
  89587. * @param generateMipMaps Define whether the new texture should create mip maps
  89588. */
  89589. resize(size: number, generateMipMaps: boolean): void;
  89590. private _checkUniform;
  89591. /**
  89592. * Set a texture in the shader program used to render.
  89593. * @param name Define the name of the uniform samplers as defined in the shader
  89594. * @param texture Define the texture to bind to this sampler
  89595. * @return the texture itself allowing "fluent" like uniform updates
  89596. */
  89597. setTexture(name: string, texture: Texture): ProceduralTexture;
  89598. /**
  89599. * Set a float in the shader.
  89600. * @param name Define the name of the uniform as defined in the shader
  89601. * @param value Define the value to give to the uniform
  89602. * @return the texture itself allowing "fluent" like uniform updates
  89603. */
  89604. setFloat(name: string, value: number): ProceduralTexture;
  89605. /**
  89606. * Set a int in the shader.
  89607. * @param name Define the name of the uniform as defined in the shader
  89608. * @param value Define the value to give to the uniform
  89609. * @return the texture itself allowing "fluent" like uniform updates
  89610. */
  89611. setInt(name: string, value: number): ProceduralTexture;
  89612. /**
  89613. * Set an array of floats in the shader.
  89614. * @param name Define the name of the uniform as defined in the shader
  89615. * @param value Define the value to give to the uniform
  89616. * @return the texture itself allowing "fluent" like uniform updates
  89617. */
  89618. setFloats(name: string, value: number[]): ProceduralTexture;
  89619. /**
  89620. * Set a vec3 in the shader from a Color3.
  89621. * @param name Define the name of the uniform as defined in the shader
  89622. * @param value Define the value to give to the uniform
  89623. * @return the texture itself allowing "fluent" like uniform updates
  89624. */
  89625. setColor3(name: string, value: Color3): ProceduralTexture;
  89626. /**
  89627. * Set a vec4 in the shader from a Color4.
  89628. * @param name Define the name of the uniform as defined in the shader
  89629. * @param value Define the value to give to the uniform
  89630. * @return the texture itself allowing "fluent" like uniform updates
  89631. */
  89632. setColor4(name: string, value: Color4): ProceduralTexture;
  89633. /**
  89634. * Set a vec2 in the shader from a Vector2.
  89635. * @param name Define the name of the uniform as defined in the shader
  89636. * @param value Define the value to give to the uniform
  89637. * @return the texture itself allowing "fluent" like uniform updates
  89638. */
  89639. setVector2(name: string, value: Vector2): ProceduralTexture;
  89640. /**
  89641. * Set a vec3 in the shader from a Vector3.
  89642. * @param name Define the name of the uniform as defined in the shader
  89643. * @param value Define the value to give to the uniform
  89644. * @return the texture itself allowing "fluent" like uniform updates
  89645. */
  89646. setVector3(name: string, value: Vector3): ProceduralTexture;
  89647. /**
  89648. * Set a mat4 in the shader from a MAtrix.
  89649. * @param name Define the name of the uniform as defined in the shader
  89650. * @param value Define the value to give to the uniform
  89651. * @return the texture itself allowing "fluent" like uniform updates
  89652. */
  89653. setMatrix(name: string, value: Matrix): ProceduralTexture;
  89654. /**
  89655. * Render the texture to its associated render target.
  89656. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  89657. */
  89658. render(useCameraPostProcess?: boolean): void;
  89659. /**
  89660. * Clone the texture.
  89661. * @returns the cloned texture
  89662. */
  89663. clone(): ProceduralTexture;
  89664. /**
  89665. * Dispose the texture and release its asoociated resources.
  89666. */
  89667. dispose(): void;
  89668. }
  89669. }
  89670. declare module BABYLON {
  89671. /**
  89672. * This represents the base class for particle system in Babylon.
  89673. * 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.
  89674. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  89675. * @example https://doc.babylonjs.com/babylon101/particles
  89676. */
  89677. export class BaseParticleSystem {
  89678. /**
  89679. * Source color is added to the destination color without alpha affecting the result
  89680. */
  89681. static BLENDMODE_ONEONE: number;
  89682. /**
  89683. * Blend current color and particle color using particle’s alpha
  89684. */
  89685. static BLENDMODE_STANDARD: number;
  89686. /**
  89687. * Add current color and particle color multiplied by particle’s alpha
  89688. */
  89689. static BLENDMODE_ADD: number;
  89690. /**
  89691. * Multiply current color with particle color
  89692. */
  89693. static BLENDMODE_MULTIPLY: number;
  89694. /**
  89695. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  89696. */
  89697. static BLENDMODE_MULTIPLYADD: number;
  89698. /**
  89699. * List of animations used by the particle system.
  89700. */
  89701. animations: Animation[];
  89702. /**
  89703. * The id of the Particle system.
  89704. */
  89705. id: string;
  89706. /**
  89707. * The friendly name of the Particle system.
  89708. */
  89709. name: string;
  89710. /**
  89711. * The rendering group used by the Particle system to chose when to render.
  89712. */
  89713. renderingGroupId: number;
  89714. /**
  89715. * The emitter represents the Mesh or position we are attaching the particle system to.
  89716. */
  89717. emitter: Nullable<AbstractMesh | Vector3>;
  89718. /**
  89719. * The maximum number of particles to emit per frame
  89720. */
  89721. emitRate: number;
  89722. /**
  89723. * If you want to launch only a few particles at once, that can be done, as well.
  89724. */
  89725. manualEmitCount: number;
  89726. /**
  89727. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  89728. */
  89729. updateSpeed: number;
  89730. /**
  89731. * The amount of time the particle system is running (depends of the overall update speed).
  89732. */
  89733. targetStopDuration: number;
  89734. /**
  89735. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  89736. */
  89737. disposeOnStop: boolean;
  89738. /**
  89739. * Minimum power of emitting particles.
  89740. */
  89741. minEmitPower: number;
  89742. /**
  89743. * Maximum power of emitting particles.
  89744. */
  89745. maxEmitPower: number;
  89746. /**
  89747. * Minimum life time of emitting particles.
  89748. */
  89749. minLifeTime: number;
  89750. /**
  89751. * Maximum life time of emitting particles.
  89752. */
  89753. maxLifeTime: number;
  89754. /**
  89755. * Minimum Size of emitting particles.
  89756. */
  89757. minSize: number;
  89758. /**
  89759. * Maximum Size of emitting particles.
  89760. */
  89761. maxSize: number;
  89762. /**
  89763. * Minimum scale of emitting particles on X axis.
  89764. */
  89765. minScaleX: number;
  89766. /**
  89767. * Maximum scale of emitting particles on X axis.
  89768. */
  89769. maxScaleX: number;
  89770. /**
  89771. * Minimum scale of emitting particles on Y axis.
  89772. */
  89773. minScaleY: number;
  89774. /**
  89775. * Maximum scale of emitting particles on Y axis.
  89776. */
  89777. maxScaleY: number;
  89778. /**
  89779. * Gets or sets the minimal initial rotation in radians.
  89780. */
  89781. minInitialRotation: number;
  89782. /**
  89783. * Gets or sets the maximal initial rotation in radians.
  89784. */
  89785. maxInitialRotation: number;
  89786. /**
  89787. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  89788. */
  89789. minAngularSpeed: number;
  89790. /**
  89791. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  89792. */
  89793. maxAngularSpeed: number;
  89794. /**
  89795. * The texture used to render each particle. (this can be a spritesheet)
  89796. */
  89797. particleTexture: Nullable<Texture>;
  89798. /**
  89799. * The layer mask we are rendering the particles through.
  89800. */
  89801. layerMask: number;
  89802. /**
  89803. * This can help using your own shader to render the particle system.
  89804. * The according effect will be created
  89805. */
  89806. customShader: any;
  89807. /**
  89808. * By default particle system starts as soon as they are created. This prevents the
  89809. * automatic start to happen and let you decide when to start emitting particles.
  89810. */
  89811. preventAutoStart: boolean;
  89812. private _noiseTexture;
  89813. /**
  89814. * Gets or sets a texture used to add random noise to particle positions
  89815. */
  89816. get noiseTexture(): Nullable<ProceduralTexture>;
  89817. set noiseTexture(value: Nullable<ProceduralTexture>);
  89818. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  89819. noiseStrength: Vector3;
  89820. /**
  89821. * Callback triggered when the particle animation is ending.
  89822. */
  89823. onAnimationEnd: Nullable<() => void>;
  89824. /**
  89825. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  89826. */
  89827. blendMode: number;
  89828. /**
  89829. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  89830. * to override the particles.
  89831. */
  89832. forceDepthWrite: boolean;
  89833. /** 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 */
  89834. preWarmCycles: number;
  89835. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  89836. preWarmStepOffset: number;
  89837. /**
  89838. * 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)
  89839. */
  89840. spriteCellChangeSpeed: number;
  89841. /**
  89842. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  89843. */
  89844. startSpriteCellID: number;
  89845. /**
  89846. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  89847. */
  89848. endSpriteCellID: number;
  89849. /**
  89850. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  89851. */
  89852. spriteCellWidth: number;
  89853. /**
  89854. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  89855. */
  89856. spriteCellHeight: number;
  89857. /**
  89858. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  89859. */
  89860. spriteRandomStartCell: boolean;
  89861. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  89862. translationPivot: Vector2;
  89863. /** @hidden */
  89864. protected _isAnimationSheetEnabled: boolean;
  89865. /**
  89866. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  89867. */
  89868. beginAnimationOnStart: boolean;
  89869. /**
  89870. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  89871. */
  89872. beginAnimationFrom: number;
  89873. /**
  89874. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  89875. */
  89876. beginAnimationTo: number;
  89877. /**
  89878. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  89879. */
  89880. beginAnimationLoop: boolean;
  89881. /**
  89882. * Gets or sets a world offset applied to all particles
  89883. */
  89884. worldOffset: Vector3;
  89885. /**
  89886. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  89887. */
  89888. get isAnimationSheetEnabled(): boolean;
  89889. set isAnimationSheetEnabled(value: boolean);
  89890. /**
  89891. * Get hosting scene
  89892. * @returns the scene
  89893. */
  89894. getScene(): Scene;
  89895. /**
  89896. * You can use gravity if you want to give an orientation to your particles.
  89897. */
  89898. gravity: Vector3;
  89899. protected _colorGradients: Nullable<Array<ColorGradient>>;
  89900. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  89901. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  89902. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  89903. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  89904. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  89905. protected _dragGradients: Nullable<Array<FactorGradient>>;
  89906. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  89907. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  89908. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  89909. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  89910. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  89911. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  89912. /**
  89913. * Defines the delay in milliseconds before starting the system (0 by default)
  89914. */
  89915. startDelay: number;
  89916. /**
  89917. * Gets the current list of drag gradients.
  89918. * You must use addDragGradient and removeDragGradient to udpate this list
  89919. * @returns the list of drag gradients
  89920. */
  89921. getDragGradients(): Nullable<Array<FactorGradient>>;
  89922. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  89923. limitVelocityDamping: number;
  89924. /**
  89925. * Gets the current list of limit velocity gradients.
  89926. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  89927. * @returns the list of limit velocity gradients
  89928. */
  89929. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  89930. /**
  89931. * Gets the current list of color gradients.
  89932. * You must use addColorGradient and removeColorGradient to udpate this list
  89933. * @returns the list of color gradients
  89934. */
  89935. getColorGradients(): Nullable<Array<ColorGradient>>;
  89936. /**
  89937. * Gets the current list of size gradients.
  89938. * You must use addSizeGradient and removeSizeGradient to udpate this list
  89939. * @returns the list of size gradients
  89940. */
  89941. getSizeGradients(): Nullable<Array<FactorGradient>>;
  89942. /**
  89943. * Gets the current list of color remap gradients.
  89944. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  89945. * @returns the list of color remap gradients
  89946. */
  89947. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  89948. /**
  89949. * Gets the current list of alpha remap gradients.
  89950. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  89951. * @returns the list of alpha remap gradients
  89952. */
  89953. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  89954. /**
  89955. * Gets the current list of life time gradients.
  89956. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  89957. * @returns the list of life time gradients
  89958. */
  89959. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  89960. /**
  89961. * Gets the current list of angular speed gradients.
  89962. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  89963. * @returns the list of angular speed gradients
  89964. */
  89965. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  89966. /**
  89967. * Gets the current list of velocity gradients.
  89968. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  89969. * @returns the list of velocity gradients
  89970. */
  89971. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  89972. /**
  89973. * Gets the current list of start size gradients.
  89974. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  89975. * @returns the list of start size gradients
  89976. */
  89977. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  89978. /**
  89979. * Gets the current list of emit rate gradients.
  89980. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  89981. * @returns the list of emit rate gradients
  89982. */
  89983. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  89984. /**
  89985. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89986. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89987. */
  89988. get direction1(): Vector3;
  89989. set direction1(value: Vector3);
  89990. /**
  89991. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89992. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89993. */
  89994. get direction2(): Vector3;
  89995. set direction2(value: Vector3);
  89996. /**
  89997. * 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.
  89998. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89999. */
  90000. get minEmitBox(): Vector3;
  90001. set minEmitBox(value: Vector3);
  90002. /**
  90003. * 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.
  90004. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90005. */
  90006. get maxEmitBox(): Vector3;
  90007. set maxEmitBox(value: Vector3);
  90008. /**
  90009. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  90010. */
  90011. color1: Color4;
  90012. /**
  90013. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  90014. */
  90015. color2: Color4;
  90016. /**
  90017. * Color the particle will have at the end of its lifetime
  90018. */
  90019. colorDead: Color4;
  90020. /**
  90021. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  90022. */
  90023. textureMask: Color4;
  90024. /**
  90025. * The particle emitter type defines the emitter used by the particle system.
  90026. * It can be for example box, sphere, or cone...
  90027. */
  90028. particleEmitterType: IParticleEmitterType;
  90029. /** @hidden */
  90030. _isSubEmitter: boolean;
  90031. /**
  90032. * Gets or sets the billboard mode to use when isBillboardBased = true.
  90033. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  90034. */
  90035. billboardMode: number;
  90036. protected _isBillboardBased: boolean;
  90037. /**
  90038. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  90039. */
  90040. get isBillboardBased(): boolean;
  90041. set isBillboardBased(value: boolean);
  90042. /**
  90043. * The scene the particle system belongs to.
  90044. */
  90045. protected _scene: Scene;
  90046. /**
  90047. * Local cache of defines for image processing.
  90048. */
  90049. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  90050. /**
  90051. * Default configuration related to image processing available in the standard Material.
  90052. */
  90053. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  90054. /**
  90055. * Gets the image processing configuration used either in this material.
  90056. */
  90057. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  90058. /**
  90059. * Sets the Default image processing configuration used either in the this material.
  90060. *
  90061. * If sets to null, the scene one is in use.
  90062. */
  90063. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  90064. /**
  90065. * Attaches a new image processing configuration to the Standard Material.
  90066. * @param configuration
  90067. */
  90068. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  90069. /** @hidden */
  90070. protected _reset(): void;
  90071. /** @hidden */
  90072. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  90073. /**
  90074. * Instantiates a particle system.
  90075. * 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.
  90076. * @param name The name of the particle system
  90077. */
  90078. constructor(name: string);
  90079. /**
  90080. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  90081. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90082. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90083. * @returns the emitter
  90084. */
  90085. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  90086. /**
  90087. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  90088. * @param radius The radius of the hemisphere to emit from
  90089. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90090. * @returns the emitter
  90091. */
  90092. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  90093. /**
  90094. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  90095. * @param radius The radius of the sphere to emit from
  90096. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90097. * @returns the emitter
  90098. */
  90099. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  90100. /**
  90101. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  90102. * @param radius The radius of the sphere to emit from
  90103. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  90104. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  90105. * @returns the emitter
  90106. */
  90107. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  90108. /**
  90109. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  90110. * @param radius The radius of the emission cylinder
  90111. * @param height The height of the emission cylinder
  90112. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  90113. * @param directionRandomizer How much to randomize the particle direction [0-1]
  90114. * @returns the emitter
  90115. */
  90116. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  90117. /**
  90118. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  90119. * @param radius The radius of the cylinder to emit from
  90120. * @param height The height of the emission cylinder
  90121. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90122. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  90123. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  90124. * @returns the emitter
  90125. */
  90126. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  90127. /**
  90128. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  90129. * @param radius The radius of the cone to emit from
  90130. * @param angle The base angle of the cone
  90131. * @returns the emitter
  90132. */
  90133. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  90134. /**
  90135. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  90136. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90137. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90138. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90139. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90140. * @returns the emitter
  90141. */
  90142. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  90143. }
  90144. }
  90145. declare module BABYLON {
  90146. /**
  90147. * Type of sub emitter
  90148. */
  90149. export enum SubEmitterType {
  90150. /**
  90151. * Attached to the particle over it's lifetime
  90152. */
  90153. ATTACHED = 0,
  90154. /**
  90155. * Created when the particle dies
  90156. */
  90157. END = 1
  90158. }
  90159. /**
  90160. * Sub emitter class used to emit particles from an existing particle
  90161. */
  90162. export class SubEmitter {
  90163. /**
  90164. * the particle system to be used by the sub emitter
  90165. */
  90166. particleSystem: ParticleSystem;
  90167. /**
  90168. * Type of the submitter (Default: END)
  90169. */
  90170. type: SubEmitterType;
  90171. /**
  90172. * 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)
  90173. * Note: This only is supported when using an emitter of type Mesh
  90174. */
  90175. inheritDirection: boolean;
  90176. /**
  90177. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  90178. */
  90179. inheritedVelocityAmount: number;
  90180. /**
  90181. * Creates a sub emitter
  90182. * @param particleSystem the particle system to be used by the sub emitter
  90183. */
  90184. constructor(
  90185. /**
  90186. * the particle system to be used by the sub emitter
  90187. */
  90188. particleSystem: ParticleSystem);
  90189. /**
  90190. * Clones the sub emitter
  90191. * @returns the cloned sub emitter
  90192. */
  90193. clone(): SubEmitter;
  90194. /**
  90195. * Serialize current object to a JSON object
  90196. * @returns the serialized object
  90197. */
  90198. serialize(): any;
  90199. /** @hidden */
  90200. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  90201. /**
  90202. * Creates a new SubEmitter from a serialized JSON version
  90203. * @param serializationObject defines the JSON object to read from
  90204. * @param scene defines the hosting scene
  90205. * @param rootUrl defines the rootUrl for data loading
  90206. * @returns a new SubEmitter
  90207. */
  90208. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  90209. /** Release associated resources */
  90210. dispose(): void;
  90211. }
  90212. }
  90213. declare module BABYLON {
  90214. /** @hidden */
  90215. export var imageProcessingDeclaration: {
  90216. name: string;
  90217. shader: string;
  90218. };
  90219. }
  90220. declare module BABYLON {
  90221. /** @hidden */
  90222. export var imageProcessingFunctions: {
  90223. name: string;
  90224. shader: string;
  90225. };
  90226. }
  90227. declare module BABYLON {
  90228. /** @hidden */
  90229. export var particlesPixelShader: {
  90230. name: string;
  90231. shader: string;
  90232. };
  90233. }
  90234. declare module BABYLON {
  90235. /** @hidden */
  90236. export var particlesVertexShader: {
  90237. name: string;
  90238. shader: string;
  90239. };
  90240. }
  90241. declare module BABYLON {
  90242. /**
  90243. * This represents a particle system in Babylon.
  90244. * 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.
  90245. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  90246. * @example https://doc.babylonjs.com/babylon101/particles
  90247. */
  90248. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  90249. /**
  90250. * Billboard mode will only apply to Y axis
  90251. */
  90252. static readonly BILLBOARDMODE_Y: number;
  90253. /**
  90254. * Billboard mode will apply to all axes
  90255. */
  90256. static readonly BILLBOARDMODE_ALL: number;
  90257. /**
  90258. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  90259. */
  90260. static readonly BILLBOARDMODE_STRETCHED: number;
  90261. /**
  90262. * This function can be defined to provide custom update for active particles.
  90263. * This function will be called instead of regular update (age, position, color, etc.).
  90264. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  90265. */
  90266. updateFunction: (particles: Particle[]) => void;
  90267. private _emitterWorldMatrix;
  90268. /**
  90269. * This function can be defined to specify initial direction for every new particle.
  90270. * It by default use the emitterType defined function
  90271. */
  90272. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  90273. /**
  90274. * This function can be defined to specify initial position for every new particle.
  90275. * It by default use the emitterType defined function
  90276. */
  90277. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  90278. /**
  90279. * @hidden
  90280. */
  90281. _inheritedVelocityOffset: Vector3;
  90282. /**
  90283. * An event triggered when the system is disposed
  90284. */
  90285. onDisposeObservable: Observable<ParticleSystem>;
  90286. private _onDisposeObserver;
  90287. /**
  90288. * Sets a callback that will be triggered when the system is disposed
  90289. */
  90290. set onDispose(callback: () => void);
  90291. private _particles;
  90292. private _epsilon;
  90293. private _capacity;
  90294. private _stockParticles;
  90295. private _newPartsExcess;
  90296. private _vertexData;
  90297. private _vertexBuffer;
  90298. private _vertexBuffers;
  90299. private _spriteBuffer;
  90300. private _indexBuffer;
  90301. private _effect;
  90302. private _customEffect;
  90303. private _cachedDefines;
  90304. private _scaledColorStep;
  90305. private _colorDiff;
  90306. private _scaledDirection;
  90307. private _scaledGravity;
  90308. private _currentRenderId;
  90309. private _alive;
  90310. private _useInstancing;
  90311. private _started;
  90312. private _stopped;
  90313. private _actualFrame;
  90314. private _scaledUpdateSpeed;
  90315. private _vertexBufferSize;
  90316. /** @hidden */
  90317. _currentEmitRateGradient: Nullable<FactorGradient>;
  90318. /** @hidden */
  90319. _currentEmitRate1: number;
  90320. /** @hidden */
  90321. _currentEmitRate2: number;
  90322. /** @hidden */
  90323. _currentStartSizeGradient: Nullable<FactorGradient>;
  90324. /** @hidden */
  90325. _currentStartSize1: number;
  90326. /** @hidden */
  90327. _currentStartSize2: number;
  90328. private readonly _rawTextureWidth;
  90329. private _rampGradientsTexture;
  90330. private _useRampGradients;
  90331. /** Gets or sets a boolean indicating that ramp gradients must be used
  90332. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  90333. */
  90334. get useRampGradients(): boolean;
  90335. set useRampGradients(value: boolean);
  90336. /**
  90337. * 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.
  90338. * 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: [])
  90339. */
  90340. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  90341. private _subEmitters;
  90342. /**
  90343. * @hidden
  90344. * If the particle systems emitter should be disposed when the particle system is disposed
  90345. */
  90346. _disposeEmitterOnDispose: boolean;
  90347. /**
  90348. * The current active Sub-systems, this property is used by the root particle system only.
  90349. */
  90350. activeSubSystems: Array<ParticleSystem>;
  90351. private _rootParticleSystem;
  90352. /**
  90353. * Gets the current list of active particles
  90354. */
  90355. get particles(): Particle[];
  90356. /**
  90357. * Returns the string "ParticleSystem"
  90358. * @returns a string containing the class name
  90359. */
  90360. getClassName(): string;
  90361. /**
  90362. * Instantiates a particle system.
  90363. * 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.
  90364. * @param name The name of the particle system
  90365. * @param capacity The max number of particles alive at the same time
  90366. * @param scene The scene the particle system belongs to
  90367. * @param customEffect a custom effect used to change the way particles are rendered by default
  90368. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  90369. * @param epsilon Offset used to render the particles
  90370. */
  90371. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  90372. private _addFactorGradient;
  90373. private _removeFactorGradient;
  90374. /**
  90375. * Adds a new life time gradient
  90376. * @param gradient defines the gradient to use (between 0 and 1)
  90377. * @param factor defines the life time factor to affect to the specified gradient
  90378. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90379. * @returns the current particle system
  90380. */
  90381. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90382. /**
  90383. * Remove a specific life time gradient
  90384. * @param gradient defines the gradient to remove
  90385. * @returns the current particle system
  90386. */
  90387. removeLifeTimeGradient(gradient: number): IParticleSystem;
  90388. /**
  90389. * Adds a new size gradient
  90390. * @param gradient defines the gradient to use (between 0 and 1)
  90391. * @param factor defines the size factor to affect to the specified gradient
  90392. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90393. * @returns the current particle system
  90394. */
  90395. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90396. /**
  90397. * Remove a specific size gradient
  90398. * @param gradient defines the gradient to remove
  90399. * @returns the current particle system
  90400. */
  90401. removeSizeGradient(gradient: number): IParticleSystem;
  90402. /**
  90403. * Adds a new color remap gradient
  90404. * @param gradient defines the gradient to use (between 0 and 1)
  90405. * @param min defines the color remap minimal range
  90406. * @param max defines the color remap maximal range
  90407. * @returns the current particle system
  90408. */
  90409. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90410. /**
  90411. * Remove a specific color remap gradient
  90412. * @param gradient defines the gradient to remove
  90413. * @returns the current particle system
  90414. */
  90415. removeColorRemapGradient(gradient: number): IParticleSystem;
  90416. /**
  90417. * Adds a new alpha remap gradient
  90418. * @param gradient defines the gradient to use (between 0 and 1)
  90419. * @param min defines the alpha remap minimal range
  90420. * @param max defines the alpha remap maximal range
  90421. * @returns the current particle system
  90422. */
  90423. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90424. /**
  90425. * Remove a specific alpha remap gradient
  90426. * @param gradient defines the gradient to remove
  90427. * @returns the current particle system
  90428. */
  90429. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  90430. /**
  90431. * Adds a new angular speed gradient
  90432. * @param gradient defines the gradient to use (between 0 and 1)
  90433. * @param factor defines the angular speed to affect to the specified gradient
  90434. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90435. * @returns the current particle system
  90436. */
  90437. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90438. /**
  90439. * Remove a specific angular speed gradient
  90440. * @param gradient defines the gradient to remove
  90441. * @returns the current particle system
  90442. */
  90443. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  90444. /**
  90445. * Adds a new velocity gradient
  90446. * @param gradient defines the gradient to use (between 0 and 1)
  90447. * @param factor defines the velocity to affect to the specified gradient
  90448. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90449. * @returns the current particle system
  90450. */
  90451. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90452. /**
  90453. * Remove a specific velocity gradient
  90454. * @param gradient defines the gradient to remove
  90455. * @returns the current particle system
  90456. */
  90457. removeVelocityGradient(gradient: number): IParticleSystem;
  90458. /**
  90459. * Adds a new limit velocity gradient
  90460. * @param gradient defines the gradient to use (between 0 and 1)
  90461. * @param factor defines the limit velocity value to affect to the specified gradient
  90462. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90463. * @returns the current particle system
  90464. */
  90465. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90466. /**
  90467. * Remove a specific limit velocity gradient
  90468. * @param gradient defines the gradient to remove
  90469. * @returns the current particle system
  90470. */
  90471. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  90472. /**
  90473. * Adds a new drag gradient
  90474. * @param gradient defines the gradient to use (between 0 and 1)
  90475. * @param factor defines the drag value to affect to the specified gradient
  90476. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90477. * @returns the current particle system
  90478. */
  90479. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90480. /**
  90481. * Remove a specific drag gradient
  90482. * @param gradient defines the gradient to remove
  90483. * @returns the current particle system
  90484. */
  90485. removeDragGradient(gradient: number): IParticleSystem;
  90486. /**
  90487. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  90488. * @param gradient defines the gradient to use (between 0 and 1)
  90489. * @param factor defines the emit rate value to affect to the specified gradient
  90490. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90491. * @returns the current particle system
  90492. */
  90493. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90494. /**
  90495. * Remove a specific emit rate gradient
  90496. * @param gradient defines the gradient to remove
  90497. * @returns the current particle system
  90498. */
  90499. removeEmitRateGradient(gradient: number): IParticleSystem;
  90500. /**
  90501. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  90502. * @param gradient defines the gradient to use (between 0 and 1)
  90503. * @param factor defines the start size value to affect to the specified gradient
  90504. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90505. * @returns the current particle system
  90506. */
  90507. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90508. /**
  90509. * Remove a specific start size gradient
  90510. * @param gradient defines the gradient to remove
  90511. * @returns the current particle system
  90512. */
  90513. removeStartSizeGradient(gradient: number): IParticleSystem;
  90514. private _createRampGradientTexture;
  90515. /**
  90516. * Gets the current list of ramp gradients.
  90517. * You must use addRampGradient and removeRampGradient to udpate this list
  90518. * @returns the list of ramp gradients
  90519. */
  90520. getRampGradients(): Nullable<Array<Color3Gradient>>;
  90521. /**
  90522. * Adds a new ramp gradient used to remap particle colors
  90523. * @param gradient defines the gradient to use (between 0 and 1)
  90524. * @param color defines the color to affect to the specified gradient
  90525. * @returns the current particle system
  90526. */
  90527. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  90528. /**
  90529. * Remove a specific ramp gradient
  90530. * @param gradient defines the gradient to remove
  90531. * @returns the current particle system
  90532. */
  90533. removeRampGradient(gradient: number): ParticleSystem;
  90534. /**
  90535. * Adds a new color gradient
  90536. * @param gradient defines the gradient to use (between 0 and 1)
  90537. * @param color1 defines the color to affect to the specified gradient
  90538. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  90539. * @returns this particle system
  90540. */
  90541. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  90542. /**
  90543. * Remove a specific color gradient
  90544. * @param gradient defines the gradient to remove
  90545. * @returns this particle system
  90546. */
  90547. removeColorGradient(gradient: number): IParticleSystem;
  90548. private _fetchR;
  90549. protected _reset(): void;
  90550. private _resetEffect;
  90551. private _createVertexBuffers;
  90552. private _createIndexBuffer;
  90553. /**
  90554. * Gets the maximum number of particles active at the same time.
  90555. * @returns The max number of active particles.
  90556. */
  90557. getCapacity(): number;
  90558. /**
  90559. * Gets whether there are still active particles in the system.
  90560. * @returns True if it is alive, otherwise false.
  90561. */
  90562. isAlive(): boolean;
  90563. /**
  90564. * Gets if the system has been started. (Note: this will still be true after stop is called)
  90565. * @returns True if it has been started, otherwise false.
  90566. */
  90567. isStarted(): boolean;
  90568. private _prepareSubEmitterInternalArray;
  90569. /**
  90570. * Starts the particle system and begins to emit
  90571. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  90572. */
  90573. start(delay?: number): void;
  90574. /**
  90575. * Stops the particle system.
  90576. * @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.
  90577. */
  90578. stop(stopSubEmitters?: boolean): void;
  90579. /**
  90580. * Remove all active particles
  90581. */
  90582. reset(): void;
  90583. /**
  90584. * @hidden (for internal use only)
  90585. */
  90586. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  90587. /**
  90588. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  90589. * Its lifetime will start back at 0.
  90590. */
  90591. recycleParticle: (particle: Particle) => void;
  90592. private _stopSubEmitters;
  90593. private _createParticle;
  90594. private _removeFromRoot;
  90595. private _emitFromParticle;
  90596. private _update;
  90597. /** @hidden */
  90598. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  90599. /** @hidden */
  90600. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  90601. /** @hidden */
  90602. private _getEffect;
  90603. /**
  90604. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  90605. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  90606. */
  90607. animate(preWarmOnly?: boolean): void;
  90608. private _appendParticleVertices;
  90609. /**
  90610. * Rebuilds the particle system.
  90611. */
  90612. rebuild(): void;
  90613. /**
  90614. * Is this system ready to be used/rendered
  90615. * @return true if the system is ready
  90616. */
  90617. isReady(): boolean;
  90618. private _render;
  90619. /**
  90620. * Renders the particle system in its current state.
  90621. * @returns the current number of particles
  90622. */
  90623. render(): number;
  90624. /**
  90625. * Disposes the particle system and free the associated resources
  90626. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  90627. */
  90628. dispose(disposeTexture?: boolean): void;
  90629. /**
  90630. * Clones the particle system.
  90631. * @param name The name of the cloned object
  90632. * @param newEmitter The new emitter to use
  90633. * @returns the cloned particle system
  90634. */
  90635. clone(name: string, newEmitter: any): ParticleSystem;
  90636. /**
  90637. * Serializes the particle system to a JSON object.
  90638. * @returns the JSON object
  90639. */
  90640. serialize(): any;
  90641. /** @hidden */
  90642. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  90643. /** @hidden */
  90644. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  90645. /**
  90646. * Parses a JSON object to create a particle system.
  90647. * @param parsedParticleSystem The JSON object to parse
  90648. * @param scene The scene to create the particle system in
  90649. * @param rootUrl The root url to use to load external dependencies like texture
  90650. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  90651. * @returns the Parsed particle system
  90652. */
  90653. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  90654. }
  90655. }
  90656. declare module BABYLON {
  90657. /**
  90658. * A particle represents one of the element emitted by a particle system.
  90659. * This is mainly define by its coordinates, direction, velocity and age.
  90660. */
  90661. export class Particle {
  90662. /**
  90663. * The particle system the particle belongs to.
  90664. */
  90665. particleSystem: ParticleSystem;
  90666. private static _Count;
  90667. /**
  90668. * Unique ID of the particle
  90669. */
  90670. id: number;
  90671. /**
  90672. * The world position of the particle in the scene.
  90673. */
  90674. position: Vector3;
  90675. /**
  90676. * The world direction of the particle in the scene.
  90677. */
  90678. direction: Vector3;
  90679. /**
  90680. * The color of the particle.
  90681. */
  90682. color: Color4;
  90683. /**
  90684. * The color change of the particle per step.
  90685. */
  90686. colorStep: Color4;
  90687. /**
  90688. * Defines how long will the life of the particle be.
  90689. */
  90690. lifeTime: number;
  90691. /**
  90692. * The current age of the particle.
  90693. */
  90694. age: number;
  90695. /**
  90696. * The current size of the particle.
  90697. */
  90698. size: number;
  90699. /**
  90700. * The current scale of the particle.
  90701. */
  90702. scale: Vector2;
  90703. /**
  90704. * The current angle of the particle.
  90705. */
  90706. angle: number;
  90707. /**
  90708. * Defines how fast is the angle changing.
  90709. */
  90710. angularSpeed: number;
  90711. /**
  90712. * Defines the cell index used by the particle to be rendered from a sprite.
  90713. */
  90714. cellIndex: number;
  90715. /**
  90716. * The information required to support color remapping
  90717. */
  90718. remapData: Vector4;
  90719. /** @hidden */
  90720. _randomCellOffset?: number;
  90721. /** @hidden */
  90722. _initialDirection: Nullable<Vector3>;
  90723. /** @hidden */
  90724. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  90725. /** @hidden */
  90726. _initialStartSpriteCellID: number;
  90727. /** @hidden */
  90728. _initialEndSpriteCellID: number;
  90729. /** @hidden */
  90730. _currentColorGradient: Nullable<ColorGradient>;
  90731. /** @hidden */
  90732. _currentColor1: Color4;
  90733. /** @hidden */
  90734. _currentColor2: Color4;
  90735. /** @hidden */
  90736. _currentSizeGradient: Nullable<FactorGradient>;
  90737. /** @hidden */
  90738. _currentSize1: number;
  90739. /** @hidden */
  90740. _currentSize2: number;
  90741. /** @hidden */
  90742. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  90743. /** @hidden */
  90744. _currentAngularSpeed1: number;
  90745. /** @hidden */
  90746. _currentAngularSpeed2: number;
  90747. /** @hidden */
  90748. _currentVelocityGradient: Nullable<FactorGradient>;
  90749. /** @hidden */
  90750. _currentVelocity1: number;
  90751. /** @hidden */
  90752. _currentVelocity2: number;
  90753. /** @hidden */
  90754. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  90755. /** @hidden */
  90756. _currentLimitVelocity1: number;
  90757. /** @hidden */
  90758. _currentLimitVelocity2: number;
  90759. /** @hidden */
  90760. _currentDragGradient: Nullable<FactorGradient>;
  90761. /** @hidden */
  90762. _currentDrag1: number;
  90763. /** @hidden */
  90764. _currentDrag2: number;
  90765. /** @hidden */
  90766. _randomNoiseCoordinates1: Vector3;
  90767. /** @hidden */
  90768. _randomNoiseCoordinates2: Vector3;
  90769. /**
  90770. * Creates a new instance Particle
  90771. * @param particleSystem the particle system the particle belongs to
  90772. */
  90773. constructor(
  90774. /**
  90775. * The particle system the particle belongs to.
  90776. */
  90777. particleSystem: ParticleSystem);
  90778. private updateCellInfoFromSystem;
  90779. /**
  90780. * Defines how the sprite cell index is updated for the particle
  90781. */
  90782. updateCellIndex(): void;
  90783. /** @hidden */
  90784. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  90785. /** @hidden */
  90786. _inheritParticleInfoToSubEmitters(): void;
  90787. /** @hidden */
  90788. _reset(): void;
  90789. /**
  90790. * Copy the properties of particle to another one.
  90791. * @param other the particle to copy the information to.
  90792. */
  90793. copyTo(other: Particle): void;
  90794. }
  90795. }
  90796. declare module BABYLON {
  90797. /**
  90798. * Particle emitter represents a volume emitting particles.
  90799. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  90800. */
  90801. export interface IParticleEmitterType {
  90802. /**
  90803. * Called by the particle System when the direction is computed for the created particle.
  90804. * @param worldMatrix is the world matrix of the particle system
  90805. * @param directionToUpdate is the direction vector to update with the result
  90806. * @param particle is the particle we are computed the direction for
  90807. */
  90808. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90809. /**
  90810. * Called by the particle System when the position is computed for the created particle.
  90811. * @param worldMatrix is the world matrix of the particle system
  90812. * @param positionToUpdate is the position vector to update with the result
  90813. * @param particle is the particle we are computed the position for
  90814. */
  90815. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  90816. /**
  90817. * Clones the current emitter and returns a copy of it
  90818. * @returns the new emitter
  90819. */
  90820. clone(): IParticleEmitterType;
  90821. /**
  90822. * Called by the GPUParticleSystem to setup the update shader
  90823. * @param effect defines the update shader
  90824. */
  90825. applyToShader(effect: Effect): void;
  90826. /**
  90827. * Returns a string to use to update the GPU particles update shader
  90828. * @returns the effect defines string
  90829. */
  90830. getEffectDefines(): string;
  90831. /**
  90832. * Returns a string representing the class name
  90833. * @returns a string containing the class name
  90834. */
  90835. getClassName(): string;
  90836. /**
  90837. * Serializes the particle system to a JSON object.
  90838. * @returns the JSON object
  90839. */
  90840. serialize(): any;
  90841. /**
  90842. * Parse properties from a JSON object
  90843. * @param serializationObject defines the JSON object
  90844. */
  90845. parse(serializationObject: any): void;
  90846. }
  90847. }
  90848. declare module BABYLON {
  90849. /**
  90850. * Particle emitter emitting particles from the inside of a box.
  90851. * It emits the particles randomly between 2 given directions.
  90852. */
  90853. export class BoxParticleEmitter implements IParticleEmitterType {
  90854. /**
  90855. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90856. */
  90857. direction1: Vector3;
  90858. /**
  90859. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90860. */
  90861. direction2: Vector3;
  90862. /**
  90863. * 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.
  90864. */
  90865. minEmitBox: Vector3;
  90866. /**
  90867. * 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.
  90868. */
  90869. maxEmitBox: Vector3;
  90870. /**
  90871. * Creates a new instance BoxParticleEmitter
  90872. */
  90873. constructor();
  90874. /**
  90875. * Called by the particle System when the direction is computed for the created particle.
  90876. * @param worldMatrix is the world matrix of the particle system
  90877. * @param directionToUpdate is the direction vector to update with the result
  90878. * @param particle is the particle we are computed the direction for
  90879. */
  90880. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90881. /**
  90882. * Called by the particle System when the position is computed for the created particle.
  90883. * @param worldMatrix is the world matrix of the particle system
  90884. * @param positionToUpdate is the position vector to update with the result
  90885. * @param particle is the particle we are computed the position for
  90886. */
  90887. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  90888. /**
  90889. * Clones the current emitter and returns a copy of it
  90890. * @returns the new emitter
  90891. */
  90892. clone(): BoxParticleEmitter;
  90893. /**
  90894. * Called by the GPUParticleSystem to setup the update shader
  90895. * @param effect defines the update shader
  90896. */
  90897. applyToShader(effect: Effect): void;
  90898. /**
  90899. * Returns a string to use to update the GPU particles update shader
  90900. * @returns a string containng the defines string
  90901. */
  90902. getEffectDefines(): string;
  90903. /**
  90904. * Returns the string "BoxParticleEmitter"
  90905. * @returns a string containing the class name
  90906. */
  90907. getClassName(): string;
  90908. /**
  90909. * Serializes the particle system to a JSON object.
  90910. * @returns the JSON object
  90911. */
  90912. serialize(): any;
  90913. /**
  90914. * Parse properties from a JSON object
  90915. * @param serializationObject defines the JSON object
  90916. */
  90917. parse(serializationObject: any): void;
  90918. }
  90919. }
  90920. declare module BABYLON {
  90921. /**
  90922. * Particle emitter emitting particles from the inside of a cone.
  90923. * It emits the particles alongside the cone volume from the base to the particle.
  90924. * The emission direction might be randomized.
  90925. */
  90926. export class ConeParticleEmitter implements IParticleEmitterType {
  90927. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  90928. directionRandomizer: number;
  90929. private _radius;
  90930. private _angle;
  90931. private _height;
  90932. /**
  90933. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  90934. */
  90935. radiusRange: number;
  90936. /**
  90937. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  90938. */
  90939. heightRange: number;
  90940. /**
  90941. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  90942. */
  90943. emitFromSpawnPointOnly: boolean;
  90944. /**
  90945. * Gets or sets the radius of the emission cone
  90946. */
  90947. get radius(): number;
  90948. set radius(value: number);
  90949. /**
  90950. * Gets or sets the angle of the emission cone
  90951. */
  90952. get angle(): number;
  90953. set angle(value: number);
  90954. private _buildHeight;
  90955. /**
  90956. * Creates a new instance ConeParticleEmitter
  90957. * @param radius the radius of the emission cone (1 by default)
  90958. * @param angle the cone base angle (PI by default)
  90959. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  90960. */
  90961. constructor(radius?: number, angle?: number,
  90962. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  90963. directionRandomizer?: number);
  90964. /**
  90965. * Called by the particle System when the direction is computed for the created particle.
  90966. * @param worldMatrix is the world matrix of the particle system
  90967. * @param directionToUpdate is the direction vector to update with the result
  90968. * @param particle is the particle we are computed the direction for
  90969. */
  90970. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90971. /**
  90972. * Called by the particle System when the position is computed for the created particle.
  90973. * @param worldMatrix is the world matrix of the particle system
  90974. * @param positionToUpdate is the position vector to update with the result
  90975. * @param particle is the particle we are computed the position for
  90976. */
  90977. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  90978. /**
  90979. * Clones the current emitter and returns a copy of it
  90980. * @returns the new emitter
  90981. */
  90982. clone(): ConeParticleEmitter;
  90983. /**
  90984. * Called by the GPUParticleSystem to setup the update shader
  90985. * @param effect defines the update shader
  90986. */
  90987. applyToShader(effect: Effect): void;
  90988. /**
  90989. * Returns a string to use to update the GPU particles update shader
  90990. * @returns a string containng the defines string
  90991. */
  90992. getEffectDefines(): string;
  90993. /**
  90994. * Returns the string "ConeParticleEmitter"
  90995. * @returns a string containing the class name
  90996. */
  90997. getClassName(): string;
  90998. /**
  90999. * Serializes the particle system to a JSON object.
  91000. * @returns the JSON object
  91001. */
  91002. serialize(): any;
  91003. /**
  91004. * Parse properties from a JSON object
  91005. * @param serializationObject defines the JSON object
  91006. */
  91007. parse(serializationObject: any): void;
  91008. }
  91009. }
  91010. declare module BABYLON {
  91011. /**
  91012. * Particle emitter emitting particles from the inside of a cylinder.
  91013. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  91014. */
  91015. export class CylinderParticleEmitter implements IParticleEmitterType {
  91016. /**
  91017. * The radius of the emission cylinder.
  91018. */
  91019. radius: number;
  91020. /**
  91021. * The height of the emission cylinder.
  91022. */
  91023. height: number;
  91024. /**
  91025. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91026. */
  91027. radiusRange: number;
  91028. /**
  91029. * How much to randomize the particle direction [0-1].
  91030. */
  91031. directionRandomizer: number;
  91032. /**
  91033. * Creates a new instance CylinderParticleEmitter
  91034. * @param radius the radius of the emission cylinder (1 by default)
  91035. * @param height the height of the emission cylinder (1 by default)
  91036. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91037. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91038. */
  91039. constructor(
  91040. /**
  91041. * The radius of the emission cylinder.
  91042. */
  91043. radius?: number,
  91044. /**
  91045. * The height of the emission cylinder.
  91046. */
  91047. height?: number,
  91048. /**
  91049. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91050. */
  91051. radiusRange?: number,
  91052. /**
  91053. * How much to randomize the particle direction [0-1].
  91054. */
  91055. directionRandomizer?: number);
  91056. /**
  91057. * Called by the particle System when the direction is computed for the created particle.
  91058. * @param worldMatrix is the world matrix of the particle system
  91059. * @param directionToUpdate is the direction vector to update with the result
  91060. * @param particle is the particle we are computed the direction for
  91061. */
  91062. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91063. /**
  91064. * Called by the particle System when the position is computed for the created particle.
  91065. * @param worldMatrix is the world matrix of the particle system
  91066. * @param positionToUpdate is the position vector to update with the result
  91067. * @param particle is the particle we are computed the position for
  91068. */
  91069. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  91070. /**
  91071. * Clones the current emitter and returns a copy of it
  91072. * @returns the new emitter
  91073. */
  91074. clone(): CylinderParticleEmitter;
  91075. /**
  91076. * Called by the GPUParticleSystem to setup the update shader
  91077. * @param effect defines the update shader
  91078. */
  91079. applyToShader(effect: Effect): void;
  91080. /**
  91081. * Returns a string to use to update the GPU particles update shader
  91082. * @returns a string containng the defines string
  91083. */
  91084. getEffectDefines(): string;
  91085. /**
  91086. * Returns the string "CylinderParticleEmitter"
  91087. * @returns a string containing the class name
  91088. */
  91089. getClassName(): string;
  91090. /**
  91091. * Serializes the particle system to a JSON object.
  91092. * @returns the JSON object
  91093. */
  91094. serialize(): any;
  91095. /**
  91096. * Parse properties from a JSON object
  91097. * @param serializationObject defines the JSON object
  91098. */
  91099. parse(serializationObject: any): void;
  91100. }
  91101. /**
  91102. * Particle emitter emitting particles from the inside of a cylinder.
  91103. * It emits the particles randomly between two vectors.
  91104. */
  91105. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  91106. /**
  91107. * The min limit of the emission direction.
  91108. */
  91109. direction1: Vector3;
  91110. /**
  91111. * The max limit of the emission direction.
  91112. */
  91113. direction2: Vector3;
  91114. /**
  91115. * Creates a new instance CylinderDirectedParticleEmitter
  91116. * @param radius the radius of the emission cylinder (1 by default)
  91117. * @param height the height of the emission cylinder (1 by default)
  91118. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91119. * @param direction1 the min limit of the emission direction (up vector by default)
  91120. * @param direction2 the max limit of the emission direction (up vector by default)
  91121. */
  91122. constructor(radius?: number, height?: number, radiusRange?: number,
  91123. /**
  91124. * The min limit of the emission direction.
  91125. */
  91126. direction1?: Vector3,
  91127. /**
  91128. * The max limit of the emission direction.
  91129. */
  91130. direction2?: Vector3);
  91131. /**
  91132. * Called by the particle System when the direction is computed for the created particle.
  91133. * @param worldMatrix is the world matrix of the particle system
  91134. * @param directionToUpdate is the direction vector to update with the result
  91135. * @param particle is the particle we are computed the direction for
  91136. */
  91137. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91138. /**
  91139. * Clones the current emitter and returns a copy of it
  91140. * @returns the new emitter
  91141. */
  91142. clone(): CylinderDirectedParticleEmitter;
  91143. /**
  91144. * Called by the GPUParticleSystem to setup the update shader
  91145. * @param effect defines the update shader
  91146. */
  91147. applyToShader(effect: Effect): void;
  91148. /**
  91149. * Returns a string to use to update the GPU particles update shader
  91150. * @returns a string containng the defines string
  91151. */
  91152. getEffectDefines(): string;
  91153. /**
  91154. * Returns the string "CylinderDirectedParticleEmitter"
  91155. * @returns a string containing the class name
  91156. */
  91157. getClassName(): string;
  91158. /**
  91159. * Serializes the particle system to a JSON object.
  91160. * @returns the JSON object
  91161. */
  91162. serialize(): any;
  91163. /**
  91164. * Parse properties from a JSON object
  91165. * @param serializationObject defines the JSON object
  91166. */
  91167. parse(serializationObject: any): void;
  91168. }
  91169. }
  91170. declare module BABYLON {
  91171. /**
  91172. * Particle emitter emitting particles from the inside of a hemisphere.
  91173. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  91174. */
  91175. export class HemisphericParticleEmitter implements IParticleEmitterType {
  91176. /**
  91177. * The radius of the emission hemisphere.
  91178. */
  91179. radius: number;
  91180. /**
  91181. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91182. */
  91183. radiusRange: number;
  91184. /**
  91185. * How much to randomize the particle direction [0-1].
  91186. */
  91187. directionRandomizer: number;
  91188. /**
  91189. * Creates a new instance HemisphericParticleEmitter
  91190. * @param radius the radius of the emission hemisphere (1 by default)
  91191. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91192. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91193. */
  91194. constructor(
  91195. /**
  91196. * The radius of the emission hemisphere.
  91197. */
  91198. radius?: number,
  91199. /**
  91200. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91201. */
  91202. radiusRange?: number,
  91203. /**
  91204. * How much to randomize the particle direction [0-1].
  91205. */
  91206. directionRandomizer?: number);
  91207. /**
  91208. * Called by the particle System when the direction is computed for the created particle.
  91209. * @param worldMatrix is the world matrix of the particle system
  91210. * @param directionToUpdate is the direction vector to update with the result
  91211. * @param particle is the particle we are computed the direction for
  91212. */
  91213. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91214. /**
  91215. * Called by the particle System when the position is computed for the created particle.
  91216. * @param worldMatrix is the world matrix of the particle system
  91217. * @param positionToUpdate is the position vector to update with the result
  91218. * @param particle is the particle we are computed the position for
  91219. */
  91220. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  91221. /**
  91222. * Clones the current emitter and returns a copy of it
  91223. * @returns the new emitter
  91224. */
  91225. clone(): HemisphericParticleEmitter;
  91226. /**
  91227. * Called by the GPUParticleSystem to setup the update shader
  91228. * @param effect defines the update shader
  91229. */
  91230. applyToShader(effect: Effect): void;
  91231. /**
  91232. * Returns a string to use to update the GPU particles update shader
  91233. * @returns a string containng the defines string
  91234. */
  91235. getEffectDefines(): string;
  91236. /**
  91237. * Returns the string "HemisphericParticleEmitter"
  91238. * @returns a string containing the class name
  91239. */
  91240. getClassName(): string;
  91241. /**
  91242. * Serializes the particle system to a JSON object.
  91243. * @returns the JSON object
  91244. */
  91245. serialize(): any;
  91246. /**
  91247. * Parse properties from a JSON object
  91248. * @param serializationObject defines the JSON object
  91249. */
  91250. parse(serializationObject: any): void;
  91251. }
  91252. }
  91253. declare module BABYLON {
  91254. /**
  91255. * Particle emitter emitting particles from a point.
  91256. * It emits the particles randomly between 2 given directions.
  91257. */
  91258. export class PointParticleEmitter implements IParticleEmitterType {
  91259. /**
  91260. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91261. */
  91262. direction1: Vector3;
  91263. /**
  91264. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91265. */
  91266. direction2: Vector3;
  91267. /**
  91268. * Creates a new instance PointParticleEmitter
  91269. */
  91270. constructor();
  91271. /**
  91272. * Called by the particle System when the direction is computed for the created particle.
  91273. * @param worldMatrix is the world matrix of the particle system
  91274. * @param directionToUpdate is the direction vector to update with the result
  91275. * @param particle is the particle we are computed the direction for
  91276. */
  91277. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91278. /**
  91279. * Called by the particle System when the position is computed for the created particle.
  91280. * @param worldMatrix is the world matrix of the particle system
  91281. * @param positionToUpdate is the position vector to update with the result
  91282. * @param particle is the particle we are computed the position for
  91283. */
  91284. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  91285. /**
  91286. * Clones the current emitter and returns a copy of it
  91287. * @returns the new emitter
  91288. */
  91289. clone(): PointParticleEmitter;
  91290. /**
  91291. * Called by the GPUParticleSystem to setup the update shader
  91292. * @param effect defines the update shader
  91293. */
  91294. applyToShader(effect: Effect): void;
  91295. /**
  91296. * Returns a string to use to update the GPU particles update shader
  91297. * @returns a string containng the defines string
  91298. */
  91299. getEffectDefines(): string;
  91300. /**
  91301. * Returns the string "PointParticleEmitter"
  91302. * @returns a string containing the class name
  91303. */
  91304. getClassName(): string;
  91305. /**
  91306. * Serializes the particle system to a JSON object.
  91307. * @returns the JSON object
  91308. */
  91309. serialize(): any;
  91310. /**
  91311. * Parse properties from a JSON object
  91312. * @param serializationObject defines the JSON object
  91313. */
  91314. parse(serializationObject: any): void;
  91315. }
  91316. }
  91317. declare module BABYLON {
  91318. /**
  91319. * Particle emitter emitting particles from the inside of a sphere.
  91320. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  91321. */
  91322. export class SphereParticleEmitter implements IParticleEmitterType {
  91323. /**
  91324. * The radius of the emission sphere.
  91325. */
  91326. radius: number;
  91327. /**
  91328. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91329. */
  91330. radiusRange: number;
  91331. /**
  91332. * How much to randomize the particle direction [0-1].
  91333. */
  91334. directionRandomizer: number;
  91335. /**
  91336. * Creates a new instance SphereParticleEmitter
  91337. * @param radius the radius of the emission sphere (1 by default)
  91338. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91339. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91340. */
  91341. constructor(
  91342. /**
  91343. * The radius of the emission sphere.
  91344. */
  91345. radius?: number,
  91346. /**
  91347. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91348. */
  91349. radiusRange?: number,
  91350. /**
  91351. * How much to randomize the particle direction [0-1].
  91352. */
  91353. directionRandomizer?: number);
  91354. /**
  91355. * Called by the particle System when the direction is computed for the created particle.
  91356. * @param worldMatrix is the world matrix of the particle system
  91357. * @param directionToUpdate is the direction vector to update with the result
  91358. * @param particle is the particle we are computed the direction for
  91359. */
  91360. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91361. /**
  91362. * Called by the particle System when the position is computed for the created particle.
  91363. * @param worldMatrix is the world matrix of the particle system
  91364. * @param positionToUpdate is the position vector to update with the result
  91365. * @param particle is the particle we are computed the position for
  91366. */
  91367. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  91368. /**
  91369. * Clones the current emitter and returns a copy of it
  91370. * @returns the new emitter
  91371. */
  91372. clone(): SphereParticleEmitter;
  91373. /**
  91374. * Called by the GPUParticleSystem to setup the update shader
  91375. * @param effect defines the update shader
  91376. */
  91377. applyToShader(effect: Effect): void;
  91378. /**
  91379. * Returns a string to use to update the GPU particles update shader
  91380. * @returns a string containng the defines string
  91381. */
  91382. getEffectDefines(): string;
  91383. /**
  91384. * Returns the string "SphereParticleEmitter"
  91385. * @returns a string containing the class name
  91386. */
  91387. getClassName(): string;
  91388. /**
  91389. * Serializes the particle system to a JSON object.
  91390. * @returns the JSON object
  91391. */
  91392. serialize(): any;
  91393. /**
  91394. * Parse properties from a JSON object
  91395. * @param serializationObject defines the JSON object
  91396. */
  91397. parse(serializationObject: any): void;
  91398. }
  91399. /**
  91400. * Particle emitter emitting particles from the inside of a sphere.
  91401. * It emits the particles randomly between two vectors.
  91402. */
  91403. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  91404. /**
  91405. * The min limit of the emission direction.
  91406. */
  91407. direction1: Vector3;
  91408. /**
  91409. * The max limit of the emission direction.
  91410. */
  91411. direction2: Vector3;
  91412. /**
  91413. * Creates a new instance SphereDirectedParticleEmitter
  91414. * @param radius the radius of the emission sphere (1 by default)
  91415. * @param direction1 the min limit of the emission direction (up vector by default)
  91416. * @param direction2 the max limit of the emission direction (up vector by default)
  91417. */
  91418. constructor(radius?: number,
  91419. /**
  91420. * The min limit of the emission direction.
  91421. */
  91422. direction1?: Vector3,
  91423. /**
  91424. * The max limit of the emission direction.
  91425. */
  91426. direction2?: Vector3);
  91427. /**
  91428. * Called by the particle System when the direction is computed for the created particle.
  91429. * @param worldMatrix is the world matrix of the particle system
  91430. * @param directionToUpdate is the direction vector to update with the result
  91431. * @param particle is the particle we are computed the direction for
  91432. */
  91433. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91434. /**
  91435. * Clones the current emitter and returns a copy of it
  91436. * @returns the new emitter
  91437. */
  91438. clone(): SphereDirectedParticleEmitter;
  91439. /**
  91440. * Called by the GPUParticleSystem to setup the update shader
  91441. * @param effect defines the update shader
  91442. */
  91443. applyToShader(effect: Effect): void;
  91444. /**
  91445. * Returns a string to use to update the GPU particles update shader
  91446. * @returns a string containng the defines string
  91447. */
  91448. getEffectDefines(): string;
  91449. /**
  91450. * Returns the string "SphereDirectedParticleEmitter"
  91451. * @returns a string containing the class name
  91452. */
  91453. getClassName(): string;
  91454. /**
  91455. * Serializes the particle system to a JSON object.
  91456. * @returns the JSON object
  91457. */
  91458. serialize(): any;
  91459. /**
  91460. * Parse properties from a JSON object
  91461. * @param serializationObject defines the JSON object
  91462. */
  91463. parse(serializationObject: any): void;
  91464. }
  91465. }
  91466. declare module BABYLON {
  91467. /**
  91468. * Particle emitter emitting particles from a custom list of positions.
  91469. */
  91470. export class CustomParticleEmitter implements IParticleEmitterType {
  91471. /**
  91472. * Gets or sets the position generator that will create the inital position of each particle.
  91473. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91474. */
  91475. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  91476. /**
  91477. * Gets or sets the destination generator that will create the final destination of each particle.
  91478. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91479. */
  91480. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  91481. /**
  91482. * Creates a new instance CustomParticleEmitter
  91483. */
  91484. constructor();
  91485. /**
  91486. * Called by the particle System when the direction is computed for the created particle.
  91487. * @param worldMatrix is the world matrix of the particle system
  91488. * @param directionToUpdate is the direction vector to update with the result
  91489. * @param particle is the particle we are computed the direction for
  91490. */
  91491. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91492. /**
  91493. * Called by the particle System when the position is computed for the created particle.
  91494. * @param worldMatrix is the world matrix of the particle system
  91495. * @param positionToUpdate is the position vector to update with the result
  91496. * @param particle is the particle we are computed the position for
  91497. */
  91498. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  91499. /**
  91500. * Clones the current emitter and returns a copy of it
  91501. * @returns the new emitter
  91502. */
  91503. clone(): CustomParticleEmitter;
  91504. /**
  91505. * Called by the GPUParticleSystem to setup the update shader
  91506. * @param effect defines the update shader
  91507. */
  91508. applyToShader(effect: Effect): void;
  91509. /**
  91510. * Returns a string to use to update the GPU particles update shader
  91511. * @returns a string containng the defines string
  91512. */
  91513. getEffectDefines(): string;
  91514. /**
  91515. * Returns the string "PointParticleEmitter"
  91516. * @returns a string containing the class name
  91517. */
  91518. getClassName(): string;
  91519. /**
  91520. * Serializes the particle system to a JSON object.
  91521. * @returns the JSON object
  91522. */
  91523. serialize(): any;
  91524. /**
  91525. * Parse properties from a JSON object
  91526. * @param serializationObject defines the JSON object
  91527. */
  91528. parse(serializationObject: any): void;
  91529. }
  91530. }
  91531. declare module BABYLON {
  91532. /**
  91533. * Interface representing a particle system in Babylon.js.
  91534. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  91535. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  91536. */
  91537. export interface IParticleSystem {
  91538. /**
  91539. * List of animations used by the particle system.
  91540. */
  91541. animations: Animation[];
  91542. /**
  91543. * The id of the Particle system.
  91544. */
  91545. id: string;
  91546. /**
  91547. * The name of the Particle system.
  91548. */
  91549. name: string;
  91550. /**
  91551. * The emitter represents the Mesh or position we are attaching the particle system to.
  91552. */
  91553. emitter: Nullable<AbstractMesh | Vector3>;
  91554. /**
  91555. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  91556. */
  91557. isBillboardBased: boolean;
  91558. /**
  91559. * The rendering group used by the Particle system to chose when to render.
  91560. */
  91561. renderingGroupId: number;
  91562. /**
  91563. * The layer mask we are rendering the particles through.
  91564. */
  91565. layerMask: number;
  91566. /**
  91567. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  91568. */
  91569. updateSpeed: number;
  91570. /**
  91571. * The amount of time the particle system is running (depends of the overall update speed).
  91572. */
  91573. targetStopDuration: number;
  91574. /**
  91575. * The texture used to render each particle. (this can be a spritesheet)
  91576. */
  91577. particleTexture: Nullable<Texture>;
  91578. /**
  91579. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  91580. */
  91581. blendMode: number;
  91582. /**
  91583. * Minimum life time of emitting particles.
  91584. */
  91585. minLifeTime: number;
  91586. /**
  91587. * Maximum life time of emitting particles.
  91588. */
  91589. maxLifeTime: number;
  91590. /**
  91591. * Minimum Size of emitting particles.
  91592. */
  91593. minSize: number;
  91594. /**
  91595. * Maximum Size of emitting particles.
  91596. */
  91597. maxSize: number;
  91598. /**
  91599. * Minimum scale of emitting particles on X axis.
  91600. */
  91601. minScaleX: number;
  91602. /**
  91603. * Maximum scale of emitting particles on X axis.
  91604. */
  91605. maxScaleX: number;
  91606. /**
  91607. * Minimum scale of emitting particles on Y axis.
  91608. */
  91609. minScaleY: number;
  91610. /**
  91611. * Maximum scale of emitting particles on Y axis.
  91612. */
  91613. maxScaleY: number;
  91614. /**
  91615. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  91616. */
  91617. color1: Color4;
  91618. /**
  91619. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  91620. */
  91621. color2: Color4;
  91622. /**
  91623. * Color the particle will have at the end of its lifetime.
  91624. */
  91625. colorDead: Color4;
  91626. /**
  91627. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  91628. */
  91629. emitRate: number;
  91630. /**
  91631. * You can use gravity if you want to give an orientation to your particles.
  91632. */
  91633. gravity: Vector3;
  91634. /**
  91635. * Minimum power of emitting particles.
  91636. */
  91637. minEmitPower: number;
  91638. /**
  91639. * Maximum power of emitting particles.
  91640. */
  91641. maxEmitPower: number;
  91642. /**
  91643. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  91644. */
  91645. minAngularSpeed: number;
  91646. /**
  91647. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  91648. */
  91649. maxAngularSpeed: number;
  91650. /**
  91651. * Gets or sets the minimal initial rotation in radians.
  91652. */
  91653. minInitialRotation: number;
  91654. /**
  91655. * Gets or sets the maximal initial rotation in radians.
  91656. */
  91657. maxInitialRotation: number;
  91658. /**
  91659. * The particle emitter type defines the emitter used by the particle system.
  91660. * It can be for example box, sphere, or cone...
  91661. */
  91662. particleEmitterType: Nullable<IParticleEmitterType>;
  91663. /**
  91664. * Defines the delay in milliseconds before starting the system (0 by default)
  91665. */
  91666. startDelay: number;
  91667. /**
  91668. * 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
  91669. */
  91670. preWarmCycles: number;
  91671. /**
  91672. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  91673. */
  91674. preWarmStepOffset: number;
  91675. /**
  91676. * 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)
  91677. */
  91678. spriteCellChangeSpeed: number;
  91679. /**
  91680. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  91681. */
  91682. startSpriteCellID: number;
  91683. /**
  91684. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  91685. */
  91686. endSpriteCellID: number;
  91687. /**
  91688. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  91689. */
  91690. spriteCellWidth: number;
  91691. /**
  91692. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  91693. */
  91694. spriteCellHeight: number;
  91695. /**
  91696. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  91697. */
  91698. spriteRandomStartCell: boolean;
  91699. /**
  91700. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  91701. */
  91702. isAnimationSheetEnabled: boolean;
  91703. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  91704. translationPivot: Vector2;
  91705. /**
  91706. * Gets or sets a texture used to add random noise to particle positions
  91707. */
  91708. noiseTexture: Nullable<BaseTexture>;
  91709. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  91710. noiseStrength: Vector3;
  91711. /**
  91712. * Gets or sets the billboard mode to use when isBillboardBased = true.
  91713. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  91714. */
  91715. billboardMode: number;
  91716. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  91717. limitVelocityDamping: number;
  91718. /**
  91719. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  91720. */
  91721. beginAnimationOnStart: boolean;
  91722. /**
  91723. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  91724. */
  91725. beginAnimationFrom: number;
  91726. /**
  91727. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  91728. */
  91729. beginAnimationTo: number;
  91730. /**
  91731. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  91732. */
  91733. beginAnimationLoop: boolean;
  91734. /**
  91735. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  91736. */
  91737. disposeOnStop: boolean;
  91738. /**
  91739. * Gets the maximum number of particles active at the same time.
  91740. * @returns The max number of active particles.
  91741. */
  91742. getCapacity(): number;
  91743. /**
  91744. * Gets if the system has been started. (Note: this will still be true after stop is called)
  91745. * @returns True if it has been started, otherwise false.
  91746. */
  91747. isStarted(): boolean;
  91748. /**
  91749. * Animates the particle system for this frame.
  91750. */
  91751. animate(): void;
  91752. /**
  91753. * Renders the particle system in its current state.
  91754. * @returns the current number of particles
  91755. */
  91756. render(): number;
  91757. /**
  91758. * Dispose the particle system and frees its associated resources.
  91759. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  91760. */
  91761. dispose(disposeTexture?: boolean): void;
  91762. /**
  91763. * Clones the particle system.
  91764. * @param name The name of the cloned object
  91765. * @param newEmitter The new emitter to use
  91766. * @returns the cloned particle system
  91767. */
  91768. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  91769. /**
  91770. * Serializes the particle system to a JSON object.
  91771. * @returns the JSON object
  91772. */
  91773. serialize(): any;
  91774. /**
  91775. * Rebuild the particle system
  91776. */
  91777. rebuild(): void;
  91778. /**
  91779. * Starts the particle system and begins to emit
  91780. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  91781. */
  91782. start(delay?: number): void;
  91783. /**
  91784. * Stops the particle system.
  91785. */
  91786. stop(): void;
  91787. /**
  91788. * Remove all active particles
  91789. */
  91790. reset(): void;
  91791. /**
  91792. * Is this system ready to be used/rendered
  91793. * @return true if the system is ready
  91794. */
  91795. isReady(): boolean;
  91796. /**
  91797. * Adds a new color gradient
  91798. * @param gradient defines the gradient to use (between 0 and 1)
  91799. * @param color1 defines the color to affect to the specified gradient
  91800. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  91801. * @returns the current particle system
  91802. */
  91803. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  91804. /**
  91805. * Remove a specific color gradient
  91806. * @param gradient defines the gradient to remove
  91807. * @returns the current particle system
  91808. */
  91809. removeColorGradient(gradient: number): IParticleSystem;
  91810. /**
  91811. * Adds a new size gradient
  91812. * @param gradient defines the gradient to use (between 0 and 1)
  91813. * @param factor defines the size factor to affect to the specified gradient
  91814. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91815. * @returns the current particle system
  91816. */
  91817. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91818. /**
  91819. * Remove a specific size gradient
  91820. * @param gradient defines the gradient to remove
  91821. * @returns the current particle system
  91822. */
  91823. removeSizeGradient(gradient: number): IParticleSystem;
  91824. /**
  91825. * Gets the current list of color gradients.
  91826. * You must use addColorGradient and removeColorGradient to udpate this list
  91827. * @returns the list of color gradients
  91828. */
  91829. getColorGradients(): Nullable<Array<ColorGradient>>;
  91830. /**
  91831. * Gets the current list of size gradients.
  91832. * You must use addSizeGradient and removeSizeGradient to udpate this list
  91833. * @returns the list of size gradients
  91834. */
  91835. getSizeGradients(): Nullable<Array<FactorGradient>>;
  91836. /**
  91837. * Gets the current list of angular speed gradients.
  91838. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  91839. * @returns the list of angular speed gradients
  91840. */
  91841. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  91842. /**
  91843. * Adds a new angular speed gradient
  91844. * @param gradient defines the gradient to use (between 0 and 1)
  91845. * @param factor defines the angular speed to affect to the specified gradient
  91846. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91847. * @returns the current particle system
  91848. */
  91849. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91850. /**
  91851. * Remove a specific angular speed gradient
  91852. * @param gradient defines the gradient to remove
  91853. * @returns the current particle system
  91854. */
  91855. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  91856. /**
  91857. * Gets the current list of velocity gradients.
  91858. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  91859. * @returns the list of velocity gradients
  91860. */
  91861. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  91862. /**
  91863. * Adds a new velocity gradient
  91864. * @param gradient defines the gradient to use (between 0 and 1)
  91865. * @param factor defines the velocity to affect to the specified gradient
  91866. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91867. * @returns the current particle system
  91868. */
  91869. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91870. /**
  91871. * Remove a specific velocity gradient
  91872. * @param gradient defines the gradient to remove
  91873. * @returns the current particle system
  91874. */
  91875. removeVelocityGradient(gradient: number): IParticleSystem;
  91876. /**
  91877. * Gets the current list of limit velocity gradients.
  91878. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  91879. * @returns the list of limit velocity gradients
  91880. */
  91881. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  91882. /**
  91883. * Adds a new limit velocity gradient
  91884. * @param gradient defines the gradient to use (between 0 and 1)
  91885. * @param factor defines the limit velocity to affect to the specified gradient
  91886. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91887. * @returns the current particle system
  91888. */
  91889. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91890. /**
  91891. * Remove a specific limit velocity gradient
  91892. * @param gradient defines the gradient to remove
  91893. * @returns the current particle system
  91894. */
  91895. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  91896. /**
  91897. * Adds a new drag gradient
  91898. * @param gradient defines the gradient to use (between 0 and 1)
  91899. * @param factor defines the drag to affect to the specified gradient
  91900. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91901. * @returns the current particle system
  91902. */
  91903. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91904. /**
  91905. * Remove a specific drag gradient
  91906. * @param gradient defines the gradient to remove
  91907. * @returns the current particle system
  91908. */
  91909. removeDragGradient(gradient: number): IParticleSystem;
  91910. /**
  91911. * Gets the current list of drag gradients.
  91912. * You must use addDragGradient and removeDragGradient to udpate this list
  91913. * @returns the list of drag gradients
  91914. */
  91915. getDragGradients(): Nullable<Array<FactorGradient>>;
  91916. /**
  91917. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  91918. * @param gradient defines the gradient to use (between 0 and 1)
  91919. * @param factor defines the emit rate to affect to the specified gradient
  91920. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91921. * @returns the current particle system
  91922. */
  91923. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91924. /**
  91925. * Remove a specific emit rate gradient
  91926. * @param gradient defines the gradient to remove
  91927. * @returns the current particle system
  91928. */
  91929. removeEmitRateGradient(gradient: number): IParticleSystem;
  91930. /**
  91931. * Gets the current list of emit rate gradients.
  91932. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  91933. * @returns the list of emit rate gradients
  91934. */
  91935. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  91936. /**
  91937. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  91938. * @param gradient defines the gradient to use (between 0 and 1)
  91939. * @param factor defines the start size to affect to the specified gradient
  91940. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91941. * @returns the current particle system
  91942. */
  91943. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91944. /**
  91945. * Remove a specific start size gradient
  91946. * @param gradient defines the gradient to remove
  91947. * @returns the current particle system
  91948. */
  91949. removeStartSizeGradient(gradient: number): IParticleSystem;
  91950. /**
  91951. * Gets the current list of start size gradients.
  91952. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  91953. * @returns the list of start size gradients
  91954. */
  91955. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  91956. /**
  91957. * Adds a new life time gradient
  91958. * @param gradient defines the gradient to use (between 0 and 1)
  91959. * @param factor defines the life time factor to affect to the specified gradient
  91960. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91961. * @returns the current particle system
  91962. */
  91963. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91964. /**
  91965. * Remove a specific life time gradient
  91966. * @param gradient defines the gradient to remove
  91967. * @returns the current particle system
  91968. */
  91969. removeLifeTimeGradient(gradient: number): IParticleSystem;
  91970. /**
  91971. * Gets the current list of life time gradients.
  91972. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  91973. * @returns the list of life time gradients
  91974. */
  91975. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  91976. /**
  91977. * Gets the current list of color gradients.
  91978. * You must use addColorGradient and removeColorGradient to udpate this list
  91979. * @returns the list of color gradients
  91980. */
  91981. getColorGradients(): Nullable<Array<ColorGradient>>;
  91982. /**
  91983. * Adds a new ramp gradient used to remap particle colors
  91984. * @param gradient defines the gradient to use (between 0 and 1)
  91985. * @param color defines the color to affect to the specified gradient
  91986. * @returns the current particle system
  91987. */
  91988. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  91989. /**
  91990. * Gets the current list of ramp gradients.
  91991. * You must use addRampGradient and removeRampGradient to udpate this list
  91992. * @returns the list of ramp gradients
  91993. */
  91994. getRampGradients(): Nullable<Array<Color3Gradient>>;
  91995. /** Gets or sets a boolean indicating that ramp gradients must be used
  91996. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  91997. */
  91998. useRampGradients: boolean;
  91999. /**
  92000. * Adds a new color remap gradient
  92001. * @param gradient defines the gradient to use (between 0 and 1)
  92002. * @param min defines the color remap minimal range
  92003. * @param max defines the color remap maximal range
  92004. * @returns the current particle system
  92005. */
  92006. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92007. /**
  92008. * Gets the current list of color remap gradients.
  92009. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  92010. * @returns the list of color remap gradients
  92011. */
  92012. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  92013. /**
  92014. * Adds a new alpha remap gradient
  92015. * @param gradient defines the gradient to use (between 0 and 1)
  92016. * @param min defines the alpha remap minimal range
  92017. * @param max defines the alpha remap maximal range
  92018. * @returns the current particle system
  92019. */
  92020. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92021. /**
  92022. * Gets the current list of alpha remap gradients.
  92023. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  92024. * @returns the list of alpha remap gradients
  92025. */
  92026. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  92027. /**
  92028. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  92029. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92030. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92031. * @returns the emitter
  92032. */
  92033. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  92034. /**
  92035. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  92036. * @param radius The radius of the hemisphere to emit from
  92037. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92038. * @returns the emitter
  92039. */
  92040. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  92041. /**
  92042. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  92043. * @param radius The radius of the sphere to emit from
  92044. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92045. * @returns the emitter
  92046. */
  92047. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  92048. /**
  92049. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  92050. * @param radius The radius of the sphere to emit from
  92051. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  92052. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  92053. * @returns the emitter
  92054. */
  92055. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  92056. /**
  92057. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  92058. * @param radius The radius of the emission cylinder
  92059. * @param height The height of the emission cylinder
  92060. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  92061. * @param directionRandomizer How much to randomize the particle direction [0-1]
  92062. * @returns the emitter
  92063. */
  92064. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  92065. /**
  92066. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  92067. * @param radius The radius of the cylinder to emit from
  92068. * @param height The height of the emission cylinder
  92069. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92070. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  92071. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  92072. * @returns the emitter
  92073. */
  92074. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  92075. /**
  92076. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  92077. * @param radius The radius of the cone to emit from
  92078. * @param angle The base angle of the cone
  92079. * @returns the emitter
  92080. */
  92081. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  92082. /**
  92083. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  92084. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92085. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92086. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92087. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92088. * @returns the emitter
  92089. */
  92090. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  92091. /**
  92092. * Get hosting scene
  92093. * @returns the scene
  92094. */
  92095. getScene(): Scene;
  92096. }
  92097. }
  92098. declare module BABYLON {
  92099. /**
  92100. * Creates an instance based on a source mesh.
  92101. */
  92102. export class InstancedMesh extends AbstractMesh {
  92103. private _sourceMesh;
  92104. private _currentLOD;
  92105. /** @hidden */
  92106. _indexInSourceMeshInstanceArray: number;
  92107. constructor(name: string, source: Mesh);
  92108. /**
  92109. * Returns the string "InstancedMesh".
  92110. */
  92111. getClassName(): string;
  92112. /** Gets the list of lights affecting that mesh */
  92113. get lightSources(): Light[];
  92114. _resyncLightSources(): void;
  92115. _resyncLightSource(light: Light): void;
  92116. _removeLightSource(light: Light, dispose: boolean): void;
  92117. /**
  92118. * If the source mesh receives shadows
  92119. */
  92120. get receiveShadows(): boolean;
  92121. /**
  92122. * The material of the source mesh
  92123. */
  92124. get material(): Nullable<Material>;
  92125. /**
  92126. * Visibility of the source mesh
  92127. */
  92128. get visibility(): number;
  92129. /**
  92130. * Skeleton of the source mesh
  92131. */
  92132. get skeleton(): Nullable<Skeleton>;
  92133. /**
  92134. * Rendering ground id of the source mesh
  92135. */
  92136. get renderingGroupId(): number;
  92137. set renderingGroupId(value: number);
  92138. /**
  92139. * Returns the total number of vertices (integer).
  92140. */
  92141. getTotalVertices(): number;
  92142. /**
  92143. * Returns a positive integer : the total number of indices in this mesh geometry.
  92144. * @returns the numner of indices or zero if the mesh has no geometry.
  92145. */
  92146. getTotalIndices(): number;
  92147. /**
  92148. * The source mesh of the instance
  92149. */
  92150. get sourceMesh(): Mesh;
  92151. /**
  92152. * Is this node ready to be used/rendered
  92153. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  92154. * @return {boolean} is it ready
  92155. */
  92156. isReady(completeCheck?: boolean): boolean;
  92157. /**
  92158. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  92159. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  92160. * @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.
  92161. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  92162. */
  92163. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  92164. /**
  92165. * Sets the vertex data of the mesh geometry for the requested `kind`.
  92166. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  92167. * The `data` are either a numeric array either a Float32Array.
  92168. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  92169. * 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).
  92170. * Note that a new underlying VertexBuffer object is created each call.
  92171. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  92172. *
  92173. * Possible `kind` values :
  92174. * - VertexBuffer.PositionKind
  92175. * - VertexBuffer.UVKind
  92176. * - VertexBuffer.UV2Kind
  92177. * - VertexBuffer.UV3Kind
  92178. * - VertexBuffer.UV4Kind
  92179. * - VertexBuffer.UV5Kind
  92180. * - VertexBuffer.UV6Kind
  92181. * - VertexBuffer.ColorKind
  92182. * - VertexBuffer.MatricesIndicesKind
  92183. * - VertexBuffer.MatricesIndicesExtraKind
  92184. * - VertexBuffer.MatricesWeightsKind
  92185. * - VertexBuffer.MatricesWeightsExtraKind
  92186. *
  92187. * Returns the Mesh.
  92188. */
  92189. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  92190. /**
  92191. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  92192. * If the mesh has no geometry, it is simply returned as it is.
  92193. * The `data` are either a numeric array either a Float32Array.
  92194. * No new underlying VertexBuffer object is created.
  92195. * 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.
  92196. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  92197. *
  92198. * Possible `kind` values :
  92199. * - VertexBuffer.PositionKind
  92200. * - VertexBuffer.UVKind
  92201. * - VertexBuffer.UV2Kind
  92202. * - VertexBuffer.UV3Kind
  92203. * - VertexBuffer.UV4Kind
  92204. * - VertexBuffer.UV5Kind
  92205. * - VertexBuffer.UV6Kind
  92206. * - VertexBuffer.ColorKind
  92207. * - VertexBuffer.MatricesIndicesKind
  92208. * - VertexBuffer.MatricesIndicesExtraKind
  92209. * - VertexBuffer.MatricesWeightsKind
  92210. * - VertexBuffer.MatricesWeightsExtraKind
  92211. *
  92212. * Returns the Mesh.
  92213. */
  92214. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  92215. /**
  92216. * Sets the mesh indices.
  92217. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  92218. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  92219. * This method creates a new index buffer each call.
  92220. * Returns the Mesh.
  92221. */
  92222. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  92223. /**
  92224. * Boolean : True if the mesh owns the requested kind of data.
  92225. */
  92226. isVerticesDataPresent(kind: string): boolean;
  92227. /**
  92228. * Returns an array of indices (IndicesArray).
  92229. */
  92230. getIndices(): Nullable<IndicesArray>;
  92231. get _positions(): Nullable<Vector3[]>;
  92232. /**
  92233. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  92234. * This means the mesh underlying bounding box and sphere are recomputed.
  92235. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  92236. * @returns the current mesh
  92237. */
  92238. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  92239. /** @hidden */
  92240. _preActivate(): InstancedMesh;
  92241. /** @hidden */
  92242. _activate(renderId: number, intermediateRendering: boolean): boolean;
  92243. /** @hidden */
  92244. _postActivate(): void;
  92245. getWorldMatrix(): Matrix;
  92246. get isAnInstance(): boolean;
  92247. /**
  92248. * Returns the current associated LOD AbstractMesh.
  92249. */
  92250. getLOD(camera: Camera): AbstractMesh;
  92251. /** @hidden */
  92252. _syncSubMeshes(): InstancedMesh;
  92253. /** @hidden */
  92254. _generatePointsArray(): boolean;
  92255. /**
  92256. * Creates a new InstancedMesh from the current mesh.
  92257. * - name (string) : the cloned mesh name
  92258. * - newParent (optional Node) : the optional Node to parent the clone to.
  92259. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  92260. *
  92261. * Returns the clone.
  92262. */
  92263. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  92264. /**
  92265. * Disposes the InstancedMesh.
  92266. * Returns nothing.
  92267. */
  92268. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92269. }
  92270. interface Mesh {
  92271. /**
  92272. * Register a custom buffer that will be instanced
  92273. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  92274. * @param kind defines the buffer kind
  92275. * @param stride defines the stride in floats
  92276. */
  92277. registerInstancedBuffer(kind: string, stride: number): void;
  92278. /** @hidden */
  92279. _userInstancedBuffersStorage: {
  92280. data: {
  92281. [key: string]: Float32Array;
  92282. };
  92283. sizes: {
  92284. [key: string]: number;
  92285. };
  92286. vertexBuffers: {
  92287. [key: string]: Nullable<VertexBuffer>;
  92288. };
  92289. strides: {
  92290. [key: string]: number;
  92291. };
  92292. };
  92293. }
  92294. interface AbstractMesh {
  92295. /**
  92296. * Object used to store instanced buffers defined by user
  92297. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  92298. */
  92299. instancedBuffers: {
  92300. [key: string]: any;
  92301. };
  92302. }
  92303. }
  92304. declare module BABYLON {
  92305. /**
  92306. * Defines the options associated with the creation of a shader material.
  92307. */
  92308. export interface IShaderMaterialOptions {
  92309. /**
  92310. * Does the material work in alpha blend mode
  92311. */
  92312. needAlphaBlending: boolean;
  92313. /**
  92314. * Does the material work in alpha test mode
  92315. */
  92316. needAlphaTesting: boolean;
  92317. /**
  92318. * The list of attribute names used in the shader
  92319. */
  92320. attributes: string[];
  92321. /**
  92322. * The list of unifrom names used in the shader
  92323. */
  92324. uniforms: string[];
  92325. /**
  92326. * The list of UBO names used in the shader
  92327. */
  92328. uniformBuffers: string[];
  92329. /**
  92330. * The list of sampler names used in the shader
  92331. */
  92332. samplers: string[];
  92333. /**
  92334. * The list of defines used in the shader
  92335. */
  92336. defines: string[];
  92337. }
  92338. /**
  92339. * 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.
  92340. *
  92341. * This returned material effects how the mesh will look based on the code in the shaders.
  92342. *
  92343. * @see http://doc.babylonjs.com/how_to/shader_material
  92344. */
  92345. export class ShaderMaterial extends Material {
  92346. private _shaderPath;
  92347. private _options;
  92348. private _textures;
  92349. private _textureArrays;
  92350. private _floats;
  92351. private _ints;
  92352. private _floatsArrays;
  92353. private _colors3;
  92354. private _colors3Arrays;
  92355. private _colors4;
  92356. private _colors4Arrays;
  92357. private _vectors2;
  92358. private _vectors3;
  92359. private _vectors4;
  92360. private _matrices;
  92361. private _matrixArrays;
  92362. private _matrices3x3;
  92363. private _matrices2x2;
  92364. private _vectors2Arrays;
  92365. private _vectors3Arrays;
  92366. private _vectors4Arrays;
  92367. private _cachedWorldViewMatrix;
  92368. private _cachedWorldViewProjectionMatrix;
  92369. private _renderId;
  92370. private _multiview;
  92371. /**
  92372. * Instantiate a new shader material.
  92373. * 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.
  92374. * This returned material effects how the mesh will look based on the code in the shaders.
  92375. * @see http://doc.babylonjs.com/how_to/shader_material
  92376. * @param name Define the name of the material in the scene
  92377. * @param scene Define the scene the material belongs to
  92378. * @param shaderPath Defines the route to the shader code in one of three ways:
  92379. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  92380. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  92381. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  92382. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  92383. * @param options Define the options used to create the shader
  92384. */
  92385. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  92386. /**
  92387. * Gets the shader path used to define the shader code
  92388. * It can be modified to trigger a new compilation
  92389. */
  92390. get shaderPath(): any;
  92391. /**
  92392. * Sets the shader path used to define the shader code
  92393. * It can be modified to trigger a new compilation
  92394. */
  92395. set shaderPath(shaderPath: any);
  92396. /**
  92397. * Gets the options used to compile the shader.
  92398. * They can be modified to trigger a new compilation
  92399. */
  92400. get options(): IShaderMaterialOptions;
  92401. /**
  92402. * Gets the current class name of the material e.g. "ShaderMaterial"
  92403. * Mainly use in serialization.
  92404. * @returns the class name
  92405. */
  92406. getClassName(): string;
  92407. /**
  92408. * Specifies if the material will require alpha blending
  92409. * @returns a boolean specifying if alpha blending is needed
  92410. */
  92411. needAlphaBlending(): boolean;
  92412. /**
  92413. * Specifies if this material should be rendered in alpha test mode
  92414. * @returns a boolean specifying if an alpha test is needed.
  92415. */
  92416. needAlphaTesting(): boolean;
  92417. private _checkUniform;
  92418. /**
  92419. * Set a texture in the shader.
  92420. * @param name Define the name of the uniform samplers as defined in the shader
  92421. * @param texture Define the texture to bind to this sampler
  92422. * @return the material itself allowing "fluent" like uniform updates
  92423. */
  92424. setTexture(name: string, texture: Texture): ShaderMaterial;
  92425. /**
  92426. * Set a texture array in the shader.
  92427. * @param name Define the name of the uniform sampler array as defined in the shader
  92428. * @param textures Define the list of textures to bind to this sampler
  92429. * @return the material itself allowing "fluent" like uniform updates
  92430. */
  92431. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  92432. /**
  92433. * Set a float in the shader.
  92434. * @param name Define the name of the uniform as defined in the shader
  92435. * @param value Define the value to give to the uniform
  92436. * @return the material itself allowing "fluent" like uniform updates
  92437. */
  92438. setFloat(name: string, value: number): ShaderMaterial;
  92439. /**
  92440. * Set a int in the shader.
  92441. * @param name Define the name of the uniform as defined in the shader
  92442. * @param value Define the value to give to the uniform
  92443. * @return the material itself allowing "fluent" like uniform updates
  92444. */
  92445. setInt(name: string, value: number): ShaderMaterial;
  92446. /**
  92447. * Set an array of floats in the shader.
  92448. * @param name Define the name of the uniform as defined in the shader
  92449. * @param value Define the value to give to the uniform
  92450. * @return the material itself allowing "fluent" like uniform updates
  92451. */
  92452. setFloats(name: string, value: number[]): ShaderMaterial;
  92453. /**
  92454. * Set a vec3 in the shader from a Color3.
  92455. * @param name Define the name of the uniform as defined in the shader
  92456. * @param value Define the value to give to the uniform
  92457. * @return the material itself allowing "fluent" like uniform updates
  92458. */
  92459. setColor3(name: string, value: Color3): ShaderMaterial;
  92460. /**
  92461. * Set a vec3 array in the shader from a Color3 array.
  92462. * @param name Define the name of the uniform as defined in the shader
  92463. * @param value Define the value to give to the uniform
  92464. * @return the material itself allowing "fluent" like uniform updates
  92465. */
  92466. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  92467. /**
  92468. * Set a vec4 in the shader from a Color4.
  92469. * @param name Define the name of the uniform as defined in the shader
  92470. * @param value Define the value to give to the uniform
  92471. * @return the material itself allowing "fluent" like uniform updates
  92472. */
  92473. setColor4(name: string, value: Color4): ShaderMaterial;
  92474. /**
  92475. * Set a vec4 array in the shader from a Color4 array.
  92476. * @param name Define the name of the uniform as defined in the shader
  92477. * @param value Define the value to give to the uniform
  92478. * @return the material itself allowing "fluent" like uniform updates
  92479. */
  92480. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  92481. /**
  92482. * Set a vec2 in the shader from a Vector2.
  92483. * @param name Define the name of the uniform as defined in the shader
  92484. * @param value Define the value to give to the uniform
  92485. * @return the material itself allowing "fluent" like uniform updates
  92486. */
  92487. setVector2(name: string, value: Vector2): ShaderMaterial;
  92488. /**
  92489. * Set a vec3 in the shader from a Vector3.
  92490. * @param name Define the name of the uniform as defined in the shader
  92491. * @param value Define the value to give to the uniform
  92492. * @return the material itself allowing "fluent" like uniform updates
  92493. */
  92494. setVector3(name: string, value: Vector3): ShaderMaterial;
  92495. /**
  92496. * Set a vec4 in the shader from a Vector4.
  92497. * @param name Define the name of the uniform as defined in the shader
  92498. * @param value Define the value to give to the uniform
  92499. * @return the material itself allowing "fluent" like uniform updates
  92500. */
  92501. setVector4(name: string, value: Vector4): ShaderMaterial;
  92502. /**
  92503. * Set a mat4 in the shader from a Matrix.
  92504. * @param name Define the name of the uniform as defined in the shader
  92505. * @param value Define the value to give to the uniform
  92506. * @return the material itself allowing "fluent" like uniform updates
  92507. */
  92508. setMatrix(name: string, value: Matrix): ShaderMaterial;
  92509. /**
  92510. * Set a float32Array in the shader from a matrix array.
  92511. * @param name Define the name of the uniform as defined in the shader
  92512. * @param value Define the value to give to the uniform
  92513. * @return the material itself allowing "fluent" like uniform updates
  92514. */
  92515. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  92516. /**
  92517. * Set a mat3 in the shader from a Float32Array.
  92518. * @param name Define the name of the uniform as defined in the shader
  92519. * @param value Define the value to give to the uniform
  92520. * @return the material itself allowing "fluent" like uniform updates
  92521. */
  92522. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  92523. /**
  92524. * Set a mat2 in the shader from a Float32Array.
  92525. * @param name Define the name of the uniform as defined in the shader
  92526. * @param value Define the value to give to the uniform
  92527. * @return the material itself allowing "fluent" like uniform updates
  92528. */
  92529. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  92530. /**
  92531. * Set a vec2 array in the shader from a number array.
  92532. * @param name Define the name of the uniform as defined in the shader
  92533. * @param value Define the value to give to the uniform
  92534. * @return the material itself allowing "fluent" like uniform updates
  92535. */
  92536. setArray2(name: string, value: number[]): ShaderMaterial;
  92537. /**
  92538. * Set a vec3 array in the shader from a number array.
  92539. * @param name Define the name of the uniform as defined in the shader
  92540. * @param value Define the value to give to the uniform
  92541. * @return the material itself allowing "fluent" like uniform updates
  92542. */
  92543. setArray3(name: string, value: number[]): ShaderMaterial;
  92544. /**
  92545. * Set a vec4 array in the shader from a number array.
  92546. * @param name Define the name of the uniform as defined in the shader
  92547. * @param value Define the value to give to the uniform
  92548. * @return the material itself allowing "fluent" like uniform updates
  92549. */
  92550. setArray4(name: string, value: number[]): ShaderMaterial;
  92551. private _checkCache;
  92552. /**
  92553. * Specifies that the submesh is ready to be used
  92554. * @param mesh defines the mesh to check
  92555. * @param subMesh defines which submesh to check
  92556. * @param useInstances specifies that instances should be used
  92557. * @returns a boolean indicating that the submesh is ready or not
  92558. */
  92559. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  92560. /**
  92561. * Checks if the material is ready to render the requested mesh
  92562. * @param mesh Define the mesh to render
  92563. * @param useInstances Define whether or not the material is used with instances
  92564. * @returns true if ready, otherwise false
  92565. */
  92566. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  92567. /**
  92568. * Binds the world matrix to the material
  92569. * @param world defines the world transformation matrix
  92570. */
  92571. bindOnlyWorldMatrix(world: Matrix): void;
  92572. /**
  92573. * Binds the material to the mesh
  92574. * @param world defines the world transformation matrix
  92575. * @param mesh defines the mesh to bind the material to
  92576. */
  92577. bind(world: Matrix, mesh?: Mesh): void;
  92578. /**
  92579. * Gets the active textures from the material
  92580. * @returns an array of textures
  92581. */
  92582. getActiveTextures(): BaseTexture[];
  92583. /**
  92584. * Specifies if the material uses a texture
  92585. * @param texture defines the texture to check against the material
  92586. * @returns a boolean specifying if the material uses the texture
  92587. */
  92588. hasTexture(texture: BaseTexture): boolean;
  92589. /**
  92590. * Makes a duplicate of the material, and gives it a new name
  92591. * @param name defines the new name for the duplicated material
  92592. * @returns the cloned material
  92593. */
  92594. clone(name: string): ShaderMaterial;
  92595. /**
  92596. * Disposes the material
  92597. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  92598. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  92599. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  92600. */
  92601. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  92602. /**
  92603. * Serializes this material in a JSON representation
  92604. * @returns the serialized material object
  92605. */
  92606. serialize(): any;
  92607. /**
  92608. * Creates a shader material from parsed shader material data
  92609. * @param source defines the JSON represnetation of the material
  92610. * @param scene defines the hosting scene
  92611. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  92612. * @returns a new material
  92613. */
  92614. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  92615. }
  92616. }
  92617. declare module BABYLON {
  92618. /** @hidden */
  92619. export var colorPixelShader: {
  92620. name: string;
  92621. shader: string;
  92622. };
  92623. }
  92624. declare module BABYLON {
  92625. /** @hidden */
  92626. export var colorVertexShader: {
  92627. name: string;
  92628. shader: string;
  92629. };
  92630. }
  92631. declare module BABYLON {
  92632. /**
  92633. * Line mesh
  92634. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  92635. */
  92636. export class LinesMesh extends Mesh {
  92637. /**
  92638. * If vertex color should be applied to the mesh
  92639. */
  92640. readonly useVertexColor?: boolean | undefined;
  92641. /**
  92642. * If vertex alpha should be applied to the mesh
  92643. */
  92644. readonly useVertexAlpha?: boolean | undefined;
  92645. /**
  92646. * Color of the line (Default: White)
  92647. */
  92648. color: Color3;
  92649. /**
  92650. * Alpha of the line (Default: 1)
  92651. */
  92652. alpha: number;
  92653. /**
  92654. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  92655. * This margin is expressed in world space coordinates, so its value may vary.
  92656. * Default value is 0.1
  92657. */
  92658. intersectionThreshold: number;
  92659. private _colorShader;
  92660. private color4;
  92661. /**
  92662. * Creates a new LinesMesh
  92663. * @param name defines the name
  92664. * @param scene defines the hosting scene
  92665. * @param parent defines the parent mesh if any
  92666. * @param source defines the optional source LinesMesh used to clone data from
  92667. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  92668. * When false, achieved by calling a clone(), also passing False.
  92669. * This will make creation of children, recursive.
  92670. * @param useVertexColor defines if this LinesMesh supports vertex color
  92671. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  92672. */
  92673. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  92674. /**
  92675. * If vertex color should be applied to the mesh
  92676. */
  92677. useVertexColor?: boolean | undefined,
  92678. /**
  92679. * If vertex alpha should be applied to the mesh
  92680. */
  92681. useVertexAlpha?: boolean | undefined);
  92682. private _addClipPlaneDefine;
  92683. private _removeClipPlaneDefine;
  92684. isReady(): boolean;
  92685. /**
  92686. * Returns the string "LineMesh"
  92687. */
  92688. getClassName(): string;
  92689. /**
  92690. * @hidden
  92691. */
  92692. get material(): Material;
  92693. /**
  92694. * @hidden
  92695. */
  92696. set material(value: Material);
  92697. /**
  92698. * @hidden
  92699. */
  92700. get checkCollisions(): boolean;
  92701. /** @hidden */
  92702. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  92703. /** @hidden */
  92704. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  92705. /**
  92706. * Disposes of the line mesh
  92707. * @param doNotRecurse If children should be disposed
  92708. */
  92709. dispose(doNotRecurse?: boolean): void;
  92710. /**
  92711. * Returns a new LineMesh object cloned from the current one.
  92712. */
  92713. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  92714. /**
  92715. * Creates a new InstancedLinesMesh object from the mesh model.
  92716. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  92717. * @param name defines the name of the new instance
  92718. * @returns a new InstancedLinesMesh
  92719. */
  92720. createInstance(name: string): InstancedLinesMesh;
  92721. }
  92722. /**
  92723. * Creates an instance based on a source LinesMesh
  92724. */
  92725. export class InstancedLinesMesh extends InstancedMesh {
  92726. /**
  92727. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  92728. * This margin is expressed in world space coordinates, so its value may vary.
  92729. * Initilized with the intersectionThreshold value of the source LinesMesh
  92730. */
  92731. intersectionThreshold: number;
  92732. constructor(name: string, source: LinesMesh);
  92733. /**
  92734. * Returns the string "InstancedLinesMesh".
  92735. */
  92736. getClassName(): string;
  92737. }
  92738. }
  92739. declare module BABYLON {
  92740. /** @hidden */
  92741. export var linePixelShader: {
  92742. name: string;
  92743. shader: string;
  92744. };
  92745. }
  92746. declare module BABYLON {
  92747. /** @hidden */
  92748. export var lineVertexShader: {
  92749. name: string;
  92750. shader: string;
  92751. };
  92752. }
  92753. declare module BABYLON {
  92754. interface AbstractMesh {
  92755. /**
  92756. * Gets the edgesRenderer associated with the mesh
  92757. */
  92758. edgesRenderer: Nullable<EdgesRenderer>;
  92759. }
  92760. interface LinesMesh {
  92761. /**
  92762. * Enables the edge rendering mode on the mesh.
  92763. * This mode makes the mesh edges visible
  92764. * @param epsilon defines the maximal distance between two angles to detect a face
  92765. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  92766. * @returns the currentAbstractMesh
  92767. * @see https://www.babylonjs-playground.com/#19O9TU#0
  92768. */
  92769. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  92770. }
  92771. interface InstancedLinesMesh {
  92772. /**
  92773. * Enables the edge rendering mode on the mesh.
  92774. * This mode makes the mesh edges visible
  92775. * @param epsilon defines the maximal distance between two angles to detect a face
  92776. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  92777. * @returns the current InstancedLinesMesh
  92778. * @see https://www.babylonjs-playground.com/#19O9TU#0
  92779. */
  92780. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  92781. }
  92782. /**
  92783. * Defines the minimum contract an Edges renderer should follow.
  92784. */
  92785. export interface IEdgesRenderer extends IDisposable {
  92786. /**
  92787. * Gets or sets a boolean indicating if the edgesRenderer is active
  92788. */
  92789. isEnabled: boolean;
  92790. /**
  92791. * Renders the edges of the attached mesh,
  92792. */
  92793. render(): void;
  92794. /**
  92795. * Checks wether or not the edges renderer is ready to render.
  92796. * @return true if ready, otherwise false.
  92797. */
  92798. isReady(): boolean;
  92799. }
  92800. /**
  92801. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  92802. */
  92803. export class EdgesRenderer implements IEdgesRenderer {
  92804. /**
  92805. * Define the size of the edges with an orthographic camera
  92806. */
  92807. edgesWidthScalerForOrthographic: number;
  92808. /**
  92809. * Define the size of the edges with a perspective camera
  92810. */
  92811. edgesWidthScalerForPerspective: number;
  92812. protected _source: AbstractMesh;
  92813. protected _linesPositions: number[];
  92814. protected _linesNormals: number[];
  92815. protected _linesIndices: number[];
  92816. protected _epsilon: number;
  92817. protected _indicesCount: number;
  92818. protected _lineShader: ShaderMaterial;
  92819. protected _ib: DataBuffer;
  92820. protected _buffers: {
  92821. [key: string]: Nullable<VertexBuffer>;
  92822. };
  92823. protected _checkVerticesInsteadOfIndices: boolean;
  92824. private _meshRebuildObserver;
  92825. private _meshDisposeObserver;
  92826. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  92827. isEnabled: boolean;
  92828. /**
  92829. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  92830. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  92831. * @param source Mesh used to create edges
  92832. * @param epsilon sum of angles in adjacency to check for edge
  92833. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  92834. * @param generateEdgesLines - should generate Lines or only prepare resources.
  92835. */
  92836. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  92837. protected _prepareRessources(): void;
  92838. /** @hidden */
  92839. _rebuild(): void;
  92840. /**
  92841. * Releases the required resources for the edges renderer
  92842. */
  92843. dispose(): void;
  92844. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  92845. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  92846. /**
  92847. * Checks if the pair of p0 and p1 is en edge
  92848. * @param faceIndex
  92849. * @param edge
  92850. * @param faceNormals
  92851. * @param p0
  92852. * @param p1
  92853. * @private
  92854. */
  92855. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  92856. /**
  92857. * push line into the position, normal and index buffer
  92858. * @protected
  92859. */
  92860. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  92861. /**
  92862. * Generates lines edges from adjacencjes
  92863. * @private
  92864. */
  92865. _generateEdgesLines(): void;
  92866. /**
  92867. * Checks wether or not the edges renderer is ready to render.
  92868. * @return true if ready, otherwise false.
  92869. */
  92870. isReady(): boolean;
  92871. /**
  92872. * Renders the edges of the attached mesh,
  92873. */
  92874. render(): void;
  92875. }
  92876. /**
  92877. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  92878. */
  92879. export class LineEdgesRenderer extends EdgesRenderer {
  92880. /**
  92881. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  92882. * @param source LineMesh used to generate edges
  92883. * @param epsilon not important (specified angle for edge detection)
  92884. * @param checkVerticesInsteadOfIndices not important for LineMesh
  92885. */
  92886. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  92887. /**
  92888. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  92889. */
  92890. _generateEdgesLines(): void;
  92891. }
  92892. }
  92893. declare module BABYLON {
  92894. /**
  92895. * This represents the object necessary to create a rendering group.
  92896. * This is exclusively used and created by the rendering manager.
  92897. * To modify the behavior, you use the available helpers in your scene or meshes.
  92898. * @hidden
  92899. */
  92900. export class RenderingGroup {
  92901. index: number;
  92902. private static _zeroVector;
  92903. private _scene;
  92904. private _opaqueSubMeshes;
  92905. private _transparentSubMeshes;
  92906. private _alphaTestSubMeshes;
  92907. private _depthOnlySubMeshes;
  92908. private _particleSystems;
  92909. private _spriteManagers;
  92910. private _opaqueSortCompareFn;
  92911. private _alphaTestSortCompareFn;
  92912. private _transparentSortCompareFn;
  92913. private _renderOpaque;
  92914. private _renderAlphaTest;
  92915. private _renderTransparent;
  92916. /** @hidden */
  92917. _edgesRenderers: SmartArray<IEdgesRenderer>;
  92918. onBeforeTransparentRendering: () => void;
  92919. /**
  92920. * Set the opaque sort comparison function.
  92921. * If null the sub meshes will be render in the order they were created
  92922. */
  92923. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  92924. /**
  92925. * Set the alpha test sort comparison function.
  92926. * If null the sub meshes will be render in the order they were created
  92927. */
  92928. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  92929. /**
  92930. * Set the transparent sort comparison function.
  92931. * If null the sub meshes will be render in the order they were created
  92932. */
  92933. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  92934. /**
  92935. * Creates a new rendering group.
  92936. * @param index The rendering group index
  92937. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  92938. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  92939. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  92940. */
  92941. 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>);
  92942. /**
  92943. * Render all the sub meshes contained in the group.
  92944. * @param customRenderFunction Used to override the default render behaviour of the group.
  92945. * @returns true if rendered some submeshes.
  92946. */
  92947. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  92948. /**
  92949. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  92950. * @param subMeshes The submeshes to render
  92951. */
  92952. private renderOpaqueSorted;
  92953. /**
  92954. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  92955. * @param subMeshes The submeshes to render
  92956. */
  92957. private renderAlphaTestSorted;
  92958. /**
  92959. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  92960. * @param subMeshes The submeshes to render
  92961. */
  92962. private renderTransparentSorted;
  92963. /**
  92964. * Renders the submeshes in a specified order.
  92965. * @param subMeshes The submeshes to sort before render
  92966. * @param sortCompareFn The comparison function use to sort
  92967. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  92968. * @param transparent Specifies to activate blending if true
  92969. */
  92970. private static renderSorted;
  92971. /**
  92972. * Renders the submeshes in the order they were dispatched (no sort applied).
  92973. * @param subMeshes The submeshes to render
  92974. */
  92975. private static renderUnsorted;
  92976. /**
  92977. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  92978. * are rendered back to front if in the same alpha index.
  92979. *
  92980. * @param a The first submesh
  92981. * @param b The second submesh
  92982. * @returns The result of the comparison
  92983. */
  92984. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  92985. /**
  92986. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  92987. * are rendered back to front.
  92988. *
  92989. * @param a The first submesh
  92990. * @param b The second submesh
  92991. * @returns The result of the comparison
  92992. */
  92993. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  92994. /**
  92995. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  92996. * are rendered front to back (prevent overdraw).
  92997. *
  92998. * @param a The first submesh
  92999. * @param b The second submesh
  93000. * @returns The result of the comparison
  93001. */
  93002. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  93003. /**
  93004. * Resets the different lists of submeshes to prepare a new frame.
  93005. */
  93006. prepare(): void;
  93007. dispose(): void;
  93008. /**
  93009. * Inserts the submesh in its correct queue depending on its material.
  93010. * @param subMesh The submesh to dispatch
  93011. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  93012. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  93013. */
  93014. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  93015. dispatchSprites(spriteManager: ISpriteManager): void;
  93016. dispatchParticles(particleSystem: IParticleSystem): void;
  93017. private _renderParticles;
  93018. private _renderSprites;
  93019. }
  93020. }
  93021. declare module BABYLON {
  93022. /**
  93023. * Interface describing the different options available in the rendering manager
  93024. * regarding Auto Clear between groups.
  93025. */
  93026. export interface IRenderingManagerAutoClearSetup {
  93027. /**
  93028. * Defines whether or not autoclear is enable.
  93029. */
  93030. autoClear: boolean;
  93031. /**
  93032. * Defines whether or not to autoclear the depth buffer.
  93033. */
  93034. depth: boolean;
  93035. /**
  93036. * Defines whether or not to autoclear the stencil buffer.
  93037. */
  93038. stencil: boolean;
  93039. }
  93040. /**
  93041. * This class is used by the onRenderingGroupObservable
  93042. */
  93043. export class RenderingGroupInfo {
  93044. /**
  93045. * The Scene that being rendered
  93046. */
  93047. scene: Scene;
  93048. /**
  93049. * The camera currently used for the rendering pass
  93050. */
  93051. camera: Nullable<Camera>;
  93052. /**
  93053. * The ID of the renderingGroup being processed
  93054. */
  93055. renderingGroupId: number;
  93056. }
  93057. /**
  93058. * This is the manager responsible of all the rendering for meshes sprites and particles.
  93059. * It is enable to manage the different groups as well as the different necessary sort functions.
  93060. * This should not be used directly aside of the few static configurations
  93061. */
  93062. export class RenderingManager {
  93063. /**
  93064. * The max id used for rendering groups (not included)
  93065. */
  93066. static MAX_RENDERINGGROUPS: number;
  93067. /**
  93068. * The min id used for rendering groups (included)
  93069. */
  93070. static MIN_RENDERINGGROUPS: number;
  93071. /**
  93072. * Used to globally prevent autoclearing scenes.
  93073. */
  93074. static AUTOCLEAR: boolean;
  93075. /**
  93076. * @hidden
  93077. */
  93078. _useSceneAutoClearSetup: boolean;
  93079. private _scene;
  93080. private _renderingGroups;
  93081. private _depthStencilBufferAlreadyCleaned;
  93082. private _autoClearDepthStencil;
  93083. private _customOpaqueSortCompareFn;
  93084. private _customAlphaTestSortCompareFn;
  93085. private _customTransparentSortCompareFn;
  93086. private _renderingGroupInfo;
  93087. /**
  93088. * Instantiates a new rendering group for a particular scene
  93089. * @param scene Defines the scene the groups belongs to
  93090. */
  93091. constructor(scene: Scene);
  93092. private _clearDepthStencilBuffer;
  93093. /**
  93094. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  93095. * @hidden
  93096. */
  93097. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  93098. /**
  93099. * Resets the different information of the group to prepare a new frame
  93100. * @hidden
  93101. */
  93102. reset(): void;
  93103. /**
  93104. * Dispose and release the group and its associated resources.
  93105. * @hidden
  93106. */
  93107. dispose(): void;
  93108. /**
  93109. * Clear the info related to rendering groups preventing retention points during dispose.
  93110. */
  93111. freeRenderingGroups(): void;
  93112. private _prepareRenderingGroup;
  93113. /**
  93114. * Add a sprite manager to the rendering manager in order to render it this frame.
  93115. * @param spriteManager Define the sprite manager to render
  93116. */
  93117. dispatchSprites(spriteManager: ISpriteManager): void;
  93118. /**
  93119. * Add a particle system to the rendering manager in order to render it this frame.
  93120. * @param particleSystem Define the particle system to render
  93121. */
  93122. dispatchParticles(particleSystem: IParticleSystem): void;
  93123. /**
  93124. * Add a submesh to the manager in order to render it this frame
  93125. * @param subMesh The submesh to dispatch
  93126. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  93127. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  93128. */
  93129. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  93130. /**
  93131. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  93132. * This allowed control for front to back rendering or reversly depending of the special needs.
  93133. *
  93134. * @param renderingGroupId The rendering group id corresponding to its index
  93135. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  93136. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  93137. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  93138. */
  93139. 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;
  93140. /**
  93141. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  93142. *
  93143. * @param renderingGroupId The rendering group id corresponding to its index
  93144. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  93145. * @param depth Automatically clears depth between groups if true and autoClear is true.
  93146. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  93147. */
  93148. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  93149. /**
  93150. * Gets the current auto clear configuration for one rendering group of the rendering
  93151. * manager.
  93152. * @param index the rendering group index to get the information for
  93153. * @returns The auto clear setup for the requested rendering group
  93154. */
  93155. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  93156. }
  93157. }
  93158. declare module BABYLON {
  93159. /**
  93160. * This Helps creating a texture that will be created from a camera in your scene.
  93161. * It is basically a dynamic texture that could be used to create special effects for instance.
  93162. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  93163. */
  93164. export class RenderTargetTexture extends Texture {
  93165. isCube: boolean;
  93166. /**
  93167. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  93168. */
  93169. static readonly REFRESHRATE_RENDER_ONCE: number;
  93170. /**
  93171. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  93172. */
  93173. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  93174. /**
  93175. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  93176. * the central point of your effect and can save a lot of performances.
  93177. */
  93178. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  93179. /**
  93180. * Use this predicate to dynamically define the list of mesh you want to render.
  93181. * If set, the renderList property will be overwritten.
  93182. */
  93183. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  93184. private _renderList;
  93185. /**
  93186. * Use this list to define the list of mesh you want to render.
  93187. */
  93188. get renderList(): Nullable<Array<AbstractMesh>>;
  93189. set renderList(value: Nullable<Array<AbstractMesh>>);
  93190. /**
  93191. * Use this function to overload the renderList array at rendering time.
  93192. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  93193. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  93194. * the cube (if the RTT is a cube, else layerOrFace=0).
  93195. * The renderList passed to the function is the current render list (the one that will be used if the function returns null)
  93196. */
  93197. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>) => Nullable<Array<AbstractMesh>>;
  93198. private _hookArray;
  93199. /**
  93200. * Define if particles should be rendered in your texture.
  93201. */
  93202. renderParticles: boolean;
  93203. /**
  93204. * Define if sprites should be rendered in your texture.
  93205. */
  93206. renderSprites: boolean;
  93207. /**
  93208. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  93209. */
  93210. coordinatesMode: number;
  93211. /**
  93212. * Define the camera used to render the texture.
  93213. */
  93214. activeCamera: Nullable<Camera>;
  93215. /**
  93216. * Override the render function of the texture with your own one.
  93217. */
  93218. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  93219. /**
  93220. * Define if camera post processes should be use while rendering the texture.
  93221. */
  93222. useCameraPostProcesses: boolean;
  93223. /**
  93224. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  93225. */
  93226. ignoreCameraViewport: boolean;
  93227. private _postProcessManager;
  93228. private _postProcesses;
  93229. private _resizeObserver;
  93230. /**
  93231. * An event triggered when the texture is unbind.
  93232. */
  93233. onBeforeBindObservable: Observable<RenderTargetTexture>;
  93234. /**
  93235. * An event triggered when the texture is unbind.
  93236. */
  93237. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  93238. private _onAfterUnbindObserver;
  93239. /**
  93240. * Set a after unbind callback in the texture.
  93241. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  93242. */
  93243. set onAfterUnbind(callback: () => void);
  93244. /**
  93245. * An event triggered before rendering the texture
  93246. */
  93247. onBeforeRenderObservable: Observable<number>;
  93248. private _onBeforeRenderObserver;
  93249. /**
  93250. * Set a before render callback in the texture.
  93251. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  93252. */
  93253. set onBeforeRender(callback: (faceIndex: number) => void);
  93254. /**
  93255. * An event triggered after rendering the texture
  93256. */
  93257. onAfterRenderObservable: Observable<number>;
  93258. private _onAfterRenderObserver;
  93259. /**
  93260. * Set a after render callback in the texture.
  93261. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  93262. */
  93263. set onAfterRender(callback: (faceIndex: number) => void);
  93264. /**
  93265. * An event triggered after the texture clear
  93266. */
  93267. onClearObservable: Observable<Engine>;
  93268. private _onClearObserver;
  93269. /**
  93270. * Set a clear callback in the texture.
  93271. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  93272. */
  93273. set onClear(callback: (Engine: Engine) => void);
  93274. /**
  93275. * An event triggered when the texture is resized.
  93276. */
  93277. onResizeObservable: Observable<RenderTargetTexture>;
  93278. /**
  93279. * Define the clear color of the Render Target if it should be different from the scene.
  93280. */
  93281. clearColor: Color4;
  93282. protected _size: number | {
  93283. width: number;
  93284. height: number;
  93285. layers?: number;
  93286. };
  93287. protected _initialSizeParameter: number | {
  93288. width: number;
  93289. height: number;
  93290. } | {
  93291. ratio: number;
  93292. };
  93293. protected _sizeRatio: Nullable<number>;
  93294. /** @hidden */
  93295. _generateMipMaps: boolean;
  93296. protected _renderingManager: RenderingManager;
  93297. /** @hidden */
  93298. _waitingRenderList: string[];
  93299. protected _doNotChangeAspectRatio: boolean;
  93300. protected _currentRefreshId: number;
  93301. protected _refreshRate: number;
  93302. protected _textureMatrix: Matrix;
  93303. protected _samples: number;
  93304. protected _renderTargetOptions: RenderTargetCreationOptions;
  93305. /**
  93306. * Gets render target creation options that were used.
  93307. */
  93308. get renderTargetOptions(): RenderTargetCreationOptions;
  93309. protected _engine: Engine;
  93310. protected _onRatioRescale(): void;
  93311. /**
  93312. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  93313. * It must define where the camera used to render the texture is set
  93314. */
  93315. boundingBoxPosition: Vector3;
  93316. private _boundingBoxSize;
  93317. /**
  93318. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  93319. * When defined, the cubemap will switch to local mode
  93320. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  93321. * @example https://www.babylonjs-playground.com/#RNASML
  93322. */
  93323. set boundingBoxSize(value: Vector3);
  93324. get boundingBoxSize(): Vector3;
  93325. /**
  93326. * In case the RTT has been created with a depth texture, get the associated
  93327. * depth texture.
  93328. * Otherwise, return null.
  93329. */
  93330. get depthStencilTexture(): Nullable<InternalTexture>;
  93331. /**
  93332. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  93333. * or used a shadow, depth texture...
  93334. * @param name The friendly name of the texture
  93335. * @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)
  93336. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  93337. * @param generateMipMaps True if mip maps need to be generated after render.
  93338. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  93339. * @param type The type of the buffer in the RTT (int, half float, float...)
  93340. * @param isCube True if a cube texture needs to be created
  93341. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  93342. * @param generateDepthBuffer True to generate a depth buffer
  93343. * @param generateStencilBuffer True to generate a stencil buffer
  93344. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  93345. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  93346. * @param delayAllocation if the texture allocation should be delayed (default: false)
  93347. */
  93348. constructor(name: string, size: number | {
  93349. width: number;
  93350. height: number;
  93351. layers?: number;
  93352. } | {
  93353. ratio: number;
  93354. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  93355. /**
  93356. * Creates a depth stencil texture.
  93357. * This is only available in WebGL 2 or with the depth texture extension available.
  93358. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  93359. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  93360. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  93361. */
  93362. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  93363. private _processSizeParameter;
  93364. /**
  93365. * Define the number of samples to use in case of MSAA.
  93366. * It defaults to one meaning no MSAA has been enabled.
  93367. */
  93368. get samples(): number;
  93369. set samples(value: number);
  93370. /**
  93371. * Resets the refresh counter of the texture and start bak from scratch.
  93372. * Could be useful to regenerate the texture if it is setup to render only once.
  93373. */
  93374. resetRefreshCounter(): void;
  93375. /**
  93376. * Define the refresh rate of the texture or the rendering frequency.
  93377. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  93378. */
  93379. get refreshRate(): number;
  93380. set refreshRate(value: number);
  93381. /**
  93382. * Adds a post process to the render target rendering passes.
  93383. * @param postProcess define the post process to add
  93384. */
  93385. addPostProcess(postProcess: PostProcess): void;
  93386. /**
  93387. * Clear all the post processes attached to the render target
  93388. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  93389. */
  93390. clearPostProcesses(dispose?: boolean): void;
  93391. /**
  93392. * Remove one of the post process from the list of attached post processes to the texture
  93393. * @param postProcess define the post process to remove from the list
  93394. */
  93395. removePostProcess(postProcess: PostProcess): void;
  93396. /** @hidden */
  93397. _shouldRender(): boolean;
  93398. /**
  93399. * Gets the actual render size of the texture.
  93400. * @returns the width of the render size
  93401. */
  93402. getRenderSize(): number;
  93403. /**
  93404. * Gets the actual render width of the texture.
  93405. * @returns the width of the render size
  93406. */
  93407. getRenderWidth(): number;
  93408. /**
  93409. * Gets the actual render height of the texture.
  93410. * @returns the height of the render size
  93411. */
  93412. getRenderHeight(): number;
  93413. /**
  93414. * Gets the actual number of layers of the texture.
  93415. * @returns the number of layers
  93416. */
  93417. getRenderLayers(): number;
  93418. /**
  93419. * Get if the texture can be rescaled or not.
  93420. */
  93421. get canRescale(): boolean;
  93422. /**
  93423. * Resize the texture using a ratio.
  93424. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  93425. */
  93426. scale(ratio: number): void;
  93427. /**
  93428. * Get the texture reflection matrix used to rotate/transform the reflection.
  93429. * @returns the reflection matrix
  93430. */
  93431. getReflectionTextureMatrix(): Matrix;
  93432. /**
  93433. * Resize the texture to a new desired size.
  93434. * Be carrefull as it will recreate all the data in the new texture.
  93435. * @param size Define the new size. It can be:
  93436. * - a number for squared texture,
  93437. * - an object containing { width: number, height: number }
  93438. * - or an object containing a ratio { ratio: number }
  93439. */
  93440. resize(size: number | {
  93441. width: number;
  93442. height: number;
  93443. } | {
  93444. ratio: number;
  93445. }): void;
  93446. private _defaultRenderListPrepared;
  93447. /**
  93448. * Renders all the objects from the render list into the texture.
  93449. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  93450. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  93451. */
  93452. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  93453. private _bestReflectionRenderTargetDimension;
  93454. private _prepareRenderingManager;
  93455. /**
  93456. * @hidden
  93457. * @param faceIndex face index to bind to if this is a cubetexture
  93458. * @param layer defines the index of the texture to bind in the array
  93459. */
  93460. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  93461. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  93462. private renderToTarget;
  93463. /**
  93464. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  93465. * This allowed control for front to back rendering or reversly depending of the special needs.
  93466. *
  93467. * @param renderingGroupId The rendering group id corresponding to its index
  93468. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  93469. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  93470. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  93471. */
  93472. 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;
  93473. /**
  93474. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  93475. *
  93476. * @param renderingGroupId The rendering group id corresponding to its index
  93477. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  93478. */
  93479. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  93480. /**
  93481. * Clones the texture.
  93482. * @returns the cloned texture
  93483. */
  93484. clone(): RenderTargetTexture;
  93485. /**
  93486. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  93487. * @returns The JSON representation of the texture
  93488. */
  93489. serialize(): any;
  93490. /**
  93491. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  93492. */
  93493. disposeFramebufferObjects(): void;
  93494. /**
  93495. * Dispose the texture and release its associated resources.
  93496. */
  93497. dispose(): void;
  93498. /** @hidden */
  93499. _rebuild(): void;
  93500. /**
  93501. * Clear the info related to rendering groups preventing retention point in material dispose.
  93502. */
  93503. freeRenderingGroups(): void;
  93504. /**
  93505. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  93506. * @returns the view count
  93507. */
  93508. getViewCount(): number;
  93509. }
  93510. }
  93511. declare module BABYLON {
  93512. /**
  93513. * Options for compiling materials.
  93514. */
  93515. export interface IMaterialCompilationOptions {
  93516. /**
  93517. * Defines whether clip planes are enabled.
  93518. */
  93519. clipPlane: boolean;
  93520. /**
  93521. * Defines whether instances are enabled.
  93522. */
  93523. useInstances: boolean;
  93524. }
  93525. /**
  93526. * Base class for the main features of a material in Babylon.js
  93527. */
  93528. export class Material implements IAnimatable {
  93529. /**
  93530. * Returns the triangle fill mode
  93531. */
  93532. static readonly TriangleFillMode: number;
  93533. /**
  93534. * Returns the wireframe mode
  93535. */
  93536. static readonly WireFrameFillMode: number;
  93537. /**
  93538. * Returns the point fill mode
  93539. */
  93540. static readonly PointFillMode: number;
  93541. /**
  93542. * Returns the point list draw mode
  93543. */
  93544. static readonly PointListDrawMode: number;
  93545. /**
  93546. * Returns the line list draw mode
  93547. */
  93548. static readonly LineListDrawMode: number;
  93549. /**
  93550. * Returns the line loop draw mode
  93551. */
  93552. static readonly LineLoopDrawMode: number;
  93553. /**
  93554. * Returns the line strip draw mode
  93555. */
  93556. static readonly LineStripDrawMode: number;
  93557. /**
  93558. * Returns the triangle strip draw mode
  93559. */
  93560. static readonly TriangleStripDrawMode: number;
  93561. /**
  93562. * Returns the triangle fan draw mode
  93563. */
  93564. static readonly TriangleFanDrawMode: number;
  93565. /**
  93566. * Stores the clock-wise side orientation
  93567. */
  93568. static readonly ClockWiseSideOrientation: number;
  93569. /**
  93570. * Stores the counter clock-wise side orientation
  93571. */
  93572. static readonly CounterClockWiseSideOrientation: number;
  93573. /**
  93574. * The dirty texture flag value
  93575. */
  93576. static readonly TextureDirtyFlag: number;
  93577. /**
  93578. * The dirty light flag value
  93579. */
  93580. static readonly LightDirtyFlag: number;
  93581. /**
  93582. * The dirty fresnel flag value
  93583. */
  93584. static readonly FresnelDirtyFlag: number;
  93585. /**
  93586. * The dirty attribute flag value
  93587. */
  93588. static readonly AttributesDirtyFlag: number;
  93589. /**
  93590. * The dirty misc flag value
  93591. */
  93592. static readonly MiscDirtyFlag: number;
  93593. /**
  93594. * The all dirty flag value
  93595. */
  93596. static readonly AllDirtyFlag: number;
  93597. /**
  93598. * The ID of the material
  93599. */
  93600. id: string;
  93601. /**
  93602. * Gets or sets the unique id of the material
  93603. */
  93604. uniqueId: number;
  93605. /**
  93606. * The name of the material
  93607. */
  93608. name: string;
  93609. /**
  93610. * Gets or sets user defined metadata
  93611. */
  93612. metadata: any;
  93613. /**
  93614. * For internal use only. Please do not use.
  93615. */
  93616. reservedDataStore: any;
  93617. /**
  93618. * Specifies if the ready state should be checked on each call
  93619. */
  93620. checkReadyOnEveryCall: boolean;
  93621. /**
  93622. * Specifies if the ready state should be checked once
  93623. */
  93624. checkReadyOnlyOnce: boolean;
  93625. /**
  93626. * The state of the material
  93627. */
  93628. state: string;
  93629. /**
  93630. * The alpha value of the material
  93631. */
  93632. protected _alpha: number;
  93633. /**
  93634. * List of inspectable custom properties (used by the Inspector)
  93635. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93636. */
  93637. inspectableCustomProperties: IInspectable[];
  93638. /**
  93639. * Sets the alpha value of the material
  93640. */
  93641. set alpha(value: number);
  93642. /**
  93643. * Gets the alpha value of the material
  93644. */
  93645. get alpha(): number;
  93646. /**
  93647. * Specifies if back face culling is enabled
  93648. */
  93649. protected _backFaceCulling: boolean;
  93650. /**
  93651. * Sets the back-face culling state
  93652. */
  93653. set backFaceCulling(value: boolean);
  93654. /**
  93655. * Gets the back-face culling state
  93656. */
  93657. get backFaceCulling(): boolean;
  93658. /**
  93659. * Stores the value for side orientation
  93660. */
  93661. sideOrientation: number;
  93662. /**
  93663. * Callback triggered when the material is compiled
  93664. */
  93665. onCompiled: Nullable<(effect: Effect) => void>;
  93666. /**
  93667. * Callback triggered when an error occurs
  93668. */
  93669. onError: Nullable<(effect: Effect, errors: string) => void>;
  93670. /**
  93671. * Callback triggered to get the render target textures
  93672. */
  93673. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  93674. /**
  93675. * Gets a boolean indicating that current material needs to register RTT
  93676. */
  93677. get hasRenderTargetTextures(): boolean;
  93678. /**
  93679. * Specifies if the material should be serialized
  93680. */
  93681. doNotSerialize: boolean;
  93682. /**
  93683. * @hidden
  93684. */
  93685. _storeEffectOnSubMeshes: boolean;
  93686. /**
  93687. * Stores the animations for the material
  93688. */
  93689. animations: Nullable<Array<Animation>>;
  93690. /**
  93691. * An event triggered when the material is disposed
  93692. */
  93693. onDisposeObservable: Observable<Material>;
  93694. /**
  93695. * An observer which watches for dispose events
  93696. */
  93697. private _onDisposeObserver;
  93698. private _onUnBindObservable;
  93699. /**
  93700. * Called during a dispose event
  93701. */
  93702. set onDispose(callback: () => void);
  93703. private _onBindObservable;
  93704. /**
  93705. * An event triggered when the material is bound
  93706. */
  93707. get onBindObservable(): Observable<AbstractMesh>;
  93708. /**
  93709. * An observer which watches for bind events
  93710. */
  93711. private _onBindObserver;
  93712. /**
  93713. * Called during a bind event
  93714. */
  93715. set onBind(callback: (Mesh: AbstractMesh) => void);
  93716. /**
  93717. * An event triggered when the material is unbound
  93718. */
  93719. get onUnBindObservable(): Observable<Material>;
  93720. /**
  93721. * Stores the value of the alpha mode
  93722. */
  93723. private _alphaMode;
  93724. /**
  93725. * Sets the value of the alpha mode.
  93726. *
  93727. * | Value | Type | Description |
  93728. * | --- | --- | --- |
  93729. * | 0 | ALPHA_DISABLE | |
  93730. * | 1 | ALPHA_ADD | |
  93731. * | 2 | ALPHA_COMBINE | |
  93732. * | 3 | ALPHA_SUBTRACT | |
  93733. * | 4 | ALPHA_MULTIPLY | |
  93734. * | 5 | ALPHA_MAXIMIZED | |
  93735. * | 6 | ALPHA_ONEONE | |
  93736. * | 7 | ALPHA_PREMULTIPLIED | |
  93737. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  93738. * | 9 | ALPHA_INTERPOLATE | |
  93739. * | 10 | ALPHA_SCREENMODE | |
  93740. *
  93741. */
  93742. set alphaMode(value: number);
  93743. /**
  93744. * Gets the value of the alpha mode
  93745. */
  93746. get alphaMode(): number;
  93747. /**
  93748. * Stores the state of the need depth pre-pass value
  93749. */
  93750. private _needDepthPrePass;
  93751. /**
  93752. * Sets the need depth pre-pass value
  93753. */
  93754. set needDepthPrePass(value: boolean);
  93755. /**
  93756. * Gets the depth pre-pass value
  93757. */
  93758. get needDepthPrePass(): boolean;
  93759. /**
  93760. * Specifies if depth writing should be disabled
  93761. */
  93762. disableDepthWrite: boolean;
  93763. /**
  93764. * Specifies if depth writing should be forced
  93765. */
  93766. forceDepthWrite: boolean;
  93767. /**
  93768. * Specifies the depth function that should be used. 0 means the default engine function
  93769. */
  93770. depthFunction: number;
  93771. /**
  93772. * Specifies if there should be a separate pass for culling
  93773. */
  93774. separateCullingPass: boolean;
  93775. /**
  93776. * Stores the state specifing if fog should be enabled
  93777. */
  93778. private _fogEnabled;
  93779. /**
  93780. * Sets the state for enabling fog
  93781. */
  93782. set fogEnabled(value: boolean);
  93783. /**
  93784. * Gets the value of the fog enabled state
  93785. */
  93786. get fogEnabled(): boolean;
  93787. /**
  93788. * Stores the size of points
  93789. */
  93790. pointSize: number;
  93791. /**
  93792. * Stores the z offset value
  93793. */
  93794. zOffset: number;
  93795. /**
  93796. * Gets a value specifying if wireframe mode is enabled
  93797. */
  93798. get wireframe(): boolean;
  93799. /**
  93800. * Sets the state of wireframe mode
  93801. */
  93802. set wireframe(value: boolean);
  93803. /**
  93804. * Gets the value specifying if point clouds are enabled
  93805. */
  93806. get pointsCloud(): boolean;
  93807. /**
  93808. * Sets the state of point cloud mode
  93809. */
  93810. set pointsCloud(value: boolean);
  93811. /**
  93812. * Gets the material fill mode
  93813. */
  93814. get fillMode(): number;
  93815. /**
  93816. * Sets the material fill mode
  93817. */
  93818. set fillMode(value: number);
  93819. /**
  93820. * @hidden
  93821. * Stores the effects for the material
  93822. */
  93823. _effect: Nullable<Effect>;
  93824. /**
  93825. * Specifies if uniform buffers should be used
  93826. */
  93827. private _useUBO;
  93828. /**
  93829. * Stores a reference to the scene
  93830. */
  93831. private _scene;
  93832. /**
  93833. * Stores the fill mode state
  93834. */
  93835. private _fillMode;
  93836. /**
  93837. * Specifies if the depth write state should be cached
  93838. */
  93839. private _cachedDepthWriteState;
  93840. /**
  93841. * Specifies if the depth function state should be cached
  93842. */
  93843. private _cachedDepthFunctionState;
  93844. /**
  93845. * Stores the uniform buffer
  93846. */
  93847. protected _uniformBuffer: UniformBuffer;
  93848. /** @hidden */
  93849. _indexInSceneMaterialArray: number;
  93850. /** @hidden */
  93851. meshMap: Nullable<{
  93852. [id: string]: AbstractMesh | undefined;
  93853. }>;
  93854. /**
  93855. * Creates a material instance
  93856. * @param name defines the name of the material
  93857. * @param scene defines the scene to reference
  93858. * @param doNotAdd specifies if the material should be added to the scene
  93859. */
  93860. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  93861. /**
  93862. * Returns a string representation of the current material
  93863. * @param fullDetails defines a boolean indicating which levels of logging is desired
  93864. * @returns a string with material information
  93865. */
  93866. toString(fullDetails?: boolean): string;
  93867. /**
  93868. * Gets the class name of the material
  93869. * @returns a string with the class name of the material
  93870. */
  93871. getClassName(): string;
  93872. /**
  93873. * Specifies if updates for the material been locked
  93874. */
  93875. get isFrozen(): boolean;
  93876. /**
  93877. * Locks updates for the material
  93878. */
  93879. freeze(): void;
  93880. /**
  93881. * Unlocks updates for the material
  93882. */
  93883. unfreeze(): void;
  93884. /**
  93885. * Specifies if the material is ready to be used
  93886. * @param mesh defines the mesh to check
  93887. * @param useInstances specifies if instances should be used
  93888. * @returns a boolean indicating if the material is ready to be used
  93889. */
  93890. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  93891. /**
  93892. * Specifies that the submesh is ready to be used
  93893. * @param mesh defines the mesh to check
  93894. * @param subMesh defines which submesh to check
  93895. * @param useInstances specifies that instances should be used
  93896. * @returns a boolean indicating that the submesh is ready or not
  93897. */
  93898. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  93899. /**
  93900. * Returns the material effect
  93901. * @returns the effect associated with the material
  93902. */
  93903. getEffect(): Nullable<Effect>;
  93904. /**
  93905. * Returns the current scene
  93906. * @returns a Scene
  93907. */
  93908. getScene(): Scene;
  93909. /**
  93910. * Specifies if the material will require alpha blending
  93911. * @returns a boolean specifying if alpha blending is needed
  93912. */
  93913. needAlphaBlending(): boolean;
  93914. /**
  93915. * Specifies if the mesh will require alpha blending
  93916. * @param mesh defines the mesh to check
  93917. * @returns a boolean specifying if alpha blending is needed for the mesh
  93918. */
  93919. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  93920. /**
  93921. * Specifies if this material should be rendered in alpha test mode
  93922. * @returns a boolean specifying if an alpha test is needed.
  93923. */
  93924. needAlphaTesting(): boolean;
  93925. /**
  93926. * Gets the texture used for the alpha test
  93927. * @returns the texture to use for alpha testing
  93928. */
  93929. getAlphaTestTexture(): Nullable<BaseTexture>;
  93930. /**
  93931. * Marks the material to indicate that it needs to be re-calculated
  93932. */
  93933. markDirty(): void;
  93934. /** @hidden */
  93935. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  93936. /**
  93937. * Binds the material to the mesh
  93938. * @param world defines the world transformation matrix
  93939. * @param mesh defines the mesh to bind the material to
  93940. */
  93941. bind(world: Matrix, mesh?: Mesh): void;
  93942. /**
  93943. * Binds the submesh to the material
  93944. * @param world defines the world transformation matrix
  93945. * @param mesh defines the mesh containing the submesh
  93946. * @param subMesh defines the submesh to bind the material to
  93947. */
  93948. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  93949. /**
  93950. * Binds the world matrix to the material
  93951. * @param world defines the world transformation matrix
  93952. */
  93953. bindOnlyWorldMatrix(world: Matrix): void;
  93954. /**
  93955. * Binds the scene's uniform buffer to the effect.
  93956. * @param effect defines the effect to bind to the scene uniform buffer
  93957. * @param sceneUbo defines the uniform buffer storing scene data
  93958. */
  93959. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  93960. /**
  93961. * Binds the view matrix to the effect
  93962. * @param effect defines the effect to bind the view matrix to
  93963. */
  93964. bindView(effect: Effect): void;
  93965. /**
  93966. * Binds the view projection matrix to the effect
  93967. * @param effect defines the effect to bind the view projection matrix to
  93968. */
  93969. bindViewProjection(effect: Effect): void;
  93970. /**
  93971. * Specifies if material alpha testing should be turned on for the mesh
  93972. * @param mesh defines the mesh to check
  93973. */
  93974. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  93975. /**
  93976. * Processes to execute after binding the material to a mesh
  93977. * @param mesh defines the rendered mesh
  93978. */
  93979. protected _afterBind(mesh?: Mesh): void;
  93980. /**
  93981. * Unbinds the material from the mesh
  93982. */
  93983. unbind(): void;
  93984. /**
  93985. * Gets the active textures from the material
  93986. * @returns an array of textures
  93987. */
  93988. getActiveTextures(): BaseTexture[];
  93989. /**
  93990. * Specifies if the material uses a texture
  93991. * @param texture defines the texture to check against the material
  93992. * @returns a boolean specifying if the material uses the texture
  93993. */
  93994. hasTexture(texture: BaseTexture): boolean;
  93995. /**
  93996. * Makes a duplicate of the material, and gives it a new name
  93997. * @param name defines the new name for the duplicated material
  93998. * @returns the cloned material
  93999. */
  94000. clone(name: string): Nullable<Material>;
  94001. /**
  94002. * Gets the meshes bound to the material
  94003. * @returns an array of meshes bound to the material
  94004. */
  94005. getBindedMeshes(): AbstractMesh[];
  94006. /**
  94007. * Force shader compilation
  94008. * @param mesh defines the mesh associated with this material
  94009. * @param onCompiled defines a function to execute once the material is compiled
  94010. * @param options defines the options to configure the compilation
  94011. * @param onError defines a function to execute if the material fails compiling
  94012. */
  94013. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  94014. /**
  94015. * Force shader compilation
  94016. * @param mesh defines the mesh that will use this material
  94017. * @param options defines additional options for compiling the shaders
  94018. * @returns a promise that resolves when the compilation completes
  94019. */
  94020. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  94021. private static readonly _AllDirtyCallBack;
  94022. private static readonly _ImageProcessingDirtyCallBack;
  94023. private static readonly _TextureDirtyCallBack;
  94024. private static readonly _FresnelDirtyCallBack;
  94025. private static readonly _MiscDirtyCallBack;
  94026. private static readonly _LightsDirtyCallBack;
  94027. private static readonly _AttributeDirtyCallBack;
  94028. private static _FresnelAndMiscDirtyCallBack;
  94029. private static _TextureAndMiscDirtyCallBack;
  94030. private static readonly _DirtyCallbackArray;
  94031. private static readonly _RunDirtyCallBacks;
  94032. /**
  94033. * Marks a define in the material to indicate that it needs to be re-computed
  94034. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  94035. */
  94036. markAsDirty(flag: number): void;
  94037. /**
  94038. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  94039. * @param func defines a function which checks material defines against the submeshes
  94040. */
  94041. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  94042. /**
  94043. * Indicates that we need to re-calculated for all submeshes
  94044. */
  94045. protected _markAllSubMeshesAsAllDirty(): void;
  94046. /**
  94047. * Indicates that image processing needs to be re-calculated for all submeshes
  94048. */
  94049. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  94050. /**
  94051. * Indicates that textures need to be re-calculated for all submeshes
  94052. */
  94053. protected _markAllSubMeshesAsTexturesDirty(): void;
  94054. /**
  94055. * Indicates that fresnel needs to be re-calculated for all submeshes
  94056. */
  94057. protected _markAllSubMeshesAsFresnelDirty(): void;
  94058. /**
  94059. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  94060. */
  94061. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  94062. /**
  94063. * Indicates that lights need to be re-calculated for all submeshes
  94064. */
  94065. protected _markAllSubMeshesAsLightsDirty(): void;
  94066. /**
  94067. * Indicates that attributes need to be re-calculated for all submeshes
  94068. */
  94069. protected _markAllSubMeshesAsAttributesDirty(): void;
  94070. /**
  94071. * Indicates that misc needs to be re-calculated for all submeshes
  94072. */
  94073. protected _markAllSubMeshesAsMiscDirty(): void;
  94074. /**
  94075. * Indicates that textures and misc need to be re-calculated for all submeshes
  94076. */
  94077. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  94078. /**
  94079. * Disposes the material
  94080. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94081. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94082. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  94083. */
  94084. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  94085. /** @hidden */
  94086. private releaseVertexArrayObject;
  94087. /**
  94088. * Serializes this material
  94089. * @returns the serialized material object
  94090. */
  94091. serialize(): any;
  94092. /**
  94093. * Creates a material from parsed material data
  94094. * @param parsedMaterial defines parsed material data
  94095. * @param scene defines the hosting scene
  94096. * @param rootUrl defines the root URL to use to load textures
  94097. * @returns a new material
  94098. */
  94099. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  94100. }
  94101. }
  94102. declare module BABYLON {
  94103. /**
  94104. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94105. * separate meshes. This can be use to improve performances.
  94106. * @see http://doc.babylonjs.com/how_to/multi_materials
  94107. */
  94108. export class MultiMaterial extends Material {
  94109. private _subMaterials;
  94110. /**
  94111. * Gets or Sets the list of Materials used within the multi material.
  94112. * They need to be ordered according to the submeshes order in the associated mesh
  94113. */
  94114. get subMaterials(): Nullable<Material>[];
  94115. set subMaterials(value: Nullable<Material>[]);
  94116. /**
  94117. * Function used to align with Node.getChildren()
  94118. * @returns the list of Materials used within the multi material
  94119. */
  94120. getChildren(): Nullable<Material>[];
  94121. /**
  94122. * Instantiates a new Multi Material
  94123. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94124. * separate meshes. This can be use to improve performances.
  94125. * @see http://doc.babylonjs.com/how_to/multi_materials
  94126. * @param name Define the name in the scene
  94127. * @param scene Define the scene the material belongs to
  94128. */
  94129. constructor(name: string, scene: Scene);
  94130. private _hookArray;
  94131. /**
  94132. * Get one of the submaterial by its index in the submaterials array
  94133. * @param index The index to look the sub material at
  94134. * @returns The Material if the index has been defined
  94135. */
  94136. getSubMaterial(index: number): Nullable<Material>;
  94137. /**
  94138. * Get the list of active textures for the whole sub materials list.
  94139. * @returns All the textures that will be used during the rendering
  94140. */
  94141. getActiveTextures(): BaseTexture[];
  94142. /**
  94143. * Gets the current class name of the material e.g. "MultiMaterial"
  94144. * Mainly use in serialization.
  94145. * @returns the class name
  94146. */
  94147. getClassName(): string;
  94148. /**
  94149. * Checks if the material is ready to render the requested sub mesh
  94150. * @param mesh Define the mesh the submesh belongs to
  94151. * @param subMesh Define the sub mesh to look readyness for
  94152. * @param useInstances Define whether or not the material is used with instances
  94153. * @returns true if ready, otherwise false
  94154. */
  94155. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94156. /**
  94157. * Clones the current material and its related sub materials
  94158. * @param name Define the name of the newly cloned material
  94159. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  94160. * @returns the cloned material
  94161. */
  94162. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  94163. /**
  94164. * Serializes the materials into a JSON representation.
  94165. * @returns the JSON representation
  94166. */
  94167. serialize(): any;
  94168. /**
  94169. * Dispose the material and release its associated resources
  94170. * @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)
  94171. * @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)
  94172. * @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)
  94173. */
  94174. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  94175. /**
  94176. * Creates a MultiMaterial from parsed MultiMaterial data.
  94177. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  94178. * @param scene defines the hosting scene
  94179. * @returns a new MultiMaterial
  94180. */
  94181. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  94182. }
  94183. }
  94184. declare module BABYLON {
  94185. /**
  94186. * Base class for submeshes
  94187. */
  94188. export class BaseSubMesh {
  94189. /** @hidden */
  94190. _materialDefines: Nullable<MaterialDefines>;
  94191. /** @hidden */
  94192. _materialEffect: Nullable<Effect>;
  94193. /**
  94194. * Gets material defines used by the effect associated to the sub mesh
  94195. */
  94196. get materialDefines(): Nullable<MaterialDefines>;
  94197. /**
  94198. * Sets material defines used by the effect associated to the sub mesh
  94199. */
  94200. set materialDefines(defines: Nullable<MaterialDefines>);
  94201. /**
  94202. * Gets associated effect
  94203. */
  94204. get effect(): Nullable<Effect>;
  94205. /**
  94206. * Sets associated effect (effect used to render this submesh)
  94207. * @param effect defines the effect to associate with
  94208. * @param defines defines the set of defines used to compile this effect
  94209. */
  94210. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  94211. }
  94212. /**
  94213. * Defines a subdivision inside a mesh
  94214. */
  94215. export class SubMesh extends BaseSubMesh implements ICullable {
  94216. /** the material index to use */
  94217. materialIndex: number;
  94218. /** vertex index start */
  94219. verticesStart: number;
  94220. /** vertices count */
  94221. verticesCount: number;
  94222. /** index start */
  94223. indexStart: number;
  94224. /** indices count */
  94225. indexCount: number;
  94226. /** @hidden */
  94227. _linesIndexCount: number;
  94228. private _mesh;
  94229. private _renderingMesh;
  94230. private _boundingInfo;
  94231. private _linesIndexBuffer;
  94232. /** @hidden */
  94233. _lastColliderWorldVertices: Nullable<Vector3[]>;
  94234. /** @hidden */
  94235. _trianglePlanes: Plane[];
  94236. /** @hidden */
  94237. _lastColliderTransformMatrix: Nullable<Matrix>;
  94238. /** @hidden */
  94239. _renderId: number;
  94240. /** @hidden */
  94241. _alphaIndex: number;
  94242. /** @hidden */
  94243. _distanceToCamera: number;
  94244. /** @hidden */
  94245. _id: number;
  94246. private _currentMaterial;
  94247. /**
  94248. * Add a new submesh to a mesh
  94249. * @param materialIndex defines the material index to use
  94250. * @param verticesStart defines vertex index start
  94251. * @param verticesCount defines vertices count
  94252. * @param indexStart defines index start
  94253. * @param indexCount defines indices count
  94254. * @param mesh defines the parent mesh
  94255. * @param renderingMesh defines an optional rendering mesh
  94256. * @param createBoundingBox defines if bounding box should be created for this submesh
  94257. * @returns the new submesh
  94258. */
  94259. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  94260. /**
  94261. * Creates a new submesh
  94262. * @param materialIndex defines the material index to use
  94263. * @param verticesStart defines vertex index start
  94264. * @param verticesCount defines vertices count
  94265. * @param indexStart defines index start
  94266. * @param indexCount defines indices count
  94267. * @param mesh defines the parent mesh
  94268. * @param renderingMesh defines an optional rendering mesh
  94269. * @param createBoundingBox defines if bounding box should be created for this submesh
  94270. */
  94271. constructor(
  94272. /** the material index to use */
  94273. materialIndex: number,
  94274. /** vertex index start */
  94275. verticesStart: number,
  94276. /** vertices count */
  94277. verticesCount: number,
  94278. /** index start */
  94279. indexStart: number,
  94280. /** indices count */
  94281. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  94282. /**
  94283. * Returns true if this submesh covers the entire parent mesh
  94284. * @ignorenaming
  94285. */
  94286. get IsGlobal(): boolean;
  94287. /**
  94288. * Returns the submesh BoudingInfo object
  94289. * @returns current bounding info (or mesh's one if the submesh is global)
  94290. */
  94291. getBoundingInfo(): BoundingInfo;
  94292. /**
  94293. * Sets the submesh BoundingInfo
  94294. * @param boundingInfo defines the new bounding info to use
  94295. * @returns the SubMesh
  94296. */
  94297. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  94298. /**
  94299. * Returns the mesh of the current submesh
  94300. * @return the parent mesh
  94301. */
  94302. getMesh(): AbstractMesh;
  94303. /**
  94304. * Returns the rendering mesh of the submesh
  94305. * @returns the rendering mesh (could be different from parent mesh)
  94306. */
  94307. getRenderingMesh(): Mesh;
  94308. /**
  94309. * Returns the submesh material
  94310. * @returns null or the current material
  94311. */
  94312. getMaterial(): Nullable<Material>;
  94313. /**
  94314. * Sets a new updated BoundingInfo object to the submesh
  94315. * @param data defines an optional position array to use to determine the bounding info
  94316. * @returns the SubMesh
  94317. */
  94318. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  94319. /** @hidden */
  94320. _checkCollision(collider: Collider): boolean;
  94321. /**
  94322. * Updates the submesh BoundingInfo
  94323. * @param world defines the world matrix to use to update the bounding info
  94324. * @returns the submesh
  94325. */
  94326. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  94327. /**
  94328. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  94329. * @param frustumPlanes defines the frustum planes
  94330. * @returns true if the submesh is intersecting with the frustum
  94331. */
  94332. isInFrustum(frustumPlanes: Plane[]): boolean;
  94333. /**
  94334. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  94335. * @param frustumPlanes defines the frustum planes
  94336. * @returns true if the submesh is inside the frustum
  94337. */
  94338. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  94339. /**
  94340. * Renders the submesh
  94341. * @param enableAlphaMode defines if alpha needs to be used
  94342. * @returns the submesh
  94343. */
  94344. render(enableAlphaMode: boolean): SubMesh;
  94345. /**
  94346. * @hidden
  94347. */
  94348. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  94349. /**
  94350. * Checks if the submesh intersects with a ray
  94351. * @param ray defines the ray to test
  94352. * @returns true is the passed ray intersects the submesh bounding box
  94353. */
  94354. canIntersects(ray: Ray): boolean;
  94355. /**
  94356. * Intersects current submesh with a ray
  94357. * @param ray defines the ray to test
  94358. * @param positions defines mesh's positions array
  94359. * @param indices defines mesh's indices array
  94360. * @param fastCheck defines if only bounding info should be used
  94361. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  94362. * @returns intersection info or null if no intersection
  94363. */
  94364. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  94365. /** @hidden */
  94366. private _intersectLines;
  94367. /** @hidden */
  94368. private _intersectUnIndexedLines;
  94369. /** @hidden */
  94370. private _intersectTriangles;
  94371. /** @hidden */
  94372. private _intersectUnIndexedTriangles;
  94373. /** @hidden */
  94374. _rebuild(): void;
  94375. /**
  94376. * Creates a new submesh from the passed mesh
  94377. * @param newMesh defines the new hosting mesh
  94378. * @param newRenderingMesh defines an optional rendering mesh
  94379. * @returns the new submesh
  94380. */
  94381. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  94382. /**
  94383. * Release associated resources
  94384. */
  94385. dispose(): void;
  94386. /**
  94387. * Gets the class name
  94388. * @returns the string "SubMesh".
  94389. */
  94390. getClassName(): string;
  94391. /**
  94392. * Creates a new submesh from indices data
  94393. * @param materialIndex the index of the main mesh material
  94394. * @param startIndex the index where to start the copy in the mesh indices array
  94395. * @param indexCount the number of indices to copy then from the startIndex
  94396. * @param mesh the main mesh to create the submesh from
  94397. * @param renderingMesh the optional rendering mesh
  94398. * @returns a new submesh
  94399. */
  94400. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  94401. }
  94402. }
  94403. declare module BABYLON {
  94404. /**
  94405. * Class used to represent data loading progression
  94406. */
  94407. export class SceneLoaderFlags {
  94408. private static _ForceFullSceneLoadingForIncremental;
  94409. private static _ShowLoadingScreen;
  94410. private static _CleanBoneMatrixWeights;
  94411. private static _loggingLevel;
  94412. /**
  94413. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  94414. */
  94415. static get ForceFullSceneLoadingForIncremental(): boolean;
  94416. static set ForceFullSceneLoadingForIncremental(value: boolean);
  94417. /**
  94418. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  94419. */
  94420. static get ShowLoadingScreen(): boolean;
  94421. static set ShowLoadingScreen(value: boolean);
  94422. /**
  94423. * Defines the current logging level (while loading the scene)
  94424. * @ignorenaming
  94425. */
  94426. static get loggingLevel(): number;
  94427. static set loggingLevel(value: number);
  94428. /**
  94429. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  94430. */
  94431. static get CleanBoneMatrixWeights(): boolean;
  94432. static set CleanBoneMatrixWeights(value: boolean);
  94433. }
  94434. }
  94435. declare module BABYLON {
  94436. /**
  94437. * Class used to store geometry data (vertex buffers + index buffer)
  94438. */
  94439. export class Geometry implements IGetSetVerticesData {
  94440. /**
  94441. * Gets or sets the ID of the geometry
  94442. */
  94443. id: string;
  94444. /**
  94445. * Gets or sets the unique ID of the geometry
  94446. */
  94447. uniqueId: number;
  94448. /**
  94449. * Gets the delay loading state of the geometry (none by default which means not delayed)
  94450. */
  94451. delayLoadState: number;
  94452. /**
  94453. * Gets the file containing the data to load when running in delay load state
  94454. */
  94455. delayLoadingFile: Nullable<string>;
  94456. /**
  94457. * Callback called when the geometry is updated
  94458. */
  94459. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  94460. private _scene;
  94461. private _engine;
  94462. private _meshes;
  94463. private _totalVertices;
  94464. /** @hidden */
  94465. _indices: IndicesArray;
  94466. /** @hidden */
  94467. _vertexBuffers: {
  94468. [key: string]: VertexBuffer;
  94469. };
  94470. private _isDisposed;
  94471. private _extend;
  94472. private _boundingBias;
  94473. /** @hidden */
  94474. _delayInfo: Array<string>;
  94475. private _indexBuffer;
  94476. private _indexBufferIsUpdatable;
  94477. /** @hidden */
  94478. _boundingInfo: Nullable<BoundingInfo>;
  94479. /** @hidden */
  94480. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  94481. /** @hidden */
  94482. _softwareSkinningFrameId: number;
  94483. private _vertexArrayObjects;
  94484. private _updatable;
  94485. /** @hidden */
  94486. _positions: Nullable<Vector3[]>;
  94487. /**
  94488. * 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
  94489. */
  94490. get boundingBias(): Vector2;
  94491. /**
  94492. * 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
  94493. */
  94494. set boundingBias(value: Vector2);
  94495. /**
  94496. * Static function used to attach a new empty geometry to a mesh
  94497. * @param mesh defines the mesh to attach the geometry to
  94498. * @returns the new Geometry
  94499. */
  94500. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  94501. /**
  94502. * Creates a new geometry
  94503. * @param id defines the unique ID
  94504. * @param scene defines the hosting scene
  94505. * @param vertexData defines the VertexData used to get geometry data
  94506. * @param updatable defines if geometry must be updatable (false by default)
  94507. * @param mesh defines the mesh that will be associated with the geometry
  94508. */
  94509. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  94510. /**
  94511. * Gets the current extend of the geometry
  94512. */
  94513. get extend(): {
  94514. minimum: Vector3;
  94515. maximum: Vector3;
  94516. };
  94517. /**
  94518. * Gets the hosting scene
  94519. * @returns the hosting Scene
  94520. */
  94521. getScene(): Scene;
  94522. /**
  94523. * Gets the hosting engine
  94524. * @returns the hosting Engine
  94525. */
  94526. getEngine(): Engine;
  94527. /**
  94528. * Defines if the geometry is ready to use
  94529. * @returns true if the geometry is ready to be used
  94530. */
  94531. isReady(): boolean;
  94532. /**
  94533. * Gets a value indicating that the geometry should not be serialized
  94534. */
  94535. get doNotSerialize(): boolean;
  94536. /** @hidden */
  94537. _rebuild(): void;
  94538. /**
  94539. * Affects all geometry data in one call
  94540. * @param vertexData defines the geometry data
  94541. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  94542. */
  94543. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  94544. /**
  94545. * Set specific vertex data
  94546. * @param kind defines the data kind (Position, normal, etc...)
  94547. * @param data defines the vertex data to use
  94548. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  94549. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  94550. */
  94551. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  94552. /**
  94553. * Removes a specific vertex data
  94554. * @param kind defines the data kind (Position, normal, etc...)
  94555. */
  94556. removeVerticesData(kind: string): void;
  94557. /**
  94558. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  94559. * @param buffer defines the vertex buffer to use
  94560. * @param totalVertices defines the total number of vertices for position kind (could be null)
  94561. */
  94562. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  94563. /**
  94564. * Update a specific vertex buffer
  94565. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  94566. * It will do nothing if the buffer is not updatable
  94567. * @param kind defines the data kind (Position, normal, etc...)
  94568. * @param data defines the data to use
  94569. * @param offset defines the offset in the target buffer where to store the data
  94570. * @param useBytes set to true if the offset is in bytes
  94571. */
  94572. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  94573. /**
  94574. * Update a specific vertex buffer
  94575. * This function will create a new buffer if the current one is not updatable
  94576. * @param kind defines the data kind (Position, normal, etc...)
  94577. * @param data defines the data to use
  94578. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  94579. */
  94580. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  94581. private _updateBoundingInfo;
  94582. /** @hidden */
  94583. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  94584. /**
  94585. * Gets total number of vertices
  94586. * @returns the total number of vertices
  94587. */
  94588. getTotalVertices(): number;
  94589. /**
  94590. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  94591. * @param kind defines the data kind (Position, normal, etc...)
  94592. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  94593. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  94594. * @returns a float array containing vertex data
  94595. */
  94596. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  94597. /**
  94598. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  94599. * @param kind defines the data kind (Position, normal, etc...)
  94600. * @returns true if the vertex buffer with the specified kind is updatable
  94601. */
  94602. isVertexBufferUpdatable(kind: string): boolean;
  94603. /**
  94604. * Gets a specific vertex buffer
  94605. * @param kind defines the data kind (Position, normal, etc...)
  94606. * @returns a VertexBuffer
  94607. */
  94608. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  94609. /**
  94610. * Returns all vertex buffers
  94611. * @return an object holding all vertex buffers indexed by kind
  94612. */
  94613. getVertexBuffers(): Nullable<{
  94614. [key: string]: VertexBuffer;
  94615. }>;
  94616. /**
  94617. * Gets a boolean indicating if specific vertex buffer is present
  94618. * @param kind defines the data kind (Position, normal, etc...)
  94619. * @returns true if data is present
  94620. */
  94621. isVerticesDataPresent(kind: string): boolean;
  94622. /**
  94623. * Gets a list of all attached data kinds (Position, normal, etc...)
  94624. * @returns a list of string containing all kinds
  94625. */
  94626. getVerticesDataKinds(): string[];
  94627. /**
  94628. * Update index buffer
  94629. * @param indices defines the indices to store in the index buffer
  94630. * @param offset defines the offset in the target buffer where to store the data
  94631. * @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)
  94632. */
  94633. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  94634. /**
  94635. * Creates a new index buffer
  94636. * @param indices defines the indices to store in the index buffer
  94637. * @param totalVertices defines the total number of vertices (could be null)
  94638. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  94639. */
  94640. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  94641. /**
  94642. * Return the total number of indices
  94643. * @returns the total number of indices
  94644. */
  94645. getTotalIndices(): number;
  94646. /**
  94647. * Gets the index buffer array
  94648. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  94649. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  94650. * @returns the index buffer array
  94651. */
  94652. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  94653. /**
  94654. * Gets the index buffer
  94655. * @return the index buffer
  94656. */
  94657. getIndexBuffer(): Nullable<DataBuffer>;
  94658. /** @hidden */
  94659. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  94660. /**
  94661. * Release the associated resources for a specific mesh
  94662. * @param mesh defines the source mesh
  94663. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  94664. */
  94665. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  94666. /**
  94667. * Apply current geometry to a given mesh
  94668. * @param mesh defines the mesh to apply geometry to
  94669. */
  94670. applyToMesh(mesh: Mesh): void;
  94671. private _updateExtend;
  94672. private _applyToMesh;
  94673. private notifyUpdate;
  94674. /**
  94675. * Load the geometry if it was flagged as delay loaded
  94676. * @param scene defines the hosting scene
  94677. * @param onLoaded defines a callback called when the geometry is loaded
  94678. */
  94679. load(scene: Scene, onLoaded?: () => void): void;
  94680. private _queueLoad;
  94681. /**
  94682. * Invert the geometry to move from a right handed system to a left handed one.
  94683. */
  94684. toLeftHanded(): void;
  94685. /** @hidden */
  94686. _resetPointsArrayCache(): void;
  94687. /** @hidden */
  94688. _generatePointsArray(): boolean;
  94689. /**
  94690. * Gets a value indicating if the geometry is disposed
  94691. * @returns true if the geometry was disposed
  94692. */
  94693. isDisposed(): boolean;
  94694. private _disposeVertexArrayObjects;
  94695. /**
  94696. * Free all associated resources
  94697. */
  94698. dispose(): void;
  94699. /**
  94700. * Clone the current geometry into a new geometry
  94701. * @param id defines the unique ID of the new geometry
  94702. * @returns a new geometry object
  94703. */
  94704. copy(id: string): Geometry;
  94705. /**
  94706. * Serialize the current geometry info (and not the vertices data) into a JSON object
  94707. * @return a JSON representation of the current geometry data (without the vertices data)
  94708. */
  94709. serialize(): any;
  94710. private toNumberArray;
  94711. /**
  94712. * Serialize all vertices data into a JSON oject
  94713. * @returns a JSON representation of the current geometry data
  94714. */
  94715. serializeVerticeData(): any;
  94716. /**
  94717. * Extracts a clone of a mesh geometry
  94718. * @param mesh defines the source mesh
  94719. * @param id defines the unique ID of the new geometry object
  94720. * @returns the new geometry object
  94721. */
  94722. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  94723. /**
  94724. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  94725. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94726. * Be aware Math.random() could cause collisions, but:
  94727. * "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"
  94728. * @returns a string containing a new GUID
  94729. */
  94730. static RandomId(): string;
  94731. /** @hidden */
  94732. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  94733. private static _CleanMatricesWeights;
  94734. /**
  94735. * Create a new geometry from persisted data (Using .babylon file format)
  94736. * @param parsedVertexData defines the persisted data
  94737. * @param scene defines the hosting scene
  94738. * @param rootUrl defines the root url to use to load assets (like delayed data)
  94739. * @returns the new geometry object
  94740. */
  94741. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  94742. }
  94743. }
  94744. declare module BABYLON {
  94745. /**
  94746. * Define an interface for all classes that will get and set the data on vertices
  94747. */
  94748. export interface IGetSetVerticesData {
  94749. /**
  94750. * Gets a boolean indicating if specific vertex data is present
  94751. * @param kind defines the vertex data kind to use
  94752. * @returns true is data kind is present
  94753. */
  94754. isVerticesDataPresent(kind: string): boolean;
  94755. /**
  94756. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  94757. * @param kind defines the data kind (Position, normal, etc...)
  94758. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  94759. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  94760. * @returns a float array containing vertex data
  94761. */
  94762. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  94763. /**
  94764. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  94765. * @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.
  94766. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  94767. * @returns the indices array or an empty array if the mesh has no geometry
  94768. */
  94769. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  94770. /**
  94771. * Set specific vertex data
  94772. * @param kind defines the data kind (Position, normal, etc...)
  94773. * @param data defines the vertex data to use
  94774. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  94775. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  94776. */
  94777. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  94778. /**
  94779. * Update a specific associated vertex buffer
  94780. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  94781. * - VertexBuffer.PositionKind
  94782. * - VertexBuffer.UVKind
  94783. * - VertexBuffer.UV2Kind
  94784. * - VertexBuffer.UV3Kind
  94785. * - VertexBuffer.UV4Kind
  94786. * - VertexBuffer.UV5Kind
  94787. * - VertexBuffer.UV6Kind
  94788. * - VertexBuffer.ColorKind
  94789. * - VertexBuffer.MatricesIndicesKind
  94790. * - VertexBuffer.MatricesIndicesExtraKind
  94791. * - VertexBuffer.MatricesWeightsKind
  94792. * - VertexBuffer.MatricesWeightsExtraKind
  94793. * @param data defines the data source
  94794. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  94795. * @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)
  94796. */
  94797. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  94798. /**
  94799. * Creates a new index buffer
  94800. * @param indices defines the indices to store in the index buffer
  94801. * @param totalVertices defines the total number of vertices (could be null)
  94802. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  94803. */
  94804. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  94805. }
  94806. /**
  94807. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  94808. */
  94809. export class VertexData {
  94810. /**
  94811. * Mesh side orientation : usually the external or front surface
  94812. */
  94813. static readonly FRONTSIDE: number;
  94814. /**
  94815. * Mesh side orientation : usually the internal or back surface
  94816. */
  94817. static readonly BACKSIDE: number;
  94818. /**
  94819. * Mesh side orientation : both internal and external or front and back surfaces
  94820. */
  94821. static readonly DOUBLESIDE: number;
  94822. /**
  94823. * Mesh side orientation : by default, `FRONTSIDE`
  94824. */
  94825. static readonly DEFAULTSIDE: number;
  94826. /**
  94827. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  94828. */
  94829. positions: Nullable<FloatArray>;
  94830. /**
  94831. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  94832. */
  94833. normals: Nullable<FloatArray>;
  94834. /**
  94835. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  94836. */
  94837. tangents: Nullable<FloatArray>;
  94838. /**
  94839. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  94840. */
  94841. uvs: Nullable<FloatArray>;
  94842. /**
  94843. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  94844. */
  94845. uvs2: Nullable<FloatArray>;
  94846. /**
  94847. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  94848. */
  94849. uvs3: Nullable<FloatArray>;
  94850. /**
  94851. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  94852. */
  94853. uvs4: Nullable<FloatArray>;
  94854. /**
  94855. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  94856. */
  94857. uvs5: Nullable<FloatArray>;
  94858. /**
  94859. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  94860. */
  94861. uvs6: Nullable<FloatArray>;
  94862. /**
  94863. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  94864. */
  94865. colors: Nullable<FloatArray>;
  94866. /**
  94867. * 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).
  94868. */
  94869. matricesIndices: Nullable<FloatArray>;
  94870. /**
  94871. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  94872. */
  94873. matricesWeights: Nullable<FloatArray>;
  94874. /**
  94875. * An array extending the number of possible indices
  94876. */
  94877. matricesIndicesExtra: Nullable<FloatArray>;
  94878. /**
  94879. * An array extending the number of possible weights when the number of indices is extended
  94880. */
  94881. matricesWeightsExtra: Nullable<FloatArray>;
  94882. /**
  94883. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  94884. */
  94885. indices: Nullable<IndicesArray>;
  94886. /**
  94887. * Uses the passed data array to set the set the values for the specified kind of data
  94888. * @param data a linear array of floating numbers
  94889. * @param kind the type of data that is being set, eg positions, colors etc
  94890. */
  94891. set(data: FloatArray, kind: string): void;
  94892. /**
  94893. * Associates the vertexData to the passed Mesh.
  94894. * Sets it as updatable or not (default `false`)
  94895. * @param mesh the mesh the vertexData is applied to
  94896. * @param updatable when used and having the value true allows new data to update the vertexData
  94897. * @returns the VertexData
  94898. */
  94899. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  94900. /**
  94901. * Associates the vertexData to the passed Geometry.
  94902. * Sets it as updatable or not (default `false`)
  94903. * @param geometry the geometry the vertexData is applied to
  94904. * @param updatable when used and having the value true allows new data to update the vertexData
  94905. * @returns VertexData
  94906. */
  94907. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  94908. /**
  94909. * Updates the associated mesh
  94910. * @param mesh the mesh to be updated
  94911. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  94912. * @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
  94913. * @returns VertexData
  94914. */
  94915. updateMesh(mesh: Mesh): VertexData;
  94916. /**
  94917. * Updates the associated geometry
  94918. * @param geometry the geometry to be updated
  94919. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  94920. * @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
  94921. * @returns VertexData.
  94922. */
  94923. updateGeometry(geometry: Geometry): VertexData;
  94924. private _applyTo;
  94925. private _update;
  94926. /**
  94927. * Transforms each position and each normal of the vertexData according to the passed Matrix
  94928. * @param matrix the transforming matrix
  94929. * @returns the VertexData
  94930. */
  94931. transform(matrix: Matrix): VertexData;
  94932. /**
  94933. * Merges the passed VertexData into the current one
  94934. * @param other the VertexData to be merged into the current one
  94935. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  94936. * @returns the modified VertexData
  94937. */
  94938. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  94939. private _mergeElement;
  94940. private _validate;
  94941. /**
  94942. * Serializes the VertexData
  94943. * @returns a serialized object
  94944. */
  94945. serialize(): any;
  94946. /**
  94947. * Extracts the vertexData from a mesh
  94948. * @param mesh the mesh from which to extract the VertexData
  94949. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  94950. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  94951. * @returns the object VertexData associated to the passed mesh
  94952. */
  94953. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  94954. /**
  94955. * Extracts the vertexData from the geometry
  94956. * @param geometry the geometry from which to extract the VertexData
  94957. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  94958. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  94959. * @returns the object VertexData associated to the passed mesh
  94960. */
  94961. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  94962. private static _ExtractFrom;
  94963. /**
  94964. * Creates the VertexData for a Ribbon
  94965. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  94966. * * pathArray array of paths, each of which an array of successive Vector3
  94967. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  94968. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  94969. * * 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
  94970. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94971. * * 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)
  94972. * * 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)
  94973. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  94974. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  94975. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  94976. * @returns the VertexData of the ribbon
  94977. */
  94978. static CreateRibbon(options: {
  94979. pathArray: Vector3[][];
  94980. closeArray?: boolean;
  94981. closePath?: boolean;
  94982. offset?: number;
  94983. sideOrientation?: number;
  94984. frontUVs?: Vector4;
  94985. backUVs?: Vector4;
  94986. invertUV?: boolean;
  94987. uvs?: Vector2[];
  94988. colors?: Color4[];
  94989. }): VertexData;
  94990. /**
  94991. * Creates the VertexData for a box
  94992. * @param options an object used to set the following optional parameters for the box, required but can be empty
  94993. * * size sets the width, height and depth of the box to the value of size, optional default 1
  94994. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  94995. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  94996. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  94997. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  94998. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  94999. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95000. * * 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)
  95001. * * 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)
  95002. * @returns the VertexData of the box
  95003. */
  95004. static CreateBox(options: {
  95005. size?: number;
  95006. width?: number;
  95007. height?: number;
  95008. depth?: number;
  95009. faceUV?: Vector4[];
  95010. faceColors?: Color4[];
  95011. sideOrientation?: number;
  95012. frontUVs?: Vector4;
  95013. backUVs?: Vector4;
  95014. }): VertexData;
  95015. /**
  95016. * Creates the VertexData for a tiled box
  95017. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95018. * * faceTiles sets the pattern, tile size and number of tiles for a face
  95019. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95020. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95021. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95022. * @returns the VertexData of the box
  95023. */
  95024. static CreateTiledBox(options: {
  95025. pattern?: number;
  95026. width?: number;
  95027. height?: number;
  95028. depth?: number;
  95029. tileSize?: number;
  95030. tileWidth?: number;
  95031. tileHeight?: number;
  95032. alignHorizontal?: number;
  95033. alignVertical?: number;
  95034. faceUV?: Vector4[];
  95035. faceColors?: Color4[];
  95036. sideOrientation?: number;
  95037. }): VertexData;
  95038. /**
  95039. * Creates the VertexData for a tiled plane
  95040. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95041. * * pattern a limited pattern arrangement depending on the number
  95042. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  95043. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  95044. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  95045. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95046. * * 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)
  95047. * * 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)
  95048. * @returns the VertexData of the tiled plane
  95049. */
  95050. static CreateTiledPlane(options: {
  95051. pattern?: number;
  95052. tileSize?: number;
  95053. tileWidth?: number;
  95054. tileHeight?: number;
  95055. size?: number;
  95056. width?: number;
  95057. height?: number;
  95058. alignHorizontal?: number;
  95059. alignVertical?: number;
  95060. sideOrientation?: number;
  95061. frontUVs?: Vector4;
  95062. backUVs?: Vector4;
  95063. }): VertexData;
  95064. /**
  95065. * Creates the VertexData for an ellipsoid, defaults to a sphere
  95066. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95067. * * segments sets the number of horizontal strips optional, default 32
  95068. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  95069. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  95070. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  95071. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  95072. * * 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
  95073. * * 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
  95074. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95075. * * 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)
  95076. * * 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)
  95077. * @returns the VertexData of the ellipsoid
  95078. */
  95079. static CreateSphere(options: {
  95080. segments?: number;
  95081. diameter?: number;
  95082. diameterX?: number;
  95083. diameterY?: number;
  95084. diameterZ?: number;
  95085. arc?: number;
  95086. slice?: number;
  95087. sideOrientation?: number;
  95088. frontUVs?: Vector4;
  95089. backUVs?: Vector4;
  95090. }): VertexData;
  95091. /**
  95092. * Creates the VertexData for a cylinder, cone or prism
  95093. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95094. * * height sets the height (y direction) of the cylinder, optional, default 2
  95095. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  95096. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  95097. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  95098. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95099. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  95100. * * 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
  95101. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95102. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95103. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  95104. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  95105. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95106. * * 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)
  95107. * * 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)
  95108. * @returns the VertexData of the cylinder, cone or prism
  95109. */
  95110. static CreateCylinder(options: {
  95111. height?: number;
  95112. diameterTop?: number;
  95113. diameterBottom?: number;
  95114. diameter?: number;
  95115. tessellation?: number;
  95116. subdivisions?: number;
  95117. arc?: number;
  95118. faceColors?: Color4[];
  95119. faceUV?: Vector4[];
  95120. hasRings?: boolean;
  95121. enclose?: boolean;
  95122. sideOrientation?: number;
  95123. frontUVs?: Vector4;
  95124. backUVs?: Vector4;
  95125. }): VertexData;
  95126. /**
  95127. * Creates the VertexData for a torus
  95128. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95129. * * diameter the diameter of the torus, optional default 1
  95130. * * thickness the diameter of the tube forming the torus, optional default 0.5
  95131. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95132. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95133. * * 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)
  95134. * * 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)
  95135. * @returns the VertexData of the torus
  95136. */
  95137. static CreateTorus(options: {
  95138. diameter?: number;
  95139. thickness?: number;
  95140. tessellation?: number;
  95141. sideOrientation?: number;
  95142. frontUVs?: Vector4;
  95143. backUVs?: Vector4;
  95144. }): VertexData;
  95145. /**
  95146. * Creates the VertexData of the LineSystem
  95147. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  95148. * - lines an array of lines, each line being an array of successive Vector3
  95149. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  95150. * @returns the VertexData of the LineSystem
  95151. */
  95152. static CreateLineSystem(options: {
  95153. lines: Vector3[][];
  95154. colors?: Nullable<Color4[][]>;
  95155. }): VertexData;
  95156. /**
  95157. * Create the VertexData for a DashedLines
  95158. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  95159. * - points an array successive Vector3
  95160. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  95161. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  95162. * - dashNb the intended total number of dashes, optional, default 200
  95163. * @returns the VertexData for the DashedLines
  95164. */
  95165. static CreateDashedLines(options: {
  95166. points: Vector3[];
  95167. dashSize?: number;
  95168. gapSize?: number;
  95169. dashNb?: number;
  95170. }): VertexData;
  95171. /**
  95172. * Creates the VertexData for a Ground
  95173. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95174. * - width the width (x direction) of the ground, optional, default 1
  95175. * - height the height (z direction) of the ground, optional, default 1
  95176. * - subdivisions the number of subdivisions per side, optional, default 1
  95177. * @returns the VertexData of the Ground
  95178. */
  95179. static CreateGround(options: {
  95180. width?: number;
  95181. height?: number;
  95182. subdivisions?: number;
  95183. subdivisionsX?: number;
  95184. subdivisionsY?: number;
  95185. }): VertexData;
  95186. /**
  95187. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  95188. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95189. * * xmin the ground minimum X coordinate, optional, default -1
  95190. * * zmin the ground minimum Z coordinate, optional, default -1
  95191. * * xmax the ground maximum X coordinate, optional, default 1
  95192. * * zmax the ground maximum Z coordinate, optional, default 1
  95193. * * 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}
  95194. * * 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}
  95195. * @returns the VertexData of the TiledGround
  95196. */
  95197. static CreateTiledGround(options: {
  95198. xmin: number;
  95199. zmin: number;
  95200. xmax: number;
  95201. zmax: number;
  95202. subdivisions?: {
  95203. w: number;
  95204. h: number;
  95205. };
  95206. precision?: {
  95207. w: number;
  95208. h: number;
  95209. };
  95210. }): VertexData;
  95211. /**
  95212. * Creates the VertexData of the Ground designed from a heightmap
  95213. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  95214. * * width the width (x direction) of the ground
  95215. * * height the height (z direction) of the ground
  95216. * * subdivisions the number of subdivisions per side
  95217. * * minHeight the minimum altitude on the ground, optional, default 0
  95218. * * maxHeight the maximum altitude on the ground, optional default 1
  95219. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  95220. * * buffer the array holding the image color data
  95221. * * bufferWidth the width of image
  95222. * * bufferHeight the height of image
  95223. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  95224. * @returns the VertexData of the Ground designed from a heightmap
  95225. */
  95226. static CreateGroundFromHeightMap(options: {
  95227. width: number;
  95228. height: number;
  95229. subdivisions: number;
  95230. minHeight: number;
  95231. maxHeight: number;
  95232. colorFilter: Color3;
  95233. buffer: Uint8Array;
  95234. bufferWidth: number;
  95235. bufferHeight: number;
  95236. alphaFilter: number;
  95237. }): VertexData;
  95238. /**
  95239. * Creates the VertexData for a Plane
  95240. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  95241. * * size sets the width and height of the plane to the value of size, optional default 1
  95242. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  95243. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  95244. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95245. * * 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)
  95246. * * 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)
  95247. * @returns the VertexData of the box
  95248. */
  95249. static CreatePlane(options: {
  95250. size?: number;
  95251. width?: number;
  95252. height?: number;
  95253. sideOrientation?: number;
  95254. frontUVs?: Vector4;
  95255. backUVs?: Vector4;
  95256. }): VertexData;
  95257. /**
  95258. * Creates the VertexData of the Disc or regular Polygon
  95259. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  95260. * * radius the radius of the disc, optional default 0.5
  95261. * * tessellation the number of polygon sides, optional, default 64
  95262. * * 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
  95263. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95264. * * 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)
  95265. * * 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)
  95266. * @returns the VertexData of the box
  95267. */
  95268. static CreateDisc(options: {
  95269. radius?: number;
  95270. tessellation?: number;
  95271. arc?: number;
  95272. sideOrientation?: number;
  95273. frontUVs?: Vector4;
  95274. backUVs?: Vector4;
  95275. }): VertexData;
  95276. /**
  95277. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  95278. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  95279. * @param polygon a mesh built from polygonTriangulation.build()
  95280. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95281. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95282. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95283. * @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)
  95284. * @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)
  95285. * @returns the VertexData of the Polygon
  95286. */
  95287. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  95288. /**
  95289. * Creates the VertexData of the IcoSphere
  95290. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  95291. * * radius the radius of the IcoSphere, optional default 1
  95292. * * radiusX allows stretching in the x direction, optional, default radius
  95293. * * radiusY allows stretching in the y direction, optional, default radius
  95294. * * radiusZ allows stretching in the z direction, optional, default radius
  95295. * * flat when true creates a flat shaded mesh, optional, default true
  95296. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95297. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95298. * * 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)
  95299. * * 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)
  95300. * @returns the VertexData of the IcoSphere
  95301. */
  95302. static CreateIcoSphere(options: {
  95303. radius?: number;
  95304. radiusX?: number;
  95305. radiusY?: number;
  95306. radiusZ?: number;
  95307. flat?: boolean;
  95308. subdivisions?: number;
  95309. sideOrientation?: number;
  95310. frontUVs?: Vector4;
  95311. backUVs?: Vector4;
  95312. }): VertexData;
  95313. /**
  95314. * Creates the VertexData for a Polyhedron
  95315. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  95316. * * type provided types are:
  95317. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  95318. * * 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)
  95319. * * size the size of the IcoSphere, optional default 1
  95320. * * sizeX allows stretching in the x direction, optional, default size
  95321. * * sizeY allows stretching in the y direction, optional, default size
  95322. * * sizeZ allows stretching in the z direction, optional, default size
  95323. * * 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
  95324. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95325. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95326. * * flat when true creates a flat shaded mesh, optional, default true
  95327. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95328. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95329. * * 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)
  95330. * * 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)
  95331. * @returns the VertexData of the Polyhedron
  95332. */
  95333. static CreatePolyhedron(options: {
  95334. type?: number;
  95335. size?: number;
  95336. sizeX?: number;
  95337. sizeY?: number;
  95338. sizeZ?: number;
  95339. custom?: any;
  95340. faceUV?: Vector4[];
  95341. faceColors?: Color4[];
  95342. flat?: boolean;
  95343. sideOrientation?: number;
  95344. frontUVs?: Vector4;
  95345. backUVs?: Vector4;
  95346. }): VertexData;
  95347. /**
  95348. * Creates the VertexData for a TorusKnot
  95349. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  95350. * * radius the radius of the torus knot, optional, default 2
  95351. * * tube the thickness of the tube, optional, default 0.5
  95352. * * radialSegments the number of sides on each tube segments, optional, default 32
  95353. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  95354. * * p the number of windings around the z axis, optional, default 2
  95355. * * q the number of windings around the x axis, optional, default 3
  95356. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95357. * * 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)
  95358. * * 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)
  95359. * @returns the VertexData of the Torus Knot
  95360. */
  95361. static CreateTorusKnot(options: {
  95362. radius?: number;
  95363. tube?: number;
  95364. radialSegments?: number;
  95365. tubularSegments?: number;
  95366. p?: number;
  95367. q?: number;
  95368. sideOrientation?: number;
  95369. frontUVs?: Vector4;
  95370. backUVs?: Vector4;
  95371. }): VertexData;
  95372. /**
  95373. * Compute normals for given positions and indices
  95374. * @param positions an array of vertex positions, [...., x, y, z, ......]
  95375. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  95376. * @param normals an array of vertex normals, [...., x, y, z, ......]
  95377. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  95378. * * facetNormals : optional array of facet normals (vector3)
  95379. * * facetPositions : optional array of facet positions (vector3)
  95380. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  95381. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  95382. * * bInfo : optional bounding info, required for facetPartitioning computation
  95383. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  95384. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  95385. * * useRightHandedSystem: optional boolean to for right handed system computation
  95386. * * depthSort : optional boolean to enable the facet depth sort computation
  95387. * * distanceTo : optional Vector3 to compute the facet depth from this location
  95388. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  95389. */
  95390. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  95391. facetNormals?: any;
  95392. facetPositions?: any;
  95393. facetPartitioning?: any;
  95394. ratio?: number;
  95395. bInfo?: any;
  95396. bbSize?: Vector3;
  95397. subDiv?: any;
  95398. useRightHandedSystem?: boolean;
  95399. depthSort?: boolean;
  95400. distanceTo?: Vector3;
  95401. depthSortedFacets?: any;
  95402. }): void;
  95403. /** @hidden */
  95404. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  95405. /**
  95406. * Applies VertexData created from the imported parameters to the geometry
  95407. * @param parsedVertexData the parsed data from an imported file
  95408. * @param geometry the geometry to apply the VertexData to
  95409. */
  95410. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  95411. }
  95412. }
  95413. declare module BABYLON {
  95414. /**
  95415. * Defines a target to use with MorphTargetManager
  95416. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  95417. */
  95418. export class MorphTarget implements IAnimatable {
  95419. /** defines the name of the target */
  95420. name: string;
  95421. /**
  95422. * Gets or sets the list of animations
  95423. */
  95424. animations: Animation[];
  95425. private _scene;
  95426. private _positions;
  95427. private _normals;
  95428. private _tangents;
  95429. private _uvs;
  95430. private _influence;
  95431. private _uniqueId;
  95432. /**
  95433. * Observable raised when the influence changes
  95434. */
  95435. onInfluenceChanged: Observable<boolean>;
  95436. /** @hidden */
  95437. _onDataLayoutChanged: Observable<void>;
  95438. /**
  95439. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  95440. */
  95441. get influence(): number;
  95442. set influence(influence: number);
  95443. /**
  95444. * Gets or sets the id of the morph Target
  95445. */
  95446. id: string;
  95447. private _animationPropertiesOverride;
  95448. /**
  95449. * Gets or sets the animation properties override
  95450. */
  95451. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95452. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  95453. /**
  95454. * Creates a new MorphTarget
  95455. * @param name defines the name of the target
  95456. * @param influence defines the influence to use
  95457. * @param scene defines the scene the morphtarget belongs to
  95458. */
  95459. constructor(
  95460. /** defines the name of the target */
  95461. name: string, influence?: number, scene?: Nullable<Scene>);
  95462. /**
  95463. * Gets the unique ID of this manager
  95464. */
  95465. get uniqueId(): number;
  95466. /**
  95467. * Gets a boolean defining if the target contains position data
  95468. */
  95469. get hasPositions(): boolean;
  95470. /**
  95471. * Gets a boolean defining if the target contains normal data
  95472. */
  95473. get hasNormals(): boolean;
  95474. /**
  95475. * Gets a boolean defining if the target contains tangent data
  95476. */
  95477. get hasTangents(): boolean;
  95478. /**
  95479. * Gets a boolean defining if the target contains texture coordinates data
  95480. */
  95481. get hasUVs(): boolean;
  95482. /**
  95483. * Affects position data to this target
  95484. * @param data defines the position data to use
  95485. */
  95486. setPositions(data: Nullable<FloatArray>): void;
  95487. /**
  95488. * Gets the position data stored in this target
  95489. * @returns a FloatArray containing the position data (or null if not present)
  95490. */
  95491. getPositions(): Nullable<FloatArray>;
  95492. /**
  95493. * Affects normal data to this target
  95494. * @param data defines the normal data to use
  95495. */
  95496. setNormals(data: Nullable<FloatArray>): void;
  95497. /**
  95498. * Gets the normal data stored in this target
  95499. * @returns a FloatArray containing the normal data (or null if not present)
  95500. */
  95501. getNormals(): Nullable<FloatArray>;
  95502. /**
  95503. * Affects tangent data to this target
  95504. * @param data defines the tangent data to use
  95505. */
  95506. setTangents(data: Nullable<FloatArray>): void;
  95507. /**
  95508. * Gets the tangent data stored in this target
  95509. * @returns a FloatArray containing the tangent data (or null if not present)
  95510. */
  95511. getTangents(): Nullable<FloatArray>;
  95512. /**
  95513. * Affects texture coordinates data to this target
  95514. * @param data defines the texture coordinates data to use
  95515. */
  95516. setUVs(data: Nullable<FloatArray>): void;
  95517. /**
  95518. * Gets the texture coordinates data stored in this target
  95519. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  95520. */
  95521. getUVs(): Nullable<FloatArray>;
  95522. /**
  95523. * Clone the current target
  95524. * @returns a new MorphTarget
  95525. */
  95526. clone(): MorphTarget;
  95527. /**
  95528. * Serializes the current target into a Serialization object
  95529. * @returns the serialized object
  95530. */
  95531. serialize(): any;
  95532. /**
  95533. * Returns the string "MorphTarget"
  95534. * @returns "MorphTarget"
  95535. */
  95536. getClassName(): string;
  95537. /**
  95538. * Creates a new target from serialized data
  95539. * @param serializationObject defines the serialized data to use
  95540. * @returns a new MorphTarget
  95541. */
  95542. static Parse(serializationObject: any): MorphTarget;
  95543. /**
  95544. * Creates a MorphTarget from mesh data
  95545. * @param mesh defines the source mesh
  95546. * @param name defines the name to use for the new target
  95547. * @param influence defines the influence to attach to the target
  95548. * @returns a new MorphTarget
  95549. */
  95550. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  95551. }
  95552. }
  95553. declare module BABYLON {
  95554. /**
  95555. * This class is used to deform meshes using morphing between different targets
  95556. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  95557. */
  95558. export class MorphTargetManager {
  95559. private _targets;
  95560. private _targetInfluenceChangedObservers;
  95561. private _targetDataLayoutChangedObservers;
  95562. private _activeTargets;
  95563. private _scene;
  95564. private _influences;
  95565. private _supportsNormals;
  95566. private _supportsTangents;
  95567. private _supportsUVs;
  95568. private _vertexCount;
  95569. private _uniqueId;
  95570. private _tempInfluences;
  95571. /**
  95572. * Gets or sets a boolean indicating if normals must be morphed
  95573. */
  95574. enableNormalMorphing: boolean;
  95575. /**
  95576. * Gets or sets a boolean indicating if tangents must be morphed
  95577. */
  95578. enableTangentMorphing: boolean;
  95579. /**
  95580. * Gets or sets a boolean indicating if UV must be morphed
  95581. */
  95582. enableUVMorphing: boolean;
  95583. /**
  95584. * Creates a new MorphTargetManager
  95585. * @param scene defines the current scene
  95586. */
  95587. constructor(scene?: Nullable<Scene>);
  95588. /**
  95589. * Gets the unique ID of this manager
  95590. */
  95591. get uniqueId(): number;
  95592. /**
  95593. * Gets the number of vertices handled by this manager
  95594. */
  95595. get vertexCount(): number;
  95596. /**
  95597. * Gets a boolean indicating if this manager supports morphing of normals
  95598. */
  95599. get supportsNormals(): boolean;
  95600. /**
  95601. * Gets a boolean indicating if this manager supports morphing of tangents
  95602. */
  95603. get supportsTangents(): boolean;
  95604. /**
  95605. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  95606. */
  95607. get supportsUVs(): boolean;
  95608. /**
  95609. * Gets the number of targets stored in this manager
  95610. */
  95611. get numTargets(): number;
  95612. /**
  95613. * Gets the number of influencers (ie. the number of targets with influences > 0)
  95614. */
  95615. get numInfluencers(): number;
  95616. /**
  95617. * Gets the list of influences (one per target)
  95618. */
  95619. get influences(): Float32Array;
  95620. /**
  95621. * Gets the active target at specified index. An active target is a target with an influence > 0
  95622. * @param index defines the index to check
  95623. * @returns the requested target
  95624. */
  95625. getActiveTarget(index: number): MorphTarget;
  95626. /**
  95627. * Gets the target at specified index
  95628. * @param index defines the index to check
  95629. * @returns the requested target
  95630. */
  95631. getTarget(index: number): MorphTarget;
  95632. /**
  95633. * Add a new target to this manager
  95634. * @param target defines the target to add
  95635. */
  95636. addTarget(target: MorphTarget): void;
  95637. /**
  95638. * Removes a target from the manager
  95639. * @param target defines the target to remove
  95640. */
  95641. removeTarget(target: MorphTarget): void;
  95642. /**
  95643. * Clone the current manager
  95644. * @returns a new MorphTargetManager
  95645. */
  95646. clone(): MorphTargetManager;
  95647. /**
  95648. * Serializes the current manager into a Serialization object
  95649. * @returns the serialized object
  95650. */
  95651. serialize(): any;
  95652. private _syncActiveTargets;
  95653. /**
  95654. * Syncrhonize the targets with all the meshes using this morph target manager
  95655. */
  95656. synchronize(): void;
  95657. /**
  95658. * Creates a new MorphTargetManager from serialized data
  95659. * @param serializationObject defines the serialized data
  95660. * @param scene defines the hosting scene
  95661. * @returns the new MorphTargetManager
  95662. */
  95663. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  95664. }
  95665. }
  95666. declare module BABYLON {
  95667. /**
  95668. * Class used to represent a specific level of detail of a mesh
  95669. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  95670. */
  95671. export class MeshLODLevel {
  95672. /** Defines the distance where this level should start being displayed */
  95673. distance: number;
  95674. /** Defines the mesh to use to render this level */
  95675. mesh: Nullable<Mesh>;
  95676. /**
  95677. * Creates a new LOD level
  95678. * @param distance defines the distance where this level should star being displayed
  95679. * @param mesh defines the mesh to use to render this level
  95680. */
  95681. constructor(
  95682. /** Defines the distance where this level should start being displayed */
  95683. distance: number,
  95684. /** Defines the mesh to use to render this level */
  95685. mesh: Nullable<Mesh>);
  95686. }
  95687. }
  95688. declare module BABYLON {
  95689. /**
  95690. * Mesh representing the gorund
  95691. */
  95692. export class GroundMesh extends Mesh {
  95693. /** If octree should be generated */
  95694. generateOctree: boolean;
  95695. private _heightQuads;
  95696. /** @hidden */
  95697. _subdivisionsX: number;
  95698. /** @hidden */
  95699. _subdivisionsY: number;
  95700. /** @hidden */
  95701. _width: number;
  95702. /** @hidden */
  95703. _height: number;
  95704. /** @hidden */
  95705. _minX: number;
  95706. /** @hidden */
  95707. _maxX: number;
  95708. /** @hidden */
  95709. _minZ: number;
  95710. /** @hidden */
  95711. _maxZ: number;
  95712. constructor(name: string, scene: Scene);
  95713. /**
  95714. * "GroundMesh"
  95715. * @returns "GroundMesh"
  95716. */
  95717. getClassName(): string;
  95718. /**
  95719. * The minimum of x and y subdivisions
  95720. */
  95721. get subdivisions(): number;
  95722. /**
  95723. * X subdivisions
  95724. */
  95725. get subdivisionsX(): number;
  95726. /**
  95727. * Y subdivisions
  95728. */
  95729. get subdivisionsY(): number;
  95730. /**
  95731. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  95732. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  95733. * @param chunksCount the number of subdivisions for x and y
  95734. * @param octreeBlocksSize (Default: 32)
  95735. */
  95736. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  95737. /**
  95738. * Returns a height (y) value in the Worl system :
  95739. * the ground altitude at the coordinates (x, z) expressed in the World system.
  95740. * @param x x coordinate
  95741. * @param z z coordinate
  95742. * @returns the ground y position if (x, z) are outside the ground surface.
  95743. */
  95744. getHeightAtCoordinates(x: number, z: number): number;
  95745. /**
  95746. * Returns a normalized vector (Vector3) orthogonal to the ground
  95747. * at the ground coordinates (x, z) expressed in the World system.
  95748. * @param x x coordinate
  95749. * @param z z coordinate
  95750. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  95751. */
  95752. getNormalAtCoordinates(x: number, z: number): Vector3;
  95753. /**
  95754. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  95755. * at the ground coordinates (x, z) expressed in the World system.
  95756. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  95757. * @param x x coordinate
  95758. * @param z z coordinate
  95759. * @param ref vector to store the result
  95760. * @returns the GroundMesh.
  95761. */
  95762. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  95763. /**
  95764. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  95765. * if the ground has been updated.
  95766. * This can be used in the render loop.
  95767. * @returns the GroundMesh.
  95768. */
  95769. updateCoordinateHeights(): GroundMesh;
  95770. private _getFacetAt;
  95771. private _initHeightQuads;
  95772. private _computeHeightQuads;
  95773. /**
  95774. * Serializes this ground mesh
  95775. * @param serializationObject object to write serialization to
  95776. */
  95777. serialize(serializationObject: any): void;
  95778. /**
  95779. * Parses a serialized ground mesh
  95780. * @param parsedMesh the serialized mesh
  95781. * @param scene the scene to create the ground mesh in
  95782. * @returns the created ground mesh
  95783. */
  95784. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  95785. }
  95786. }
  95787. declare module BABYLON {
  95788. /**
  95789. * Interface for Physics-Joint data
  95790. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95791. */
  95792. export interface PhysicsJointData {
  95793. /**
  95794. * The main pivot of the joint
  95795. */
  95796. mainPivot?: Vector3;
  95797. /**
  95798. * The connected pivot of the joint
  95799. */
  95800. connectedPivot?: Vector3;
  95801. /**
  95802. * The main axis of the joint
  95803. */
  95804. mainAxis?: Vector3;
  95805. /**
  95806. * The connected axis of the joint
  95807. */
  95808. connectedAxis?: Vector3;
  95809. /**
  95810. * The collision of the joint
  95811. */
  95812. collision?: boolean;
  95813. /**
  95814. * Native Oimo/Cannon/Energy data
  95815. */
  95816. nativeParams?: any;
  95817. }
  95818. /**
  95819. * This is a holder class for the physics joint created by the physics plugin
  95820. * It holds a set of functions to control the underlying joint
  95821. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95822. */
  95823. export class PhysicsJoint {
  95824. /**
  95825. * The type of the physics joint
  95826. */
  95827. type: number;
  95828. /**
  95829. * The data for the physics joint
  95830. */
  95831. jointData: PhysicsJointData;
  95832. private _physicsJoint;
  95833. protected _physicsPlugin: IPhysicsEnginePlugin;
  95834. /**
  95835. * Initializes the physics joint
  95836. * @param type The type of the physics joint
  95837. * @param jointData The data for the physics joint
  95838. */
  95839. constructor(
  95840. /**
  95841. * The type of the physics joint
  95842. */
  95843. type: number,
  95844. /**
  95845. * The data for the physics joint
  95846. */
  95847. jointData: PhysicsJointData);
  95848. /**
  95849. * Gets the physics joint
  95850. */
  95851. get physicsJoint(): any;
  95852. /**
  95853. * Sets the physics joint
  95854. */
  95855. set physicsJoint(newJoint: any);
  95856. /**
  95857. * Sets the physics plugin
  95858. */
  95859. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  95860. /**
  95861. * Execute a function that is physics-plugin specific.
  95862. * @param {Function} func the function that will be executed.
  95863. * It accepts two parameters: the physics world and the physics joint
  95864. */
  95865. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  95866. /**
  95867. * Distance-Joint type
  95868. */
  95869. static DistanceJoint: number;
  95870. /**
  95871. * Hinge-Joint type
  95872. */
  95873. static HingeJoint: number;
  95874. /**
  95875. * Ball-and-Socket joint type
  95876. */
  95877. static BallAndSocketJoint: number;
  95878. /**
  95879. * Wheel-Joint type
  95880. */
  95881. static WheelJoint: number;
  95882. /**
  95883. * Slider-Joint type
  95884. */
  95885. static SliderJoint: number;
  95886. /**
  95887. * Prismatic-Joint type
  95888. */
  95889. static PrismaticJoint: number;
  95890. /**
  95891. * Universal-Joint type
  95892. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  95893. */
  95894. static UniversalJoint: number;
  95895. /**
  95896. * Hinge-Joint 2 type
  95897. */
  95898. static Hinge2Joint: number;
  95899. /**
  95900. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  95901. */
  95902. static PointToPointJoint: number;
  95903. /**
  95904. * Spring-Joint type
  95905. */
  95906. static SpringJoint: number;
  95907. /**
  95908. * Lock-Joint type
  95909. */
  95910. static LockJoint: number;
  95911. }
  95912. /**
  95913. * A class representing a physics distance joint
  95914. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95915. */
  95916. export class DistanceJoint extends PhysicsJoint {
  95917. /**
  95918. *
  95919. * @param jointData The data for the Distance-Joint
  95920. */
  95921. constructor(jointData: DistanceJointData);
  95922. /**
  95923. * Update the predefined distance.
  95924. * @param maxDistance The maximum preferred distance
  95925. * @param minDistance The minimum preferred distance
  95926. */
  95927. updateDistance(maxDistance: number, minDistance?: number): void;
  95928. }
  95929. /**
  95930. * Represents a Motor-Enabled Joint
  95931. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95932. */
  95933. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  95934. /**
  95935. * Initializes the Motor-Enabled Joint
  95936. * @param type The type of the joint
  95937. * @param jointData The physica joint data for the joint
  95938. */
  95939. constructor(type: number, jointData: PhysicsJointData);
  95940. /**
  95941. * Set the motor values.
  95942. * Attention, this function is plugin specific. Engines won't react 100% the same.
  95943. * @param force the force to apply
  95944. * @param maxForce max force for this motor.
  95945. */
  95946. setMotor(force?: number, maxForce?: number): void;
  95947. /**
  95948. * Set the motor's limits.
  95949. * Attention, this function is plugin specific. Engines won't react 100% the same.
  95950. * @param upperLimit The upper limit of the motor
  95951. * @param lowerLimit The lower limit of the motor
  95952. */
  95953. setLimit(upperLimit: number, lowerLimit?: number): void;
  95954. }
  95955. /**
  95956. * This class represents a single physics Hinge-Joint
  95957. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95958. */
  95959. export class HingeJoint extends MotorEnabledJoint {
  95960. /**
  95961. * Initializes the Hinge-Joint
  95962. * @param jointData The joint data for the Hinge-Joint
  95963. */
  95964. constructor(jointData: PhysicsJointData);
  95965. /**
  95966. * Set the motor values.
  95967. * Attention, this function is plugin specific. Engines won't react 100% the same.
  95968. * @param {number} force the force to apply
  95969. * @param {number} maxForce max force for this motor.
  95970. */
  95971. setMotor(force?: number, maxForce?: number): void;
  95972. /**
  95973. * Set the motor's limits.
  95974. * Attention, this function is plugin specific. Engines won't react 100% the same.
  95975. * @param upperLimit The upper limit of the motor
  95976. * @param lowerLimit The lower limit of the motor
  95977. */
  95978. setLimit(upperLimit: number, lowerLimit?: number): void;
  95979. }
  95980. /**
  95981. * This class represents a dual hinge physics joint (same as wheel joint)
  95982. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  95983. */
  95984. export class Hinge2Joint extends MotorEnabledJoint {
  95985. /**
  95986. * Initializes the Hinge2-Joint
  95987. * @param jointData The joint data for the Hinge2-Joint
  95988. */
  95989. constructor(jointData: PhysicsJointData);
  95990. /**
  95991. * Set the motor values.
  95992. * Attention, this function is plugin specific. Engines won't react 100% the same.
  95993. * @param {number} targetSpeed the speed the motor is to reach
  95994. * @param {number} maxForce max force for this motor.
  95995. * @param {motorIndex} the motor's index, 0 or 1.
  95996. */
  95997. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  95998. /**
  95999. * Set the motor limits.
  96000. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96001. * @param {number} upperLimit the upper limit
  96002. * @param {number} lowerLimit lower limit
  96003. * @param {motorIndex} the motor's index, 0 or 1.
  96004. */
  96005. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96006. }
  96007. /**
  96008. * Interface for a motor enabled joint
  96009. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96010. */
  96011. export interface IMotorEnabledJoint {
  96012. /**
  96013. * Physics joint
  96014. */
  96015. physicsJoint: any;
  96016. /**
  96017. * Sets the motor of the motor-enabled joint
  96018. * @param force The force of the motor
  96019. * @param maxForce The maximum force of the motor
  96020. * @param motorIndex The index of the motor
  96021. */
  96022. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  96023. /**
  96024. * Sets the limit of the motor
  96025. * @param upperLimit The upper limit of the motor
  96026. * @param lowerLimit The lower limit of the motor
  96027. * @param motorIndex The index of the motor
  96028. */
  96029. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96030. }
  96031. /**
  96032. * Joint data for a Distance-Joint
  96033. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96034. */
  96035. export interface DistanceJointData extends PhysicsJointData {
  96036. /**
  96037. * Max distance the 2 joint objects can be apart
  96038. */
  96039. maxDistance: number;
  96040. }
  96041. /**
  96042. * Joint data from a spring joint
  96043. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96044. */
  96045. export interface SpringJointData extends PhysicsJointData {
  96046. /**
  96047. * Length of the spring
  96048. */
  96049. length: number;
  96050. /**
  96051. * Stiffness of the spring
  96052. */
  96053. stiffness: number;
  96054. /**
  96055. * Damping of the spring
  96056. */
  96057. damping: number;
  96058. /** this callback will be called when applying the force to the impostors. */
  96059. forceApplicationCallback: () => void;
  96060. }
  96061. }
  96062. declare module BABYLON {
  96063. /**
  96064. * Holds the data for the raycast result
  96065. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96066. */
  96067. export class PhysicsRaycastResult {
  96068. private _hasHit;
  96069. private _hitDistance;
  96070. private _hitNormalWorld;
  96071. private _hitPointWorld;
  96072. private _rayFromWorld;
  96073. private _rayToWorld;
  96074. /**
  96075. * Gets if there was a hit
  96076. */
  96077. get hasHit(): boolean;
  96078. /**
  96079. * Gets the distance from the hit
  96080. */
  96081. get hitDistance(): number;
  96082. /**
  96083. * Gets the hit normal/direction in the world
  96084. */
  96085. get hitNormalWorld(): Vector3;
  96086. /**
  96087. * Gets the hit point in the world
  96088. */
  96089. get hitPointWorld(): Vector3;
  96090. /**
  96091. * Gets the ray "start point" of the ray in the world
  96092. */
  96093. get rayFromWorld(): Vector3;
  96094. /**
  96095. * Gets the ray "end point" of the ray in the world
  96096. */
  96097. get rayToWorld(): Vector3;
  96098. /**
  96099. * Sets the hit data (normal & point in world space)
  96100. * @param hitNormalWorld defines the normal in world space
  96101. * @param hitPointWorld defines the point in world space
  96102. */
  96103. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  96104. /**
  96105. * Sets the distance from the start point to the hit point
  96106. * @param distance
  96107. */
  96108. setHitDistance(distance: number): void;
  96109. /**
  96110. * Calculates the distance manually
  96111. */
  96112. calculateHitDistance(): void;
  96113. /**
  96114. * Resets all the values to default
  96115. * @param from The from point on world space
  96116. * @param to The to point on world space
  96117. */
  96118. reset(from?: Vector3, to?: Vector3): void;
  96119. }
  96120. /**
  96121. * Interface for the size containing width and height
  96122. */
  96123. interface IXYZ {
  96124. /**
  96125. * X
  96126. */
  96127. x: number;
  96128. /**
  96129. * Y
  96130. */
  96131. y: number;
  96132. /**
  96133. * Z
  96134. */
  96135. z: number;
  96136. }
  96137. }
  96138. declare module BABYLON {
  96139. /**
  96140. * Interface used to describe a physics joint
  96141. */
  96142. export interface PhysicsImpostorJoint {
  96143. /** Defines the main impostor to which the joint is linked */
  96144. mainImpostor: PhysicsImpostor;
  96145. /** Defines the impostor that is connected to the main impostor using this joint */
  96146. connectedImpostor: PhysicsImpostor;
  96147. /** Defines the joint itself */
  96148. joint: PhysicsJoint;
  96149. }
  96150. /** @hidden */
  96151. export interface IPhysicsEnginePlugin {
  96152. world: any;
  96153. name: string;
  96154. setGravity(gravity: Vector3): void;
  96155. setTimeStep(timeStep: number): void;
  96156. getTimeStep(): number;
  96157. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  96158. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96159. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96160. generatePhysicsBody(impostor: PhysicsImpostor): void;
  96161. removePhysicsBody(impostor: PhysicsImpostor): void;
  96162. generateJoint(joint: PhysicsImpostorJoint): void;
  96163. removeJoint(joint: PhysicsImpostorJoint): void;
  96164. isSupported(): boolean;
  96165. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  96166. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  96167. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96168. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96169. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96170. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96171. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  96172. getBodyMass(impostor: PhysicsImpostor): number;
  96173. getBodyFriction(impostor: PhysicsImpostor): number;
  96174. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  96175. getBodyRestitution(impostor: PhysicsImpostor): number;
  96176. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  96177. getBodyPressure?(impostor: PhysicsImpostor): number;
  96178. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  96179. getBodyStiffness?(impostor: PhysicsImpostor): number;
  96180. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  96181. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  96182. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  96183. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  96184. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  96185. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96186. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96187. sleepBody(impostor: PhysicsImpostor): void;
  96188. wakeUpBody(impostor: PhysicsImpostor): void;
  96189. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96190. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  96191. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  96192. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96193. getRadius(impostor: PhysicsImpostor): number;
  96194. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  96195. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  96196. dispose(): void;
  96197. }
  96198. /**
  96199. * Interface used to define a physics engine
  96200. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  96201. */
  96202. export interface IPhysicsEngine {
  96203. /**
  96204. * Gets the gravity vector used by the simulation
  96205. */
  96206. gravity: Vector3;
  96207. /**
  96208. * Sets the gravity vector used by the simulation
  96209. * @param gravity defines the gravity vector to use
  96210. */
  96211. setGravity(gravity: Vector3): void;
  96212. /**
  96213. * Set the time step of the physics engine.
  96214. * Default is 1/60.
  96215. * To slow it down, enter 1/600 for example.
  96216. * To speed it up, 1/30
  96217. * @param newTimeStep the new timestep to apply to this world.
  96218. */
  96219. setTimeStep(newTimeStep: number): void;
  96220. /**
  96221. * Get the time step of the physics engine.
  96222. * @returns the current time step
  96223. */
  96224. getTimeStep(): number;
  96225. /**
  96226. * Set the sub time step of the physics engine.
  96227. * Default is 0 meaning there is no sub steps
  96228. * To increase physics resolution precision, set a small value (like 1 ms)
  96229. * @param subTimeStep defines the new sub timestep used for physics resolution.
  96230. */
  96231. setSubTimeStep(subTimeStep: number): void;
  96232. /**
  96233. * Get the sub time step of the physics engine.
  96234. * @returns the current sub time step
  96235. */
  96236. getSubTimeStep(): number;
  96237. /**
  96238. * Release all resources
  96239. */
  96240. dispose(): void;
  96241. /**
  96242. * Gets the name of the current physics plugin
  96243. * @returns the name of the plugin
  96244. */
  96245. getPhysicsPluginName(): string;
  96246. /**
  96247. * Adding a new impostor for the impostor tracking.
  96248. * This will be done by the impostor itself.
  96249. * @param impostor the impostor to add
  96250. */
  96251. addImpostor(impostor: PhysicsImpostor): void;
  96252. /**
  96253. * Remove an impostor from the engine.
  96254. * This impostor and its mesh will not longer be updated by the physics engine.
  96255. * @param impostor the impostor to remove
  96256. */
  96257. removeImpostor(impostor: PhysicsImpostor): void;
  96258. /**
  96259. * Add a joint to the physics engine
  96260. * @param mainImpostor defines the main impostor to which the joint is added.
  96261. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  96262. * @param joint defines the joint that will connect both impostors.
  96263. */
  96264. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96265. /**
  96266. * Removes a joint from the simulation
  96267. * @param mainImpostor defines the impostor used with the joint
  96268. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  96269. * @param joint defines the joint to remove
  96270. */
  96271. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96272. /**
  96273. * Gets the current plugin used to run the simulation
  96274. * @returns current plugin
  96275. */
  96276. getPhysicsPlugin(): IPhysicsEnginePlugin;
  96277. /**
  96278. * Gets the list of physic impostors
  96279. * @returns an array of PhysicsImpostor
  96280. */
  96281. getImpostors(): Array<PhysicsImpostor>;
  96282. /**
  96283. * Gets the impostor for a physics enabled object
  96284. * @param object defines the object impersonated by the impostor
  96285. * @returns the PhysicsImpostor or null if not found
  96286. */
  96287. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  96288. /**
  96289. * Gets the impostor for a physics body object
  96290. * @param body defines physics body used by the impostor
  96291. * @returns the PhysicsImpostor or null if not found
  96292. */
  96293. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  96294. /**
  96295. * Does a raycast in the physics world
  96296. * @param from when should the ray start?
  96297. * @param to when should the ray end?
  96298. * @returns PhysicsRaycastResult
  96299. */
  96300. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96301. /**
  96302. * Called by the scene. No need to call it.
  96303. * @param delta defines the timespam between frames
  96304. */
  96305. _step(delta: number): void;
  96306. }
  96307. }
  96308. declare module BABYLON {
  96309. /**
  96310. * The interface for the physics imposter parameters
  96311. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96312. */
  96313. export interface PhysicsImpostorParameters {
  96314. /**
  96315. * The mass of the physics imposter
  96316. */
  96317. mass: number;
  96318. /**
  96319. * The friction of the physics imposter
  96320. */
  96321. friction?: number;
  96322. /**
  96323. * The coefficient of restitution of the physics imposter
  96324. */
  96325. restitution?: number;
  96326. /**
  96327. * The native options of the physics imposter
  96328. */
  96329. nativeOptions?: any;
  96330. /**
  96331. * Specifies if the parent should be ignored
  96332. */
  96333. ignoreParent?: boolean;
  96334. /**
  96335. * Specifies if bi-directional transformations should be disabled
  96336. */
  96337. disableBidirectionalTransformation?: boolean;
  96338. /**
  96339. * The pressure inside the physics imposter, soft object only
  96340. */
  96341. pressure?: number;
  96342. /**
  96343. * The stiffness the physics imposter, soft object only
  96344. */
  96345. stiffness?: number;
  96346. /**
  96347. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  96348. */
  96349. velocityIterations?: number;
  96350. /**
  96351. * The number of iterations used in maintaining consistent vertex positions, soft object only
  96352. */
  96353. positionIterations?: number;
  96354. /**
  96355. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  96356. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  96357. * Add to fix multiple points
  96358. */
  96359. fixedPoints?: number;
  96360. /**
  96361. * The collision margin around a soft object
  96362. */
  96363. margin?: number;
  96364. /**
  96365. * The collision margin around a soft object
  96366. */
  96367. damping?: number;
  96368. /**
  96369. * The path for a rope based on an extrusion
  96370. */
  96371. path?: any;
  96372. /**
  96373. * The shape of an extrusion used for a rope based on an extrusion
  96374. */
  96375. shape?: any;
  96376. }
  96377. /**
  96378. * Interface for a physics-enabled object
  96379. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96380. */
  96381. export interface IPhysicsEnabledObject {
  96382. /**
  96383. * The position of the physics-enabled object
  96384. */
  96385. position: Vector3;
  96386. /**
  96387. * The rotation of the physics-enabled object
  96388. */
  96389. rotationQuaternion: Nullable<Quaternion>;
  96390. /**
  96391. * The scale of the physics-enabled object
  96392. */
  96393. scaling: Vector3;
  96394. /**
  96395. * The rotation of the physics-enabled object
  96396. */
  96397. rotation?: Vector3;
  96398. /**
  96399. * The parent of the physics-enabled object
  96400. */
  96401. parent?: any;
  96402. /**
  96403. * The bounding info of the physics-enabled object
  96404. * @returns The bounding info of the physics-enabled object
  96405. */
  96406. getBoundingInfo(): BoundingInfo;
  96407. /**
  96408. * Computes the world matrix
  96409. * @param force Specifies if the world matrix should be computed by force
  96410. * @returns A world matrix
  96411. */
  96412. computeWorldMatrix(force: boolean): Matrix;
  96413. /**
  96414. * Gets the world matrix
  96415. * @returns A world matrix
  96416. */
  96417. getWorldMatrix?(): Matrix;
  96418. /**
  96419. * Gets the child meshes
  96420. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  96421. * @returns An array of abstract meshes
  96422. */
  96423. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  96424. /**
  96425. * Gets the vertex data
  96426. * @param kind The type of vertex data
  96427. * @returns A nullable array of numbers, or a float32 array
  96428. */
  96429. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  96430. /**
  96431. * Gets the indices from the mesh
  96432. * @returns A nullable array of index arrays
  96433. */
  96434. getIndices?(): Nullable<IndicesArray>;
  96435. /**
  96436. * Gets the scene from the mesh
  96437. * @returns the indices array or null
  96438. */
  96439. getScene?(): Scene;
  96440. /**
  96441. * Gets the absolute position from the mesh
  96442. * @returns the absolute position
  96443. */
  96444. getAbsolutePosition(): Vector3;
  96445. /**
  96446. * Gets the absolute pivot point from the mesh
  96447. * @returns the absolute pivot point
  96448. */
  96449. getAbsolutePivotPoint(): Vector3;
  96450. /**
  96451. * Rotates the mesh
  96452. * @param axis The axis of rotation
  96453. * @param amount The amount of rotation
  96454. * @param space The space of the rotation
  96455. * @returns The rotation transform node
  96456. */
  96457. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  96458. /**
  96459. * Translates the mesh
  96460. * @param axis The axis of translation
  96461. * @param distance The distance of translation
  96462. * @param space The space of the translation
  96463. * @returns The transform node
  96464. */
  96465. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  96466. /**
  96467. * Sets the absolute position of the mesh
  96468. * @param absolutePosition The absolute position of the mesh
  96469. * @returns The transform node
  96470. */
  96471. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  96472. /**
  96473. * Gets the class name of the mesh
  96474. * @returns The class name
  96475. */
  96476. getClassName(): string;
  96477. }
  96478. /**
  96479. * Represents a physics imposter
  96480. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96481. */
  96482. export class PhysicsImpostor {
  96483. /**
  96484. * The physics-enabled object used as the physics imposter
  96485. */
  96486. object: IPhysicsEnabledObject;
  96487. /**
  96488. * The type of the physics imposter
  96489. */
  96490. type: number;
  96491. private _options;
  96492. private _scene?;
  96493. /**
  96494. * The default object size of the imposter
  96495. */
  96496. static DEFAULT_OBJECT_SIZE: Vector3;
  96497. /**
  96498. * The identity quaternion of the imposter
  96499. */
  96500. static IDENTITY_QUATERNION: Quaternion;
  96501. /** @hidden */
  96502. _pluginData: any;
  96503. private _physicsEngine;
  96504. private _physicsBody;
  96505. private _bodyUpdateRequired;
  96506. private _onBeforePhysicsStepCallbacks;
  96507. private _onAfterPhysicsStepCallbacks;
  96508. /** @hidden */
  96509. _onPhysicsCollideCallbacks: Array<{
  96510. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  96511. otherImpostors: Array<PhysicsImpostor>;
  96512. }>;
  96513. private _deltaPosition;
  96514. private _deltaRotation;
  96515. private _deltaRotationConjugated;
  96516. /** @hidden */
  96517. _isFromLine: boolean;
  96518. private _parent;
  96519. private _isDisposed;
  96520. private static _tmpVecs;
  96521. private static _tmpQuat;
  96522. /**
  96523. * Specifies if the physics imposter is disposed
  96524. */
  96525. get isDisposed(): boolean;
  96526. /**
  96527. * Gets the mass of the physics imposter
  96528. */
  96529. get mass(): number;
  96530. set mass(value: number);
  96531. /**
  96532. * Gets the coefficient of friction
  96533. */
  96534. get friction(): number;
  96535. /**
  96536. * Sets the coefficient of friction
  96537. */
  96538. set friction(value: number);
  96539. /**
  96540. * Gets the coefficient of restitution
  96541. */
  96542. get restitution(): number;
  96543. /**
  96544. * Sets the coefficient of restitution
  96545. */
  96546. set restitution(value: number);
  96547. /**
  96548. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  96549. */
  96550. get pressure(): number;
  96551. /**
  96552. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  96553. */
  96554. set pressure(value: number);
  96555. /**
  96556. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  96557. */
  96558. get stiffness(): number;
  96559. /**
  96560. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  96561. */
  96562. set stiffness(value: number);
  96563. /**
  96564. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  96565. */
  96566. get velocityIterations(): number;
  96567. /**
  96568. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  96569. */
  96570. set velocityIterations(value: number);
  96571. /**
  96572. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  96573. */
  96574. get positionIterations(): number;
  96575. /**
  96576. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  96577. */
  96578. set positionIterations(value: number);
  96579. /**
  96580. * The unique id of the physics imposter
  96581. * set by the physics engine when adding this impostor to the array
  96582. */
  96583. uniqueId: number;
  96584. /**
  96585. * @hidden
  96586. */
  96587. soft: boolean;
  96588. /**
  96589. * @hidden
  96590. */
  96591. segments: number;
  96592. private _joints;
  96593. /**
  96594. * Initializes the physics imposter
  96595. * @param object The physics-enabled object used as the physics imposter
  96596. * @param type The type of the physics imposter
  96597. * @param _options The options for the physics imposter
  96598. * @param _scene The Babylon scene
  96599. */
  96600. constructor(
  96601. /**
  96602. * The physics-enabled object used as the physics imposter
  96603. */
  96604. object: IPhysicsEnabledObject,
  96605. /**
  96606. * The type of the physics imposter
  96607. */
  96608. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  96609. /**
  96610. * This function will completly initialize this impostor.
  96611. * It will create a new body - but only if this mesh has no parent.
  96612. * If it has, this impostor will not be used other than to define the impostor
  96613. * of the child mesh.
  96614. * @hidden
  96615. */
  96616. _init(): void;
  96617. private _getPhysicsParent;
  96618. /**
  96619. * Should a new body be generated.
  96620. * @returns boolean specifying if body initialization is required
  96621. */
  96622. isBodyInitRequired(): boolean;
  96623. /**
  96624. * Sets the updated scaling
  96625. * @param updated Specifies if the scaling is updated
  96626. */
  96627. setScalingUpdated(): void;
  96628. /**
  96629. * Force a regeneration of this or the parent's impostor's body.
  96630. * Use under cautious - This will remove all joints already implemented.
  96631. */
  96632. forceUpdate(): void;
  96633. /**
  96634. * Gets the body that holds this impostor. Either its own, or its parent.
  96635. */
  96636. get physicsBody(): any;
  96637. /**
  96638. * Get the parent of the physics imposter
  96639. * @returns Physics imposter or null
  96640. */
  96641. get parent(): Nullable<PhysicsImpostor>;
  96642. /**
  96643. * Sets the parent of the physics imposter
  96644. */
  96645. set parent(value: Nullable<PhysicsImpostor>);
  96646. /**
  96647. * Set the physics body. Used mainly by the physics engine/plugin
  96648. */
  96649. set physicsBody(physicsBody: any);
  96650. /**
  96651. * Resets the update flags
  96652. */
  96653. resetUpdateFlags(): void;
  96654. /**
  96655. * Gets the object extend size
  96656. * @returns the object extend size
  96657. */
  96658. getObjectExtendSize(): Vector3;
  96659. /**
  96660. * Gets the object center
  96661. * @returns The object center
  96662. */
  96663. getObjectCenter(): Vector3;
  96664. /**
  96665. * Get a specific parameter from the options parameters
  96666. * @param paramName The object parameter name
  96667. * @returns The object parameter
  96668. */
  96669. getParam(paramName: string): any;
  96670. /**
  96671. * Sets a specific parameter in the options given to the physics plugin
  96672. * @param paramName The parameter name
  96673. * @param value The value of the parameter
  96674. */
  96675. setParam(paramName: string, value: number): void;
  96676. /**
  96677. * Specifically change the body's mass option. Won't recreate the physics body object
  96678. * @param mass The mass of the physics imposter
  96679. */
  96680. setMass(mass: number): void;
  96681. /**
  96682. * Gets the linear velocity
  96683. * @returns linear velocity or null
  96684. */
  96685. getLinearVelocity(): Nullable<Vector3>;
  96686. /**
  96687. * Sets the linear velocity
  96688. * @param velocity linear velocity or null
  96689. */
  96690. setLinearVelocity(velocity: Nullable<Vector3>): void;
  96691. /**
  96692. * Gets the angular velocity
  96693. * @returns angular velocity or null
  96694. */
  96695. getAngularVelocity(): Nullable<Vector3>;
  96696. /**
  96697. * Sets the angular velocity
  96698. * @param velocity The velocity or null
  96699. */
  96700. setAngularVelocity(velocity: Nullable<Vector3>): void;
  96701. /**
  96702. * Execute a function with the physics plugin native code
  96703. * Provide a function the will have two variables - the world object and the physics body object
  96704. * @param func The function to execute with the physics plugin native code
  96705. */
  96706. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  96707. /**
  96708. * Register a function that will be executed before the physics world is stepping forward
  96709. * @param func The function to execute before the physics world is stepped forward
  96710. */
  96711. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  96712. /**
  96713. * Unregister a function that will be executed before the physics world is stepping forward
  96714. * @param func The function to execute before the physics world is stepped forward
  96715. */
  96716. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  96717. /**
  96718. * Register a function that will be executed after the physics step
  96719. * @param func The function to execute after physics step
  96720. */
  96721. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  96722. /**
  96723. * Unregisters a function that will be executed after the physics step
  96724. * @param func The function to execute after physics step
  96725. */
  96726. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  96727. /**
  96728. * register a function that will be executed when this impostor collides against a different body
  96729. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  96730. * @param func Callback that is executed on collision
  96731. */
  96732. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  96733. /**
  96734. * Unregisters the physics imposter on contact
  96735. * @param collideAgainst The physics object to collide against
  96736. * @param func Callback to execute on collision
  96737. */
  96738. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  96739. private _tmpQuat;
  96740. private _tmpQuat2;
  96741. /**
  96742. * Get the parent rotation
  96743. * @returns The parent rotation
  96744. */
  96745. getParentsRotation(): Quaternion;
  96746. /**
  96747. * this function is executed by the physics engine.
  96748. */
  96749. beforeStep: () => void;
  96750. /**
  96751. * this function is executed by the physics engine
  96752. */
  96753. afterStep: () => void;
  96754. /**
  96755. * Legacy collision detection event support
  96756. */
  96757. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  96758. /**
  96759. * event and body object due to cannon's event-based architecture.
  96760. */
  96761. onCollide: (e: {
  96762. body: any;
  96763. }) => void;
  96764. /**
  96765. * Apply a force
  96766. * @param force The force to apply
  96767. * @param contactPoint The contact point for the force
  96768. * @returns The physics imposter
  96769. */
  96770. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  96771. /**
  96772. * Apply an impulse
  96773. * @param force The impulse force
  96774. * @param contactPoint The contact point for the impulse force
  96775. * @returns The physics imposter
  96776. */
  96777. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  96778. /**
  96779. * A help function to create a joint
  96780. * @param otherImpostor A physics imposter used to create a joint
  96781. * @param jointType The type of joint
  96782. * @param jointData The data for the joint
  96783. * @returns The physics imposter
  96784. */
  96785. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  96786. /**
  96787. * Add a joint to this impostor with a different impostor
  96788. * @param otherImpostor A physics imposter used to add a joint
  96789. * @param joint The joint to add
  96790. * @returns The physics imposter
  96791. */
  96792. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  96793. /**
  96794. * Add an anchor to a cloth impostor
  96795. * @param otherImpostor rigid impostor to anchor to
  96796. * @param width ratio across width from 0 to 1
  96797. * @param height ratio up height from 0 to 1
  96798. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  96799. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  96800. * @returns impostor the soft imposter
  96801. */
  96802. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  96803. /**
  96804. * Add a hook to a rope impostor
  96805. * @param otherImpostor rigid impostor to anchor to
  96806. * @param length ratio across rope from 0 to 1
  96807. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  96808. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  96809. * @returns impostor the rope imposter
  96810. */
  96811. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  96812. /**
  96813. * Will keep this body still, in a sleep mode.
  96814. * @returns the physics imposter
  96815. */
  96816. sleep(): PhysicsImpostor;
  96817. /**
  96818. * Wake the body up.
  96819. * @returns The physics imposter
  96820. */
  96821. wakeUp(): PhysicsImpostor;
  96822. /**
  96823. * Clones the physics imposter
  96824. * @param newObject The physics imposter clones to this physics-enabled object
  96825. * @returns A nullable physics imposter
  96826. */
  96827. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  96828. /**
  96829. * Disposes the physics imposter
  96830. */
  96831. dispose(): void;
  96832. /**
  96833. * Sets the delta position
  96834. * @param position The delta position amount
  96835. */
  96836. setDeltaPosition(position: Vector3): void;
  96837. /**
  96838. * Sets the delta rotation
  96839. * @param rotation The delta rotation amount
  96840. */
  96841. setDeltaRotation(rotation: Quaternion): void;
  96842. /**
  96843. * Gets the box size of the physics imposter and stores the result in the input parameter
  96844. * @param result Stores the box size
  96845. * @returns The physics imposter
  96846. */
  96847. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  96848. /**
  96849. * Gets the radius of the physics imposter
  96850. * @returns Radius of the physics imposter
  96851. */
  96852. getRadius(): number;
  96853. /**
  96854. * Sync a bone with this impostor
  96855. * @param bone The bone to sync to the impostor.
  96856. * @param boneMesh The mesh that the bone is influencing.
  96857. * @param jointPivot The pivot of the joint / bone in local space.
  96858. * @param distToJoint Optional distance from the impostor to the joint.
  96859. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  96860. */
  96861. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  96862. /**
  96863. * Sync impostor to a bone
  96864. * @param bone The bone that the impostor will be synced to.
  96865. * @param boneMesh The mesh that the bone is influencing.
  96866. * @param jointPivot The pivot of the joint / bone in local space.
  96867. * @param distToJoint Optional distance from the impostor to the joint.
  96868. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  96869. * @param boneAxis Optional vector3 axis the bone is aligned with
  96870. */
  96871. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  96872. /**
  96873. * No-Imposter type
  96874. */
  96875. static NoImpostor: number;
  96876. /**
  96877. * Sphere-Imposter type
  96878. */
  96879. static SphereImpostor: number;
  96880. /**
  96881. * Box-Imposter type
  96882. */
  96883. static BoxImpostor: number;
  96884. /**
  96885. * Plane-Imposter type
  96886. */
  96887. static PlaneImpostor: number;
  96888. /**
  96889. * Mesh-imposter type
  96890. */
  96891. static MeshImpostor: number;
  96892. /**
  96893. * Capsule-Impostor type (Ammo.js plugin only)
  96894. */
  96895. static CapsuleImpostor: number;
  96896. /**
  96897. * Cylinder-Imposter type
  96898. */
  96899. static CylinderImpostor: number;
  96900. /**
  96901. * Particle-Imposter type
  96902. */
  96903. static ParticleImpostor: number;
  96904. /**
  96905. * Heightmap-Imposter type
  96906. */
  96907. static HeightmapImpostor: number;
  96908. /**
  96909. * ConvexHull-Impostor type (Ammo.js plugin only)
  96910. */
  96911. static ConvexHullImpostor: number;
  96912. /**
  96913. * Custom-Imposter type (Ammo.js plugin only)
  96914. */
  96915. static CustomImpostor: number;
  96916. /**
  96917. * Rope-Imposter type
  96918. */
  96919. static RopeImpostor: number;
  96920. /**
  96921. * Cloth-Imposter type
  96922. */
  96923. static ClothImpostor: number;
  96924. /**
  96925. * Softbody-Imposter type
  96926. */
  96927. static SoftbodyImpostor: number;
  96928. }
  96929. }
  96930. declare module BABYLON {
  96931. /**
  96932. * @hidden
  96933. **/
  96934. export class _CreationDataStorage {
  96935. closePath?: boolean;
  96936. closeArray?: boolean;
  96937. idx: number[];
  96938. dashSize: number;
  96939. gapSize: number;
  96940. path3D: Path3D;
  96941. pathArray: Vector3[][];
  96942. arc: number;
  96943. radius: number;
  96944. cap: number;
  96945. tessellation: number;
  96946. }
  96947. /**
  96948. * @hidden
  96949. **/
  96950. class _InstanceDataStorage {
  96951. visibleInstances: any;
  96952. batchCache: _InstancesBatch;
  96953. instancesBufferSize: number;
  96954. instancesBuffer: Nullable<Buffer>;
  96955. instancesData: Float32Array;
  96956. overridenInstanceCount: number;
  96957. isFrozen: boolean;
  96958. previousBatch: Nullable<_InstancesBatch>;
  96959. hardwareInstancedRendering: boolean;
  96960. sideOrientation: number;
  96961. manualUpdate: boolean;
  96962. }
  96963. /**
  96964. * @hidden
  96965. **/
  96966. export class _InstancesBatch {
  96967. mustReturn: boolean;
  96968. visibleInstances: Nullable<InstancedMesh[]>[];
  96969. renderSelf: boolean[];
  96970. hardwareInstancedRendering: boolean[];
  96971. }
  96972. /**
  96973. * Class used to represent renderable models
  96974. */
  96975. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  96976. /**
  96977. * Mesh side orientation : usually the external or front surface
  96978. */
  96979. static readonly FRONTSIDE: number;
  96980. /**
  96981. * Mesh side orientation : usually the internal or back surface
  96982. */
  96983. static readonly BACKSIDE: number;
  96984. /**
  96985. * Mesh side orientation : both internal and external or front and back surfaces
  96986. */
  96987. static readonly DOUBLESIDE: number;
  96988. /**
  96989. * Mesh side orientation : by default, `FRONTSIDE`
  96990. */
  96991. static readonly DEFAULTSIDE: number;
  96992. /**
  96993. * Mesh cap setting : no cap
  96994. */
  96995. static readonly NO_CAP: number;
  96996. /**
  96997. * Mesh cap setting : one cap at the beginning of the mesh
  96998. */
  96999. static readonly CAP_START: number;
  97000. /**
  97001. * Mesh cap setting : one cap at the end of the mesh
  97002. */
  97003. static readonly CAP_END: number;
  97004. /**
  97005. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  97006. */
  97007. static readonly CAP_ALL: number;
  97008. /**
  97009. * Mesh pattern setting : no flip or rotate
  97010. */
  97011. static readonly NO_FLIP: number;
  97012. /**
  97013. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  97014. */
  97015. static readonly FLIP_TILE: number;
  97016. /**
  97017. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  97018. */
  97019. static readonly ROTATE_TILE: number;
  97020. /**
  97021. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  97022. */
  97023. static readonly FLIP_ROW: number;
  97024. /**
  97025. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  97026. */
  97027. static readonly ROTATE_ROW: number;
  97028. /**
  97029. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  97030. */
  97031. static readonly FLIP_N_ROTATE_TILE: number;
  97032. /**
  97033. * Mesh pattern setting : rotate pattern and rotate
  97034. */
  97035. static readonly FLIP_N_ROTATE_ROW: number;
  97036. /**
  97037. * Mesh tile positioning : part tiles same on left/right or top/bottom
  97038. */
  97039. static readonly CENTER: number;
  97040. /**
  97041. * Mesh tile positioning : part tiles on left
  97042. */
  97043. static readonly LEFT: number;
  97044. /**
  97045. * Mesh tile positioning : part tiles on right
  97046. */
  97047. static readonly RIGHT: number;
  97048. /**
  97049. * Mesh tile positioning : part tiles on top
  97050. */
  97051. static readonly TOP: number;
  97052. /**
  97053. * Mesh tile positioning : part tiles on bottom
  97054. */
  97055. static readonly BOTTOM: number;
  97056. /**
  97057. * Gets the default side orientation.
  97058. * @param orientation the orientation to value to attempt to get
  97059. * @returns the default orientation
  97060. * @hidden
  97061. */
  97062. static _GetDefaultSideOrientation(orientation?: number): number;
  97063. private _internalMeshDataInfo;
  97064. /**
  97065. * An event triggered before rendering the mesh
  97066. */
  97067. get onBeforeRenderObservable(): Observable<Mesh>;
  97068. /**
  97069. * An event triggered before binding the mesh
  97070. */
  97071. get onBeforeBindObservable(): Observable<Mesh>;
  97072. /**
  97073. * An event triggered after rendering the mesh
  97074. */
  97075. get onAfterRenderObservable(): Observable<Mesh>;
  97076. /**
  97077. * An event triggered before drawing the mesh
  97078. */
  97079. get onBeforeDrawObservable(): Observable<Mesh>;
  97080. private _onBeforeDrawObserver;
  97081. /**
  97082. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  97083. */
  97084. set onBeforeDraw(callback: () => void);
  97085. get hasInstances(): boolean;
  97086. /**
  97087. * Gets the delay loading state of the mesh (when delay loading is turned on)
  97088. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  97089. */
  97090. delayLoadState: number;
  97091. /**
  97092. * Gets the list of instances created from this mesh
  97093. * it is not supposed to be modified manually.
  97094. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  97095. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  97096. */
  97097. instances: InstancedMesh[];
  97098. /**
  97099. * Gets the file containing delay loading data for this mesh
  97100. */
  97101. delayLoadingFile: string;
  97102. /** @hidden */
  97103. _binaryInfo: any;
  97104. /**
  97105. * User defined function used to change how LOD level selection is done
  97106. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  97107. */
  97108. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  97109. /**
  97110. * Gets or sets the morph target manager
  97111. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  97112. */
  97113. get morphTargetManager(): Nullable<MorphTargetManager>;
  97114. set morphTargetManager(value: Nullable<MorphTargetManager>);
  97115. /** @hidden */
  97116. _creationDataStorage: Nullable<_CreationDataStorage>;
  97117. /** @hidden */
  97118. _geometry: Nullable<Geometry>;
  97119. /** @hidden */
  97120. _delayInfo: Array<string>;
  97121. /** @hidden */
  97122. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  97123. /** @hidden */
  97124. _instanceDataStorage: _InstanceDataStorage;
  97125. private _effectiveMaterial;
  97126. /** @hidden */
  97127. _shouldGenerateFlatShading: boolean;
  97128. /** @hidden */
  97129. _originalBuilderSideOrientation: number;
  97130. /**
  97131. * Use this property to change the original side orientation defined at construction time
  97132. */
  97133. overrideMaterialSideOrientation: Nullable<number>;
  97134. /**
  97135. * Gets the source mesh (the one used to clone this one from)
  97136. */
  97137. get source(): Nullable<Mesh>;
  97138. /**
  97139. * Gets or sets a boolean indicating that this mesh does not use index buffer
  97140. */
  97141. get isUnIndexed(): boolean;
  97142. set isUnIndexed(value: boolean);
  97143. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  97144. get worldMatrixInstancedBuffer(): Float32Array;
  97145. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  97146. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  97147. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  97148. /**
  97149. * @constructor
  97150. * @param name The value used by scene.getMeshByName() to do a lookup.
  97151. * @param scene The scene to add this mesh to.
  97152. * @param parent The parent of this mesh, if it has one
  97153. * @param source An optional Mesh from which geometry is shared, cloned.
  97154. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97155. * When false, achieved by calling a clone(), also passing False.
  97156. * This will make creation of children, recursive.
  97157. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  97158. */
  97159. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  97160. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  97161. doNotInstantiate: boolean;
  97162. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  97163. /**
  97164. * Gets the class name
  97165. * @returns the string "Mesh".
  97166. */
  97167. getClassName(): string;
  97168. /** @hidden */
  97169. get _isMesh(): boolean;
  97170. /**
  97171. * Returns a description of this mesh
  97172. * @param fullDetails define if full details about this mesh must be used
  97173. * @returns a descriptive string representing this mesh
  97174. */
  97175. toString(fullDetails?: boolean): string;
  97176. /** @hidden */
  97177. _unBindEffect(): void;
  97178. /**
  97179. * Gets a boolean indicating if this mesh has LOD
  97180. */
  97181. get hasLODLevels(): boolean;
  97182. /**
  97183. * Gets the list of MeshLODLevel associated with the current mesh
  97184. * @returns an array of MeshLODLevel
  97185. */
  97186. getLODLevels(): MeshLODLevel[];
  97187. private _sortLODLevels;
  97188. /**
  97189. * Add a mesh as LOD level triggered at the given distance.
  97190. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97191. * @param distance The distance from the center of the object to show this level
  97192. * @param mesh The mesh to be added as LOD level (can be null)
  97193. * @return This mesh (for chaining)
  97194. */
  97195. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  97196. /**
  97197. * Returns the LOD level mesh at the passed distance or null if not found.
  97198. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97199. * @param distance The distance from the center of the object to show this level
  97200. * @returns a Mesh or `null`
  97201. */
  97202. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  97203. /**
  97204. * Remove a mesh from the LOD array
  97205. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97206. * @param mesh defines the mesh to be removed
  97207. * @return This mesh (for chaining)
  97208. */
  97209. removeLODLevel(mesh: Mesh): Mesh;
  97210. /**
  97211. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  97212. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97213. * @param camera defines the camera to use to compute distance
  97214. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  97215. * @return This mesh (for chaining)
  97216. */
  97217. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  97218. /**
  97219. * Gets the mesh internal Geometry object
  97220. */
  97221. get geometry(): Nullable<Geometry>;
  97222. /**
  97223. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  97224. * @returns the total number of vertices
  97225. */
  97226. getTotalVertices(): number;
  97227. /**
  97228. * Returns the content of an associated vertex buffer
  97229. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97230. * - VertexBuffer.PositionKind
  97231. * - VertexBuffer.UVKind
  97232. * - VertexBuffer.UV2Kind
  97233. * - VertexBuffer.UV3Kind
  97234. * - VertexBuffer.UV4Kind
  97235. * - VertexBuffer.UV5Kind
  97236. * - VertexBuffer.UV6Kind
  97237. * - VertexBuffer.ColorKind
  97238. * - VertexBuffer.MatricesIndicesKind
  97239. * - VertexBuffer.MatricesIndicesExtraKind
  97240. * - VertexBuffer.MatricesWeightsKind
  97241. * - VertexBuffer.MatricesWeightsExtraKind
  97242. * @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
  97243. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  97244. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  97245. */
  97246. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  97247. /**
  97248. * Returns the mesh VertexBuffer object from the requested `kind`
  97249. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97250. * - VertexBuffer.PositionKind
  97251. * - VertexBuffer.NormalKind
  97252. * - VertexBuffer.UVKind
  97253. * - VertexBuffer.UV2Kind
  97254. * - VertexBuffer.UV3Kind
  97255. * - VertexBuffer.UV4Kind
  97256. * - VertexBuffer.UV5Kind
  97257. * - VertexBuffer.UV6Kind
  97258. * - VertexBuffer.ColorKind
  97259. * - VertexBuffer.MatricesIndicesKind
  97260. * - VertexBuffer.MatricesIndicesExtraKind
  97261. * - VertexBuffer.MatricesWeightsKind
  97262. * - VertexBuffer.MatricesWeightsExtraKind
  97263. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  97264. */
  97265. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  97266. /**
  97267. * Tests if a specific vertex buffer is associated with this mesh
  97268. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97269. * - VertexBuffer.PositionKind
  97270. * - VertexBuffer.NormalKind
  97271. * - VertexBuffer.UVKind
  97272. * - VertexBuffer.UV2Kind
  97273. * - VertexBuffer.UV3Kind
  97274. * - VertexBuffer.UV4Kind
  97275. * - VertexBuffer.UV5Kind
  97276. * - VertexBuffer.UV6Kind
  97277. * - VertexBuffer.ColorKind
  97278. * - VertexBuffer.MatricesIndicesKind
  97279. * - VertexBuffer.MatricesIndicesExtraKind
  97280. * - VertexBuffer.MatricesWeightsKind
  97281. * - VertexBuffer.MatricesWeightsExtraKind
  97282. * @returns a boolean
  97283. */
  97284. isVerticesDataPresent(kind: string): boolean;
  97285. /**
  97286. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  97287. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97288. * - VertexBuffer.PositionKind
  97289. * - VertexBuffer.UVKind
  97290. * - VertexBuffer.UV2Kind
  97291. * - VertexBuffer.UV3Kind
  97292. * - VertexBuffer.UV4Kind
  97293. * - VertexBuffer.UV5Kind
  97294. * - VertexBuffer.UV6Kind
  97295. * - VertexBuffer.ColorKind
  97296. * - VertexBuffer.MatricesIndicesKind
  97297. * - VertexBuffer.MatricesIndicesExtraKind
  97298. * - VertexBuffer.MatricesWeightsKind
  97299. * - VertexBuffer.MatricesWeightsExtraKind
  97300. * @returns a boolean
  97301. */
  97302. isVertexBufferUpdatable(kind: string): boolean;
  97303. /**
  97304. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  97305. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97306. * - VertexBuffer.PositionKind
  97307. * - VertexBuffer.NormalKind
  97308. * - VertexBuffer.UVKind
  97309. * - VertexBuffer.UV2Kind
  97310. * - VertexBuffer.UV3Kind
  97311. * - VertexBuffer.UV4Kind
  97312. * - VertexBuffer.UV5Kind
  97313. * - VertexBuffer.UV6Kind
  97314. * - VertexBuffer.ColorKind
  97315. * - VertexBuffer.MatricesIndicesKind
  97316. * - VertexBuffer.MatricesIndicesExtraKind
  97317. * - VertexBuffer.MatricesWeightsKind
  97318. * - VertexBuffer.MatricesWeightsExtraKind
  97319. * @returns an array of strings
  97320. */
  97321. getVerticesDataKinds(): string[];
  97322. /**
  97323. * Returns a positive integer : the total number of indices in this mesh geometry.
  97324. * @returns the numner of indices or zero if the mesh has no geometry.
  97325. */
  97326. getTotalIndices(): number;
  97327. /**
  97328. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  97329. * @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.
  97330. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  97331. * @returns the indices array or an empty array if the mesh has no geometry
  97332. */
  97333. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  97334. get isBlocked(): boolean;
  97335. /**
  97336. * Determine if the current mesh is ready to be rendered
  97337. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97338. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  97339. * @returns true if all associated assets are ready (material, textures, shaders)
  97340. */
  97341. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  97342. /**
  97343. * 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.
  97344. */
  97345. get areNormalsFrozen(): boolean;
  97346. /**
  97347. * 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.
  97348. * @returns the current mesh
  97349. */
  97350. freezeNormals(): Mesh;
  97351. /**
  97352. * 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
  97353. * @returns the current mesh
  97354. */
  97355. unfreezeNormals(): Mesh;
  97356. /**
  97357. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  97358. */
  97359. set overridenInstanceCount(count: number);
  97360. /** @hidden */
  97361. _preActivate(): Mesh;
  97362. /** @hidden */
  97363. _preActivateForIntermediateRendering(renderId: number): Mesh;
  97364. /** @hidden */
  97365. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  97366. /**
  97367. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  97368. * This means the mesh underlying bounding box and sphere are recomputed.
  97369. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  97370. * @returns the current mesh
  97371. */
  97372. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  97373. /** @hidden */
  97374. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  97375. /**
  97376. * This function will subdivide the mesh into multiple submeshes
  97377. * @param count defines the expected number of submeshes
  97378. */
  97379. subdivide(count: number): void;
  97380. /**
  97381. * Copy a FloatArray into a specific associated vertex buffer
  97382. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97383. * - VertexBuffer.PositionKind
  97384. * - VertexBuffer.UVKind
  97385. * - VertexBuffer.UV2Kind
  97386. * - VertexBuffer.UV3Kind
  97387. * - VertexBuffer.UV4Kind
  97388. * - VertexBuffer.UV5Kind
  97389. * - VertexBuffer.UV6Kind
  97390. * - VertexBuffer.ColorKind
  97391. * - VertexBuffer.MatricesIndicesKind
  97392. * - VertexBuffer.MatricesIndicesExtraKind
  97393. * - VertexBuffer.MatricesWeightsKind
  97394. * - VertexBuffer.MatricesWeightsExtraKind
  97395. * @param data defines the data source
  97396. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  97397. * @param stride defines the data stride size (can be null)
  97398. * @returns the current mesh
  97399. */
  97400. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  97401. /**
  97402. * Delete a vertex buffer associated with this mesh
  97403. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  97404. * - VertexBuffer.PositionKind
  97405. * - VertexBuffer.UVKind
  97406. * - VertexBuffer.UV2Kind
  97407. * - VertexBuffer.UV3Kind
  97408. * - VertexBuffer.UV4Kind
  97409. * - VertexBuffer.UV5Kind
  97410. * - VertexBuffer.UV6Kind
  97411. * - VertexBuffer.ColorKind
  97412. * - VertexBuffer.MatricesIndicesKind
  97413. * - VertexBuffer.MatricesIndicesExtraKind
  97414. * - VertexBuffer.MatricesWeightsKind
  97415. * - VertexBuffer.MatricesWeightsExtraKind
  97416. */
  97417. removeVerticesData(kind: string): void;
  97418. /**
  97419. * Flags an associated vertex buffer as updatable
  97420. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  97421. * - VertexBuffer.PositionKind
  97422. * - VertexBuffer.UVKind
  97423. * - VertexBuffer.UV2Kind
  97424. * - VertexBuffer.UV3Kind
  97425. * - VertexBuffer.UV4Kind
  97426. * - VertexBuffer.UV5Kind
  97427. * - VertexBuffer.UV6Kind
  97428. * - VertexBuffer.ColorKind
  97429. * - VertexBuffer.MatricesIndicesKind
  97430. * - VertexBuffer.MatricesIndicesExtraKind
  97431. * - VertexBuffer.MatricesWeightsKind
  97432. * - VertexBuffer.MatricesWeightsExtraKind
  97433. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  97434. */
  97435. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  97436. /**
  97437. * Sets the mesh global Vertex Buffer
  97438. * @param buffer defines the buffer to use
  97439. * @returns the current mesh
  97440. */
  97441. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  97442. /**
  97443. * Update a specific associated vertex buffer
  97444. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97445. * - VertexBuffer.PositionKind
  97446. * - VertexBuffer.UVKind
  97447. * - VertexBuffer.UV2Kind
  97448. * - VertexBuffer.UV3Kind
  97449. * - VertexBuffer.UV4Kind
  97450. * - VertexBuffer.UV5Kind
  97451. * - VertexBuffer.UV6Kind
  97452. * - VertexBuffer.ColorKind
  97453. * - VertexBuffer.MatricesIndicesKind
  97454. * - VertexBuffer.MatricesIndicesExtraKind
  97455. * - VertexBuffer.MatricesWeightsKind
  97456. * - VertexBuffer.MatricesWeightsExtraKind
  97457. * @param data defines the data source
  97458. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  97459. * @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)
  97460. * @returns the current mesh
  97461. */
  97462. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  97463. /**
  97464. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  97465. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  97466. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  97467. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  97468. * @returns the current mesh
  97469. */
  97470. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  97471. /**
  97472. * Creates a un-shared specific occurence of the geometry for the mesh.
  97473. * @returns the current mesh
  97474. */
  97475. makeGeometryUnique(): Mesh;
  97476. /**
  97477. * Set the index buffer of this mesh
  97478. * @param indices defines the source data
  97479. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  97480. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  97481. * @returns the current mesh
  97482. */
  97483. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  97484. /**
  97485. * Update the current index buffer
  97486. * @param indices defines the source data
  97487. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  97488. * @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)
  97489. * @returns the current mesh
  97490. */
  97491. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  97492. /**
  97493. * Invert the geometry to move from a right handed system to a left handed one.
  97494. * @returns the current mesh
  97495. */
  97496. toLeftHanded(): Mesh;
  97497. /** @hidden */
  97498. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  97499. /** @hidden */
  97500. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  97501. /**
  97502. * Registers for this mesh a javascript function called just before the rendering process
  97503. * @param func defines the function to call before rendering this mesh
  97504. * @returns the current mesh
  97505. */
  97506. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  97507. /**
  97508. * Disposes a previously registered javascript function called before the rendering
  97509. * @param func defines the function to remove
  97510. * @returns the current mesh
  97511. */
  97512. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  97513. /**
  97514. * Registers for this mesh a javascript function called just after the rendering is complete
  97515. * @param func defines the function to call after rendering this mesh
  97516. * @returns the current mesh
  97517. */
  97518. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  97519. /**
  97520. * Disposes a previously registered javascript function called after the rendering.
  97521. * @param func defines the function to remove
  97522. * @returns the current mesh
  97523. */
  97524. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  97525. /** @hidden */
  97526. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  97527. /** @hidden */
  97528. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  97529. /** @hidden */
  97530. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  97531. /** @hidden */
  97532. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  97533. /** @hidden */
  97534. _rebuild(): void;
  97535. /** @hidden */
  97536. _freeze(): void;
  97537. /** @hidden */
  97538. _unFreeze(): void;
  97539. /**
  97540. * 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
  97541. * @param subMesh defines the subMesh to render
  97542. * @param enableAlphaMode defines if alpha mode can be changed
  97543. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  97544. * @returns the current mesh
  97545. */
  97546. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  97547. private _onBeforeDraw;
  97548. /**
  97549. * Renormalize the mesh and patch it up if there are no weights
  97550. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  97551. * However in the case of zero weights then we set just a single influence to 1.
  97552. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  97553. */
  97554. cleanMatrixWeights(): void;
  97555. private normalizeSkinFourWeights;
  97556. private normalizeSkinWeightsAndExtra;
  97557. /**
  97558. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  97559. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  97560. * the user know there was an issue with importing the mesh
  97561. * @returns a validation object with skinned, valid and report string
  97562. */
  97563. validateSkinning(): {
  97564. skinned: boolean;
  97565. valid: boolean;
  97566. report: string;
  97567. };
  97568. /** @hidden */
  97569. _checkDelayState(): Mesh;
  97570. private _queueLoad;
  97571. /**
  97572. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  97573. * A mesh is in the frustum if its bounding box intersects the frustum
  97574. * @param frustumPlanes defines the frustum to test
  97575. * @returns true if the mesh is in the frustum planes
  97576. */
  97577. isInFrustum(frustumPlanes: Plane[]): boolean;
  97578. /**
  97579. * Sets the mesh material by the material or multiMaterial `id` property
  97580. * @param id is a string identifying the material or the multiMaterial
  97581. * @returns the current mesh
  97582. */
  97583. setMaterialByID(id: string): Mesh;
  97584. /**
  97585. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  97586. * @returns an array of IAnimatable
  97587. */
  97588. getAnimatables(): IAnimatable[];
  97589. /**
  97590. * Modifies the mesh geometry according to the passed transformation matrix.
  97591. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  97592. * The mesh normals are modified using the same transformation.
  97593. * Note that, under the hood, this method sets a new VertexBuffer each call.
  97594. * @param transform defines the transform matrix to use
  97595. * @see http://doc.babylonjs.com/resources/baking_transformations
  97596. * @returns the current mesh
  97597. */
  97598. bakeTransformIntoVertices(transform: Matrix): Mesh;
  97599. /**
  97600. * Modifies the mesh geometry according to its own current World Matrix.
  97601. * The mesh World Matrix is then reset.
  97602. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  97603. * Note that, under the hood, this method sets a new VertexBuffer each call.
  97604. * @see http://doc.babylonjs.com/resources/baking_transformations
  97605. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  97606. * @returns the current mesh
  97607. */
  97608. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  97609. /** @hidden */
  97610. get _positions(): Nullable<Vector3[]>;
  97611. /** @hidden */
  97612. _resetPointsArrayCache(): Mesh;
  97613. /** @hidden */
  97614. _generatePointsArray(): boolean;
  97615. /**
  97616. * Returns a new Mesh object generated from the current mesh properties.
  97617. * This method must not get confused with createInstance()
  97618. * @param name is a string, the name given to the new mesh
  97619. * @param newParent can be any Node object (default `null`)
  97620. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  97621. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  97622. * @returns a new mesh
  97623. */
  97624. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  97625. /**
  97626. * Releases resources associated with this mesh.
  97627. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  97628. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  97629. */
  97630. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97631. /** @hidden */
  97632. _disposeInstanceSpecificData(): void;
  97633. /**
  97634. * Modifies the mesh geometry according to a displacement map.
  97635. * 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.
  97636. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  97637. * @param url is a string, the URL from the image file is to be downloaded.
  97638. * @param minHeight is the lower limit of the displacement.
  97639. * @param maxHeight is the upper limit of the displacement.
  97640. * @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.
  97641. * @param uvOffset is an optional vector2 used to offset UV.
  97642. * @param uvScale is an optional vector2 used to scale UV.
  97643. * @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.
  97644. * @returns the Mesh.
  97645. */
  97646. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  97647. /**
  97648. * Modifies the mesh geometry according to a displacementMap buffer.
  97649. * 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.
  97650. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  97651. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  97652. * @param heightMapWidth is the width of the buffer image.
  97653. * @param heightMapHeight is the height of the buffer image.
  97654. * @param minHeight is the lower limit of the displacement.
  97655. * @param maxHeight is the upper limit of the displacement.
  97656. * @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.
  97657. * @param uvOffset is an optional vector2 used to offset UV.
  97658. * @param uvScale is an optional vector2 used to scale UV.
  97659. * @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.
  97660. * @returns the Mesh.
  97661. */
  97662. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  97663. /**
  97664. * Modify the mesh to get a flat shading rendering.
  97665. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  97666. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  97667. * @returns current mesh
  97668. */
  97669. convertToFlatShadedMesh(): Mesh;
  97670. /**
  97671. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  97672. * In other words, more vertices, no more indices and a single bigger VBO.
  97673. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  97674. * @returns current mesh
  97675. */
  97676. convertToUnIndexedMesh(): Mesh;
  97677. /**
  97678. * Inverses facet orientations.
  97679. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  97680. * @param flipNormals will also inverts the normals
  97681. * @returns current mesh
  97682. */
  97683. flipFaces(flipNormals?: boolean): Mesh;
  97684. /**
  97685. * Increase the number of facets and hence vertices in a mesh
  97686. * Vertex normals are interpolated from existing vertex normals
  97687. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  97688. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  97689. */
  97690. increaseVertices(numberPerEdge: number): void;
  97691. /**
  97692. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  97693. * This will undo any application of covertToFlatShadedMesh
  97694. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  97695. */
  97696. forceSharedVertices(): void;
  97697. /** @hidden */
  97698. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  97699. /** @hidden */
  97700. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  97701. /**
  97702. * Creates a new InstancedMesh object from the mesh model.
  97703. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  97704. * @param name defines the name of the new instance
  97705. * @returns a new InstancedMesh
  97706. */
  97707. createInstance(name: string): InstancedMesh;
  97708. /**
  97709. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  97710. * After this call, all the mesh instances have the same submeshes than the current mesh.
  97711. * @returns the current mesh
  97712. */
  97713. synchronizeInstances(): Mesh;
  97714. /**
  97715. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  97716. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  97717. * This should be used together with the simplification to avoid disappearing triangles.
  97718. * @param successCallback an optional success callback to be called after the optimization finished.
  97719. * @returns the current mesh
  97720. */
  97721. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  97722. /**
  97723. * Serialize current mesh
  97724. * @param serializationObject defines the object which will receive the serialization data
  97725. */
  97726. serialize(serializationObject: any): void;
  97727. /** @hidden */
  97728. _syncGeometryWithMorphTargetManager(): void;
  97729. /** @hidden */
  97730. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  97731. /**
  97732. * Returns a new Mesh object parsed from the source provided.
  97733. * @param parsedMesh is the source
  97734. * @param scene defines the hosting scene
  97735. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  97736. * @returns a new Mesh
  97737. */
  97738. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  97739. /**
  97740. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  97741. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  97742. * @param name defines the name of the mesh to create
  97743. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  97744. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  97745. * @param closePath creates a seam between the first and the last points of each path of the path array
  97746. * @param offset is taken in account only if the `pathArray` is containing a single path
  97747. * @param scene defines the hosting scene
  97748. * @param updatable defines if the mesh must be flagged as updatable
  97749. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97750. * @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)
  97751. * @returns a new Mesh
  97752. */
  97753. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  97754. /**
  97755. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  97756. * @param name defines the name of the mesh to create
  97757. * @param radius sets the radius size (float) of the polygon (default 0.5)
  97758. * @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
  97759. * @param scene defines the hosting scene
  97760. * @param updatable defines if the mesh must be flagged as updatable
  97761. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97762. * @returns a new Mesh
  97763. */
  97764. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  97765. /**
  97766. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  97767. * @param name defines the name of the mesh to create
  97768. * @param size sets the size (float) of each box side (default 1)
  97769. * @param scene defines the hosting scene
  97770. * @param updatable defines if the mesh must be flagged as updatable
  97771. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97772. * @returns a new Mesh
  97773. */
  97774. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  97775. /**
  97776. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  97777. * @param name defines the name of the mesh to create
  97778. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  97779. * @param diameter sets the diameter size (float) of the sphere (default 1)
  97780. * @param scene defines the hosting scene
  97781. * @param updatable defines if the mesh must be flagged as updatable
  97782. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97783. * @returns a new Mesh
  97784. */
  97785. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  97786. /**
  97787. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  97788. * @param name defines the name of the mesh to create
  97789. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  97790. * @param diameter sets the diameter size (float) of the sphere (default 1)
  97791. * @param scene defines the hosting scene
  97792. * @returns a new Mesh
  97793. */
  97794. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  97795. /**
  97796. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  97797. * @param name defines the name of the mesh to create
  97798. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  97799. * @param diameterTop set the top cap diameter (floats, default 1)
  97800. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  97801. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  97802. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  97803. * @param scene defines the hosting scene
  97804. * @param updatable defines if the mesh must be flagged as updatable
  97805. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97806. * @returns a new Mesh
  97807. */
  97808. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  97809. /**
  97810. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  97811. * @param name defines the name of the mesh to create
  97812. * @param diameter sets the diameter size (float) of the torus (default 1)
  97813. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  97814. * @param tessellation sets the number of torus sides (postive integer, default 16)
  97815. * @param scene defines the hosting scene
  97816. * @param updatable defines if the mesh must be flagged as updatable
  97817. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97818. * @returns a new Mesh
  97819. */
  97820. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  97821. /**
  97822. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  97823. * @param name defines the name of the mesh to create
  97824. * @param radius sets the global radius size (float) of the torus knot (default 2)
  97825. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  97826. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  97827. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  97828. * @param p the number of windings on X axis (positive integers, default 2)
  97829. * @param q the number of windings on Y axis (positive integers, default 3)
  97830. * @param scene defines the hosting scene
  97831. * @param updatable defines if the mesh must be flagged as updatable
  97832. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97833. * @returns a new Mesh
  97834. */
  97835. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  97836. /**
  97837. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  97838. * @param name defines the name of the mesh to create
  97839. * @param points is an array successive Vector3
  97840. * @param scene defines the hosting scene
  97841. * @param updatable defines if the mesh must be flagged as updatable
  97842. * @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).
  97843. * @returns a new Mesh
  97844. */
  97845. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  97846. /**
  97847. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  97848. * @param name defines the name of the mesh to create
  97849. * @param points is an array successive Vector3
  97850. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  97851. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  97852. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  97853. * @param scene defines the hosting scene
  97854. * @param updatable defines if the mesh must be flagged as updatable
  97855. * @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)
  97856. * @returns a new Mesh
  97857. */
  97858. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  97859. /**
  97860. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  97861. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  97862. * 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.
  97863. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97864. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97865. * Remember you can only change the shape positions, not their number when updating a polygon.
  97866. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  97867. * @param name defines the name of the mesh to create
  97868. * @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
  97869. * @param scene defines the hosting scene
  97870. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  97871. * @param updatable defines if the mesh must be flagged as updatable
  97872. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97873. * @param earcutInjection can be used to inject your own earcut reference
  97874. * @returns a new Mesh
  97875. */
  97876. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  97877. /**
  97878. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  97879. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  97880. * @param name defines the name of the mesh to create
  97881. * @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
  97882. * @param depth defines the height of extrusion
  97883. * @param scene defines the hosting scene
  97884. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  97885. * @param updatable defines if the mesh must be flagged as updatable
  97886. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97887. * @param earcutInjection can be used to inject your own earcut reference
  97888. * @returns a new Mesh
  97889. */
  97890. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  97891. /**
  97892. * Creates an extruded shape mesh.
  97893. * 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
  97894. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  97895. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  97896. * @param name defines the name of the mesh to create
  97897. * @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
  97898. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  97899. * @param scale is the value to scale the shape
  97900. * @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
  97901. * @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
  97902. * @param scene defines the hosting scene
  97903. * @param updatable defines if the mesh must be flagged as updatable
  97904. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97905. * @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)
  97906. * @returns a new Mesh
  97907. */
  97908. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  97909. /**
  97910. * Creates an custom extruded shape mesh.
  97911. * The custom extrusion is a parametric shape.
  97912. * It has no predefined shape. Its final shape will depend on the input parameters.
  97913. * Please consider using the same method from the MeshBuilder class instead
  97914. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  97915. * @param name defines the name of the mesh to create
  97916. * @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
  97917. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  97918. * @param scaleFunction is a custom Javascript function called on each path point
  97919. * @param rotationFunction is a custom Javascript function called on each path point
  97920. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  97921. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  97922. * @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
  97923. * @param scene defines the hosting scene
  97924. * @param updatable defines if the mesh must be flagged as updatable
  97925. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97926. * @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)
  97927. * @returns a new Mesh
  97928. */
  97929. 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;
  97930. /**
  97931. * Creates lathe mesh.
  97932. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  97933. * Please consider using the same method from the MeshBuilder class instead
  97934. * @param name defines the name of the mesh to create
  97935. * @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
  97936. * @param radius is the radius value of the lathe
  97937. * @param tessellation is the side number of the lathe.
  97938. * @param scene defines the hosting scene
  97939. * @param updatable defines if the mesh must be flagged as updatable
  97940. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97941. * @returns a new Mesh
  97942. */
  97943. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  97944. /**
  97945. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  97946. * @param name defines the name of the mesh to create
  97947. * @param size sets the size (float) of both sides of the plane at once (default 1)
  97948. * @param scene defines the hosting scene
  97949. * @param updatable defines if the mesh must be flagged as updatable
  97950. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  97951. * @returns a new Mesh
  97952. */
  97953. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  97954. /**
  97955. * Creates a ground mesh.
  97956. * Please consider using the same method from the MeshBuilder class instead
  97957. * @param name defines the name of the mesh to create
  97958. * @param width set the width of the ground
  97959. * @param height set the height of the ground
  97960. * @param subdivisions sets the number of subdivisions per side
  97961. * @param scene defines the hosting scene
  97962. * @param updatable defines if the mesh must be flagged as updatable
  97963. * @returns a new Mesh
  97964. */
  97965. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  97966. /**
  97967. * Creates a tiled ground mesh.
  97968. * Please consider using the same method from the MeshBuilder class instead
  97969. * @param name defines the name of the mesh to create
  97970. * @param xmin set the ground minimum X coordinate
  97971. * @param zmin set the ground minimum Y coordinate
  97972. * @param xmax set the ground maximum X coordinate
  97973. * @param zmax set the ground maximum Z coordinate
  97974. * @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
  97975. * @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
  97976. * @param scene defines the hosting scene
  97977. * @param updatable defines if the mesh must be flagged as updatable
  97978. * @returns a new Mesh
  97979. */
  97980. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  97981. w: number;
  97982. h: number;
  97983. }, precision: {
  97984. w: number;
  97985. h: number;
  97986. }, scene: Scene, updatable?: boolean): Mesh;
  97987. /**
  97988. * Creates a ground mesh from a height map.
  97989. * Please consider using the same method from the MeshBuilder class instead
  97990. * @see http://doc.babylonjs.com/babylon101/height_map
  97991. * @param name defines the name of the mesh to create
  97992. * @param url sets the URL of the height map image resource
  97993. * @param width set the ground width size
  97994. * @param height set the ground height size
  97995. * @param subdivisions sets the number of subdivision per side
  97996. * @param minHeight is the minimum altitude on the ground
  97997. * @param maxHeight is the maximum altitude on the ground
  97998. * @param scene defines the hosting scene
  97999. * @param updatable defines if the mesh must be flagged as updatable
  98000. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  98001. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  98002. * @returns a new Mesh
  98003. */
  98004. 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;
  98005. /**
  98006. * Creates a tube mesh.
  98007. * The tube is a parametric shape.
  98008. * It has no predefined shape. Its final shape will depend on the input parameters.
  98009. * Please consider using the same method from the MeshBuilder class instead
  98010. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98011. * @param name defines the name of the mesh to create
  98012. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  98013. * @param radius sets the tube radius size
  98014. * @param tessellation is the number of sides on the tubular surface
  98015. * @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
  98016. * @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
  98017. * @param scene defines the hosting scene
  98018. * @param updatable defines if the mesh must be flagged as updatable
  98019. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98020. * @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)
  98021. * @returns a new Mesh
  98022. */
  98023. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  98024. (i: number, distance: number): number;
  98025. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98026. /**
  98027. * Creates a polyhedron mesh.
  98028. * Please consider using the same method from the MeshBuilder class instead.
  98029. * * 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
  98030. * * The parameter `size` (positive float, default 1) sets the polygon size
  98031. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  98032. * * 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`
  98033. * * 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
  98034. * * 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)`)
  98035. * * 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
  98036. * * 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
  98037. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98038. * * 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
  98039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98040. * @param name defines the name of the mesh to create
  98041. * @param options defines the options used to create the mesh
  98042. * @param scene defines the hosting scene
  98043. * @returns a new Mesh
  98044. */
  98045. static CreatePolyhedron(name: string, options: {
  98046. type?: number;
  98047. size?: number;
  98048. sizeX?: number;
  98049. sizeY?: number;
  98050. sizeZ?: number;
  98051. custom?: any;
  98052. faceUV?: Vector4[];
  98053. faceColors?: Color4[];
  98054. updatable?: boolean;
  98055. sideOrientation?: number;
  98056. }, scene: Scene): Mesh;
  98057. /**
  98058. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  98059. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  98060. * * 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`)
  98061. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  98062. * * 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
  98063. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98064. * * 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
  98065. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98066. * @param name defines the name of the mesh
  98067. * @param options defines the options used to create the mesh
  98068. * @param scene defines the hosting scene
  98069. * @returns a new Mesh
  98070. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  98071. */
  98072. static CreateIcoSphere(name: string, options: {
  98073. radius?: number;
  98074. flat?: boolean;
  98075. subdivisions?: number;
  98076. sideOrientation?: number;
  98077. updatable?: boolean;
  98078. }, scene: Scene): Mesh;
  98079. /**
  98080. * Creates a decal mesh.
  98081. * Please consider using the same method from the MeshBuilder class instead.
  98082. * A decal is a mesh usually applied as a model onto the surface of another mesh
  98083. * @param name defines the name of the mesh
  98084. * @param sourceMesh defines the mesh receiving the decal
  98085. * @param position sets the position of the decal in world coordinates
  98086. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  98087. * @param size sets the decal scaling
  98088. * @param angle sets the angle to rotate the decal
  98089. * @returns a new Mesh
  98090. */
  98091. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  98092. /**
  98093. * Prepare internal position array for software CPU skinning
  98094. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  98095. */
  98096. setPositionsForCPUSkinning(): Float32Array;
  98097. /**
  98098. * Prepare internal normal array for software CPU skinning
  98099. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  98100. */
  98101. setNormalsForCPUSkinning(): Float32Array;
  98102. /**
  98103. * Updates the vertex buffer by applying transformation from the bones
  98104. * @param skeleton defines the skeleton to apply to current mesh
  98105. * @returns the current mesh
  98106. */
  98107. applySkeleton(skeleton: Skeleton): Mesh;
  98108. /**
  98109. * 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
  98110. * @param meshes defines the list of meshes to scan
  98111. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  98112. */
  98113. static MinMax(meshes: AbstractMesh[]): {
  98114. min: Vector3;
  98115. max: Vector3;
  98116. };
  98117. /**
  98118. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  98119. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  98120. * @returns a vector3
  98121. */
  98122. static Center(meshesOrMinMaxVector: {
  98123. min: Vector3;
  98124. max: Vector3;
  98125. } | AbstractMesh[]): Vector3;
  98126. /**
  98127. * Merge the array of meshes into a single mesh for performance reasons.
  98128. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  98129. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  98130. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  98131. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  98132. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  98133. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  98134. * @returns a new mesh
  98135. */
  98136. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  98137. /** @hidden */
  98138. addInstance(instance: InstancedMesh): void;
  98139. /** @hidden */
  98140. removeInstance(instance: InstancedMesh): void;
  98141. }
  98142. }
  98143. declare module BABYLON {
  98144. /**
  98145. * This is the base class of all the camera used in the application.
  98146. * @see http://doc.babylonjs.com/features/cameras
  98147. */
  98148. export class Camera extends Node {
  98149. /** @hidden */
  98150. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  98151. /**
  98152. * This is the default projection mode used by the cameras.
  98153. * It helps recreating a feeling of perspective and better appreciate depth.
  98154. * This is the best way to simulate real life cameras.
  98155. */
  98156. static readonly PERSPECTIVE_CAMERA: number;
  98157. /**
  98158. * This helps creating camera with an orthographic mode.
  98159. * 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.
  98160. */
  98161. static readonly ORTHOGRAPHIC_CAMERA: number;
  98162. /**
  98163. * This is the default FOV mode for perspective cameras.
  98164. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  98165. */
  98166. static readonly FOVMODE_VERTICAL_FIXED: number;
  98167. /**
  98168. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  98169. */
  98170. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  98171. /**
  98172. * This specifies ther is no need for a camera rig.
  98173. * Basically only one eye is rendered corresponding to the camera.
  98174. */
  98175. static readonly RIG_MODE_NONE: number;
  98176. /**
  98177. * Simulates a camera Rig with one blue eye and one red eye.
  98178. * This can be use with 3d blue and red glasses.
  98179. */
  98180. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  98181. /**
  98182. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  98183. */
  98184. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  98185. /**
  98186. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  98187. */
  98188. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  98189. /**
  98190. * Defines that both eyes of the camera will be rendered over under each other.
  98191. */
  98192. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  98193. /**
  98194. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  98195. */
  98196. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  98197. /**
  98198. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  98199. */
  98200. static readonly RIG_MODE_VR: number;
  98201. /**
  98202. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  98203. */
  98204. static readonly RIG_MODE_WEBVR: number;
  98205. /**
  98206. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  98207. */
  98208. static readonly RIG_MODE_CUSTOM: number;
  98209. /**
  98210. * Defines if by default attaching controls should prevent the default javascript event to continue.
  98211. */
  98212. static ForceAttachControlToAlwaysPreventDefault: boolean;
  98213. /**
  98214. * Define the input manager associated with the camera.
  98215. */
  98216. inputs: CameraInputsManager<Camera>;
  98217. /** @hidden */
  98218. _position: Vector3;
  98219. /**
  98220. * Define the current local position of the camera in the scene
  98221. */
  98222. get position(): Vector3;
  98223. set position(newPosition: Vector3);
  98224. /**
  98225. * The vector the camera should consider as up.
  98226. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  98227. */
  98228. upVector: Vector3;
  98229. /**
  98230. * Define the current limit on the left side for an orthographic camera
  98231. * In scene unit
  98232. */
  98233. orthoLeft: Nullable<number>;
  98234. /**
  98235. * Define the current limit on the right side for an orthographic camera
  98236. * In scene unit
  98237. */
  98238. orthoRight: Nullable<number>;
  98239. /**
  98240. * Define the current limit on the bottom side for an orthographic camera
  98241. * In scene unit
  98242. */
  98243. orthoBottom: Nullable<number>;
  98244. /**
  98245. * Define the current limit on the top side for an orthographic camera
  98246. * In scene unit
  98247. */
  98248. orthoTop: Nullable<number>;
  98249. /**
  98250. * Field Of View is set in Radians. (default is 0.8)
  98251. */
  98252. fov: number;
  98253. /**
  98254. * Define the minimum distance the camera can see from.
  98255. * This is important to note that the depth buffer are not infinite and the closer it starts
  98256. * the more your scene might encounter depth fighting issue.
  98257. */
  98258. minZ: number;
  98259. /**
  98260. * Define the maximum distance the camera can see to.
  98261. * This is important to note that the depth buffer are not infinite and the further it end
  98262. * the more your scene might encounter depth fighting issue.
  98263. */
  98264. maxZ: number;
  98265. /**
  98266. * Define the default inertia of the camera.
  98267. * This helps giving a smooth feeling to the camera movement.
  98268. */
  98269. inertia: number;
  98270. /**
  98271. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  98272. */
  98273. mode: number;
  98274. /**
  98275. * Define whether the camera is intermediate.
  98276. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  98277. */
  98278. isIntermediate: boolean;
  98279. /**
  98280. * Define the viewport of the camera.
  98281. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  98282. */
  98283. viewport: Viewport;
  98284. /**
  98285. * Restricts the camera to viewing objects with the same layerMask.
  98286. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  98287. */
  98288. layerMask: number;
  98289. /**
  98290. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  98291. */
  98292. fovMode: number;
  98293. /**
  98294. * Rig mode of the camera.
  98295. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  98296. * This is normally controlled byt the camera themselves as internal use.
  98297. */
  98298. cameraRigMode: number;
  98299. /**
  98300. * Defines the distance between both "eyes" in case of a RIG
  98301. */
  98302. interaxialDistance: number;
  98303. /**
  98304. * Defines if stereoscopic rendering is done side by side or over under.
  98305. */
  98306. isStereoscopicSideBySide: boolean;
  98307. /**
  98308. * 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
  98309. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  98310. * else in the scene. (Eg. security camera)
  98311. *
  98312. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  98313. */
  98314. customRenderTargets: RenderTargetTexture[];
  98315. /**
  98316. * When set, the camera will render to this render target instead of the default canvas
  98317. *
  98318. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  98319. */
  98320. outputRenderTarget: Nullable<RenderTargetTexture>;
  98321. /**
  98322. * Observable triggered when the camera view matrix has changed.
  98323. */
  98324. onViewMatrixChangedObservable: Observable<Camera>;
  98325. /**
  98326. * Observable triggered when the camera Projection matrix has changed.
  98327. */
  98328. onProjectionMatrixChangedObservable: Observable<Camera>;
  98329. /**
  98330. * Observable triggered when the inputs have been processed.
  98331. */
  98332. onAfterCheckInputsObservable: Observable<Camera>;
  98333. /**
  98334. * Observable triggered when reset has been called and applied to the camera.
  98335. */
  98336. onRestoreStateObservable: Observable<Camera>;
  98337. /**
  98338. * Is this camera a part of a rig system?
  98339. */
  98340. isRigCamera: boolean;
  98341. /**
  98342. * If isRigCamera set to true this will be set with the parent camera.
  98343. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  98344. */
  98345. rigParent?: Camera;
  98346. /** @hidden */
  98347. _cameraRigParams: any;
  98348. /** @hidden */
  98349. _rigCameras: Camera[];
  98350. /** @hidden */
  98351. _rigPostProcess: Nullable<PostProcess>;
  98352. protected _webvrViewMatrix: Matrix;
  98353. /** @hidden */
  98354. _skipRendering: boolean;
  98355. /** @hidden */
  98356. _projectionMatrix: Matrix;
  98357. /** @hidden */
  98358. _postProcesses: Nullable<PostProcess>[];
  98359. /** @hidden */
  98360. _activeMeshes: SmartArray<AbstractMesh>;
  98361. protected _globalPosition: Vector3;
  98362. /** @hidden */
  98363. _computedViewMatrix: Matrix;
  98364. private _doNotComputeProjectionMatrix;
  98365. private _transformMatrix;
  98366. private _frustumPlanes;
  98367. private _refreshFrustumPlanes;
  98368. private _storedFov;
  98369. private _stateStored;
  98370. /**
  98371. * Instantiates a new camera object.
  98372. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  98373. * @see http://doc.babylonjs.com/features/cameras
  98374. * @param name Defines the name of the camera in the scene
  98375. * @param position Defines the position of the camera
  98376. * @param scene Defines the scene the camera belongs too
  98377. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  98378. */
  98379. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98380. /**
  98381. * Store current camera state (fov, position, etc..)
  98382. * @returns the camera
  98383. */
  98384. storeState(): Camera;
  98385. /**
  98386. * Restores the camera state values if it has been stored. You must call storeState() first
  98387. */
  98388. protected _restoreStateValues(): boolean;
  98389. /**
  98390. * Restored camera state. You must call storeState() first.
  98391. * @returns true if restored and false otherwise
  98392. */
  98393. restoreState(): boolean;
  98394. /**
  98395. * Gets the class name of the camera.
  98396. * @returns the class name
  98397. */
  98398. getClassName(): string;
  98399. /** @hidden */
  98400. readonly _isCamera: boolean;
  98401. /**
  98402. * Gets a string representation of the camera useful for debug purpose.
  98403. * @param fullDetails Defines that a more verboe level of logging is required
  98404. * @returns the string representation
  98405. */
  98406. toString(fullDetails?: boolean): string;
  98407. /**
  98408. * Gets the current world space position of the camera.
  98409. */
  98410. get globalPosition(): Vector3;
  98411. /**
  98412. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  98413. * @returns the active meshe list
  98414. */
  98415. getActiveMeshes(): SmartArray<AbstractMesh>;
  98416. /**
  98417. * Check whether a mesh is part of the current active mesh list of the camera
  98418. * @param mesh Defines the mesh to check
  98419. * @returns true if active, false otherwise
  98420. */
  98421. isActiveMesh(mesh: Mesh): boolean;
  98422. /**
  98423. * Is this camera ready to be used/rendered
  98424. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  98425. * @return true if the camera is ready
  98426. */
  98427. isReady(completeCheck?: boolean): boolean;
  98428. /** @hidden */
  98429. _initCache(): void;
  98430. /** @hidden */
  98431. _updateCache(ignoreParentClass?: boolean): void;
  98432. /** @hidden */
  98433. _isSynchronized(): boolean;
  98434. /** @hidden */
  98435. _isSynchronizedViewMatrix(): boolean;
  98436. /** @hidden */
  98437. _isSynchronizedProjectionMatrix(): boolean;
  98438. /**
  98439. * Attach the input controls to a specific dom element to get the input from.
  98440. * @param element Defines the element the controls should be listened from
  98441. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98442. */
  98443. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98444. /**
  98445. * Detach the current controls from the specified dom element.
  98446. * @param element Defines the element to stop listening the inputs from
  98447. */
  98448. detachControl(element: HTMLElement): void;
  98449. /**
  98450. * Update the camera state according to the different inputs gathered during the frame.
  98451. */
  98452. update(): void;
  98453. /** @hidden */
  98454. _checkInputs(): void;
  98455. /** @hidden */
  98456. get rigCameras(): Camera[];
  98457. /**
  98458. * Gets the post process used by the rig cameras
  98459. */
  98460. get rigPostProcess(): Nullable<PostProcess>;
  98461. /**
  98462. * Internal, gets the first post proces.
  98463. * @returns the first post process to be run on this camera.
  98464. */
  98465. _getFirstPostProcess(): Nullable<PostProcess>;
  98466. private _cascadePostProcessesToRigCams;
  98467. /**
  98468. * Attach a post process to the camera.
  98469. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  98470. * @param postProcess The post process to attach to the camera
  98471. * @param insertAt The position of the post process in case several of them are in use in the scene
  98472. * @returns the position the post process has been inserted at
  98473. */
  98474. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  98475. /**
  98476. * Detach a post process to the camera.
  98477. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  98478. * @param postProcess The post process to detach from the camera
  98479. */
  98480. detachPostProcess(postProcess: PostProcess): void;
  98481. /**
  98482. * Gets the current world matrix of the camera
  98483. */
  98484. getWorldMatrix(): Matrix;
  98485. /** @hidden */
  98486. _getViewMatrix(): Matrix;
  98487. /**
  98488. * Gets the current view matrix of the camera.
  98489. * @param force forces the camera to recompute the matrix without looking at the cached state
  98490. * @returns the view matrix
  98491. */
  98492. getViewMatrix(force?: boolean): Matrix;
  98493. /**
  98494. * Freeze the projection matrix.
  98495. * It will prevent the cache check of the camera projection compute and can speed up perf
  98496. * if no parameter of the camera are meant to change
  98497. * @param projection Defines manually a projection if necessary
  98498. */
  98499. freezeProjectionMatrix(projection?: Matrix): void;
  98500. /**
  98501. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  98502. */
  98503. unfreezeProjectionMatrix(): void;
  98504. /**
  98505. * Gets the current projection matrix of the camera.
  98506. * @param force forces the camera to recompute the matrix without looking at the cached state
  98507. * @returns the projection matrix
  98508. */
  98509. getProjectionMatrix(force?: boolean): Matrix;
  98510. /**
  98511. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  98512. * @returns a Matrix
  98513. */
  98514. getTransformationMatrix(): Matrix;
  98515. private _updateFrustumPlanes;
  98516. /**
  98517. * Checks if a cullable object (mesh...) is in the camera frustum
  98518. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  98519. * @param target The object to check
  98520. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  98521. * @returns true if the object is in frustum otherwise false
  98522. */
  98523. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  98524. /**
  98525. * Checks if a cullable object (mesh...) is in the camera frustum
  98526. * Unlike isInFrustum this cheks the full bounding box
  98527. * @param target The object to check
  98528. * @returns true if the object is in frustum otherwise false
  98529. */
  98530. isCompletelyInFrustum(target: ICullable): boolean;
  98531. /**
  98532. * Gets a ray in the forward direction from the camera.
  98533. * @param length Defines the length of the ray to create
  98534. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  98535. * @param origin Defines the start point of the ray which defaults to the camera position
  98536. * @returns the forward ray
  98537. */
  98538. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  98539. /**
  98540. * Releases resources associated with this node.
  98541. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98542. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98543. */
  98544. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98545. /** @hidden */
  98546. _isLeftCamera: boolean;
  98547. /**
  98548. * Gets the left camera of a rig setup in case of Rigged Camera
  98549. */
  98550. get isLeftCamera(): boolean;
  98551. /** @hidden */
  98552. _isRightCamera: boolean;
  98553. /**
  98554. * Gets the right camera of a rig setup in case of Rigged Camera
  98555. */
  98556. get isRightCamera(): boolean;
  98557. /**
  98558. * Gets the left camera of a rig setup in case of Rigged Camera
  98559. */
  98560. get leftCamera(): Nullable<FreeCamera>;
  98561. /**
  98562. * Gets the right camera of a rig setup in case of Rigged Camera
  98563. */
  98564. get rightCamera(): Nullable<FreeCamera>;
  98565. /**
  98566. * Gets the left camera target of a rig setup in case of Rigged Camera
  98567. * @returns the target position
  98568. */
  98569. getLeftTarget(): Nullable<Vector3>;
  98570. /**
  98571. * Gets the right camera target of a rig setup in case of Rigged Camera
  98572. * @returns the target position
  98573. */
  98574. getRightTarget(): Nullable<Vector3>;
  98575. /**
  98576. * @hidden
  98577. */
  98578. setCameraRigMode(mode: number, rigParams: any): void;
  98579. /** @hidden */
  98580. static _setStereoscopicRigMode(camera: Camera): void;
  98581. /** @hidden */
  98582. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  98583. /** @hidden */
  98584. static _setVRRigMode(camera: Camera, rigParams: any): void;
  98585. /** @hidden */
  98586. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  98587. /** @hidden */
  98588. _getVRProjectionMatrix(): Matrix;
  98589. protected _updateCameraRotationMatrix(): void;
  98590. protected _updateWebVRCameraRotationMatrix(): void;
  98591. /**
  98592. * This function MUST be overwritten by the different WebVR cameras available.
  98593. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  98594. * @hidden
  98595. */
  98596. _getWebVRProjectionMatrix(): Matrix;
  98597. /**
  98598. * This function MUST be overwritten by the different WebVR cameras available.
  98599. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  98600. * @hidden
  98601. */
  98602. _getWebVRViewMatrix(): Matrix;
  98603. /** @hidden */
  98604. setCameraRigParameter(name: string, value: any): void;
  98605. /**
  98606. * needs to be overridden by children so sub has required properties to be copied
  98607. * @hidden
  98608. */
  98609. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  98610. /**
  98611. * May need to be overridden by children
  98612. * @hidden
  98613. */
  98614. _updateRigCameras(): void;
  98615. /** @hidden */
  98616. _setupInputs(): void;
  98617. /**
  98618. * Serialiaze the camera setup to a json represention
  98619. * @returns the JSON representation
  98620. */
  98621. serialize(): any;
  98622. /**
  98623. * Clones the current camera.
  98624. * @param name The cloned camera name
  98625. * @returns the cloned camera
  98626. */
  98627. clone(name: string): Camera;
  98628. /**
  98629. * Gets the direction of the camera relative to a given local axis.
  98630. * @param localAxis Defines the reference axis to provide a relative direction.
  98631. * @return the direction
  98632. */
  98633. getDirection(localAxis: Vector3): Vector3;
  98634. /**
  98635. * Returns the current camera absolute rotation
  98636. */
  98637. get absoluteRotation(): Quaternion;
  98638. /**
  98639. * Gets the direction of the camera relative to a given local axis into a passed vector.
  98640. * @param localAxis Defines the reference axis to provide a relative direction.
  98641. * @param result Defines the vector to store the result in
  98642. */
  98643. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  98644. /**
  98645. * Gets a camera constructor for a given camera type
  98646. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  98647. * @param name The name of the camera the result will be able to instantiate
  98648. * @param scene The scene the result will construct the camera in
  98649. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  98650. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  98651. * @returns a factory method to construc the camera
  98652. */
  98653. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  98654. /**
  98655. * Compute the world matrix of the camera.
  98656. * @returns the camera world matrix
  98657. */
  98658. computeWorldMatrix(): Matrix;
  98659. /**
  98660. * Parse a JSON and creates the camera from the parsed information
  98661. * @param parsedCamera The JSON to parse
  98662. * @param scene The scene to instantiate the camera in
  98663. * @returns the newly constructed camera
  98664. */
  98665. static Parse(parsedCamera: any, scene: Scene): Camera;
  98666. }
  98667. }
  98668. declare module BABYLON {
  98669. /**
  98670. * Class containing static functions to help procedurally build meshes
  98671. */
  98672. export class DiscBuilder {
  98673. /**
  98674. * Creates a plane polygonal mesh. By default, this is a disc
  98675. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  98676. * * 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
  98677. * * 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
  98678. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98679. * * 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
  98680. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98681. * @param name defines the name of the mesh
  98682. * @param options defines the options used to create the mesh
  98683. * @param scene defines the hosting scene
  98684. * @returns the plane polygonal mesh
  98685. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  98686. */
  98687. static CreateDisc(name: string, options: {
  98688. radius?: number;
  98689. tessellation?: number;
  98690. arc?: number;
  98691. updatable?: boolean;
  98692. sideOrientation?: number;
  98693. frontUVs?: Vector4;
  98694. backUVs?: Vector4;
  98695. }, scene?: Nullable<Scene>): Mesh;
  98696. }
  98697. }
  98698. declare module BABYLON {
  98699. /**
  98700. * This represents all the required information to add a fresnel effect on a material:
  98701. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98702. */
  98703. export class FresnelParameters {
  98704. private _isEnabled;
  98705. /**
  98706. * Define if the fresnel effect is enable or not.
  98707. */
  98708. get isEnabled(): boolean;
  98709. set isEnabled(value: boolean);
  98710. /**
  98711. * Define the color used on edges (grazing angle)
  98712. */
  98713. leftColor: Color3;
  98714. /**
  98715. * Define the color used on center
  98716. */
  98717. rightColor: Color3;
  98718. /**
  98719. * Define bias applied to computed fresnel term
  98720. */
  98721. bias: number;
  98722. /**
  98723. * Defined the power exponent applied to fresnel term
  98724. */
  98725. power: number;
  98726. /**
  98727. * Clones the current fresnel and its valuues
  98728. * @returns a clone fresnel configuration
  98729. */
  98730. clone(): FresnelParameters;
  98731. /**
  98732. * Serializes the current fresnel parameters to a JSON representation.
  98733. * @return the JSON serialization
  98734. */
  98735. serialize(): any;
  98736. /**
  98737. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  98738. * @param parsedFresnelParameters Define the JSON representation
  98739. * @returns the parsed parameters
  98740. */
  98741. static Parse(parsedFresnelParameters: any): FresnelParameters;
  98742. }
  98743. }
  98744. declare module BABYLON {
  98745. /**
  98746. * Base class of materials working in push mode in babylon JS
  98747. * @hidden
  98748. */
  98749. export class PushMaterial extends Material {
  98750. protected _activeEffect: Effect;
  98751. protected _normalMatrix: Matrix;
  98752. /**
  98753. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  98754. * This means that the material can keep using a previous shader while a new one is being compiled.
  98755. * This is mostly used when shader parallel compilation is supported (true by default)
  98756. */
  98757. allowShaderHotSwapping: boolean;
  98758. constructor(name: string, scene: Scene);
  98759. getEffect(): Effect;
  98760. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  98761. /**
  98762. * Binds the given world matrix to the active effect
  98763. *
  98764. * @param world the matrix to bind
  98765. */
  98766. bindOnlyWorldMatrix(world: Matrix): void;
  98767. /**
  98768. * Binds the given normal matrix to the active effect
  98769. *
  98770. * @param normalMatrix the matrix to bind
  98771. */
  98772. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  98773. bind(world: Matrix, mesh?: Mesh): void;
  98774. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  98775. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  98776. }
  98777. }
  98778. declare module BABYLON {
  98779. /**
  98780. * This groups all the flags used to control the materials channel.
  98781. */
  98782. export class MaterialFlags {
  98783. private static _DiffuseTextureEnabled;
  98784. /**
  98785. * Are diffuse textures enabled in the application.
  98786. */
  98787. static get DiffuseTextureEnabled(): boolean;
  98788. static set DiffuseTextureEnabled(value: boolean);
  98789. private static _AmbientTextureEnabled;
  98790. /**
  98791. * Are ambient textures enabled in the application.
  98792. */
  98793. static get AmbientTextureEnabled(): boolean;
  98794. static set AmbientTextureEnabled(value: boolean);
  98795. private static _OpacityTextureEnabled;
  98796. /**
  98797. * Are opacity textures enabled in the application.
  98798. */
  98799. static get OpacityTextureEnabled(): boolean;
  98800. static set OpacityTextureEnabled(value: boolean);
  98801. private static _ReflectionTextureEnabled;
  98802. /**
  98803. * Are reflection textures enabled in the application.
  98804. */
  98805. static get ReflectionTextureEnabled(): boolean;
  98806. static set ReflectionTextureEnabled(value: boolean);
  98807. private static _EmissiveTextureEnabled;
  98808. /**
  98809. * Are emissive textures enabled in the application.
  98810. */
  98811. static get EmissiveTextureEnabled(): boolean;
  98812. static set EmissiveTextureEnabled(value: boolean);
  98813. private static _SpecularTextureEnabled;
  98814. /**
  98815. * Are specular textures enabled in the application.
  98816. */
  98817. static get SpecularTextureEnabled(): boolean;
  98818. static set SpecularTextureEnabled(value: boolean);
  98819. private static _BumpTextureEnabled;
  98820. /**
  98821. * Are bump textures enabled in the application.
  98822. */
  98823. static get BumpTextureEnabled(): boolean;
  98824. static set BumpTextureEnabled(value: boolean);
  98825. private static _LightmapTextureEnabled;
  98826. /**
  98827. * Are lightmap textures enabled in the application.
  98828. */
  98829. static get LightmapTextureEnabled(): boolean;
  98830. static set LightmapTextureEnabled(value: boolean);
  98831. private static _RefractionTextureEnabled;
  98832. /**
  98833. * Are refraction textures enabled in the application.
  98834. */
  98835. static get RefractionTextureEnabled(): boolean;
  98836. static set RefractionTextureEnabled(value: boolean);
  98837. private static _ColorGradingTextureEnabled;
  98838. /**
  98839. * Are color grading textures enabled in the application.
  98840. */
  98841. static get ColorGradingTextureEnabled(): boolean;
  98842. static set ColorGradingTextureEnabled(value: boolean);
  98843. private static _FresnelEnabled;
  98844. /**
  98845. * Are fresnels enabled in the application.
  98846. */
  98847. static get FresnelEnabled(): boolean;
  98848. static set FresnelEnabled(value: boolean);
  98849. private static _ClearCoatTextureEnabled;
  98850. /**
  98851. * Are clear coat textures enabled in the application.
  98852. */
  98853. static get ClearCoatTextureEnabled(): boolean;
  98854. static set ClearCoatTextureEnabled(value: boolean);
  98855. private static _ClearCoatBumpTextureEnabled;
  98856. /**
  98857. * Are clear coat bump textures enabled in the application.
  98858. */
  98859. static get ClearCoatBumpTextureEnabled(): boolean;
  98860. static set ClearCoatBumpTextureEnabled(value: boolean);
  98861. private static _ClearCoatTintTextureEnabled;
  98862. /**
  98863. * Are clear coat tint textures enabled in the application.
  98864. */
  98865. static get ClearCoatTintTextureEnabled(): boolean;
  98866. static set ClearCoatTintTextureEnabled(value: boolean);
  98867. private static _SheenTextureEnabled;
  98868. /**
  98869. * Are sheen textures enabled in the application.
  98870. */
  98871. static get SheenTextureEnabled(): boolean;
  98872. static set SheenTextureEnabled(value: boolean);
  98873. private static _AnisotropicTextureEnabled;
  98874. /**
  98875. * Are anisotropic textures enabled in the application.
  98876. */
  98877. static get AnisotropicTextureEnabled(): boolean;
  98878. static set AnisotropicTextureEnabled(value: boolean);
  98879. private static _ThicknessTextureEnabled;
  98880. /**
  98881. * Are thickness textures enabled in the application.
  98882. */
  98883. static get ThicknessTextureEnabled(): boolean;
  98884. static set ThicknessTextureEnabled(value: boolean);
  98885. }
  98886. }
  98887. declare module BABYLON {
  98888. /** @hidden */
  98889. export var defaultFragmentDeclaration: {
  98890. name: string;
  98891. shader: string;
  98892. };
  98893. }
  98894. declare module BABYLON {
  98895. /** @hidden */
  98896. export var defaultUboDeclaration: {
  98897. name: string;
  98898. shader: string;
  98899. };
  98900. }
  98901. declare module BABYLON {
  98902. /** @hidden */
  98903. export var lightFragmentDeclaration: {
  98904. name: string;
  98905. shader: string;
  98906. };
  98907. }
  98908. declare module BABYLON {
  98909. /** @hidden */
  98910. export var lightUboDeclaration: {
  98911. name: string;
  98912. shader: string;
  98913. };
  98914. }
  98915. declare module BABYLON {
  98916. /** @hidden */
  98917. export var lightsFragmentFunctions: {
  98918. name: string;
  98919. shader: string;
  98920. };
  98921. }
  98922. declare module BABYLON {
  98923. /** @hidden */
  98924. export var shadowsFragmentFunctions: {
  98925. name: string;
  98926. shader: string;
  98927. };
  98928. }
  98929. declare module BABYLON {
  98930. /** @hidden */
  98931. export var fresnelFunction: {
  98932. name: string;
  98933. shader: string;
  98934. };
  98935. }
  98936. declare module BABYLON {
  98937. /** @hidden */
  98938. export var reflectionFunction: {
  98939. name: string;
  98940. shader: string;
  98941. };
  98942. }
  98943. declare module BABYLON {
  98944. /** @hidden */
  98945. export var bumpFragmentFunctions: {
  98946. name: string;
  98947. shader: string;
  98948. };
  98949. }
  98950. declare module BABYLON {
  98951. /** @hidden */
  98952. export var logDepthDeclaration: {
  98953. name: string;
  98954. shader: string;
  98955. };
  98956. }
  98957. declare module BABYLON {
  98958. /** @hidden */
  98959. export var bumpFragment: {
  98960. name: string;
  98961. shader: string;
  98962. };
  98963. }
  98964. declare module BABYLON {
  98965. /** @hidden */
  98966. export var depthPrePass: {
  98967. name: string;
  98968. shader: string;
  98969. };
  98970. }
  98971. declare module BABYLON {
  98972. /** @hidden */
  98973. export var lightFragment: {
  98974. name: string;
  98975. shader: string;
  98976. };
  98977. }
  98978. declare module BABYLON {
  98979. /** @hidden */
  98980. export var logDepthFragment: {
  98981. name: string;
  98982. shader: string;
  98983. };
  98984. }
  98985. declare module BABYLON {
  98986. /** @hidden */
  98987. export var defaultPixelShader: {
  98988. name: string;
  98989. shader: string;
  98990. };
  98991. }
  98992. declare module BABYLON {
  98993. /** @hidden */
  98994. export var defaultVertexDeclaration: {
  98995. name: string;
  98996. shader: string;
  98997. };
  98998. }
  98999. declare module BABYLON {
  99000. /** @hidden */
  99001. export var bumpVertexDeclaration: {
  99002. name: string;
  99003. shader: string;
  99004. };
  99005. }
  99006. declare module BABYLON {
  99007. /** @hidden */
  99008. export var bumpVertex: {
  99009. name: string;
  99010. shader: string;
  99011. };
  99012. }
  99013. declare module BABYLON {
  99014. /** @hidden */
  99015. export var fogVertex: {
  99016. name: string;
  99017. shader: string;
  99018. };
  99019. }
  99020. declare module BABYLON {
  99021. /** @hidden */
  99022. export var shadowsVertex: {
  99023. name: string;
  99024. shader: string;
  99025. };
  99026. }
  99027. declare module BABYLON {
  99028. /** @hidden */
  99029. export var pointCloudVertex: {
  99030. name: string;
  99031. shader: string;
  99032. };
  99033. }
  99034. declare module BABYLON {
  99035. /** @hidden */
  99036. export var logDepthVertex: {
  99037. name: string;
  99038. shader: string;
  99039. };
  99040. }
  99041. declare module BABYLON {
  99042. /** @hidden */
  99043. export var defaultVertexShader: {
  99044. name: string;
  99045. shader: string;
  99046. };
  99047. }
  99048. declare module BABYLON {
  99049. /** @hidden */
  99050. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  99051. MAINUV1: boolean;
  99052. MAINUV2: boolean;
  99053. DIFFUSE: boolean;
  99054. DIFFUSEDIRECTUV: number;
  99055. AMBIENT: boolean;
  99056. AMBIENTDIRECTUV: number;
  99057. OPACITY: boolean;
  99058. OPACITYDIRECTUV: number;
  99059. OPACITYRGB: boolean;
  99060. REFLECTION: boolean;
  99061. EMISSIVE: boolean;
  99062. EMISSIVEDIRECTUV: number;
  99063. SPECULAR: boolean;
  99064. SPECULARDIRECTUV: number;
  99065. BUMP: boolean;
  99066. BUMPDIRECTUV: number;
  99067. PARALLAX: boolean;
  99068. PARALLAXOCCLUSION: boolean;
  99069. SPECULAROVERALPHA: boolean;
  99070. CLIPPLANE: boolean;
  99071. CLIPPLANE2: boolean;
  99072. CLIPPLANE3: boolean;
  99073. CLIPPLANE4: boolean;
  99074. CLIPPLANE5: boolean;
  99075. CLIPPLANE6: boolean;
  99076. ALPHATEST: boolean;
  99077. DEPTHPREPASS: boolean;
  99078. ALPHAFROMDIFFUSE: boolean;
  99079. POINTSIZE: boolean;
  99080. FOG: boolean;
  99081. SPECULARTERM: boolean;
  99082. DIFFUSEFRESNEL: boolean;
  99083. OPACITYFRESNEL: boolean;
  99084. REFLECTIONFRESNEL: boolean;
  99085. REFRACTIONFRESNEL: boolean;
  99086. EMISSIVEFRESNEL: boolean;
  99087. FRESNEL: boolean;
  99088. NORMAL: boolean;
  99089. UV1: boolean;
  99090. UV2: boolean;
  99091. VERTEXCOLOR: boolean;
  99092. VERTEXALPHA: boolean;
  99093. NUM_BONE_INFLUENCERS: number;
  99094. BonesPerMesh: number;
  99095. BONETEXTURE: boolean;
  99096. INSTANCES: boolean;
  99097. GLOSSINESS: boolean;
  99098. ROUGHNESS: boolean;
  99099. EMISSIVEASILLUMINATION: boolean;
  99100. LINKEMISSIVEWITHDIFFUSE: boolean;
  99101. REFLECTIONFRESNELFROMSPECULAR: boolean;
  99102. LIGHTMAP: boolean;
  99103. LIGHTMAPDIRECTUV: number;
  99104. OBJECTSPACE_NORMALMAP: boolean;
  99105. USELIGHTMAPASSHADOWMAP: boolean;
  99106. REFLECTIONMAP_3D: boolean;
  99107. REFLECTIONMAP_SPHERICAL: boolean;
  99108. REFLECTIONMAP_PLANAR: boolean;
  99109. REFLECTIONMAP_CUBIC: boolean;
  99110. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  99111. REFLECTIONMAP_PROJECTION: boolean;
  99112. REFLECTIONMAP_SKYBOX: boolean;
  99113. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  99114. REFLECTIONMAP_EXPLICIT: boolean;
  99115. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  99116. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  99117. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  99118. INVERTCUBICMAP: boolean;
  99119. LOGARITHMICDEPTH: boolean;
  99120. REFRACTION: boolean;
  99121. REFRACTIONMAP_3D: boolean;
  99122. REFLECTIONOVERALPHA: boolean;
  99123. TWOSIDEDLIGHTING: boolean;
  99124. SHADOWFLOAT: boolean;
  99125. MORPHTARGETS: boolean;
  99126. MORPHTARGETS_NORMAL: boolean;
  99127. MORPHTARGETS_TANGENT: boolean;
  99128. MORPHTARGETS_UV: boolean;
  99129. NUM_MORPH_INFLUENCERS: number;
  99130. NONUNIFORMSCALING: boolean;
  99131. PREMULTIPLYALPHA: boolean;
  99132. IMAGEPROCESSING: boolean;
  99133. VIGNETTE: boolean;
  99134. VIGNETTEBLENDMODEMULTIPLY: boolean;
  99135. VIGNETTEBLENDMODEOPAQUE: boolean;
  99136. TONEMAPPING: boolean;
  99137. TONEMAPPING_ACES: boolean;
  99138. CONTRAST: boolean;
  99139. COLORCURVES: boolean;
  99140. COLORGRADING: boolean;
  99141. COLORGRADING3D: boolean;
  99142. SAMPLER3DGREENDEPTH: boolean;
  99143. SAMPLER3DBGRMAP: boolean;
  99144. IMAGEPROCESSINGPOSTPROCESS: boolean;
  99145. MULTIVIEW: boolean;
  99146. /**
  99147. * If the reflection texture on this material is in linear color space
  99148. * @hidden
  99149. */
  99150. IS_REFLECTION_LINEAR: boolean;
  99151. /**
  99152. * If the refraction texture on this material is in linear color space
  99153. * @hidden
  99154. */
  99155. IS_REFRACTION_LINEAR: boolean;
  99156. EXPOSURE: boolean;
  99157. constructor();
  99158. setReflectionMode(modeToEnable: string): void;
  99159. }
  99160. /**
  99161. * This is the default material used in Babylon. It is the best trade off between quality
  99162. * and performances.
  99163. * @see http://doc.babylonjs.com/babylon101/materials
  99164. */
  99165. export class StandardMaterial extends PushMaterial {
  99166. private _diffuseTexture;
  99167. /**
  99168. * The basic texture of the material as viewed under a light.
  99169. */
  99170. diffuseTexture: Nullable<BaseTexture>;
  99171. private _ambientTexture;
  99172. /**
  99173. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  99174. */
  99175. ambientTexture: Nullable<BaseTexture>;
  99176. private _opacityTexture;
  99177. /**
  99178. * Define the transparency of the material from a texture.
  99179. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  99180. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  99181. */
  99182. opacityTexture: Nullable<BaseTexture>;
  99183. private _reflectionTexture;
  99184. /**
  99185. * Define the texture used to display the reflection.
  99186. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99187. */
  99188. reflectionTexture: Nullable<BaseTexture>;
  99189. private _emissiveTexture;
  99190. /**
  99191. * Define texture of the material as if self lit.
  99192. * This will be mixed in the final result even in the absence of light.
  99193. */
  99194. emissiveTexture: Nullable<BaseTexture>;
  99195. private _specularTexture;
  99196. /**
  99197. * Define how the color and intensity of the highlight given by the light in the material.
  99198. */
  99199. specularTexture: Nullable<BaseTexture>;
  99200. private _bumpTexture;
  99201. /**
  99202. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  99203. * 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.
  99204. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  99205. */
  99206. bumpTexture: Nullable<BaseTexture>;
  99207. private _lightmapTexture;
  99208. /**
  99209. * Complex lighting can be computationally expensive to compute at runtime.
  99210. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  99211. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  99212. */
  99213. lightmapTexture: Nullable<BaseTexture>;
  99214. private _refractionTexture;
  99215. /**
  99216. * Define the texture used to display the refraction.
  99217. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99218. */
  99219. refractionTexture: Nullable<BaseTexture>;
  99220. /**
  99221. * The color of the material lit by the environmental background lighting.
  99222. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  99223. */
  99224. ambientColor: Color3;
  99225. /**
  99226. * The basic color of the material as viewed under a light.
  99227. */
  99228. diffuseColor: Color3;
  99229. /**
  99230. * Define how the color and intensity of the highlight given by the light in the material.
  99231. */
  99232. specularColor: Color3;
  99233. /**
  99234. * Define the color of the material as if self lit.
  99235. * This will be mixed in the final result even in the absence of light.
  99236. */
  99237. emissiveColor: Color3;
  99238. /**
  99239. * Defines how sharp are the highlights in the material.
  99240. * The bigger the value the sharper giving a more glossy feeling to the result.
  99241. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  99242. */
  99243. specularPower: number;
  99244. private _useAlphaFromDiffuseTexture;
  99245. /**
  99246. * Does the transparency come from the diffuse texture alpha channel.
  99247. */
  99248. useAlphaFromDiffuseTexture: boolean;
  99249. private _useEmissiveAsIllumination;
  99250. /**
  99251. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  99252. */
  99253. useEmissiveAsIllumination: boolean;
  99254. private _linkEmissiveWithDiffuse;
  99255. /**
  99256. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  99257. * the emissive level when the final color is close to one.
  99258. */
  99259. linkEmissiveWithDiffuse: boolean;
  99260. private _useSpecularOverAlpha;
  99261. /**
  99262. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  99263. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  99264. */
  99265. useSpecularOverAlpha: boolean;
  99266. private _useReflectionOverAlpha;
  99267. /**
  99268. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  99269. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  99270. */
  99271. useReflectionOverAlpha: boolean;
  99272. private _disableLighting;
  99273. /**
  99274. * Does lights from the scene impacts this material.
  99275. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  99276. */
  99277. disableLighting: boolean;
  99278. private _useObjectSpaceNormalMap;
  99279. /**
  99280. * Allows using an object space normal map (instead of tangent space).
  99281. */
  99282. useObjectSpaceNormalMap: boolean;
  99283. private _useParallax;
  99284. /**
  99285. * Is parallax enabled or not.
  99286. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99287. */
  99288. useParallax: boolean;
  99289. private _useParallaxOcclusion;
  99290. /**
  99291. * Is parallax occlusion enabled or not.
  99292. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  99293. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99294. */
  99295. useParallaxOcclusion: boolean;
  99296. /**
  99297. * 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.
  99298. */
  99299. parallaxScaleBias: number;
  99300. private _roughness;
  99301. /**
  99302. * Helps to define how blurry the reflections should appears in the material.
  99303. */
  99304. roughness: number;
  99305. /**
  99306. * In case of refraction, define the value of the index of refraction.
  99307. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99308. */
  99309. indexOfRefraction: number;
  99310. /**
  99311. * Invert the refraction texture alongside the y axis.
  99312. * It can be useful with procedural textures or probe for instance.
  99313. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99314. */
  99315. invertRefractionY: boolean;
  99316. /**
  99317. * Defines the alpha limits in alpha test mode.
  99318. */
  99319. alphaCutOff: number;
  99320. private _useLightmapAsShadowmap;
  99321. /**
  99322. * In case of light mapping, define whether the map contains light or shadow informations.
  99323. */
  99324. useLightmapAsShadowmap: boolean;
  99325. private _diffuseFresnelParameters;
  99326. /**
  99327. * Define the diffuse fresnel parameters of the material.
  99328. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99329. */
  99330. diffuseFresnelParameters: FresnelParameters;
  99331. private _opacityFresnelParameters;
  99332. /**
  99333. * Define the opacity fresnel parameters of the material.
  99334. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99335. */
  99336. opacityFresnelParameters: FresnelParameters;
  99337. private _reflectionFresnelParameters;
  99338. /**
  99339. * Define the reflection fresnel parameters of the material.
  99340. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99341. */
  99342. reflectionFresnelParameters: FresnelParameters;
  99343. private _refractionFresnelParameters;
  99344. /**
  99345. * Define the refraction fresnel parameters of the material.
  99346. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99347. */
  99348. refractionFresnelParameters: FresnelParameters;
  99349. private _emissiveFresnelParameters;
  99350. /**
  99351. * Define the emissive fresnel parameters of the material.
  99352. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99353. */
  99354. emissiveFresnelParameters: FresnelParameters;
  99355. private _useReflectionFresnelFromSpecular;
  99356. /**
  99357. * If true automatically deducts the fresnels values from the material specularity.
  99358. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99359. */
  99360. useReflectionFresnelFromSpecular: boolean;
  99361. private _useGlossinessFromSpecularMapAlpha;
  99362. /**
  99363. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  99364. */
  99365. useGlossinessFromSpecularMapAlpha: boolean;
  99366. private _maxSimultaneousLights;
  99367. /**
  99368. * Defines the maximum number of lights that can be used in the material
  99369. */
  99370. maxSimultaneousLights: number;
  99371. private _invertNormalMapX;
  99372. /**
  99373. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  99374. */
  99375. invertNormalMapX: boolean;
  99376. private _invertNormalMapY;
  99377. /**
  99378. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  99379. */
  99380. invertNormalMapY: boolean;
  99381. private _twoSidedLighting;
  99382. /**
  99383. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  99384. */
  99385. twoSidedLighting: boolean;
  99386. /**
  99387. * Default configuration related to image processing available in the standard Material.
  99388. */
  99389. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99390. /**
  99391. * Gets the image processing configuration used either in this material.
  99392. */
  99393. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  99394. /**
  99395. * Sets the Default image processing configuration used either in the this material.
  99396. *
  99397. * If sets to null, the scene one is in use.
  99398. */
  99399. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  99400. /**
  99401. * Keep track of the image processing observer to allow dispose and replace.
  99402. */
  99403. private _imageProcessingObserver;
  99404. /**
  99405. * Attaches a new image processing configuration to the Standard Material.
  99406. * @param configuration
  99407. */
  99408. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99409. /**
  99410. * Gets wether the color curves effect is enabled.
  99411. */
  99412. get cameraColorCurvesEnabled(): boolean;
  99413. /**
  99414. * Sets wether the color curves effect is enabled.
  99415. */
  99416. set cameraColorCurvesEnabled(value: boolean);
  99417. /**
  99418. * Gets wether the color grading effect is enabled.
  99419. */
  99420. get cameraColorGradingEnabled(): boolean;
  99421. /**
  99422. * Gets wether the color grading effect is enabled.
  99423. */
  99424. set cameraColorGradingEnabled(value: boolean);
  99425. /**
  99426. * Gets wether tonemapping is enabled or not.
  99427. */
  99428. get cameraToneMappingEnabled(): boolean;
  99429. /**
  99430. * Sets wether tonemapping is enabled or not
  99431. */
  99432. set cameraToneMappingEnabled(value: boolean);
  99433. /**
  99434. * The camera exposure used on this material.
  99435. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99436. * This corresponds to a photographic exposure.
  99437. */
  99438. get cameraExposure(): number;
  99439. /**
  99440. * The camera exposure used on this material.
  99441. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99442. * This corresponds to a photographic exposure.
  99443. */
  99444. set cameraExposure(value: number);
  99445. /**
  99446. * Gets The camera contrast used on this material.
  99447. */
  99448. get cameraContrast(): number;
  99449. /**
  99450. * Sets The camera contrast used on this material.
  99451. */
  99452. set cameraContrast(value: number);
  99453. /**
  99454. * Gets the Color Grading 2D Lookup Texture.
  99455. */
  99456. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  99457. /**
  99458. * Sets the Color Grading 2D Lookup Texture.
  99459. */
  99460. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  99461. /**
  99462. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99463. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99464. * 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;
  99465. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99466. */
  99467. get cameraColorCurves(): Nullable<ColorCurves>;
  99468. /**
  99469. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99470. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99471. * 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;
  99472. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99473. */
  99474. set cameraColorCurves(value: Nullable<ColorCurves>);
  99475. /**
  99476. * Custom callback helping to override the default shader used in the material.
  99477. */
  99478. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  99479. protected _renderTargets: SmartArray<RenderTargetTexture>;
  99480. protected _worldViewProjectionMatrix: Matrix;
  99481. protected _globalAmbientColor: Color3;
  99482. protected _useLogarithmicDepth: boolean;
  99483. protected _rebuildInParallel: boolean;
  99484. /**
  99485. * Instantiates a new standard material.
  99486. * This is the default material used in Babylon. It is the best trade off between quality
  99487. * and performances.
  99488. * @see http://doc.babylonjs.com/babylon101/materials
  99489. * @param name Define the name of the material in the scene
  99490. * @param scene Define the scene the material belong to
  99491. */
  99492. constructor(name: string, scene: Scene);
  99493. /**
  99494. * Gets a boolean indicating that current material needs to register RTT
  99495. */
  99496. get hasRenderTargetTextures(): boolean;
  99497. /**
  99498. * Gets the current class name of the material e.g. "StandardMaterial"
  99499. * Mainly use in serialization.
  99500. * @returns the class name
  99501. */
  99502. getClassName(): string;
  99503. /**
  99504. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  99505. * You can try switching to logarithmic depth.
  99506. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  99507. */
  99508. get useLogarithmicDepth(): boolean;
  99509. set useLogarithmicDepth(value: boolean);
  99510. /**
  99511. * Specifies if the material will require alpha blending
  99512. * @returns a boolean specifying if alpha blending is needed
  99513. */
  99514. needAlphaBlending(): boolean;
  99515. /**
  99516. * Specifies if this material should be rendered in alpha test mode
  99517. * @returns a boolean specifying if an alpha test is needed.
  99518. */
  99519. needAlphaTesting(): boolean;
  99520. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  99521. /**
  99522. * Get the texture used for alpha test purpose.
  99523. * @returns the diffuse texture in case of the standard material.
  99524. */
  99525. getAlphaTestTexture(): Nullable<BaseTexture>;
  99526. /**
  99527. * Get if the submesh is ready to be used and all its information available.
  99528. * Child classes can use it to update shaders
  99529. * @param mesh defines the mesh to check
  99530. * @param subMesh defines which submesh to check
  99531. * @param useInstances specifies that instances should be used
  99532. * @returns a boolean indicating that the submesh is ready or not
  99533. */
  99534. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99535. /**
  99536. * Builds the material UBO layouts.
  99537. * Used internally during the effect preparation.
  99538. */
  99539. buildUniformLayout(): void;
  99540. /**
  99541. * Unbinds the material from the mesh
  99542. */
  99543. unbind(): void;
  99544. /**
  99545. * Binds the submesh to this material by preparing the effect and shader to draw
  99546. * @param world defines the world transformation matrix
  99547. * @param mesh defines the mesh containing the submesh
  99548. * @param subMesh defines the submesh to bind the material to
  99549. */
  99550. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99551. /**
  99552. * Get the list of animatables in the material.
  99553. * @returns the list of animatables object used in the material
  99554. */
  99555. getAnimatables(): IAnimatable[];
  99556. /**
  99557. * Gets the active textures from the material
  99558. * @returns an array of textures
  99559. */
  99560. getActiveTextures(): BaseTexture[];
  99561. /**
  99562. * Specifies if the material uses a texture
  99563. * @param texture defines the texture to check against the material
  99564. * @returns a boolean specifying if the material uses the texture
  99565. */
  99566. hasTexture(texture: BaseTexture): boolean;
  99567. /**
  99568. * Disposes the material
  99569. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  99570. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  99571. */
  99572. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  99573. /**
  99574. * Makes a duplicate of the material, and gives it a new name
  99575. * @param name defines the new name for the duplicated material
  99576. * @returns the cloned material
  99577. */
  99578. clone(name: string): StandardMaterial;
  99579. /**
  99580. * Serializes this material in a JSON representation
  99581. * @returns the serialized material object
  99582. */
  99583. serialize(): any;
  99584. /**
  99585. * Creates a standard material from parsed material data
  99586. * @param source defines the JSON representation of the material
  99587. * @param scene defines the hosting scene
  99588. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99589. * @returns a new standard material
  99590. */
  99591. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  99592. /**
  99593. * Are diffuse textures enabled in the application.
  99594. */
  99595. static get DiffuseTextureEnabled(): boolean;
  99596. static set DiffuseTextureEnabled(value: boolean);
  99597. /**
  99598. * Are ambient textures enabled in the application.
  99599. */
  99600. static get AmbientTextureEnabled(): boolean;
  99601. static set AmbientTextureEnabled(value: boolean);
  99602. /**
  99603. * Are opacity textures enabled in the application.
  99604. */
  99605. static get OpacityTextureEnabled(): boolean;
  99606. static set OpacityTextureEnabled(value: boolean);
  99607. /**
  99608. * Are reflection textures enabled in the application.
  99609. */
  99610. static get ReflectionTextureEnabled(): boolean;
  99611. static set ReflectionTextureEnabled(value: boolean);
  99612. /**
  99613. * Are emissive textures enabled in the application.
  99614. */
  99615. static get EmissiveTextureEnabled(): boolean;
  99616. static set EmissiveTextureEnabled(value: boolean);
  99617. /**
  99618. * Are specular textures enabled in the application.
  99619. */
  99620. static get SpecularTextureEnabled(): boolean;
  99621. static set SpecularTextureEnabled(value: boolean);
  99622. /**
  99623. * Are bump textures enabled in the application.
  99624. */
  99625. static get BumpTextureEnabled(): boolean;
  99626. static set BumpTextureEnabled(value: boolean);
  99627. /**
  99628. * Are lightmap textures enabled in the application.
  99629. */
  99630. static get LightmapTextureEnabled(): boolean;
  99631. static set LightmapTextureEnabled(value: boolean);
  99632. /**
  99633. * Are refraction textures enabled in the application.
  99634. */
  99635. static get RefractionTextureEnabled(): boolean;
  99636. static set RefractionTextureEnabled(value: boolean);
  99637. /**
  99638. * Are color grading textures enabled in the application.
  99639. */
  99640. static get ColorGradingTextureEnabled(): boolean;
  99641. static set ColorGradingTextureEnabled(value: boolean);
  99642. /**
  99643. * Are fresnels enabled in the application.
  99644. */
  99645. static get FresnelEnabled(): boolean;
  99646. static set FresnelEnabled(value: boolean);
  99647. }
  99648. }
  99649. declare module BABYLON {
  99650. /**
  99651. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  99652. *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.
  99653. * The SPS is also a particle system. It provides some methods to manage the particles.
  99654. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  99655. *
  99656. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  99657. */
  99658. export class SolidParticleSystem implements IDisposable {
  99659. /**
  99660. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  99661. * Example : var p = SPS.particles[i];
  99662. */
  99663. particles: SolidParticle[];
  99664. /**
  99665. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  99666. */
  99667. nbParticles: number;
  99668. /**
  99669. * If the particles must ever face the camera (default false). Useful for planar particles.
  99670. */
  99671. billboard: boolean;
  99672. /**
  99673. * Recompute normals when adding a shape
  99674. */
  99675. recomputeNormals: boolean;
  99676. /**
  99677. * This a counter ofr your own usage. It's not set by any SPS functions.
  99678. */
  99679. counter: number;
  99680. /**
  99681. * The SPS name. This name is also given to the underlying mesh.
  99682. */
  99683. name: string;
  99684. /**
  99685. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  99686. */
  99687. mesh: Mesh;
  99688. /**
  99689. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  99690. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  99691. */
  99692. vars: any;
  99693. /**
  99694. * This array is populated when the SPS is set as 'pickable'.
  99695. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  99696. * Each element of this array is an object `{idx: int, faceId: int}`.
  99697. * `idx` is the picked particle index in the `SPS.particles` array
  99698. * `faceId` is the picked face index counted within this particle.
  99699. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  99700. */
  99701. pickedParticles: {
  99702. idx: number;
  99703. faceId: number;
  99704. }[];
  99705. /**
  99706. * This array is populated when `enableDepthSort` is set to true.
  99707. * Each element of this array is an instance of the class DepthSortedParticle.
  99708. */
  99709. depthSortedParticles: DepthSortedParticle[];
  99710. /**
  99711. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  99712. * @hidden
  99713. */
  99714. _bSphereOnly: boolean;
  99715. /**
  99716. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  99717. * @hidden
  99718. */
  99719. _bSphereRadiusFactor: number;
  99720. private _scene;
  99721. private _positions;
  99722. private _indices;
  99723. private _normals;
  99724. private _colors;
  99725. private _uvs;
  99726. private _indices32;
  99727. private _positions32;
  99728. private _normals32;
  99729. private _fixedNormal32;
  99730. private _colors32;
  99731. private _uvs32;
  99732. private _index;
  99733. private _updatable;
  99734. private _pickable;
  99735. private _isVisibilityBoxLocked;
  99736. private _alwaysVisible;
  99737. private _depthSort;
  99738. private _expandable;
  99739. private _shapeCounter;
  99740. private _copy;
  99741. private _color;
  99742. private _computeParticleColor;
  99743. private _computeParticleTexture;
  99744. private _computeParticleRotation;
  99745. private _computeParticleVertex;
  99746. private _computeBoundingBox;
  99747. private _depthSortParticles;
  99748. private _camera;
  99749. private _mustUnrotateFixedNormals;
  99750. private _particlesIntersect;
  99751. private _needs32Bits;
  99752. private _isNotBuilt;
  99753. private _lastParticleId;
  99754. private _idxOfId;
  99755. private _multimaterialEnabled;
  99756. private _useModelMaterial;
  99757. private _indicesByMaterial;
  99758. private _materialIndexes;
  99759. private _depthSortFunction;
  99760. private _materialSortFunction;
  99761. private _materials;
  99762. private _multimaterial;
  99763. private _materialIndexesById;
  99764. private _defaultMaterial;
  99765. private _autoUpdateSubMeshes;
  99766. /**
  99767. * Creates a SPS (Solid Particle System) object.
  99768. * @param name (String) is the SPS name, this will be the underlying mesh name.
  99769. * @param scene (Scene) is the scene in which the SPS is added.
  99770. * @param options defines the options of the sps e.g.
  99771. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  99772. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  99773. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  99774. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  99775. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  99776. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  99777. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  99778. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  99779. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  99780. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  99781. */
  99782. constructor(name: string, scene: Scene, options?: {
  99783. updatable?: boolean;
  99784. isPickable?: boolean;
  99785. enableDepthSort?: boolean;
  99786. particleIntersection?: boolean;
  99787. boundingSphereOnly?: boolean;
  99788. bSphereRadiusFactor?: number;
  99789. expandable?: boolean;
  99790. useModelMaterial?: boolean;
  99791. enableMultiMaterial?: boolean;
  99792. });
  99793. /**
  99794. * Builds the SPS underlying mesh. Returns a standard Mesh.
  99795. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  99796. * @returns the created mesh
  99797. */
  99798. buildMesh(): Mesh;
  99799. /**
  99800. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  99801. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  99802. * Thus the particles generated from `digest()` have their property `position` set yet.
  99803. * @param mesh ( Mesh ) is the mesh to be digested
  99804. * @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
  99805. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  99806. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  99807. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  99808. * @returns the current SPS
  99809. */
  99810. digest(mesh: Mesh, options?: {
  99811. facetNb?: number;
  99812. number?: number;
  99813. delta?: number;
  99814. storage?: [];
  99815. }): SolidParticleSystem;
  99816. /**
  99817. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  99818. * @hidden
  99819. */
  99820. private _unrotateFixedNormals;
  99821. /**
  99822. * Resets the temporary working copy particle
  99823. * @hidden
  99824. */
  99825. private _resetCopy;
  99826. /**
  99827. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  99828. * @param p the current index in the positions array to be updated
  99829. * @param ind the current index in the indices array
  99830. * @param shape a Vector3 array, the shape geometry
  99831. * @param positions the positions array to be updated
  99832. * @param meshInd the shape indices array
  99833. * @param indices the indices array to be updated
  99834. * @param meshUV the shape uv array
  99835. * @param uvs the uv array to be updated
  99836. * @param meshCol the shape color array
  99837. * @param colors the color array to be updated
  99838. * @param meshNor the shape normals array
  99839. * @param normals the normals array to be updated
  99840. * @param idx the particle index
  99841. * @param idxInShape the particle index in its shape
  99842. * @param options the addShape() method passed options
  99843. * @model the particle model
  99844. * @hidden
  99845. */
  99846. private _meshBuilder;
  99847. /**
  99848. * Returns a shape Vector3 array from positions float array
  99849. * @param positions float array
  99850. * @returns a vector3 array
  99851. * @hidden
  99852. */
  99853. private _posToShape;
  99854. /**
  99855. * Returns a shapeUV array from a float uvs (array deep copy)
  99856. * @param uvs as a float array
  99857. * @returns a shapeUV array
  99858. * @hidden
  99859. */
  99860. private _uvsToShapeUV;
  99861. /**
  99862. * Adds a new particle object in the particles array
  99863. * @param idx particle index in particles array
  99864. * @param id particle id
  99865. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  99866. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  99867. * @param model particle ModelShape object
  99868. * @param shapeId model shape identifier
  99869. * @param idxInShape index of the particle in the current model
  99870. * @param bInfo model bounding info object
  99871. * @param storage target storage array, if any
  99872. * @hidden
  99873. */
  99874. private _addParticle;
  99875. /**
  99876. * Adds some particles to the SPS from the model shape. Returns the shape id.
  99877. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  99878. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  99879. * @param nb (positive integer) the number of particles to be created from this model
  99880. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  99881. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  99882. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  99883. * @returns the number of shapes in the system
  99884. */
  99885. addShape(mesh: Mesh, nb: number, options?: {
  99886. positionFunction?: any;
  99887. vertexFunction?: any;
  99888. storage?: [];
  99889. }): number;
  99890. /**
  99891. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  99892. * @hidden
  99893. */
  99894. private _rebuildParticle;
  99895. /**
  99896. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  99897. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  99898. * @returns the SPS.
  99899. */
  99900. rebuildMesh(reset?: boolean): SolidParticleSystem;
  99901. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  99902. * Returns an array with the removed particles.
  99903. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  99904. * The SPS can't be empty so at least one particle needs to remain in place.
  99905. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  99906. * @param start index of the first particle to remove
  99907. * @param end index of the last particle to remove (included)
  99908. * @returns an array populated with the removed particles
  99909. */
  99910. removeParticles(start: number, end: number): SolidParticle[];
  99911. /**
  99912. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  99913. * @param solidParticleArray an array populated with Solid Particles objects
  99914. * @returns the SPS
  99915. */
  99916. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  99917. /**
  99918. * Creates a new particle and modifies the SPS mesh geometry :
  99919. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  99920. * - calls _addParticle() to populate the particle array
  99921. * factorized code from addShape() and insertParticlesFromArray()
  99922. * @param idx particle index in the particles array
  99923. * @param i particle index in its shape
  99924. * @param modelShape particle ModelShape object
  99925. * @param shape shape vertex array
  99926. * @param meshInd shape indices array
  99927. * @param meshUV shape uv array
  99928. * @param meshCol shape color array
  99929. * @param meshNor shape normals array
  99930. * @param bbInfo shape bounding info
  99931. * @param storage target particle storage
  99932. * @options addShape() passed options
  99933. * @hidden
  99934. */
  99935. private _insertNewParticle;
  99936. /**
  99937. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  99938. * This method calls `updateParticle()` for each particle of the SPS.
  99939. * For an animated SPS, it is usually called within the render loop.
  99940. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  99941. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  99942. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  99943. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  99944. * @returns the SPS.
  99945. */
  99946. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  99947. /**
  99948. * Disposes the SPS.
  99949. */
  99950. dispose(): void;
  99951. /**
  99952. * Returns a SolidParticle object from its identifier : particle.id
  99953. * @param id (integer) the particle Id
  99954. * @returns the searched particle or null if not found in the SPS.
  99955. */
  99956. getParticleById(id: number): Nullable<SolidParticle>;
  99957. /**
  99958. * Returns a new array populated with the particles having the passed shapeId.
  99959. * @param shapeId (integer) the shape identifier
  99960. * @returns a new solid particle array
  99961. */
  99962. getParticlesByShapeId(shapeId: number): SolidParticle[];
  99963. /**
  99964. * Populates the passed array "ref" with the particles having the passed shapeId.
  99965. * @param shapeId the shape identifier
  99966. * @returns the SPS
  99967. * @param ref
  99968. */
  99969. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  99970. /**
  99971. * Computes the required SubMeshes according the materials assigned to the particles.
  99972. * @returns the solid particle system.
  99973. * Does nothing if called before the SPS mesh is built.
  99974. */
  99975. computeSubMeshes(): SolidParticleSystem;
  99976. /**
  99977. * Sorts the solid particles by material when MultiMaterial is enabled.
  99978. * Updates the indices32 array.
  99979. * Updates the indicesByMaterial array.
  99980. * Updates the mesh indices array.
  99981. * @returns the SPS
  99982. * @hidden
  99983. */
  99984. private _sortParticlesByMaterial;
  99985. /**
  99986. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  99987. * @hidden
  99988. */
  99989. private _setMaterialIndexesById;
  99990. /**
  99991. * Returns an array with unique values of Materials from the passed array
  99992. * @param array the material array to be checked and filtered
  99993. * @hidden
  99994. */
  99995. private _filterUniqueMaterialId;
  99996. /**
  99997. * Sets a new Standard Material as _defaultMaterial if not already set.
  99998. * @hidden
  99999. */
  100000. private _setDefaultMaterial;
  100001. /**
  100002. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  100003. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100004. * @returns the SPS.
  100005. */
  100006. refreshVisibleSize(): SolidParticleSystem;
  100007. /**
  100008. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  100009. * @param size the size (float) of the visibility box
  100010. * note : this doesn't lock the SPS mesh bounding box.
  100011. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100012. */
  100013. setVisibilityBox(size: number): void;
  100014. /**
  100015. * Gets whether the SPS as always visible or not
  100016. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100017. */
  100018. get isAlwaysVisible(): boolean;
  100019. /**
  100020. * Sets the SPS as always visible or not
  100021. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100022. */
  100023. set isAlwaysVisible(val: boolean);
  100024. /**
  100025. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100026. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100027. */
  100028. set isVisibilityBoxLocked(val: boolean);
  100029. /**
  100030. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100031. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100032. */
  100033. get isVisibilityBoxLocked(): boolean;
  100034. /**
  100035. * Tells to `setParticles()` to compute the particle rotations or not.
  100036. * Default value : true. The SPS is faster when it's set to false.
  100037. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100038. */
  100039. set computeParticleRotation(val: boolean);
  100040. /**
  100041. * Tells to `setParticles()` to compute the particle colors or not.
  100042. * Default value : true. The SPS is faster when it's set to false.
  100043. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100044. */
  100045. set computeParticleColor(val: boolean);
  100046. set computeParticleTexture(val: boolean);
  100047. /**
  100048. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  100049. * Default value : false. The SPS is faster when it's set to false.
  100050. * Note : the particle custom vertex positions aren't stored values.
  100051. */
  100052. set computeParticleVertex(val: boolean);
  100053. /**
  100054. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  100055. */
  100056. set computeBoundingBox(val: boolean);
  100057. /**
  100058. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  100059. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100060. * Default : `true`
  100061. */
  100062. set depthSortParticles(val: boolean);
  100063. /**
  100064. * Gets if `setParticles()` computes the particle rotations or not.
  100065. * Default value : true. The SPS is faster when it's set to false.
  100066. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100067. */
  100068. get computeParticleRotation(): boolean;
  100069. /**
  100070. * Gets if `setParticles()` computes the particle colors or not.
  100071. * Default value : true. The SPS is faster when it's set to false.
  100072. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100073. */
  100074. get computeParticleColor(): boolean;
  100075. /**
  100076. * Gets if `setParticles()` computes the particle textures or not.
  100077. * Default value : true. The SPS is faster when it's set to false.
  100078. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  100079. */
  100080. get computeParticleTexture(): boolean;
  100081. /**
  100082. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  100083. * Default value : false. The SPS is faster when it's set to false.
  100084. * Note : the particle custom vertex positions aren't stored values.
  100085. */
  100086. get computeParticleVertex(): boolean;
  100087. /**
  100088. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  100089. */
  100090. get computeBoundingBox(): boolean;
  100091. /**
  100092. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  100093. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100094. * Default : `true`
  100095. */
  100096. get depthSortParticles(): boolean;
  100097. /**
  100098. * Gets if the SPS is created as expandable at construction time.
  100099. * Default : `false`
  100100. */
  100101. get expandable(): boolean;
  100102. /**
  100103. * Gets if the SPS supports the Multi Materials
  100104. */
  100105. get multimaterialEnabled(): boolean;
  100106. /**
  100107. * Gets if the SPS uses the model materials for its own multimaterial.
  100108. */
  100109. get useModelMaterial(): boolean;
  100110. /**
  100111. * The SPS used material array.
  100112. */
  100113. get materials(): Material[];
  100114. /**
  100115. * Sets the SPS MultiMaterial from the passed materials.
  100116. * Note : the passed array is internally copied and not used then by reference.
  100117. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  100118. */
  100119. setMultiMaterial(materials: Material[]): void;
  100120. /**
  100121. * The SPS computed multimaterial object
  100122. */
  100123. get multimaterial(): MultiMaterial;
  100124. set multimaterial(mm: MultiMaterial);
  100125. /**
  100126. * If the subMeshes must be updated on the next call to setParticles()
  100127. */
  100128. get autoUpdateSubMeshes(): boolean;
  100129. set autoUpdateSubMeshes(val: boolean);
  100130. /**
  100131. * This function does nothing. It may be overwritten to set all the particle first values.
  100132. * The SPS doesn't call this function, you may have to call it by your own.
  100133. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100134. */
  100135. initParticles(): void;
  100136. /**
  100137. * This function does nothing. It may be overwritten to recycle a particle.
  100138. * The SPS doesn't call this function, you may have to call it by your own.
  100139. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100140. * @param particle The particle to recycle
  100141. * @returns the recycled particle
  100142. */
  100143. recycleParticle(particle: SolidParticle): SolidParticle;
  100144. /**
  100145. * Updates a particle : this function should be overwritten by the user.
  100146. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  100147. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100148. * @example : just set a particle position or velocity and recycle conditions
  100149. * @param particle The particle to update
  100150. * @returns the updated particle
  100151. */
  100152. updateParticle(particle: SolidParticle): SolidParticle;
  100153. /**
  100154. * Updates a vertex of a particle : it can be overwritten by the user.
  100155. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  100156. * @param particle the current particle
  100157. * @param vertex the current index of the current particle
  100158. * @param pt the index of the current vertex in the particle shape
  100159. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  100160. * @example : just set a vertex particle position
  100161. * @returns the updated vertex
  100162. */
  100163. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  100164. /**
  100165. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  100166. * This does nothing and may be overwritten by the user.
  100167. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100168. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100169. * @param update the boolean update value actually passed to setParticles()
  100170. */
  100171. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100172. /**
  100173. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  100174. * This will be passed three parameters.
  100175. * This does nothing and may be overwritten by the user.
  100176. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100177. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100178. * @param update the boolean update value actually passed to setParticles()
  100179. */
  100180. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100181. }
  100182. }
  100183. declare module BABYLON {
  100184. /**
  100185. * Represents one particle of a solid particle system.
  100186. */
  100187. export class SolidParticle {
  100188. /**
  100189. * particle global index
  100190. */
  100191. idx: number;
  100192. /**
  100193. * particle identifier
  100194. */
  100195. id: number;
  100196. /**
  100197. * The color of the particle
  100198. */
  100199. color: Nullable<Color4>;
  100200. /**
  100201. * The world space position of the particle.
  100202. */
  100203. position: Vector3;
  100204. /**
  100205. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  100206. */
  100207. rotation: Vector3;
  100208. /**
  100209. * The world space rotation quaternion of the particle.
  100210. */
  100211. rotationQuaternion: Nullable<Quaternion>;
  100212. /**
  100213. * The scaling of the particle.
  100214. */
  100215. scaling: Vector3;
  100216. /**
  100217. * The uvs of the particle.
  100218. */
  100219. uvs: Vector4;
  100220. /**
  100221. * The current speed of the particle.
  100222. */
  100223. velocity: Vector3;
  100224. /**
  100225. * The pivot point in the particle local space.
  100226. */
  100227. pivot: Vector3;
  100228. /**
  100229. * Must the particle be translated from its pivot point in its local space ?
  100230. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  100231. * Default : false
  100232. */
  100233. translateFromPivot: boolean;
  100234. /**
  100235. * Is the particle active or not ?
  100236. */
  100237. alive: boolean;
  100238. /**
  100239. * Is the particle visible or not ?
  100240. */
  100241. isVisible: boolean;
  100242. /**
  100243. * Index of this particle in the global "positions" array (Internal use)
  100244. * @hidden
  100245. */
  100246. _pos: number;
  100247. /**
  100248. * @hidden Index of this particle in the global "indices" array (Internal use)
  100249. */
  100250. _ind: number;
  100251. /**
  100252. * @hidden ModelShape of this particle (Internal use)
  100253. */
  100254. _model: ModelShape;
  100255. /**
  100256. * ModelShape id of this particle
  100257. */
  100258. shapeId: number;
  100259. /**
  100260. * Index of the particle in its shape id
  100261. */
  100262. idxInShape: number;
  100263. /**
  100264. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  100265. */
  100266. _modelBoundingInfo: BoundingInfo;
  100267. /**
  100268. * @hidden Particle BoundingInfo object (Internal use)
  100269. */
  100270. _boundingInfo: BoundingInfo;
  100271. /**
  100272. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  100273. */
  100274. _sps: SolidParticleSystem;
  100275. /**
  100276. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  100277. */
  100278. _stillInvisible: boolean;
  100279. /**
  100280. * @hidden Last computed particle rotation matrix
  100281. */
  100282. _rotationMatrix: number[];
  100283. /**
  100284. * Parent particle Id, if any.
  100285. * Default null.
  100286. */
  100287. parentId: Nullable<number>;
  100288. /**
  100289. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  100290. */
  100291. materialIndex: Nullable<number>;
  100292. /**
  100293. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  100294. * The possible values are :
  100295. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  100296. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100297. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  100298. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  100299. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100300. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  100301. * */
  100302. cullingStrategy: number;
  100303. /**
  100304. * @hidden Internal global position in the SPS.
  100305. */
  100306. _globalPosition: Vector3;
  100307. /**
  100308. * Creates a Solid Particle object.
  100309. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  100310. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  100311. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  100312. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  100313. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  100314. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  100315. * @param shapeId (integer) is the model shape identifier in the SPS.
  100316. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  100317. * @param sps defines the sps it is associated to
  100318. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  100319. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  100320. */
  100321. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  100322. /**
  100323. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  100324. * @param target the particle target
  100325. * @returns the current particle
  100326. */
  100327. copyToRef(target: SolidParticle): SolidParticle;
  100328. /**
  100329. * Legacy support, changed scale to scaling
  100330. */
  100331. get scale(): Vector3;
  100332. /**
  100333. * Legacy support, changed scale to scaling
  100334. */
  100335. set scale(scale: Vector3);
  100336. /**
  100337. * Legacy support, changed quaternion to rotationQuaternion
  100338. */
  100339. get quaternion(): Nullable<Quaternion>;
  100340. /**
  100341. * Legacy support, changed quaternion to rotationQuaternion
  100342. */
  100343. set quaternion(q: Nullable<Quaternion>);
  100344. /**
  100345. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  100346. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  100347. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  100348. * @returns true if it intersects
  100349. */
  100350. intersectsMesh(target: Mesh | SolidParticle): boolean;
  100351. /**
  100352. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  100353. * A particle is in the frustum if its bounding box intersects the frustum
  100354. * @param frustumPlanes defines the frustum to test
  100355. * @returns true if the particle is in the frustum planes
  100356. */
  100357. isInFrustum(frustumPlanes: Plane[]): boolean;
  100358. /**
  100359. * get the rotation matrix of the particle
  100360. * @hidden
  100361. */
  100362. getRotationMatrix(m: Matrix): void;
  100363. }
  100364. /**
  100365. * Represents the shape of the model used by one particle of a solid particle system.
  100366. * SPS internal tool, don't use it manually.
  100367. */
  100368. export class ModelShape {
  100369. /**
  100370. * The shape id
  100371. * @hidden
  100372. */
  100373. shapeID: number;
  100374. /**
  100375. * flat array of model positions (internal use)
  100376. * @hidden
  100377. */
  100378. _shape: Vector3[];
  100379. /**
  100380. * flat array of model UVs (internal use)
  100381. * @hidden
  100382. */
  100383. _shapeUV: number[];
  100384. /**
  100385. * color array of the model
  100386. * @hidden
  100387. */
  100388. _shapeColors: number[];
  100389. /**
  100390. * indices array of the model
  100391. * @hidden
  100392. */
  100393. _indices: number[];
  100394. /**
  100395. * normals array of the model
  100396. * @hidden
  100397. */
  100398. _normals: number[];
  100399. /**
  100400. * length of the shape in the model indices array (internal use)
  100401. * @hidden
  100402. */
  100403. _indicesLength: number;
  100404. /**
  100405. * Custom position function (internal use)
  100406. * @hidden
  100407. */
  100408. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  100409. /**
  100410. * Custom vertex function (internal use)
  100411. * @hidden
  100412. */
  100413. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  100414. /**
  100415. * Model material (internal use)
  100416. * @hidden
  100417. */
  100418. _material: Nullable<Material>;
  100419. /**
  100420. * 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.
  100421. * SPS internal tool, don't use it manually.
  100422. * @hidden
  100423. */
  100424. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  100425. }
  100426. /**
  100427. * Represents a Depth Sorted Particle in the solid particle system.
  100428. * @hidden
  100429. */
  100430. export class DepthSortedParticle {
  100431. /**
  100432. * Index of the particle in the "indices" array
  100433. */
  100434. ind: number;
  100435. /**
  100436. * Length of the particle shape in the "indices" array
  100437. */
  100438. indicesLength: number;
  100439. /**
  100440. * Squared distance from the particle to the camera
  100441. */
  100442. sqDistance: number;
  100443. /**
  100444. * Material index when used with MultiMaterials
  100445. */
  100446. materialIndex: number;
  100447. /**
  100448. * Creates a new sorted particle
  100449. * @param materialIndex
  100450. */
  100451. constructor(ind: number, indLength: number, materialIndex: number);
  100452. }
  100453. }
  100454. declare module BABYLON {
  100455. /**
  100456. * @hidden
  100457. */
  100458. export class _MeshCollisionData {
  100459. _checkCollisions: boolean;
  100460. _collisionMask: number;
  100461. _collisionGroup: number;
  100462. _collider: Nullable<Collider>;
  100463. _oldPositionForCollisions: Vector3;
  100464. _diffPositionForCollisions: Vector3;
  100465. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  100466. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  100467. }
  100468. }
  100469. declare module BABYLON {
  100470. /** @hidden */
  100471. class _FacetDataStorage {
  100472. facetPositions: Vector3[];
  100473. facetNormals: Vector3[];
  100474. facetPartitioning: number[][];
  100475. facetNb: number;
  100476. partitioningSubdivisions: number;
  100477. partitioningBBoxRatio: number;
  100478. facetDataEnabled: boolean;
  100479. facetParameters: any;
  100480. bbSize: Vector3;
  100481. subDiv: {
  100482. max: number;
  100483. X: number;
  100484. Y: number;
  100485. Z: number;
  100486. };
  100487. facetDepthSort: boolean;
  100488. facetDepthSortEnabled: boolean;
  100489. depthSortedIndices: IndicesArray;
  100490. depthSortedFacets: {
  100491. ind: number;
  100492. sqDistance: number;
  100493. }[];
  100494. facetDepthSortFunction: (f1: {
  100495. ind: number;
  100496. sqDistance: number;
  100497. }, f2: {
  100498. ind: number;
  100499. sqDistance: number;
  100500. }) => number;
  100501. facetDepthSortFrom: Vector3;
  100502. facetDepthSortOrigin: Vector3;
  100503. invertedMatrix: Matrix;
  100504. }
  100505. /**
  100506. * @hidden
  100507. **/
  100508. class _InternalAbstractMeshDataInfo {
  100509. _hasVertexAlpha: boolean;
  100510. _useVertexColors: boolean;
  100511. _numBoneInfluencers: number;
  100512. _applyFog: boolean;
  100513. _receiveShadows: boolean;
  100514. _facetData: _FacetDataStorage;
  100515. _visibility: number;
  100516. _skeleton: Nullable<Skeleton>;
  100517. _layerMask: number;
  100518. _computeBonesUsingShaders: boolean;
  100519. _isActive: boolean;
  100520. _onlyForInstances: boolean;
  100521. _isActiveIntermediate: boolean;
  100522. _onlyForInstancesIntermediate: boolean;
  100523. _actAsRegularMesh: boolean;
  100524. }
  100525. /**
  100526. * Class used to store all common mesh properties
  100527. */
  100528. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  100529. /** No occlusion */
  100530. static OCCLUSION_TYPE_NONE: number;
  100531. /** Occlusion set to optimisitic */
  100532. static OCCLUSION_TYPE_OPTIMISTIC: number;
  100533. /** Occlusion set to strict */
  100534. static OCCLUSION_TYPE_STRICT: number;
  100535. /** Use an accurante occlusion algorithm */
  100536. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  100537. /** Use a conservative occlusion algorithm */
  100538. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  100539. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  100540. * Test order :
  100541. * Is the bounding sphere outside the frustum ?
  100542. * If not, are the bounding box vertices outside the frustum ?
  100543. * It not, then the cullable object is in the frustum.
  100544. */
  100545. static readonly CULLINGSTRATEGY_STANDARD: number;
  100546. /** Culling strategy : Bounding Sphere Only.
  100547. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  100548. * It's also less accurate than the standard because some not visible objects can still be selected.
  100549. * Test : is the bounding sphere outside the frustum ?
  100550. * If not, then the cullable object is in the frustum.
  100551. */
  100552. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  100553. /** Culling strategy : Optimistic Inclusion.
  100554. * This in an inclusion test first, then the standard exclusion test.
  100555. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  100556. * 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.
  100557. * Anyway, it's as accurate as the standard strategy.
  100558. * Test :
  100559. * Is the cullable object bounding sphere center in the frustum ?
  100560. * If not, apply the default culling strategy.
  100561. */
  100562. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  100563. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  100564. * This in an inclusion test first, then the bounding sphere only exclusion test.
  100565. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  100566. * 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.
  100567. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  100568. * Test :
  100569. * Is the cullable object bounding sphere center in the frustum ?
  100570. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  100571. */
  100572. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  100573. /**
  100574. * No billboard
  100575. */
  100576. static get BILLBOARDMODE_NONE(): number;
  100577. /** Billboard on X axis */
  100578. static get BILLBOARDMODE_X(): number;
  100579. /** Billboard on Y axis */
  100580. static get BILLBOARDMODE_Y(): number;
  100581. /** Billboard on Z axis */
  100582. static get BILLBOARDMODE_Z(): number;
  100583. /** Billboard on all axes */
  100584. static get BILLBOARDMODE_ALL(): number;
  100585. /** Billboard on using position instead of orientation */
  100586. static get BILLBOARDMODE_USE_POSITION(): number;
  100587. /** @hidden */
  100588. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  100589. /**
  100590. * The culling strategy to use to check whether the mesh must be rendered or not.
  100591. * This value can be changed at any time and will be used on the next render mesh selection.
  100592. * The possible values are :
  100593. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  100594. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100595. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  100596. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  100597. * Please read each static variable documentation to get details about the culling process.
  100598. * */
  100599. cullingStrategy: number;
  100600. /**
  100601. * Gets the number of facets in the mesh
  100602. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  100603. */
  100604. get facetNb(): number;
  100605. /**
  100606. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  100607. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  100608. */
  100609. get partitioningSubdivisions(): number;
  100610. set partitioningSubdivisions(nb: number);
  100611. /**
  100612. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  100613. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  100614. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  100615. */
  100616. get partitioningBBoxRatio(): number;
  100617. set partitioningBBoxRatio(ratio: number);
  100618. /**
  100619. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  100620. * Works only for updatable meshes.
  100621. * Doesn't work with multi-materials
  100622. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  100623. */
  100624. get mustDepthSortFacets(): boolean;
  100625. set mustDepthSortFacets(sort: boolean);
  100626. /**
  100627. * The location (Vector3) where the facet depth sort must be computed from.
  100628. * By default, the active camera position.
  100629. * Used only when facet depth sort is enabled
  100630. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  100631. */
  100632. get facetDepthSortFrom(): Vector3;
  100633. set facetDepthSortFrom(location: Vector3);
  100634. /**
  100635. * gets a boolean indicating if facetData is enabled
  100636. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  100637. */
  100638. get isFacetDataEnabled(): boolean;
  100639. /** @hidden */
  100640. _updateNonUniformScalingState(value: boolean): boolean;
  100641. /**
  100642. * An event triggered when this mesh collides with another one
  100643. */
  100644. onCollideObservable: Observable<AbstractMesh>;
  100645. /** Set a function to call when this mesh collides with another one */
  100646. set onCollide(callback: () => void);
  100647. /**
  100648. * An event triggered when the collision's position changes
  100649. */
  100650. onCollisionPositionChangeObservable: Observable<Vector3>;
  100651. /** Set a function to call when the collision's position changes */
  100652. set onCollisionPositionChange(callback: () => void);
  100653. /**
  100654. * An event triggered when material is changed
  100655. */
  100656. onMaterialChangedObservable: Observable<AbstractMesh>;
  100657. /**
  100658. * Gets or sets the orientation for POV movement & rotation
  100659. */
  100660. definedFacingForward: boolean;
  100661. /** @hidden */
  100662. _occlusionQuery: Nullable<WebGLQuery>;
  100663. /** @hidden */
  100664. _renderingGroup: Nullable<RenderingGroup>;
  100665. /**
  100666. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  100667. */
  100668. get visibility(): number;
  100669. /**
  100670. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  100671. */
  100672. set visibility(value: number);
  100673. /** Gets or sets the alpha index used to sort transparent meshes
  100674. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  100675. */
  100676. alphaIndex: number;
  100677. /**
  100678. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  100679. */
  100680. isVisible: boolean;
  100681. /**
  100682. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  100683. */
  100684. isPickable: boolean;
  100685. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  100686. showSubMeshesBoundingBox: boolean;
  100687. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  100688. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100689. */
  100690. isBlocker: boolean;
  100691. /**
  100692. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  100693. */
  100694. enablePointerMoveEvents: boolean;
  100695. /**
  100696. * Specifies the rendering group id for this mesh (0 by default)
  100697. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  100698. */
  100699. renderingGroupId: number;
  100700. private _material;
  100701. /** Gets or sets current material */
  100702. get material(): Nullable<Material>;
  100703. set material(value: Nullable<Material>);
  100704. /**
  100705. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  100706. * @see http://doc.babylonjs.com/babylon101/shadows
  100707. */
  100708. get receiveShadows(): boolean;
  100709. set receiveShadows(value: boolean);
  100710. /** Defines color to use when rendering outline */
  100711. outlineColor: Color3;
  100712. /** Define width to use when rendering outline */
  100713. outlineWidth: number;
  100714. /** Defines color to use when rendering overlay */
  100715. overlayColor: Color3;
  100716. /** Defines alpha to use when rendering overlay */
  100717. overlayAlpha: number;
  100718. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  100719. get hasVertexAlpha(): boolean;
  100720. set hasVertexAlpha(value: boolean);
  100721. /** 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) */
  100722. get useVertexColors(): boolean;
  100723. set useVertexColors(value: boolean);
  100724. /**
  100725. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  100726. */
  100727. get computeBonesUsingShaders(): boolean;
  100728. set computeBonesUsingShaders(value: boolean);
  100729. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  100730. get numBoneInfluencers(): number;
  100731. set numBoneInfluencers(value: number);
  100732. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  100733. get applyFog(): boolean;
  100734. set applyFog(value: boolean);
  100735. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  100736. useOctreeForRenderingSelection: boolean;
  100737. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  100738. useOctreeForPicking: boolean;
  100739. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  100740. useOctreeForCollisions: boolean;
  100741. /**
  100742. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  100743. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  100744. */
  100745. get layerMask(): number;
  100746. set layerMask(value: number);
  100747. /**
  100748. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  100749. */
  100750. alwaysSelectAsActiveMesh: boolean;
  100751. /**
  100752. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  100753. */
  100754. doNotSyncBoundingInfo: boolean;
  100755. /**
  100756. * Gets or sets the current action manager
  100757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  100758. */
  100759. actionManager: Nullable<AbstractActionManager>;
  100760. private _meshCollisionData;
  100761. /**
  100762. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  100763. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100764. */
  100765. ellipsoid: Vector3;
  100766. /**
  100767. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  100768. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100769. */
  100770. ellipsoidOffset: Vector3;
  100771. /**
  100772. * Gets or sets a collision mask used to mask collisions (default is -1).
  100773. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  100774. */
  100775. get collisionMask(): number;
  100776. set collisionMask(mask: number);
  100777. /**
  100778. * Gets or sets the current collision group mask (-1 by default).
  100779. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  100780. */
  100781. get collisionGroup(): number;
  100782. set collisionGroup(mask: number);
  100783. /**
  100784. * Defines edge width used when edgesRenderer is enabled
  100785. * @see https://www.babylonjs-playground.com/#10OJSG#13
  100786. */
  100787. edgesWidth: number;
  100788. /**
  100789. * Defines edge color used when edgesRenderer is enabled
  100790. * @see https://www.babylonjs-playground.com/#10OJSG#13
  100791. */
  100792. edgesColor: Color4;
  100793. /** @hidden */
  100794. _edgesRenderer: Nullable<IEdgesRenderer>;
  100795. /** @hidden */
  100796. _masterMesh: Nullable<AbstractMesh>;
  100797. /** @hidden */
  100798. _boundingInfo: Nullable<BoundingInfo>;
  100799. /** @hidden */
  100800. _renderId: number;
  100801. /**
  100802. * Gets or sets the list of subMeshes
  100803. * @see http://doc.babylonjs.com/how_to/multi_materials
  100804. */
  100805. subMeshes: SubMesh[];
  100806. /** @hidden */
  100807. _intersectionsInProgress: AbstractMesh[];
  100808. /** @hidden */
  100809. _unIndexed: boolean;
  100810. /** @hidden */
  100811. _lightSources: Light[];
  100812. /** Gets the list of lights affecting that mesh */
  100813. get lightSources(): Light[];
  100814. /** @hidden */
  100815. get _positions(): Nullable<Vector3[]>;
  100816. /** @hidden */
  100817. _waitingData: {
  100818. lods: Nullable<any>;
  100819. actions: Nullable<any>;
  100820. freezeWorldMatrix: Nullable<boolean>;
  100821. };
  100822. /** @hidden */
  100823. _bonesTransformMatrices: Nullable<Float32Array>;
  100824. /** @hidden */
  100825. _transformMatrixTexture: Nullable<RawTexture>;
  100826. /**
  100827. * Gets or sets a skeleton to apply skining transformations
  100828. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  100829. */
  100830. set skeleton(value: Nullable<Skeleton>);
  100831. get skeleton(): Nullable<Skeleton>;
  100832. /**
  100833. * An event triggered when the mesh is rebuilt.
  100834. */
  100835. onRebuildObservable: Observable<AbstractMesh>;
  100836. /**
  100837. * Creates a new AbstractMesh
  100838. * @param name defines the name of the mesh
  100839. * @param scene defines the hosting scene
  100840. */
  100841. constructor(name: string, scene?: Nullable<Scene>);
  100842. /**
  100843. * Returns the string "AbstractMesh"
  100844. * @returns "AbstractMesh"
  100845. */
  100846. getClassName(): string;
  100847. /**
  100848. * Gets a string representation of the current mesh
  100849. * @param fullDetails defines a boolean indicating if full details must be included
  100850. * @returns a string representation of the current mesh
  100851. */
  100852. toString(fullDetails?: boolean): string;
  100853. /**
  100854. * @hidden
  100855. */
  100856. protected _getEffectiveParent(): Nullable<Node>;
  100857. /** @hidden */
  100858. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  100859. /** @hidden */
  100860. _rebuild(): void;
  100861. /** @hidden */
  100862. _resyncLightSources(): void;
  100863. /** @hidden */
  100864. _resyncLightSource(light: Light): void;
  100865. /** @hidden */
  100866. _unBindEffect(): void;
  100867. /** @hidden */
  100868. _removeLightSource(light: Light, dispose: boolean): void;
  100869. private _markSubMeshesAsDirty;
  100870. /** @hidden */
  100871. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  100872. /** @hidden */
  100873. _markSubMeshesAsAttributesDirty(): void;
  100874. /** @hidden */
  100875. _markSubMeshesAsMiscDirty(): void;
  100876. /**
  100877. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  100878. */
  100879. get scaling(): Vector3;
  100880. set scaling(newScaling: Vector3);
  100881. /**
  100882. * Returns true if the mesh is blocked. Implemented by child classes
  100883. */
  100884. get isBlocked(): boolean;
  100885. /**
  100886. * Returns the mesh itself by default. Implemented by child classes
  100887. * @param camera defines the camera to use to pick the right LOD level
  100888. * @returns the currentAbstractMesh
  100889. */
  100890. getLOD(camera: Camera): Nullable<AbstractMesh>;
  100891. /**
  100892. * Returns 0 by default. Implemented by child classes
  100893. * @returns an integer
  100894. */
  100895. getTotalVertices(): number;
  100896. /**
  100897. * Returns a positive integer : the total number of indices in this mesh geometry.
  100898. * @returns the numner of indices or zero if the mesh has no geometry.
  100899. */
  100900. getTotalIndices(): number;
  100901. /**
  100902. * Returns null by default. Implemented by child classes
  100903. * @returns null
  100904. */
  100905. getIndices(): Nullable<IndicesArray>;
  100906. /**
  100907. * Returns the array of the requested vertex data kind. Implemented by child classes
  100908. * @param kind defines the vertex data kind to use
  100909. * @returns null
  100910. */
  100911. getVerticesData(kind: string): Nullable<FloatArray>;
  100912. /**
  100913. * Sets the vertex data of the mesh geometry for the requested `kind`.
  100914. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  100915. * Note that a new underlying VertexBuffer object is created each call.
  100916. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  100917. * @param kind defines vertex data kind:
  100918. * * VertexBuffer.PositionKind
  100919. * * VertexBuffer.UVKind
  100920. * * VertexBuffer.UV2Kind
  100921. * * VertexBuffer.UV3Kind
  100922. * * VertexBuffer.UV4Kind
  100923. * * VertexBuffer.UV5Kind
  100924. * * VertexBuffer.UV6Kind
  100925. * * VertexBuffer.ColorKind
  100926. * * VertexBuffer.MatricesIndicesKind
  100927. * * VertexBuffer.MatricesIndicesExtraKind
  100928. * * VertexBuffer.MatricesWeightsKind
  100929. * * VertexBuffer.MatricesWeightsExtraKind
  100930. * @param data defines the data source
  100931. * @param updatable defines if the data must be flagged as updatable (or static)
  100932. * @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
  100933. * @returns the current mesh
  100934. */
  100935. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  100936. /**
  100937. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  100938. * If the mesh has no geometry, it is simply returned as it is.
  100939. * @param kind defines vertex data kind:
  100940. * * VertexBuffer.PositionKind
  100941. * * VertexBuffer.UVKind
  100942. * * VertexBuffer.UV2Kind
  100943. * * VertexBuffer.UV3Kind
  100944. * * VertexBuffer.UV4Kind
  100945. * * VertexBuffer.UV5Kind
  100946. * * VertexBuffer.UV6Kind
  100947. * * VertexBuffer.ColorKind
  100948. * * VertexBuffer.MatricesIndicesKind
  100949. * * VertexBuffer.MatricesIndicesExtraKind
  100950. * * VertexBuffer.MatricesWeightsKind
  100951. * * VertexBuffer.MatricesWeightsExtraKind
  100952. * @param data defines the data source
  100953. * @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
  100954. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  100955. * @returns the current mesh
  100956. */
  100957. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  100958. /**
  100959. * Sets the mesh indices,
  100960. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  100961. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  100962. * @param totalVertices Defines the total number of vertices
  100963. * @returns the current mesh
  100964. */
  100965. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  100966. /**
  100967. * Gets a boolean indicating if specific vertex data is present
  100968. * @param kind defines the vertex data kind to use
  100969. * @returns true is data kind is present
  100970. */
  100971. isVerticesDataPresent(kind: string): boolean;
  100972. /**
  100973. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  100974. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  100975. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  100976. * @returns a BoundingInfo
  100977. */
  100978. getBoundingInfo(): BoundingInfo;
  100979. /**
  100980. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  100981. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  100982. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  100983. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  100984. * @returns the current mesh
  100985. */
  100986. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  100987. /**
  100988. * Overwrite the current bounding info
  100989. * @param boundingInfo defines the new bounding info
  100990. * @returns the current mesh
  100991. */
  100992. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  100993. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  100994. get useBones(): boolean;
  100995. /** @hidden */
  100996. _preActivate(): void;
  100997. /** @hidden */
  100998. _preActivateForIntermediateRendering(renderId: number): void;
  100999. /** @hidden */
  101000. _activate(renderId: number, intermediateRendering: boolean): boolean;
  101001. /** @hidden */
  101002. _postActivate(): void;
  101003. /** @hidden */
  101004. _freeze(): void;
  101005. /** @hidden */
  101006. _unFreeze(): void;
  101007. /**
  101008. * Gets the current world matrix
  101009. * @returns a Matrix
  101010. */
  101011. getWorldMatrix(): Matrix;
  101012. /** @hidden */
  101013. _getWorldMatrixDeterminant(): number;
  101014. /**
  101015. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  101016. */
  101017. get isAnInstance(): boolean;
  101018. /**
  101019. * Gets a boolean indicating if this mesh has instances
  101020. */
  101021. get hasInstances(): boolean;
  101022. /**
  101023. * Perform relative position change from the point of view of behind the front of the mesh.
  101024. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101025. * Supports definition of mesh facing forward or backward
  101026. * @param amountRight defines the distance on the right axis
  101027. * @param amountUp defines the distance on the up axis
  101028. * @param amountForward defines the distance on the forward axis
  101029. * @returns the current mesh
  101030. */
  101031. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  101032. /**
  101033. * Calculate relative position change from the point of view of behind the front of the mesh.
  101034. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101035. * Supports definition of mesh facing forward or backward
  101036. * @param amountRight defines the distance on the right axis
  101037. * @param amountUp defines the distance on the up axis
  101038. * @param amountForward defines the distance on the forward axis
  101039. * @returns the new displacement vector
  101040. */
  101041. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  101042. /**
  101043. * Perform relative rotation change from the point of view of behind the front of the mesh.
  101044. * Supports definition of mesh facing forward or backward
  101045. * @param flipBack defines the flip
  101046. * @param twirlClockwise defines the twirl
  101047. * @param tiltRight defines the tilt
  101048. * @returns the current mesh
  101049. */
  101050. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  101051. /**
  101052. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  101053. * Supports definition of mesh facing forward or backward.
  101054. * @param flipBack defines the flip
  101055. * @param twirlClockwise defines the twirl
  101056. * @param tiltRight defines the tilt
  101057. * @returns the new rotation vector
  101058. */
  101059. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  101060. /**
  101061. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  101062. * This means the mesh underlying bounding box and sphere are recomputed.
  101063. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  101064. * @returns the current mesh
  101065. */
  101066. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  101067. /** @hidden */
  101068. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  101069. /** @hidden */
  101070. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  101071. /** @hidden */
  101072. _updateBoundingInfo(): AbstractMesh;
  101073. /** @hidden */
  101074. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  101075. /** @hidden */
  101076. protected _afterComputeWorldMatrix(): void;
  101077. /** @hidden */
  101078. get _effectiveMesh(): AbstractMesh;
  101079. /**
  101080. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  101081. * A mesh is in the frustum if its bounding box intersects the frustum
  101082. * @param frustumPlanes defines the frustum to test
  101083. * @returns true if the mesh is in the frustum planes
  101084. */
  101085. isInFrustum(frustumPlanes: Plane[]): boolean;
  101086. /**
  101087. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  101088. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  101089. * @param frustumPlanes defines the frustum to test
  101090. * @returns true if the mesh is completely in the frustum planes
  101091. */
  101092. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  101093. /**
  101094. * True if the mesh intersects another mesh or a SolidParticle object
  101095. * @param mesh defines a target mesh or SolidParticle to test
  101096. * @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)
  101097. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  101098. * @returns true if there is an intersection
  101099. */
  101100. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  101101. /**
  101102. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  101103. * @param point defines the point to test
  101104. * @returns true if there is an intersection
  101105. */
  101106. intersectsPoint(point: Vector3): boolean;
  101107. /**
  101108. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  101109. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101110. */
  101111. get checkCollisions(): boolean;
  101112. set checkCollisions(collisionEnabled: boolean);
  101113. /**
  101114. * Gets Collider object used to compute collisions (not physics)
  101115. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101116. */
  101117. get collider(): Nullable<Collider>;
  101118. /**
  101119. * Move the mesh using collision engine
  101120. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101121. * @param displacement defines the requested displacement vector
  101122. * @returns the current mesh
  101123. */
  101124. moveWithCollisions(displacement: Vector3): AbstractMesh;
  101125. private _onCollisionPositionChange;
  101126. /** @hidden */
  101127. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  101128. /** @hidden */
  101129. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  101130. /** @hidden */
  101131. _checkCollision(collider: Collider): AbstractMesh;
  101132. /** @hidden */
  101133. _generatePointsArray(): boolean;
  101134. /**
  101135. * Checks if the passed Ray intersects with the mesh
  101136. * @param ray defines the ray to use
  101137. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  101138. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101139. * @returns the picking info
  101140. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  101141. */
  101142. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  101143. /**
  101144. * Clones the current mesh
  101145. * @param name defines the mesh name
  101146. * @param newParent defines the new mesh parent
  101147. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  101148. * @returns the new mesh
  101149. */
  101150. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  101151. /**
  101152. * Disposes all the submeshes of the current meshnp
  101153. * @returns the current mesh
  101154. */
  101155. releaseSubMeshes(): AbstractMesh;
  101156. /**
  101157. * Releases resources associated with this abstract mesh.
  101158. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101159. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101160. */
  101161. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101162. /**
  101163. * Adds the passed mesh as a child to the current mesh
  101164. * @param mesh defines the child mesh
  101165. * @returns the current mesh
  101166. */
  101167. addChild(mesh: AbstractMesh): AbstractMesh;
  101168. /**
  101169. * Removes the passed mesh from the current mesh children list
  101170. * @param mesh defines the child mesh
  101171. * @returns the current mesh
  101172. */
  101173. removeChild(mesh: AbstractMesh): AbstractMesh;
  101174. /** @hidden */
  101175. private _initFacetData;
  101176. /**
  101177. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  101178. * This method can be called within the render loop.
  101179. * 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
  101180. * @returns the current mesh
  101181. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101182. */
  101183. updateFacetData(): AbstractMesh;
  101184. /**
  101185. * Returns the facetLocalNormals array.
  101186. * The normals are expressed in the mesh local spac
  101187. * @returns an array of Vector3
  101188. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101189. */
  101190. getFacetLocalNormals(): Vector3[];
  101191. /**
  101192. * Returns the facetLocalPositions array.
  101193. * The facet positions are expressed in the mesh local space
  101194. * @returns an array of Vector3
  101195. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101196. */
  101197. getFacetLocalPositions(): Vector3[];
  101198. /**
  101199. * Returns the facetLocalPartioning array
  101200. * @returns an array of array of numbers
  101201. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101202. */
  101203. getFacetLocalPartitioning(): number[][];
  101204. /**
  101205. * Returns the i-th facet position in the world system.
  101206. * This method allocates a new Vector3 per call
  101207. * @param i defines the facet index
  101208. * @returns a new Vector3
  101209. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101210. */
  101211. getFacetPosition(i: number): Vector3;
  101212. /**
  101213. * Sets the reference Vector3 with the i-th facet position in the world system
  101214. * @param i defines the facet index
  101215. * @param ref defines the target vector
  101216. * @returns the current mesh
  101217. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101218. */
  101219. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  101220. /**
  101221. * Returns the i-th facet normal in the world system.
  101222. * This method allocates a new Vector3 per call
  101223. * @param i defines the facet index
  101224. * @returns a new Vector3
  101225. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101226. */
  101227. getFacetNormal(i: number): Vector3;
  101228. /**
  101229. * Sets the reference Vector3 with the i-th facet normal in the world system
  101230. * @param i defines the facet index
  101231. * @param ref defines the target vector
  101232. * @returns the current mesh
  101233. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101234. */
  101235. getFacetNormalToRef(i: number, ref: Vector3): this;
  101236. /**
  101237. * 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)
  101238. * @param x defines x coordinate
  101239. * @param y defines y coordinate
  101240. * @param z defines z coordinate
  101241. * @returns the array of facet indexes
  101242. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101243. */
  101244. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  101245. /**
  101246. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  101247. * @param projected sets as the (x,y,z) world projection on the facet
  101248. * @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
  101249. * @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
  101250. * @param x defines x coordinate
  101251. * @param y defines y coordinate
  101252. * @param z defines z coordinate
  101253. * @returns the face index if found (or null instead)
  101254. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101255. */
  101256. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101257. /**
  101258. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  101259. * @param projected sets as the (x,y,z) local projection on the facet
  101260. * @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
  101261. * @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
  101262. * @param x defines x coordinate
  101263. * @param y defines y coordinate
  101264. * @param z defines z coordinate
  101265. * @returns the face index if found (or null instead)
  101266. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101267. */
  101268. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101269. /**
  101270. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  101271. * @returns the parameters
  101272. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101273. */
  101274. getFacetDataParameters(): any;
  101275. /**
  101276. * Disables the feature FacetData and frees the related memory
  101277. * @returns the current mesh
  101278. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101279. */
  101280. disableFacetData(): AbstractMesh;
  101281. /**
  101282. * Updates the AbstractMesh indices array
  101283. * @param indices defines the data source
  101284. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  101285. * @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)
  101286. * @returns the current mesh
  101287. */
  101288. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  101289. /**
  101290. * Creates new normals data for the mesh
  101291. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  101292. * @returns the current mesh
  101293. */
  101294. createNormals(updatable: boolean): AbstractMesh;
  101295. /**
  101296. * Align the mesh with a normal
  101297. * @param normal defines the normal to use
  101298. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  101299. * @returns the current mesh
  101300. */
  101301. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  101302. /** @hidden */
  101303. _checkOcclusionQuery(): boolean;
  101304. /**
  101305. * Disables the mesh edge rendering mode
  101306. * @returns the currentAbstractMesh
  101307. */
  101308. disableEdgesRendering(): AbstractMesh;
  101309. /**
  101310. * Enables the edge rendering mode on the mesh.
  101311. * This mode makes the mesh edges visible
  101312. * @param epsilon defines the maximal distance between two angles to detect a face
  101313. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  101314. * @returns the currentAbstractMesh
  101315. * @see https://www.babylonjs-playground.com/#19O9TU#0
  101316. */
  101317. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  101318. }
  101319. }
  101320. declare module BABYLON {
  101321. /**
  101322. * Interface used to define ActionEvent
  101323. */
  101324. export interface IActionEvent {
  101325. /** The mesh or sprite that triggered the action */
  101326. source: any;
  101327. /** The X mouse cursor position at the time of the event */
  101328. pointerX: number;
  101329. /** The Y mouse cursor position at the time of the event */
  101330. pointerY: number;
  101331. /** The mesh that is currently pointed at (can be null) */
  101332. meshUnderPointer: Nullable<AbstractMesh>;
  101333. /** the original (browser) event that triggered the ActionEvent */
  101334. sourceEvent?: any;
  101335. /** additional data for the event */
  101336. additionalData?: any;
  101337. }
  101338. /**
  101339. * ActionEvent is the event being sent when an action is triggered.
  101340. */
  101341. export class ActionEvent implements IActionEvent {
  101342. /** The mesh or sprite that triggered the action */
  101343. source: any;
  101344. /** The X mouse cursor position at the time of the event */
  101345. pointerX: number;
  101346. /** The Y mouse cursor position at the time of the event */
  101347. pointerY: number;
  101348. /** The mesh that is currently pointed at (can be null) */
  101349. meshUnderPointer: Nullable<AbstractMesh>;
  101350. /** the original (browser) event that triggered the ActionEvent */
  101351. sourceEvent?: any;
  101352. /** additional data for the event */
  101353. additionalData?: any;
  101354. /**
  101355. * Creates a new ActionEvent
  101356. * @param source The mesh or sprite that triggered the action
  101357. * @param pointerX The X mouse cursor position at the time of the event
  101358. * @param pointerY The Y mouse cursor position at the time of the event
  101359. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  101360. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  101361. * @param additionalData additional data for the event
  101362. */
  101363. constructor(
  101364. /** The mesh or sprite that triggered the action */
  101365. source: any,
  101366. /** The X mouse cursor position at the time of the event */
  101367. pointerX: number,
  101368. /** The Y mouse cursor position at the time of the event */
  101369. pointerY: number,
  101370. /** The mesh that is currently pointed at (can be null) */
  101371. meshUnderPointer: Nullable<AbstractMesh>,
  101372. /** the original (browser) event that triggered the ActionEvent */
  101373. sourceEvent?: any,
  101374. /** additional data for the event */
  101375. additionalData?: any);
  101376. /**
  101377. * Helper function to auto-create an ActionEvent from a source mesh.
  101378. * @param source The source mesh that triggered the event
  101379. * @param evt The original (browser) event
  101380. * @param additionalData additional data for the event
  101381. * @returns the new ActionEvent
  101382. */
  101383. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  101384. /**
  101385. * Helper function to auto-create an ActionEvent from a source sprite
  101386. * @param source The source sprite that triggered the event
  101387. * @param scene Scene associated with the sprite
  101388. * @param evt The original (browser) event
  101389. * @param additionalData additional data for the event
  101390. * @returns the new ActionEvent
  101391. */
  101392. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  101393. /**
  101394. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  101395. * @param scene the scene where the event occurred
  101396. * @param evt The original (browser) event
  101397. * @returns the new ActionEvent
  101398. */
  101399. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  101400. /**
  101401. * Helper function to auto-create an ActionEvent from a primitive
  101402. * @param prim defines the target primitive
  101403. * @param pointerPos defines the pointer position
  101404. * @param evt The original (browser) event
  101405. * @param additionalData additional data for the event
  101406. * @returns the new ActionEvent
  101407. */
  101408. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  101409. }
  101410. }
  101411. declare module BABYLON {
  101412. /**
  101413. * Abstract class used to decouple action Manager from scene and meshes.
  101414. * Do not instantiate.
  101415. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101416. */
  101417. export abstract class AbstractActionManager implements IDisposable {
  101418. /** Gets the list of active triggers */
  101419. static Triggers: {
  101420. [key: string]: number;
  101421. };
  101422. /** Gets the cursor to use when hovering items */
  101423. hoverCursor: string;
  101424. /** Gets the list of actions */
  101425. actions: IAction[];
  101426. /**
  101427. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  101428. */
  101429. isRecursive: boolean;
  101430. /**
  101431. * Releases all associated resources
  101432. */
  101433. abstract dispose(): void;
  101434. /**
  101435. * Does this action manager has pointer triggers
  101436. */
  101437. abstract get hasPointerTriggers(): boolean;
  101438. /**
  101439. * Does this action manager has pick triggers
  101440. */
  101441. abstract get hasPickTriggers(): boolean;
  101442. /**
  101443. * Process a specific trigger
  101444. * @param trigger defines the trigger to process
  101445. * @param evt defines the event details to be processed
  101446. */
  101447. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  101448. /**
  101449. * Does this action manager handles actions of any of the given triggers
  101450. * @param triggers defines the triggers to be tested
  101451. * @return a boolean indicating whether one (or more) of the triggers is handled
  101452. */
  101453. abstract hasSpecificTriggers(triggers: number[]): boolean;
  101454. /**
  101455. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  101456. * speed.
  101457. * @param triggerA defines the trigger to be tested
  101458. * @param triggerB defines the trigger to be tested
  101459. * @return a boolean indicating whether one (or more) of the triggers is handled
  101460. */
  101461. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  101462. /**
  101463. * Does this action manager handles actions of a given trigger
  101464. * @param trigger defines the trigger to be tested
  101465. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  101466. * @return whether the trigger is handled
  101467. */
  101468. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  101469. /**
  101470. * Serialize this manager to a JSON object
  101471. * @param name defines the property name to store this manager
  101472. * @returns a JSON representation of this manager
  101473. */
  101474. abstract serialize(name: string): any;
  101475. /**
  101476. * Registers an action to this action manager
  101477. * @param action defines the action to be registered
  101478. * @return the action amended (prepared) after registration
  101479. */
  101480. abstract registerAction(action: IAction): Nullable<IAction>;
  101481. /**
  101482. * Unregisters an action to this action manager
  101483. * @param action defines the action to be unregistered
  101484. * @return a boolean indicating whether the action has been unregistered
  101485. */
  101486. abstract unregisterAction(action: IAction): Boolean;
  101487. /**
  101488. * Does exist one action manager with at least one trigger
  101489. **/
  101490. static get HasTriggers(): boolean;
  101491. /**
  101492. * Does exist one action manager with at least one pick trigger
  101493. **/
  101494. static get HasPickTriggers(): boolean;
  101495. /**
  101496. * Does exist one action manager that handles actions of a given trigger
  101497. * @param trigger defines the trigger to be tested
  101498. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  101499. **/
  101500. static HasSpecificTrigger(trigger: number): boolean;
  101501. }
  101502. }
  101503. declare module BABYLON {
  101504. /**
  101505. * Defines how a node can be built from a string name.
  101506. */
  101507. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  101508. /**
  101509. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  101510. */
  101511. export class Node implements IBehaviorAware<Node> {
  101512. /** @hidden */
  101513. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  101514. private static _NodeConstructors;
  101515. /**
  101516. * Add a new node constructor
  101517. * @param type defines the type name of the node to construct
  101518. * @param constructorFunc defines the constructor function
  101519. */
  101520. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  101521. /**
  101522. * Returns a node constructor based on type name
  101523. * @param type defines the type name
  101524. * @param name defines the new node name
  101525. * @param scene defines the hosting scene
  101526. * @param options defines optional options to transmit to constructors
  101527. * @returns the new constructor or null
  101528. */
  101529. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  101530. /**
  101531. * Gets or sets the name of the node
  101532. */
  101533. name: string;
  101534. /**
  101535. * Gets or sets the id of the node
  101536. */
  101537. id: string;
  101538. /**
  101539. * Gets or sets the unique id of the node
  101540. */
  101541. uniqueId: number;
  101542. /**
  101543. * Gets or sets a string used to store user defined state for the node
  101544. */
  101545. state: string;
  101546. /**
  101547. * Gets or sets an object used to store user defined information for the node
  101548. */
  101549. metadata: any;
  101550. /**
  101551. * For internal use only. Please do not use.
  101552. */
  101553. reservedDataStore: any;
  101554. /**
  101555. * List of inspectable custom properties (used by the Inspector)
  101556. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101557. */
  101558. inspectableCustomProperties: IInspectable[];
  101559. private _doNotSerialize;
  101560. /**
  101561. * Gets or sets a boolean used to define if the node must be serialized
  101562. */
  101563. get doNotSerialize(): boolean;
  101564. set doNotSerialize(value: boolean);
  101565. /** @hidden */
  101566. _isDisposed: boolean;
  101567. /**
  101568. * Gets a list of Animations associated with the node
  101569. */
  101570. animations: Animation[];
  101571. protected _ranges: {
  101572. [name: string]: Nullable<AnimationRange>;
  101573. };
  101574. /**
  101575. * Callback raised when the node is ready to be used
  101576. */
  101577. onReady: Nullable<(node: Node) => void>;
  101578. private _isEnabled;
  101579. private _isParentEnabled;
  101580. private _isReady;
  101581. /** @hidden */
  101582. _currentRenderId: number;
  101583. private _parentUpdateId;
  101584. /** @hidden */
  101585. _childUpdateId: number;
  101586. /** @hidden */
  101587. _waitingParentId: Nullable<string>;
  101588. /** @hidden */
  101589. _scene: Scene;
  101590. /** @hidden */
  101591. _cache: any;
  101592. private _parentNode;
  101593. private _children;
  101594. /** @hidden */
  101595. _worldMatrix: Matrix;
  101596. /** @hidden */
  101597. _worldMatrixDeterminant: number;
  101598. /** @hidden */
  101599. _worldMatrixDeterminantIsDirty: boolean;
  101600. /** @hidden */
  101601. private _sceneRootNodesIndex;
  101602. /**
  101603. * Gets a boolean indicating if the node has been disposed
  101604. * @returns true if the node was disposed
  101605. */
  101606. isDisposed(): boolean;
  101607. /**
  101608. * Gets or sets the parent of the node (without keeping the current position in the scene)
  101609. * @see https://doc.babylonjs.com/how_to/parenting
  101610. */
  101611. set parent(parent: Nullable<Node>);
  101612. get parent(): Nullable<Node>;
  101613. /** @hidden */
  101614. _addToSceneRootNodes(): void;
  101615. /** @hidden */
  101616. _removeFromSceneRootNodes(): void;
  101617. private _animationPropertiesOverride;
  101618. /**
  101619. * Gets or sets the animation properties override
  101620. */
  101621. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  101622. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  101623. /**
  101624. * Gets a string idenfifying the name of the class
  101625. * @returns "Node" string
  101626. */
  101627. getClassName(): string;
  101628. /** @hidden */
  101629. readonly _isNode: boolean;
  101630. /**
  101631. * An event triggered when the mesh is disposed
  101632. */
  101633. onDisposeObservable: Observable<Node>;
  101634. private _onDisposeObserver;
  101635. /**
  101636. * Sets a callback that will be raised when the node will be disposed
  101637. */
  101638. set onDispose(callback: () => void);
  101639. /**
  101640. * Creates a new Node
  101641. * @param name the name and id to be given to this node
  101642. * @param scene the scene this node will be added to
  101643. */
  101644. constructor(name: string, scene?: Nullable<Scene>);
  101645. /**
  101646. * Gets the scene of the node
  101647. * @returns a scene
  101648. */
  101649. getScene(): Scene;
  101650. /**
  101651. * Gets the engine of the node
  101652. * @returns a Engine
  101653. */
  101654. getEngine(): Engine;
  101655. private _behaviors;
  101656. /**
  101657. * Attach a behavior to the node
  101658. * @see http://doc.babylonjs.com/features/behaviour
  101659. * @param behavior defines the behavior to attach
  101660. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  101661. * @returns the current Node
  101662. */
  101663. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  101664. /**
  101665. * Remove an attached behavior
  101666. * @see http://doc.babylonjs.com/features/behaviour
  101667. * @param behavior defines the behavior to attach
  101668. * @returns the current Node
  101669. */
  101670. removeBehavior(behavior: Behavior<Node>): Node;
  101671. /**
  101672. * Gets the list of attached behaviors
  101673. * @see http://doc.babylonjs.com/features/behaviour
  101674. */
  101675. get behaviors(): Behavior<Node>[];
  101676. /**
  101677. * Gets an attached behavior by name
  101678. * @param name defines the name of the behavior to look for
  101679. * @see http://doc.babylonjs.com/features/behaviour
  101680. * @returns null if behavior was not found else the requested behavior
  101681. */
  101682. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  101683. /**
  101684. * Returns the latest update of the World matrix
  101685. * @returns a Matrix
  101686. */
  101687. getWorldMatrix(): Matrix;
  101688. /** @hidden */
  101689. _getWorldMatrixDeterminant(): number;
  101690. /**
  101691. * Returns directly the latest state of the mesh World matrix.
  101692. * A Matrix is returned.
  101693. */
  101694. get worldMatrixFromCache(): Matrix;
  101695. /** @hidden */
  101696. _initCache(): void;
  101697. /** @hidden */
  101698. updateCache(force?: boolean): void;
  101699. /** @hidden */
  101700. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  101701. /** @hidden */
  101702. _updateCache(ignoreParentClass?: boolean): void;
  101703. /** @hidden */
  101704. _isSynchronized(): boolean;
  101705. /** @hidden */
  101706. _markSyncedWithParent(): void;
  101707. /** @hidden */
  101708. isSynchronizedWithParent(): boolean;
  101709. /** @hidden */
  101710. isSynchronized(): boolean;
  101711. /**
  101712. * Is this node ready to be used/rendered
  101713. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  101714. * @return true if the node is ready
  101715. */
  101716. isReady(completeCheck?: boolean): boolean;
  101717. /**
  101718. * Is this node enabled?
  101719. * 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
  101720. * @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
  101721. * @return whether this node (and its parent) is enabled
  101722. */
  101723. isEnabled(checkAncestors?: boolean): boolean;
  101724. /** @hidden */
  101725. protected _syncParentEnabledState(): void;
  101726. /**
  101727. * Set the enabled state of this node
  101728. * @param value defines the new enabled state
  101729. */
  101730. setEnabled(value: boolean): void;
  101731. /**
  101732. * Is this node a descendant of the given node?
  101733. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  101734. * @param ancestor defines the parent node to inspect
  101735. * @returns a boolean indicating if this node is a descendant of the given node
  101736. */
  101737. isDescendantOf(ancestor: Node): boolean;
  101738. /** @hidden */
  101739. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  101740. /**
  101741. * Will return all nodes that have this node as ascendant
  101742. * @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
  101743. * @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
  101744. * @return all children nodes of all types
  101745. */
  101746. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  101747. /**
  101748. * Get all child-meshes of this node
  101749. * @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)
  101750. * @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
  101751. * @returns an array of AbstractMesh
  101752. */
  101753. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  101754. /**
  101755. * Get all direct children of this node
  101756. * @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
  101757. * @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)
  101758. * @returns an array of Node
  101759. */
  101760. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  101761. /** @hidden */
  101762. _setReady(state: boolean): void;
  101763. /**
  101764. * Get an animation by name
  101765. * @param name defines the name of the animation to look for
  101766. * @returns null if not found else the requested animation
  101767. */
  101768. getAnimationByName(name: string): Nullable<Animation>;
  101769. /**
  101770. * Creates an animation range for this node
  101771. * @param name defines the name of the range
  101772. * @param from defines the starting key
  101773. * @param to defines the end key
  101774. */
  101775. createAnimationRange(name: string, from: number, to: number): void;
  101776. /**
  101777. * Delete a specific animation range
  101778. * @param name defines the name of the range to delete
  101779. * @param deleteFrames defines if animation frames from the range must be deleted as well
  101780. */
  101781. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  101782. /**
  101783. * Get an animation range by name
  101784. * @param name defines the name of the animation range to look for
  101785. * @returns null if not found else the requested animation range
  101786. */
  101787. getAnimationRange(name: string): Nullable<AnimationRange>;
  101788. /**
  101789. * Gets the list of all animation ranges defined on this node
  101790. * @returns an array
  101791. */
  101792. getAnimationRanges(): Nullable<AnimationRange>[];
  101793. /**
  101794. * Will start the animation sequence
  101795. * @param name defines the range frames for animation sequence
  101796. * @param loop defines if the animation should loop (false by default)
  101797. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  101798. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  101799. * @returns the object created for this animation. If range does not exist, it will return null
  101800. */
  101801. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  101802. /**
  101803. * Serialize animation ranges into a JSON compatible object
  101804. * @returns serialization object
  101805. */
  101806. serializeAnimationRanges(): any;
  101807. /**
  101808. * Computes the world matrix of the node
  101809. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  101810. * @returns the world matrix
  101811. */
  101812. computeWorldMatrix(force?: boolean): Matrix;
  101813. /**
  101814. * Releases resources associated with this node.
  101815. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101816. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101817. */
  101818. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101819. /**
  101820. * Parse animation range data from a serialization object and store them into a given node
  101821. * @param node defines where to store the animation ranges
  101822. * @param parsedNode defines the serialization object to read data from
  101823. * @param scene defines the hosting scene
  101824. */
  101825. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  101826. /**
  101827. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  101828. * @param includeDescendants Include bounding info from descendants as well (true by default)
  101829. * @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
  101830. * @returns the new bounding vectors
  101831. */
  101832. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  101833. min: Vector3;
  101834. max: Vector3;
  101835. };
  101836. }
  101837. }
  101838. declare module BABYLON {
  101839. /**
  101840. * @hidden
  101841. */
  101842. export class _IAnimationState {
  101843. key: number;
  101844. repeatCount: number;
  101845. workValue?: any;
  101846. loopMode?: number;
  101847. offsetValue?: any;
  101848. highLimitValue?: any;
  101849. }
  101850. /**
  101851. * Class used to store any kind of animation
  101852. */
  101853. export class Animation {
  101854. /**Name of the animation */
  101855. name: string;
  101856. /**Property to animate */
  101857. targetProperty: string;
  101858. /**The frames per second of the animation */
  101859. framePerSecond: number;
  101860. /**The data type of the animation */
  101861. dataType: number;
  101862. /**The loop mode of the animation */
  101863. loopMode?: number | undefined;
  101864. /**Specifies if blending should be enabled */
  101865. enableBlending?: boolean | undefined;
  101866. /**
  101867. * Use matrix interpolation instead of using direct key value when animating matrices
  101868. */
  101869. static AllowMatricesInterpolation: boolean;
  101870. /**
  101871. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  101872. */
  101873. static AllowMatrixDecomposeForInterpolation: boolean;
  101874. /**
  101875. * Stores the key frames of the animation
  101876. */
  101877. private _keys;
  101878. /**
  101879. * Stores the easing function of the animation
  101880. */
  101881. private _easingFunction;
  101882. /**
  101883. * @hidden Internal use only
  101884. */
  101885. _runtimeAnimations: RuntimeAnimation[];
  101886. /**
  101887. * The set of event that will be linked to this animation
  101888. */
  101889. private _events;
  101890. /**
  101891. * Stores an array of target property paths
  101892. */
  101893. targetPropertyPath: string[];
  101894. /**
  101895. * Stores the blending speed of the animation
  101896. */
  101897. blendingSpeed: number;
  101898. /**
  101899. * Stores the animation ranges for the animation
  101900. */
  101901. private _ranges;
  101902. /**
  101903. * @hidden Internal use
  101904. */
  101905. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  101906. /**
  101907. * Sets up an animation
  101908. * @param property The property to animate
  101909. * @param animationType The animation type to apply
  101910. * @param framePerSecond The frames per second of the animation
  101911. * @param easingFunction The easing function used in the animation
  101912. * @returns The created animation
  101913. */
  101914. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  101915. /**
  101916. * Create and start an animation on a node
  101917. * @param name defines the name of the global animation that will be run on all nodes
  101918. * @param node defines the root node where the animation will take place
  101919. * @param targetProperty defines property to animate
  101920. * @param framePerSecond defines the number of frame per second yo use
  101921. * @param totalFrame defines the number of frames in total
  101922. * @param from defines the initial value
  101923. * @param to defines the final value
  101924. * @param loopMode defines which loop mode you want to use (off by default)
  101925. * @param easingFunction defines the easing function to use (linear by default)
  101926. * @param onAnimationEnd defines the callback to call when animation end
  101927. * @returns the animatable created for this animation
  101928. */
  101929. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  101930. /**
  101931. * Create and start an animation on a node and its descendants
  101932. * @param name defines the name of the global animation that will be run on all nodes
  101933. * @param node defines the root node where the animation will take place
  101934. * @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
  101935. * @param targetProperty defines property to animate
  101936. * @param framePerSecond defines the number of frame per second to use
  101937. * @param totalFrame defines the number of frames in total
  101938. * @param from defines the initial value
  101939. * @param to defines the final value
  101940. * @param loopMode defines which loop mode you want to use (off by default)
  101941. * @param easingFunction defines the easing function to use (linear by default)
  101942. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  101943. * @returns the list of animatables created for all nodes
  101944. * @example https://www.babylonjs-playground.com/#MH0VLI
  101945. */
  101946. 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[]>;
  101947. /**
  101948. * Creates a new animation, merges it with the existing animations and starts it
  101949. * @param name Name of the animation
  101950. * @param node Node which contains the scene that begins the animations
  101951. * @param targetProperty Specifies which property to animate
  101952. * @param framePerSecond The frames per second of the animation
  101953. * @param totalFrame The total number of frames
  101954. * @param from The frame at the beginning of the animation
  101955. * @param to The frame at the end of the animation
  101956. * @param loopMode Specifies the loop mode of the animation
  101957. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  101958. * @param onAnimationEnd Callback to run once the animation is complete
  101959. * @returns Nullable animation
  101960. */
  101961. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  101962. /**
  101963. * Transition property of an host to the target Value
  101964. * @param property The property to transition
  101965. * @param targetValue The target Value of the property
  101966. * @param host The object where the property to animate belongs
  101967. * @param scene Scene used to run the animation
  101968. * @param frameRate Framerate (in frame/s) to use
  101969. * @param transition The transition type we want to use
  101970. * @param duration The duration of the animation, in milliseconds
  101971. * @param onAnimationEnd Callback trigger at the end of the animation
  101972. * @returns Nullable animation
  101973. */
  101974. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  101975. /**
  101976. * Return the array of runtime animations currently using this animation
  101977. */
  101978. get runtimeAnimations(): RuntimeAnimation[];
  101979. /**
  101980. * Specifies if any of the runtime animations are currently running
  101981. */
  101982. get hasRunningRuntimeAnimations(): boolean;
  101983. /**
  101984. * Initializes the animation
  101985. * @param name Name of the animation
  101986. * @param targetProperty Property to animate
  101987. * @param framePerSecond The frames per second of the animation
  101988. * @param dataType The data type of the animation
  101989. * @param loopMode The loop mode of the animation
  101990. * @param enableBlending Specifies if blending should be enabled
  101991. */
  101992. constructor(
  101993. /**Name of the animation */
  101994. name: string,
  101995. /**Property to animate */
  101996. targetProperty: string,
  101997. /**The frames per second of the animation */
  101998. framePerSecond: number,
  101999. /**The data type of the animation */
  102000. dataType: number,
  102001. /**The loop mode of the animation */
  102002. loopMode?: number | undefined,
  102003. /**Specifies if blending should be enabled */
  102004. enableBlending?: boolean | undefined);
  102005. /**
  102006. * Converts the animation to a string
  102007. * @param fullDetails support for multiple levels of logging within scene loading
  102008. * @returns String form of the animation
  102009. */
  102010. toString(fullDetails?: boolean): string;
  102011. /**
  102012. * Add an event to this animation
  102013. * @param event Event to add
  102014. */
  102015. addEvent(event: AnimationEvent): void;
  102016. /**
  102017. * Remove all events found at the given frame
  102018. * @param frame The frame to remove events from
  102019. */
  102020. removeEvents(frame: number): void;
  102021. /**
  102022. * Retrieves all the events from the animation
  102023. * @returns Events from the animation
  102024. */
  102025. getEvents(): AnimationEvent[];
  102026. /**
  102027. * Creates an animation range
  102028. * @param name Name of the animation range
  102029. * @param from Starting frame of the animation range
  102030. * @param to Ending frame of the animation
  102031. */
  102032. createRange(name: string, from: number, to: number): void;
  102033. /**
  102034. * Deletes an animation range by name
  102035. * @param name Name of the animation range to delete
  102036. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  102037. */
  102038. deleteRange(name: string, deleteFrames?: boolean): void;
  102039. /**
  102040. * Gets the animation range by name, or null if not defined
  102041. * @param name Name of the animation range
  102042. * @returns Nullable animation range
  102043. */
  102044. getRange(name: string): Nullable<AnimationRange>;
  102045. /**
  102046. * Gets the key frames from the animation
  102047. * @returns The key frames of the animation
  102048. */
  102049. getKeys(): Array<IAnimationKey>;
  102050. /**
  102051. * Gets the highest frame rate of the animation
  102052. * @returns Highest frame rate of the animation
  102053. */
  102054. getHighestFrame(): number;
  102055. /**
  102056. * Gets the easing function of the animation
  102057. * @returns Easing function of the animation
  102058. */
  102059. getEasingFunction(): IEasingFunction;
  102060. /**
  102061. * Sets the easing function of the animation
  102062. * @param easingFunction A custom mathematical formula for animation
  102063. */
  102064. setEasingFunction(easingFunction: EasingFunction): void;
  102065. /**
  102066. * Interpolates a scalar linearly
  102067. * @param startValue Start value of the animation curve
  102068. * @param endValue End value of the animation curve
  102069. * @param gradient Scalar amount to interpolate
  102070. * @returns Interpolated scalar value
  102071. */
  102072. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  102073. /**
  102074. * Interpolates a scalar cubically
  102075. * @param startValue Start value of the animation curve
  102076. * @param outTangent End tangent of the animation
  102077. * @param endValue End value of the animation curve
  102078. * @param inTangent Start tangent of the animation curve
  102079. * @param gradient Scalar amount to interpolate
  102080. * @returns Interpolated scalar value
  102081. */
  102082. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  102083. /**
  102084. * Interpolates a quaternion using a spherical linear interpolation
  102085. * @param startValue Start value of the animation curve
  102086. * @param endValue End value of the animation curve
  102087. * @param gradient Scalar amount to interpolate
  102088. * @returns Interpolated quaternion value
  102089. */
  102090. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  102091. /**
  102092. * Interpolates a quaternion cubically
  102093. * @param startValue Start value of the animation curve
  102094. * @param outTangent End tangent of the animation curve
  102095. * @param endValue End value of the animation curve
  102096. * @param inTangent Start tangent of the animation curve
  102097. * @param gradient Scalar amount to interpolate
  102098. * @returns Interpolated quaternion value
  102099. */
  102100. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  102101. /**
  102102. * Interpolates a Vector3 linearl
  102103. * @param startValue Start value of the animation curve
  102104. * @param endValue End value of the animation curve
  102105. * @param gradient Scalar amount to interpolate
  102106. * @returns Interpolated scalar value
  102107. */
  102108. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  102109. /**
  102110. * Interpolates a Vector3 cubically
  102111. * @param startValue Start value of the animation curve
  102112. * @param outTangent End tangent of the animation
  102113. * @param endValue End value of the animation curve
  102114. * @param inTangent Start tangent of the animation curve
  102115. * @param gradient Scalar amount to interpolate
  102116. * @returns InterpolatedVector3 value
  102117. */
  102118. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  102119. /**
  102120. * Interpolates a Vector2 linearly
  102121. * @param startValue Start value of the animation curve
  102122. * @param endValue End value of the animation curve
  102123. * @param gradient Scalar amount to interpolate
  102124. * @returns Interpolated Vector2 value
  102125. */
  102126. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  102127. /**
  102128. * Interpolates a Vector2 cubically
  102129. * @param startValue Start value of the animation curve
  102130. * @param outTangent End tangent of the animation
  102131. * @param endValue End value of the animation curve
  102132. * @param inTangent Start tangent of the animation curve
  102133. * @param gradient Scalar amount to interpolate
  102134. * @returns Interpolated Vector2 value
  102135. */
  102136. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  102137. /**
  102138. * Interpolates a size linearly
  102139. * @param startValue Start value of the animation curve
  102140. * @param endValue End value of the animation curve
  102141. * @param gradient Scalar amount to interpolate
  102142. * @returns Interpolated Size value
  102143. */
  102144. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  102145. /**
  102146. * Interpolates a Color3 linearly
  102147. * @param startValue Start value of the animation curve
  102148. * @param endValue End value of the animation curve
  102149. * @param gradient Scalar amount to interpolate
  102150. * @returns Interpolated Color3 value
  102151. */
  102152. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  102153. /**
  102154. * Interpolates a Color4 linearly
  102155. * @param startValue Start value of the animation curve
  102156. * @param endValue End value of the animation curve
  102157. * @param gradient Scalar amount to interpolate
  102158. * @returns Interpolated Color3 value
  102159. */
  102160. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  102161. /**
  102162. * @hidden Internal use only
  102163. */
  102164. _getKeyValue(value: any): any;
  102165. /**
  102166. * @hidden Internal use only
  102167. */
  102168. _interpolate(currentFrame: number, state: _IAnimationState): any;
  102169. /**
  102170. * Defines the function to use to interpolate matrices
  102171. * @param startValue defines the start matrix
  102172. * @param endValue defines the end matrix
  102173. * @param gradient defines the gradient between both matrices
  102174. * @param result defines an optional target matrix where to store the interpolation
  102175. * @returns the interpolated matrix
  102176. */
  102177. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  102178. /**
  102179. * Makes a copy of the animation
  102180. * @returns Cloned animation
  102181. */
  102182. clone(): Animation;
  102183. /**
  102184. * Sets the key frames of the animation
  102185. * @param values The animation key frames to set
  102186. */
  102187. setKeys(values: Array<IAnimationKey>): void;
  102188. /**
  102189. * Serializes the animation to an object
  102190. * @returns Serialized object
  102191. */
  102192. serialize(): any;
  102193. /**
  102194. * Float animation type
  102195. */
  102196. static readonly ANIMATIONTYPE_FLOAT: number;
  102197. /**
  102198. * Vector3 animation type
  102199. */
  102200. static readonly ANIMATIONTYPE_VECTOR3: number;
  102201. /**
  102202. * Quaternion animation type
  102203. */
  102204. static readonly ANIMATIONTYPE_QUATERNION: number;
  102205. /**
  102206. * Matrix animation type
  102207. */
  102208. static readonly ANIMATIONTYPE_MATRIX: number;
  102209. /**
  102210. * Color3 animation type
  102211. */
  102212. static readonly ANIMATIONTYPE_COLOR3: number;
  102213. /**
  102214. * Color3 animation type
  102215. */
  102216. static readonly ANIMATIONTYPE_COLOR4: number;
  102217. /**
  102218. * Vector2 animation type
  102219. */
  102220. static readonly ANIMATIONTYPE_VECTOR2: number;
  102221. /**
  102222. * Size animation type
  102223. */
  102224. static readonly ANIMATIONTYPE_SIZE: number;
  102225. /**
  102226. * Relative Loop Mode
  102227. */
  102228. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  102229. /**
  102230. * Cycle Loop Mode
  102231. */
  102232. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  102233. /**
  102234. * Constant Loop Mode
  102235. */
  102236. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  102237. /** @hidden */
  102238. static _UniversalLerp(left: any, right: any, amount: number): any;
  102239. /**
  102240. * Parses an animation object and creates an animation
  102241. * @param parsedAnimation Parsed animation object
  102242. * @returns Animation object
  102243. */
  102244. static Parse(parsedAnimation: any): Animation;
  102245. /**
  102246. * Appends the serialized animations from the source animations
  102247. * @param source Source containing the animations
  102248. * @param destination Target to store the animations
  102249. */
  102250. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102251. }
  102252. }
  102253. declare module BABYLON {
  102254. /**
  102255. * Interface containing an array of animations
  102256. */
  102257. export interface IAnimatable {
  102258. /**
  102259. * Array of animations
  102260. */
  102261. animations: Nullable<Array<Animation>>;
  102262. }
  102263. }
  102264. declare module BABYLON {
  102265. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  102266. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102267. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102268. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102269. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102270. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102271. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102272. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102273. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102274. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102275. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102276. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102277. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102278. /**
  102279. * Decorator used to define property that can be serialized as reference to a camera
  102280. * @param sourceName defines the name of the property to decorate
  102281. */
  102282. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102283. /**
  102284. * Class used to help serialization objects
  102285. */
  102286. export class SerializationHelper {
  102287. /** @hidden */
  102288. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  102289. /** @hidden */
  102290. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  102291. /** @hidden */
  102292. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  102293. /** @hidden */
  102294. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  102295. /**
  102296. * Appends the serialized animations from the source animations
  102297. * @param source Source containing the animations
  102298. * @param destination Target to store the animations
  102299. */
  102300. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102301. /**
  102302. * Static function used to serialized a specific entity
  102303. * @param entity defines the entity to serialize
  102304. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  102305. * @returns a JSON compatible object representing the serialization of the entity
  102306. */
  102307. static Serialize<T>(entity: T, serializationObject?: any): any;
  102308. /**
  102309. * Creates a new entity from a serialization data object
  102310. * @param creationFunction defines a function used to instanciated the new entity
  102311. * @param source defines the source serialization data
  102312. * @param scene defines the hosting scene
  102313. * @param rootUrl defines the root url for resources
  102314. * @returns a new entity
  102315. */
  102316. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  102317. /**
  102318. * Clones an object
  102319. * @param creationFunction defines the function used to instanciate the new object
  102320. * @param source defines the source object
  102321. * @returns the cloned object
  102322. */
  102323. static Clone<T>(creationFunction: () => T, source: T): T;
  102324. /**
  102325. * Instanciates a new object based on a source one (some data will be shared between both object)
  102326. * @param creationFunction defines the function used to instanciate the new object
  102327. * @param source defines the source object
  102328. * @returns the new object
  102329. */
  102330. static Instanciate<T>(creationFunction: () => T, source: T): T;
  102331. }
  102332. }
  102333. declare module BABYLON {
  102334. /**
  102335. * Class used to manipulate GUIDs
  102336. */
  102337. export class GUID {
  102338. /**
  102339. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102340. * Be aware Math.random() could cause collisions, but:
  102341. * "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"
  102342. * @returns a pseudo random id
  102343. */
  102344. static RandomId(): string;
  102345. }
  102346. }
  102347. declare module BABYLON {
  102348. /**
  102349. * Base class of all the textures in babylon.
  102350. * It groups all the common properties the materials, post process, lights... might need
  102351. * in order to make a correct use of the texture.
  102352. */
  102353. export class BaseTexture implements IAnimatable {
  102354. /**
  102355. * Default anisotropic filtering level for the application.
  102356. * It is set to 4 as a good tradeoff between perf and quality.
  102357. */
  102358. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  102359. /**
  102360. * Gets or sets the unique id of the texture
  102361. */
  102362. uniqueId: number;
  102363. /**
  102364. * Define the name of the texture.
  102365. */
  102366. name: string;
  102367. /**
  102368. * Gets or sets an object used to store user defined information.
  102369. */
  102370. metadata: any;
  102371. /**
  102372. * For internal use only. Please do not use.
  102373. */
  102374. reservedDataStore: any;
  102375. private _hasAlpha;
  102376. /**
  102377. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  102378. */
  102379. set hasAlpha(value: boolean);
  102380. get hasAlpha(): boolean;
  102381. /**
  102382. * Defines if the alpha value should be determined via the rgb values.
  102383. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  102384. */
  102385. getAlphaFromRGB: boolean;
  102386. /**
  102387. * Intensity or strength of the texture.
  102388. * It is commonly used by materials to fine tune the intensity of the texture
  102389. */
  102390. level: number;
  102391. /**
  102392. * Define the UV chanel to use starting from 0 and defaulting to 0.
  102393. * This is part of the texture as textures usually maps to one uv set.
  102394. */
  102395. coordinatesIndex: number;
  102396. private _coordinatesMode;
  102397. /**
  102398. * How a texture is mapped.
  102399. *
  102400. * | Value | Type | Description |
  102401. * | ----- | ----------------------------------- | ----------- |
  102402. * | 0 | EXPLICIT_MODE | |
  102403. * | 1 | SPHERICAL_MODE | |
  102404. * | 2 | PLANAR_MODE | |
  102405. * | 3 | CUBIC_MODE | |
  102406. * | 4 | PROJECTION_MODE | |
  102407. * | 5 | SKYBOX_MODE | |
  102408. * | 6 | INVCUBIC_MODE | |
  102409. * | 7 | EQUIRECTANGULAR_MODE | |
  102410. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  102411. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  102412. */
  102413. set coordinatesMode(value: number);
  102414. get coordinatesMode(): number;
  102415. /**
  102416. * | Value | Type | Description |
  102417. * | ----- | ------------------ | ----------- |
  102418. * | 0 | CLAMP_ADDRESSMODE | |
  102419. * | 1 | WRAP_ADDRESSMODE | |
  102420. * | 2 | MIRROR_ADDRESSMODE | |
  102421. */
  102422. wrapU: number;
  102423. /**
  102424. * | Value | Type | Description |
  102425. * | ----- | ------------------ | ----------- |
  102426. * | 0 | CLAMP_ADDRESSMODE | |
  102427. * | 1 | WRAP_ADDRESSMODE | |
  102428. * | 2 | MIRROR_ADDRESSMODE | |
  102429. */
  102430. wrapV: number;
  102431. /**
  102432. * | Value | Type | Description |
  102433. * | ----- | ------------------ | ----------- |
  102434. * | 0 | CLAMP_ADDRESSMODE | |
  102435. * | 1 | WRAP_ADDRESSMODE | |
  102436. * | 2 | MIRROR_ADDRESSMODE | |
  102437. */
  102438. wrapR: number;
  102439. /**
  102440. * With compliant hardware and browser (supporting anisotropic filtering)
  102441. * this defines the level of anisotropic filtering in the texture.
  102442. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  102443. */
  102444. anisotropicFilteringLevel: number;
  102445. /**
  102446. * Define if the texture is a cube texture or if false a 2d texture.
  102447. */
  102448. get isCube(): boolean;
  102449. set isCube(value: boolean);
  102450. /**
  102451. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  102452. */
  102453. get is3D(): boolean;
  102454. set is3D(value: boolean);
  102455. /**
  102456. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  102457. */
  102458. get is2DArray(): boolean;
  102459. set is2DArray(value: boolean);
  102460. /**
  102461. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  102462. * HDR texture are usually stored in linear space.
  102463. * This only impacts the PBR and Background materials
  102464. */
  102465. gammaSpace: boolean;
  102466. /**
  102467. * Gets or sets whether or not the texture contains RGBD data.
  102468. */
  102469. get isRGBD(): boolean;
  102470. set isRGBD(value: boolean);
  102471. /**
  102472. * Is Z inverted in the texture (useful in a cube texture).
  102473. */
  102474. invertZ: boolean;
  102475. /**
  102476. * Are mip maps generated for this texture or not.
  102477. */
  102478. get noMipmap(): boolean;
  102479. /**
  102480. * @hidden
  102481. */
  102482. lodLevelInAlpha: boolean;
  102483. /**
  102484. * With prefiltered texture, defined the offset used during the prefiltering steps.
  102485. */
  102486. get lodGenerationOffset(): number;
  102487. set lodGenerationOffset(value: number);
  102488. /**
  102489. * With prefiltered texture, defined the scale used during the prefiltering steps.
  102490. */
  102491. get lodGenerationScale(): number;
  102492. set lodGenerationScale(value: number);
  102493. /**
  102494. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  102495. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  102496. * average roughness values.
  102497. */
  102498. get linearSpecularLOD(): boolean;
  102499. set linearSpecularLOD(value: boolean);
  102500. /**
  102501. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  102502. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  102503. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  102504. */
  102505. get irradianceTexture(): Nullable<BaseTexture>;
  102506. set irradianceTexture(value: Nullable<BaseTexture>);
  102507. /**
  102508. * Define if the texture is a render target.
  102509. */
  102510. isRenderTarget: boolean;
  102511. /**
  102512. * Define the unique id of the texture in the scene.
  102513. */
  102514. get uid(): string;
  102515. /**
  102516. * Return a string representation of the texture.
  102517. * @returns the texture as a string
  102518. */
  102519. toString(): string;
  102520. /**
  102521. * Get the class name of the texture.
  102522. * @returns "BaseTexture"
  102523. */
  102524. getClassName(): string;
  102525. /**
  102526. * Define the list of animation attached to the texture.
  102527. */
  102528. animations: Animation[];
  102529. /**
  102530. * An event triggered when the texture is disposed.
  102531. */
  102532. onDisposeObservable: Observable<BaseTexture>;
  102533. private _onDisposeObserver;
  102534. /**
  102535. * Callback triggered when the texture has been disposed.
  102536. * Kept for back compatibility, you can use the onDisposeObservable instead.
  102537. */
  102538. set onDispose(callback: () => void);
  102539. /**
  102540. * Define the current state of the loading sequence when in delayed load mode.
  102541. */
  102542. delayLoadState: number;
  102543. private _scene;
  102544. /** @hidden */
  102545. _texture: Nullable<InternalTexture>;
  102546. private _uid;
  102547. /**
  102548. * Define if the texture is preventinga material to render or not.
  102549. * If not and the texture is not ready, the engine will use a default black texture instead.
  102550. */
  102551. get isBlocking(): boolean;
  102552. /**
  102553. * Instantiates a new BaseTexture.
  102554. * Base class of all the textures in babylon.
  102555. * It groups all the common properties the materials, post process, lights... might need
  102556. * in order to make a correct use of the texture.
  102557. * @param scene Define the scene the texture blongs to
  102558. */
  102559. constructor(scene: Nullable<Scene>);
  102560. /**
  102561. * Get the scene the texture belongs to.
  102562. * @returns the scene or null if undefined
  102563. */
  102564. getScene(): Nullable<Scene>;
  102565. /**
  102566. * Get the texture transform matrix used to offset tile the texture for istance.
  102567. * @returns the transformation matrix
  102568. */
  102569. getTextureMatrix(): Matrix;
  102570. /**
  102571. * Get the texture reflection matrix used to rotate/transform the reflection.
  102572. * @returns the reflection matrix
  102573. */
  102574. getReflectionTextureMatrix(): Matrix;
  102575. /**
  102576. * Get the underlying lower level texture from Babylon.
  102577. * @returns the insternal texture
  102578. */
  102579. getInternalTexture(): Nullable<InternalTexture>;
  102580. /**
  102581. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  102582. * @returns true if ready or not blocking
  102583. */
  102584. isReadyOrNotBlocking(): boolean;
  102585. /**
  102586. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  102587. * @returns true if fully ready
  102588. */
  102589. isReady(): boolean;
  102590. private _cachedSize;
  102591. /**
  102592. * Get the size of the texture.
  102593. * @returns the texture size.
  102594. */
  102595. getSize(): ISize;
  102596. /**
  102597. * Get the base size of the texture.
  102598. * It can be different from the size if the texture has been resized for POT for instance
  102599. * @returns the base size
  102600. */
  102601. getBaseSize(): ISize;
  102602. /**
  102603. * Update the sampling mode of the texture.
  102604. * Default is Trilinear mode.
  102605. *
  102606. * | Value | Type | Description |
  102607. * | ----- | ------------------ | ----------- |
  102608. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  102609. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  102610. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  102611. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  102612. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  102613. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  102614. * | 7 | NEAREST_LINEAR | |
  102615. * | 8 | NEAREST_NEAREST | |
  102616. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  102617. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  102618. * | 11 | LINEAR_LINEAR | |
  102619. * | 12 | LINEAR_NEAREST | |
  102620. *
  102621. * > _mag_: magnification filter (close to the viewer)
  102622. * > _min_: minification filter (far from the viewer)
  102623. * > _mip_: filter used between mip map levels
  102624. *@param samplingMode Define the new sampling mode of the texture
  102625. */
  102626. updateSamplingMode(samplingMode: number): void;
  102627. /**
  102628. * Scales the texture if is `canRescale()`
  102629. * @param ratio the resize factor we want to use to rescale
  102630. */
  102631. scale(ratio: number): void;
  102632. /**
  102633. * Get if the texture can rescale.
  102634. */
  102635. get canRescale(): boolean;
  102636. /** @hidden */
  102637. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  102638. /** @hidden */
  102639. _rebuild(): void;
  102640. /**
  102641. * Triggers the load sequence in delayed load mode.
  102642. */
  102643. delayLoad(): void;
  102644. /**
  102645. * Clones the texture.
  102646. * @returns the cloned texture
  102647. */
  102648. clone(): Nullable<BaseTexture>;
  102649. /**
  102650. * Get the texture underlying type (INT, FLOAT...)
  102651. */
  102652. get textureType(): number;
  102653. /**
  102654. * Get the texture underlying format (RGB, RGBA...)
  102655. */
  102656. get textureFormat(): number;
  102657. /**
  102658. * Indicates that textures need to be re-calculated for all materials
  102659. */
  102660. protected _markAllSubMeshesAsTexturesDirty(): void;
  102661. /**
  102662. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  102663. * This will returns an RGBA array buffer containing either in values (0-255) or
  102664. * float values (0-1) depending of the underlying buffer type.
  102665. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  102666. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  102667. * @param buffer defines a user defined buffer to fill with data (can be null)
  102668. * @returns The Array buffer containing the pixels data.
  102669. */
  102670. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  102671. /**
  102672. * Release and destroy the underlying lower level texture aka internalTexture.
  102673. */
  102674. releaseInternalTexture(): void;
  102675. /** @hidden */
  102676. get _lodTextureHigh(): Nullable<BaseTexture>;
  102677. /** @hidden */
  102678. get _lodTextureMid(): Nullable<BaseTexture>;
  102679. /** @hidden */
  102680. get _lodTextureLow(): Nullable<BaseTexture>;
  102681. /**
  102682. * Dispose the texture and release its associated resources.
  102683. */
  102684. dispose(): void;
  102685. /**
  102686. * Serialize the texture into a JSON representation that can be parsed later on.
  102687. * @returns the JSON representation of the texture
  102688. */
  102689. serialize(): any;
  102690. /**
  102691. * Helper function to be called back once a list of texture contains only ready textures.
  102692. * @param textures Define the list of textures to wait for
  102693. * @param callback Define the callback triggered once the entire list will be ready
  102694. */
  102695. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  102696. }
  102697. }
  102698. declare module BABYLON {
  102699. /**
  102700. * Options to be used when creating an effect.
  102701. */
  102702. export interface IEffectCreationOptions {
  102703. /**
  102704. * Atrributes that will be used in the shader.
  102705. */
  102706. attributes: string[];
  102707. /**
  102708. * Uniform varible names that will be set in the shader.
  102709. */
  102710. uniformsNames: string[];
  102711. /**
  102712. * Uniform buffer variable names that will be set in the shader.
  102713. */
  102714. uniformBuffersNames: string[];
  102715. /**
  102716. * Sampler texture variable names that will be set in the shader.
  102717. */
  102718. samplers: string[];
  102719. /**
  102720. * Define statements that will be set in the shader.
  102721. */
  102722. defines: any;
  102723. /**
  102724. * Possible fallbacks for this effect to improve performance when needed.
  102725. */
  102726. fallbacks: Nullable<IEffectFallbacks>;
  102727. /**
  102728. * Callback that will be called when the shader is compiled.
  102729. */
  102730. onCompiled: Nullable<(effect: Effect) => void>;
  102731. /**
  102732. * Callback that will be called if an error occurs during shader compilation.
  102733. */
  102734. onError: Nullable<(effect: Effect, errors: string) => void>;
  102735. /**
  102736. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  102737. */
  102738. indexParameters?: any;
  102739. /**
  102740. * Max number of lights that can be used in the shader.
  102741. */
  102742. maxSimultaneousLights?: number;
  102743. /**
  102744. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  102745. */
  102746. transformFeedbackVaryings?: Nullable<string[]>;
  102747. }
  102748. /**
  102749. * Effect containing vertex and fragment shader that can be executed on an object.
  102750. */
  102751. export class Effect implements IDisposable {
  102752. /**
  102753. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  102754. */
  102755. static ShadersRepository: string;
  102756. /**
  102757. * Name of the effect.
  102758. */
  102759. name: any;
  102760. /**
  102761. * String container all the define statements that should be set on the shader.
  102762. */
  102763. defines: string;
  102764. /**
  102765. * Callback that will be called when the shader is compiled.
  102766. */
  102767. onCompiled: Nullable<(effect: Effect) => void>;
  102768. /**
  102769. * Callback that will be called if an error occurs during shader compilation.
  102770. */
  102771. onError: Nullable<(effect: Effect, errors: string) => void>;
  102772. /**
  102773. * Callback that will be called when effect is bound.
  102774. */
  102775. onBind: Nullable<(effect: Effect) => void>;
  102776. /**
  102777. * Unique ID of the effect.
  102778. */
  102779. uniqueId: number;
  102780. /**
  102781. * Observable that will be called when the shader is compiled.
  102782. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  102783. */
  102784. onCompileObservable: Observable<Effect>;
  102785. /**
  102786. * Observable that will be called if an error occurs during shader compilation.
  102787. */
  102788. onErrorObservable: Observable<Effect>;
  102789. /** @hidden */
  102790. _onBindObservable: Nullable<Observable<Effect>>;
  102791. /**
  102792. * @hidden
  102793. * Specifies if the effect was previously ready
  102794. */
  102795. _wasPreviouslyReady: boolean;
  102796. /**
  102797. * Observable that will be called when effect is bound.
  102798. */
  102799. get onBindObservable(): Observable<Effect>;
  102800. /** @hidden */
  102801. _bonesComputationForcedToCPU: boolean;
  102802. private static _uniqueIdSeed;
  102803. private _engine;
  102804. private _uniformBuffersNames;
  102805. private _uniformsNames;
  102806. private _samplerList;
  102807. private _samplers;
  102808. private _isReady;
  102809. private _compilationError;
  102810. private _allFallbacksProcessed;
  102811. private _attributesNames;
  102812. private _attributes;
  102813. private _attributeLocationByName;
  102814. private _uniforms;
  102815. /**
  102816. * Key for the effect.
  102817. * @hidden
  102818. */
  102819. _key: string;
  102820. private _indexParameters;
  102821. private _fallbacks;
  102822. private _vertexSourceCode;
  102823. private _fragmentSourceCode;
  102824. private _vertexSourceCodeOverride;
  102825. private _fragmentSourceCodeOverride;
  102826. private _transformFeedbackVaryings;
  102827. /**
  102828. * Compiled shader to webGL program.
  102829. * @hidden
  102830. */
  102831. _pipelineContext: Nullable<IPipelineContext>;
  102832. private _valueCache;
  102833. private static _baseCache;
  102834. /**
  102835. * Instantiates an effect.
  102836. * An effect can be used to create/manage/execute vertex and fragment shaders.
  102837. * @param baseName Name of the effect.
  102838. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  102839. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  102840. * @param samplers List of sampler variables that will be passed to the shader.
  102841. * @param engine Engine to be used to render the effect
  102842. * @param defines Define statements to be added to the shader.
  102843. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  102844. * @param onCompiled Callback that will be called when the shader is compiled.
  102845. * @param onError Callback that will be called if an error occurs during shader compilation.
  102846. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  102847. */
  102848. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  102849. private _useFinalCode;
  102850. /**
  102851. * Unique key for this effect
  102852. */
  102853. get key(): string;
  102854. /**
  102855. * If the effect has been compiled and prepared.
  102856. * @returns if the effect is compiled and prepared.
  102857. */
  102858. isReady(): boolean;
  102859. private _isReadyInternal;
  102860. /**
  102861. * The engine the effect was initialized with.
  102862. * @returns the engine.
  102863. */
  102864. getEngine(): Engine;
  102865. /**
  102866. * The pipeline context for this effect
  102867. * @returns the associated pipeline context
  102868. */
  102869. getPipelineContext(): Nullable<IPipelineContext>;
  102870. /**
  102871. * The set of names of attribute variables for the shader.
  102872. * @returns An array of attribute names.
  102873. */
  102874. getAttributesNames(): string[];
  102875. /**
  102876. * Returns the attribute at the given index.
  102877. * @param index The index of the attribute.
  102878. * @returns The location of the attribute.
  102879. */
  102880. getAttributeLocation(index: number): number;
  102881. /**
  102882. * Returns the attribute based on the name of the variable.
  102883. * @param name of the attribute to look up.
  102884. * @returns the attribute location.
  102885. */
  102886. getAttributeLocationByName(name: string): number;
  102887. /**
  102888. * The number of attributes.
  102889. * @returns the numnber of attributes.
  102890. */
  102891. getAttributesCount(): number;
  102892. /**
  102893. * Gets the index of a uniform variable.
  102894. * @param uniformName of the uniform to look up.
  102895. * @returns the index.
  102896. */
  102897. getUniformIndex(uniformName: string): number;
  102898. /**
  102899. * Returns the attribute based on the name of the variable.
  102900. * @param uniformName of the uniform to look up.
  102901. * @returns the location of the uniform.
  102902. */
  102903. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  102904. /**
  102905. * Returns an array of sampler variable names
  102906. * @returns The array of sampler variable neames.
  102907. */
  102908. getSamplers(): string[];
  102909. /**
  102910. * The error from the last compilation.
  102911. * @returns the error string.
  102912. */
  102913. getCompilationError(): string;
  102914. /**
  102915. * Gets a boolean indicating that all fallbacks were used during compilation
  102916. * @returns true if all fallbacks were used
  102917. */
  102918. allFallbacksProcessed(): boolean;
  102919. /**
  102920. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  102921. * @param func The callback to be used.
  102922. */
  102923. executeWhenCompiled(func: (effect: Effect) => void): void;
  102924. private _checkIsReady;
  102925. private _loadShader;
  102926. /**
  102927. * Recompiles the webGL program
  102928. * @param vertexSourceCode The source code for the vertex shader.
  102929. * @param fragmentSourceCode The source code for the fragment shader.
  102930. * @param onCompiled Callback called when completed.
  102931. * @param onError Callback called on error.
  102932. * @hidden
  102933. */
  102934. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  102935. /**
  102936. * Prepares the effect
  102937. * @hidden
  102938. */
  102939. _prepareEffect(): void;
  102940. private _processCompilationErrors;
  102941. /**
  102942. * Checks if the effect is supported. (Must be called after compilation)
  102943. */
  102944. get isSupported(): boolean;
  102945. /**
  102946. * Binds a texture to the engine to be used as output of the shader.
  102947. * @param channel Name of the output variable.
  102948. * @param texture Texture to bind.
  102949. * @hidden
  102950. */
  102951. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  102952. /**
  102953. * Sets a texture on the engine to be used in the shader.
  102954. * @param channel Name of the sampler variable.
  102955. * @param texture Texture to set.
  102956. */
  102957. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  102958. /**
  102959. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  102960. * @param channel Name of the sampler variable.
  102961. * @param texture Texture to set.
  102962. */
  102963. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  102964. /**
  102965. * Sets an array of textures on the engine to be used in the shader.
  102966. * @param channel Name of the variable.
  102967. * @param textures Textures to set.
  102968. */
  102969. setTextureArray(channel: string, textures: BaseTexture[]): void;
  102970. /**
  102971. * 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)
  102972. * @param channel Name of the sampler variable.
  102973. * @param postProcess Post process to get the input texture from.
  102974. */
  102975. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  102976. /**
  102977. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  102978. * 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)
  102979. * @param channel Name of the sampler variable.
  102980. * @param postProcess Post process to get the output texture from.
  102981. */
  102982. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  102983. /** @hidden */
  102984. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  102985. /** @hidden */
  102986. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  102987. /** @hidden */
  102988. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  102989. /** @hidden */
  102990. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  102991. /**
  102992. * Binds a buffer to a uniform.
  102993. * @param buffer Buffer to bind.
  102994. * @param name Name of the uniform variable to bind to.
  102995. */
  102996. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  102997. /**
  102998. * Binds block to a uniform.
  102999. * @param blockName Name of the block to bind.
  103000. * @param index Index to bind.
  103001. */
  103002. bindUniformBlock(blockName: string, index: number): void;
  103003. /**
  103004. * Sets an interger value on a uniform variable.
  103005. * @param uniformName Name of the variable.
  103006. * @param value Value to be set.
  103007. * @returns this effect.
  103008. */
  103009. setInt(uniformName: string, value: number): Effect;
  103010. /**
  103011. * Sets an int array on a uniform variable.
  103012. * @param uniformName Name of the variable.
  103013. * @param array array to be set.
  103014. * @returns this effect.
  103015. */
  103016. setIntArray(uniformName: string, array: Int32Array): Effect;
  103017. /**
  103018. * 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)
  103019. * @param uniformName Name of the variable.
  103020. * @param array array to be set.
  103021. * @returns this effect.
  103022. */
  103023. setIntArray2(uniformName: string, array: Int32Array): Effect;
  103024. /**
  103025. * 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)
  103026. * @param uniformName Name of the variable.
  103027. * @param array array to be set.
  103028. * @returns this effect.
  103029. */
  103030. setIntArray3(uniformName: string, array: Int32Array): Effect;
  103031. /**
  103032. * 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)
  103033. * @param uniformName Name of the variable.
  103034. * @param array array to be set.
  103035. * @returns this effect.
  103036. */
  103037. setIntArray4(uniformName: string, array: Int32Array): Effect;
  103038. /**
  103039. * Sets an float array on a uniform variable.
  103040. * @param uniformName Name of the variable.
  103041. * @param array array to be set.
  103042. * @returns this effect.
  103043. */
  103044. setFloatArray(uniformName: string, array: Float32Array): Effect;
  103045. /**
  103046. * 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)
  103047. * @param uniformName Name of the variable.
  103048. * @param array array to be set.
  103049. * @returns this effect.
  103050. */
  103051. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  103052. /**
  103053. * 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)
  103054. * @param uniformName Name of the variable.
  103055. * @param array array to be set.
  103056. * @returns this effect.
  103057. */
  103058. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  103059. /**
  103060. * 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)
  103061. * @param uniformName Name of the variable.
  103062. * @param array array to be set.
  103063. * @returns this effect.
  103064. */
  103065. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  103066. /**
  103067. * Sets an array on a uniform variable.
  103068. * @param uniformName Name of the variable.
  103069. * @param array array to be set.
  103070. * @returns this effect.
  103071. */
  103072. setArray(uniformName: string, array: number[]): Effect;
  103073. /**
  103074. * 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)
  103075. * @param uniformName Name of the variable.
  103076. * @param array array to be set.
  103077. * @returns this effect.
  103078. */
  103079. setArray2(uniformName: string, array: number[]): Effect;
  103080. /**
  103081. * 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)
  103082. * @param uniformName Name of the variable.
  103083. * @param array array to be set.
  103084. * @returns this effect.
  103085. */
  103086. setArray3(uniformName: string, array: number[]): Effect;
  103087. /**
  103088. * 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)
  103089. * @param uniformName Name of the variable.
  103090. * @param array array to be set.
  103091. * @returns this effect.
  103092. */
  103093. setArray4(uniformName: string, array: number[]): Effect;
  103094. /**
  103095. * Sets matrices on a uniform variable.
  103096. * @param uniformName Name of the variable.
  103097. * @param matrices matrices to be set.
  103098. * @returns this effect.
  103099. */
  103100. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  103101. /**
  103102. * Sets matrix on a uniform variable.
  103103. * @param uniformName Name of the variable.
  103104. * @param matrix matrix to be set.
  103105. * @returns this effect.
  103106. */
  103107. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  103108. /**
  103109. * 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)
  103110. * @param uniformName Name of the variable.
  103111. * @param matrix matrix to be set.
  103112. * @returns this effect.
  103113. */
  103114. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  103115. /**
  103116. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  103117. * @param uniformName Name of the variable.
  103118. * @param matrix matrix to be set.
  103119. * @returns this effect.
  103120. */
  103121. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  103122. /**
  103123. * Sets a float on a uniform variable.
  103124. * @param uniformName Name of the variable.
  103125. * @param value value to be set.
  103126. * @returns this effect.
  103127. */
  103128. setFloat(uniformName: string, value: number): Effect;
  103129. /**
  103130. * Sets a boolean on a uniform variable.
  103131. * @param uniformName Name of the variable.
  103132. * @param bool value to be set.
  103133. * @returns this effect.
  103134. */
  103135. setBool(uniformName: string, bool: boolean): Effect;
  103136. /**
  103137. * Sets a Vector2 on a uniform variable.
  103138. * @param uniformName Name of the variable.
  103139. * @param vector2 vector2 to be set.
  103140. * @returns this effect.
  103141. */
  103142. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  103143. /**
  103144. * Sets a float2 on a uniform variable.
  103145. * @param uniformName Name of the variable.
  103146. * @param x First float in float2.
  103147. * @param y Second float in float2.
  103148. * @returns this effect.
  103149. */
  103150. setFloat2(uniformName: string, x: number, y: number): Effect;
  103151. /**
  103152. * Sets a Vector3 on a uniform variable.
  103153. * @param uniformName Name of the variable.
  103154. * @param vector3 Value to be set.
  103155. * @returns this effect.
  103156. */
  103157. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  103158. /**
  103159. * Sets a float3 on a uniform variable.
  103160. * @param uniformName Name of the variable.
  103161. * @param x First float in float3.
  103162. * @param y Second float in float3.
  103163. * @param z Third float in float3.
  103164. * @returns this effect.
  103165. */
  103166. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  103167. /**
  103168. * Sets a Vector4 on a uniform variable.
  103169. * @param uniformName Name of the variable.
  103170. * @param vector4 Value to be set.
  103171. * @returns this effect.
  103172. */
  103173. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  103174. /**
  103175. * Sets a float4 on a uniform variable.
  103176. * @param uniformName Name of the variable.
  103177. * @param x First float in float4.
  103178. * @param y Second float in float4.
  103179. * @param z Third float in float4.
  103180. * @param w Fourth float in float4.
  103181. * @returns this effect.
  103182. */
  103183. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  103184. /**
  103185. * Sets a Color3 on a uniform variable.
  103186. * @param uniformName Name of the variable.
  103187. * @param color3 Value to be set.
  103188. * @returns this effect.
  103189. */
  103190. setColor3(uniformName: string, color3: IColor3Like): Effect;
  103191. /**
  103192. * Sets a Color4 on a uniform variable.
  103193. * @param uniformName Name of the variable.
  103194. * @param color3 Value to be set.
  103195. * @param alpha Alpha value to be set.
  103196. * @returns this effect.
  103197. */
  103198. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  103199. /**
  103200. * Sets a Color4 on a uniform variable
  103201. * @param uniformName defines the name of the variable
  103202. * @param color4 defines the value to be set
  103203. * @returns this effect.
  103204. */
  103205. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  103206. /** Release all associated resources */
  103207. dispose(): void;
  103208. /**
  103209. * This function will add a new shader to the shader store
  103210. * @param name the name of the shader
  103211. * @param pixelShader optional pixel shader content
  103212. * @param vertexShader optional vertex shader content
  103213. */
  103214. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  103215. /**
  103216. * Store of each shader (The can be looked up using effect.key)
  103217. */
  103218. static ShadersStore: {
  103219. [key: string]: string;
  103220. };
  103221. /**
  103222. * Store of each included file for a shader (The can be looked up using effect.key)
  103223. */
  103224. static IncludesShadersStore: {
  103225. [key: string]: string;
  103226. };
  103227. /**
  103228. * Resets the cache of effects.
  103229. */
  103230. static ResetCache(): void;
  103231. }
  103232. }
  103233. declare module BABYLON {
  103234. /**
  103235. * Interface used to describe the capabilities of the engine relatively to the current browser
  103236. */
  103237. export interface EngineCapabilities {
  103238. /** Maximum textures units per fragment shader */
  103239. maxTexturesImageUnits: number;
  103240. /** Maximum texture units per vertex shader */
  103241. maxVertexTextureImageUnits: number;
  103242. /** Maximum textures units in the entire pipeline */
  103243. maxCombinedTexturesImageUnits: number;
  103244. /** Maximum texture size */
  103245. maxTextureSize: number;
  103246. /** Maximum texture samples */
  103247. maxSamples?: number;
  103248. /** Maximum cube texture size */
  103249. maxCubemapTextureSize: number;
  103250. /** Maximum render texture size */
  103251. maxRenderTextureSize: number;
  103252. /** Maximum number of vertex attributes */
  103253. maxVertexAttribs: number;
  103254. /** Maximum number of varyings */
  103255. maxVaryingVectors: number;
  103256. /** Maximum number of uniforms per vertex shader */
  103257. maxVertexUniformVectors: number;
  103258. /** Maximum number of uniforms per fragment shader */
  103259. maxFragmentUniformVectors: number;
  103260. /** Defines if standard derivates (dx/dy) are supported */
  103261. standardDerivatives: boolean;
  103262. /** Defines if s3tc texture compression is supported */
  103263. s3tc?: WEBGL_compressed_texture_s3tc;
  103264. /** Defines if pvrtc texture compression is supported */
  103265. pvrtc: any;
  103266. /** Defines if etc1 texture compression is supported */
  103267. etc1: any;
  103268. /** Defines if etc2 texture compression is supported */
  103269. etc2: any;
  103270. /** Defines if astc texture compression is supported */
  103271. astc: any;
  103272. /** Defines if float textures are supported */
  103273. textureFloat: boolean;
  103274. /** Defines if vertex array objects are supported */
  103275. vertexArrayObject: boolean;
  103276. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  103277. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  103278. /** Gets the maximum level of anisotropy supported */
  103279. maxAnisotropy: number;
  103280. /** Defines if instancing is supported */
  103281. instancedArrays: boolean;
  103282. /** Defines if 32 bits indices are supported */
  103283. uintIndices: boolean;
  103284. /** Defines if high precision shaders are supported */
  103285. highPrecisionShaderSupported: boolean;
  103286. /** Defines if depth reading in the fragment shader is supported */
  103287. fragmentDepthSupported: boolean;
  103288. /** Defines if float texture linear filtering is supported*/
  103289. textureFloatLinearFiltering: boolean;
  103290. /** Defines if rendering to float textures is supported */
  103291. textureFloatRender: boolean;
  103292. /** Defines if half float textures are supported*/
  103293. textureHalfFloat: boolean;
  103294. /** Defines if half float texture linear filtering is supported*/
  103295. textureHalfFloatLinearFiltering: boolean;
  103296. /** Defines if rendering to half float textures is supported */
  103297. textureHalfFloatRender: boolean;
  103298. /** Defines if textureLOD shader command is supported */
  103299. textureLOD: boolean;
  103300. /** Defines if draw buffers extension is supported */
  103301. drawBuffersExtension: boolean;
  103302. /** Defines if depth textures are supported */
  103303. depthTextureExtension: boolean;
  103304. /** Defines if float color buffer are supported */
  103305. colorBufferFloat: boolean;
  103306. /** Gets disjoint timer query extension (null if not supported) */
  103307. timerQuery?: EXT_disjoint_timer_query;
  103308. /** Defines if timestamp can be used with timer query */
  103309. canUseTimestampForTimerQuery: boolean;
  103310. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  103311. multiview?: any;
  103312. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  103313. oculusMultiview?: any;
  103314. /** Function used to let the system compiles shaders in background */
  103315. parallelShaderCompile?: {
  103316. COMPLETION_STATUS_KHR: number;
  103317. };
  103318. /** Max number of texture samples for MSAA */
  103319. maxMSAASamples: number;
  103320. /** Defines if the blend min max extension is supported */
  103321. blendMinMax: boolean;
  103322. }
  103323. }
  103324. declare module BABYLON {
  103325. /**
  103326. * @hidden
  103327. **/
  103328. export class DepthCullingState {
  103329. private _isDepthTestDirty;
  103330. private _isDepthMaskDirty;
  103331. private _isDepthFuncDirty;
  103332. private _isCullFaceDirty;
  103333. private _isCullDirty;
  103334. private _isZOffsetDirty;
  103335. private _isFrontFaceDirty;
  103336. private _depthTest;
  103337. private _depthMask;
  103338. private _depthFunc;
  103339. private _cull;
  103340. private _cullFace;
  103341. private _zOffset;
  103342. private _frontFace;
  103343. /**
  103344. * Initializes the state.
  103345. */
  103346. constructor();
  103347. get isDirty(): boolean;
  103348. get zOffset(): number;
  103349. set zOffset(value: number);
  103350. get cullFace(): Nullable<number>;
  103351. set cullFace(value: Nullable<number>);
  103352. get cull(): Nullable<boolean>;
  103353. set cull(value: Nullable<boolean>);
  103354. get depthFunc(): Nullable<number>;
  103355. set depthFunc(value: Nullable<number>);
  103356. get depthMask(): boolean;
  103357. set depthMask(value: boolean);
  103358. get depthTest(): boolean;
  103359. set depthTest(value: boolean);
  103360. get frontFace(): Nullable<number>;
  103361. set frontFace(value: Nullable<number>);
  103362. reset(): void;
  103363. apply(gl: WebGLRenderingContext): void;
  103364. }
  103365. }
  103366. declare module BABYLON {
  103367. /**
  103368. * @hidden
  103369. **/
  103370. export class StencilState {
  103371. /** 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 */
  103372. static readonly ALWAYS: number;
  103373. /** Passed to stencilOperation to specify that stencil value must be kept */
  103374. static readonly KEEP: number;
  103375. /** Passed to stencilOperation to specify that stencil value must be replaced */
  103376. static readonly REPLACE: number;
  103377. private _isStencilTestDirty;
  103378. private _isStencilMaskDirty;
  103379. private _isStencilFuncDirty;
  103380. private _isStencilOpDirty;
  103381. private _stencilTest;
  103382. private _stencilMask;
  103383. private _stencilFunc;
  103384. private _stencilFuncRef;
  103385. private _stencilFuncMask;
  103386. private _stencilOpStencilFail;
  103387. private _stencilOpDepthFail;
  103388. private _stencilOpStencilDepthPass;
  103389. get isDirty(): boolean;
  103390. get stencilFunc(): number;
  103391. set stencilFunc(value: number);
  103392. get stencilFuncRef(): number;
  103393. set stencilFuncRef(value: number);
  103394. get stencilFuncMask(): number;
  103395. set stencilFuncMask(value: number);
  103396. get stencilOpStencilFail(): number;
  103397. set stencilOpStencilFail(value: number);
  103398. get stencilOpDepthFail(): number;
  103399. set stencilOpDepthFail(value: number);
  103400. get stencilOpStencilDepthPass(): number;
  103401. set stencilOpStencilDepthPass(value: number);
  103402. get stencilMask(): number;
  103403. set stencilMask(value: number);
  103404. get stencilTest(): boolean;
  103405. set stencilTest(value: boolean);
  103406. constructor();
  103407. reset(): void;
  103408. apply(gl: WebGLRenderingContext): void;
  103409. }
  103410. }
  103411. declare module BABYLON {
  103412. /**
  103413. * @hidden
  103414. **/
  103415. export class AlphaState {
  103416. private _isAlphaBlendDirty;
  103417. private _isBlendFunctionParametersDirty;
  103418. private _isBlendEquationParametersDirty;
  103419. private _isBlendConstantsDirty;
  103420. private _alphaBlend;
  103421. private _blendFunctionParameters;
  103422. private _blendEquationParameters;
  103423. private _blendConstants;
  103424. /**
  103425. * Initializes the state.
  103426. */
  103427. constructor();
  103428. get isDirty(): boolean;
  103429. get alphaBlend(): boolean;
  103430. set alphaBlend(value: boolean);
  103431. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  103432. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  103433. setAlphaEquationParameters(rgb: number, alpha: number): void;
  103434. reset(): void;
  103435. apply(gl: WebGLRenderingContext): void;
  103436. }
  103437. }
  103438. declare module BABYLON {
  103439. /** @hidden */
  103440. export class WebGL2ShaderProcessor implements IShaderProcessor {
  103441. attributeProcessor(attribute: string): string;
  103442. varyingProcessor(varying: string, isFragment: boolean): string;
  103443. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  103444. }
  103445. }
  103446. declare module BABYLON {
  103447. /**
  103448. * Interface for attribute information associated with buffer instanciation
  103449. */
  103450. export interface InstancingAttributeInfo {
  103451. /**
  103452. * Name of the GLSL attribute
  103453. * if attribute index is not specified, this is used to retrieve the index from the effect
  103454. */
  103455. attributeName: string;
  103456. /**
  103457. * Index/offset of the attribute in the vertex shader
  103458. * if not specified, this will be computes from the name.
  103459. */
  103460. index?: number;
  103461. /**
  103462. * size of the attribute, 1, 2, 3 or 4
  103463. */
  103464. attributeSize: number;
  103465. /**
  103466. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  103467. */
  103468. offset: number;
  103469. /**
  103470. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  103471. * default to 1
  103472. */
  103473. divisor?: number;
  103474. /**
  103475. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  103476. * default is FLOAT
  103477. */
  103478. attributeType?: number;
  103479. /**
  103480. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  103481. */
  103482. normalized?: boolean;
  103483. }
  103484. }
  103485. declare module BABYLON {
  103486. interface ThinEngine {
  103487. /**
  103488. * Update a video texture
  103489. * @param texture defines the texture to update
  103490. * @param video defines the video element to use
  103491. * @param invertY defines if data must be stored with Y axis inverted
  103492. */
  103493. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  103494. }
  103495. }
  103496. declare module BABYLON {
  103497. /**
  103498. * Settings for finer control over video usage
  103499. */
  103500. export interface VideoTextureSettings {
  103501. /**
  103502. * Applies `autoplay` to video, if specified
  103503. */
  103504. autoPlay?: boolean;
  103505. /**
  103506. * Applies `loop` to video, if specified
  103507. */
  103508. loop?: boolean;
  103509. /**
  103510. * Automatically updates internal texture from video at every frame in the render loop
  103511. */
  103512. autoUpdateTexture: boolean;
  103513. /**
  103514. * Image src displayed during the video loading or until the user interacts with the video.
  103515. */
  103516. poster?: string;
  103517. }
  103518. /**
  103519. * If you want to display a video in your scene, this is the special texture for that.
  103520. * This special texture works similar to other textures, with the exception of a few parameters.
  103521. * @see https://doc.babylonjs.com/how_to/video_texture
  103522. */
  103523. export class VideoTexture extends Texture {
  103524. /**
  103525. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  103526. */
  103527. readonly autoUpdateTexture: boolean;
  103528. /**
  103529. * The video instance used by the texture internally
  103530. */
  103531. readonly video: HTMLVideoElement;
  103532. private _onUserActionRequestedObservable;
  103533. /**
  103534. * Event triggerd when a dom action is required by the user to play the video.
  103535. * This happens due to recent changes in browser policies preventing video to auto start.
  103536. */
  103537. get onUserActionRequestedObservable(): Observable<Texture>;
  103538. private _generateMipMaps;
  103539. private _engine;
  103540. private _stillImageCaptured;
  103541. private _displayingPosterTexture;
  103542. private _settings;
  103543. private _createInternalTextureOnEvent;
  103544. private _frameId;
  103545. private _currentSrc;
  103546. /**
  103547. * Creates a video texture.
  103548. * If you want to display a video in your scene, this is the special texture for that.
  103549. * This special texture works similar to other textures, with the exception of a few parameters.
  103550. * @see https://doc.babylonjs.com/how_to/video_texture
  103551. * @param name optional name, will detect from video source, if not defined
  103552. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  103553. * @param scene is obviously the current scene.
  103554. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  103555. * @param invertY is false by default but can be used to invert video on Y axis
  103556. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  103557. * @param settings allows finer control over video usage
  103558. */
  103559. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  103560. private _getName;
  103561. private _getVideo;
  103562. private _createInternalTexture;
  103563. private reset;
  103564. /**
  103565. * @hidden Internal method to initiate `update`.
  103566. */
  103567. _rebuild(): void;
  103568. /**
  103569. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  103570. */
  103571. update(): void;
  103572. /**
  103573. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  103574. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  103575. */
  103576. updateTexture(isVisible: boolean): void;
  103577. protected _updateInternalTexture: () => void;
  103578. /**
  103579. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  103580. * @param url New url.
  103581. */
  103582. updateURL(url: string): void;
  103583. /**
  103584. * Clones the texture.
  103585. * @returns the cloned texture
  103586. */
  103587. clone(): VideoTexture;
  103588. /**
  103589. * Dispose the texture and release its associated resources.
  103590. */
  103591. dispose(): void;
  103592. /**
  103593. * Creates a video texture straight from a stream.
  103594. * @param scene Define the scene the texture should be created in
  103595. * @param stream Define the stream the texture should be created from
  103596. * @returns The created video texture as a promise
  103597. */
  103598. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  103599. /**
  103600. * Creates a video texture straight from your WebCam video feed.
  103601. * @param scene Define the scene the texture should be created in
  103602. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  103603. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  103604. * @returns The created video texture as a promise
  103605. */
  103606. static CreateFromWebCamAsync(scene: Scene, constraints: {
  103607. minWidth: number;
  103608. maxWidth: number;
  103609. minHeight: number;
  103610. maxHeight: number;
  103611. deviceId: string;
  103612. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  103613. /**
  103614. * Creates a video texture straight from your WebCam video feed.
  103615. * @param scene Define the scene the texture should be created in
  103616. * @param onReady Define a callback to triggered once the texture will be ready
  103617. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  103618. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  103619. */
  103620. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  103621. minWidth: number;
  103622. maxWidth: number;
  103623. minHeight: number;
  103624. maxHeight: number;
  103625. deviceId: string;
  103626. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  103627. }
  103628. }
  103629. declare module BABYLON {
  103630. /**
  103631. * Defines the interface used by objects working like Scene
  103632. * @hidden
  103633. */
  103634. interface ISceneLike {
  103635. _addPendingData(data: any): void;
  103636. _removePendingData(data: any): void;
  103637. offlineProvider: IOfflineProvider;
  103638. }
  103639. /** Interface defining initialization parameters for Engine class */
  103640. export interface EngineOptions extends WebGLContextAttributes {
  103641. /**
  103642. * Defines if the engine should no exceed a specified device ratio
  103643. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  103644. */
  103645. limitDeviceRatio?: number;
  103646. /**
  103647. * Defines if webvr should be enabled automatically
  103648. * @see http://doc.babylonjs.com/how_to/webvr_camera
  103649. */
  103650. autoEnableWebVR?: boolean;
  103651. /**
  103652. * Defines if webgl2 should be turned off even if supported
  103653. * @see http://doc.babylonjs.com/features/webgl2
  103654. */
  103655. disableWebGL2Support?: boolean;
  103656. /**
  103657. * Defines if webaudio should be initialized as well
  103658. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103659. */
  103660. audioEngine?: boolean;
  103661. /**
  103662. * Defines if animations should run using a deterministic lock step
  103663. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103664. */
  103665. deterministicLockstep?: boolean;
  103666. /** Defines the maximum steps to use with deterministic lock step mode */
  103667. lockstepMaxSteps?: number;
  103668. /** Defines the seconds between each deterministic lock step */
  103669. timeStep?: number;
  103670. /**
  103671. * Defines that engine should ignore context lost events
  103672. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  103673. */
  103674. doNotHandleContextLost?: boolean;
  103675. /**
  103676. * Defines that engine should ignore modifying touch action attribute and style
  103677. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  103678. */
  103679. doNotHandleTouchAction?: boolean;
  103680. /**
  103681. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  103682. */
  103683. useHighPrecisionFloats?: boolean;
  103684. }
  103685. /**
  103686. * The base engine class (root of all engines)
  103687. */
  103688. export class ThinEngine {
  103689. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  103690. static ExceptionList: ({
  103691. key: string;
  103692. capture: string;
  103693. captureConstraint: number;
  103694. targets: string[];
  103695. } | {
  103696. key: string;
  103697. capture: null;
  103698. captureConstraint: null;
  103699. targets: string[];
  103700. })[];
  103701. /** @hidden */
  103702. static _TextureLoaders: IInternalTextureLoader[];
  103703. /**
  103704. * Returns the current npm package of the sdk
  103705. */
  103706. static get NpmPackage(): string;
  103707. /**
  103708. * Returns the current version of the framework
  103709. */
  103710. static get Version(): string;
  103711. /**
  103712. * Returns a string describing the current engine
  103713. */
  103714. get description(): string;
  103715. /**
  103716. * Gets or sets the epsilon value used by collision engine
  103717. */
  103718. static CollisionsEpsilon: number;
  103719. /**
  103720. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  103721. */
  103722. static get ShadersRepository(): string;
  103723. static set ShadersRepository(value: string);
  103724. /**
  103725. * Gets or sets the textures that the engine should not attempt to load as compressed
  103726. */
  103727. protected _excludedCompressedTextures: string[];
  103728. /**
  103729. * Filters the compressed texture formats to only include
  103730. * files that are not included in the skippable list
  103731. *
  103732. * @param url the current extension
  103733. * @param textureFormatInUse the current compressed texture format
  103734. * @returns "format" string
  103735. */
  103736. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  103737. /** @hidden */
  103738. _shaderProcessor: IShaderProcessor;
  103739. /**
  103740. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  103741. */
  103742. forcePOTTextures: boolean;
  103743. /**
  103744. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  103745. */
  103746. isFullscreen: boolean;
  103747. /**
  103748. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  103749. */
  103750. cullBackFaces: boolean;
  103751. /**
  103752. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  103753. */
  103754. renderEvenInBackground: boolean;
  103755. /**
  103756. * Gets or sets a boolean indicating that cache can be kept between frames
  103757. */
  103758. preventCacheWipeBetweenFrames: boolean;
  103759. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  103760. validateShaderPrograms: boolean;
  103761. /**
  103762. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  103763. * This can provide greater z depth for distant objects.
  103764. */
  103765. useReverseDepthBuffer: boolean;
  103766. /**
  103767. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  103768. */
  103769. disableUniformBuffers: boolean;
  103770. /** @hidden */
  103771. _uniformBuffers: UniformBuffer[];
  103772. /**
  103773. * Gets a boolean indicating that the engine supports uniform buffers
  103774. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  103775. */
  103776. get supportsUniformBuffers(): boolean;
  103777. /** @hidden */
  103778. _gl: WebGLRenderingContext;
  103779. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  103780. protected _windowIsBackground: boolean;
  103781. protected _webGLVersion: number;
  103782. protected _creationOptions: EngineOptions;
  103783. protected _highPrecisionShadersAllowed: boolean;
  103784. /** @hidden */
  103785. get _shouldUseHighPrecisionShader(): boolean;
  103786. /**
  103787. * Gets a boolean indicating that only power of 2 textures are supported
  103788. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  103789. */
  103790. get needPOTTextures(): boolean;
  103791. /** @hidden */
  103792. _badOS: boolean;
  103793. /** @hidden */
  103794. _badDesktopOS: boolean;
  103795. private _hardwareScalingLevel;
  103796. /** @hidden */
  103797. _caps: EngineCapabilities;
  103798. private _isStencilEnable;
  103799. private _glVersion;
  103800. private _glRenderer;
  103801. private _glVendor;
  103802. /** @hidden */
  103803. _videoTextureSupported: boolean;
  103804. protected _renderingQueueLaunched: boolean;
  103805. protected _activeRenderLoops: (() => void)[];
  103806. /**
  103807. * Observable signaled when a context lost event is raised
  103808. */
  103809. onContextLostObservable: Observable<ThinEngine>;
  103810. /**
  103811. * Observable signaled when a context restored event is raised
  103812. */
  103813. onContextRestoredObservable: Observable<ThinEngine>;
  103814. private _onContextLost;
  103815. private _onContextRestored;
  103816. protected _contextWasLost: boolean;
  103817. /** @hidden */
  103818. _doNotHandleContextLost: boolean;
  103819. /**
  103820. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  103821. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  103822. */
  103823. get doNotHandleContextLost(): boolean;
  103824. set doNotHandleContextLost(value: boolean);
  103825. /**
  103826. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  103827. */
  103828. disableVertexArrayObjects: boolean;
  103829. /** @hidden */
  103830. protected _colorWrite: boolean;
  103831. /** @hidden */
  103832. protected _colorWriteChanged: boolean;
  103833. /** @hidden */
  103834. protected _depthCullingState: DepthCullingState;
  103835. /** @hidden */
  103836. protected _stencilState: StencilState;
  103837. /** @hidden */
  103838. _alphaState: AlphaState;
  103839. /** @hidden */
  103840. _alphaMode: number;
  103841. /** @hidden */
  103842. _alphaEquation: number;
  103843. /** @hidden */
  103844. _internalTexturesCache: InternalTexture[];
  103845. /** @hidden */
  103846. protected _activeChannel: number;
  103847. private _currentTextureChannel;
  103848. /** @hidden */
  103849. protected _boundTexturesCache: {
  103850. [key: string]: Nullable<InternalTexture>;
  103851. };
  103852. /** @hidden */
  103853. protected _currentEffect: Nullable<Effect>;
  103854. /** @hidden */
  103855. protected _currentProgram: Nullable<WebGLProgram>;
  103856. private _compiledEffects;
  103857. private _vertexAttribArraysEnabled;
  103858. /** @hidden */
  103859. protected _cachedViewport: Nullable<IViewportLike>;
  103860. private _cachedVertexArrayObject;
  103861. /** @hidden */
  103862. protected _cachedVertexBuffers: any;
  103863. /** @hidden */
  103864. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  103865. /** @hidden */
  103866. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  103867. /** @hidden */
  103868. _currentRenderTarget: Nullable<InternalTexture>;
  103869. private _uintIndicesCurrentlySet;
  103870. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  103871. /** @hidden */
  103872. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  103873. private _currentBufferPointers;
  103874. private _currentInstanceLocations;
  103875. private _currentInstanceBuffers;
  103876. private _textureUnits;
  103877. /** @hidden */
  103878. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  103879. /** @hidden */
  103880. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  103881. /** @hidden */
  103882. _boundRenderFunction: any;
  103883. private _vaoRecordInProgress;
  103884. private _mustWipeVertexAttributes;
  103885. private _emptyTexture;
  103886. private _emptyCubeTexture;
  103887. private _emptyTexture3D;
  103888. private _emptyTexture2DArray;
  103889. /** @hidden */
  103890. _frameHandler: number;
  103891. private _nextFreeTextureSlots;
  103892. private _maxSimultaneousTextures;
  103893. private _activeRequests;
  103894. protected _texturesSupported: string[];
  103895. /** @hidden */
  103896. _textureFormatInUse: Nullable<string>;
  103897. protected get _supportsHardwareTextureRescaling(): boolean;
  103898. /**
  103899. * Gets the list of texture formats supported
  103900. */
  103901. get texturesSupported(): Array<string>;
  103902. /**
  103903. * Gets the list of texture formats in use
  103904. */
  103905. get textureFormatInUse(): Nullable<string>;
  103906. /**
  103907. * Gets the current viewport
  103908. */
  103909. get currentViewport(): Nullable<IViewportLike>;
  103910. /**
  103911. * Gets the default empty texture
  103912. */
  103913. get emptyTexture(): InternalTexture;
  103914. /**
  103915. * Gets the default empty 3D texture
  103916. */
  103917. get emptyTexture3D(): InternalTexture;
  103918. /**
  103919. * Gets the default empty 2D array texture
  103920. */
  103921. get emptyTexture2DArray(): InternalTexture;
  103922. /**
  103923. * Gets the default empty cube texture
  103924. */
  103925. get emptyCubeTexture(): InternalTexture;
  103926. /**
  103927. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  103928. */
  103929. readonly premultipliedAlpha: boolean;
  103930. /**
  103931. * Observable event triggered before each texture is initialized
  103932. */
  103933. onBeforeTextureInitObservable: Observable<Texture>;
  103934. /**
  103935. * Creates a new engine
  103936. * @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
  103937. * @param antialias defines enable antialiasing (default: false)
  103938. * @param options defines further options to be sent to the getContext() function
  103939. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  103940. */
  103941. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  103942. private _rebuildInternalTextures;
  103943. private _rebuildEffects;
  103944. /**
  103945. * Gets a boolean indicating if all created effects are ready
  103946. * @returns true if all effects are ready
  103947. */
  103948. areAllEffectsReady(): boolean;
  103949. protected _rebuildBuffers(): void;
  103950. private _initGLContext;
  103951. /**
  103952. * Gets version of the current webGL context
  103953. */
  103954. get webGLVersion(): number;
  103955. /**
  103956. * Gets a string idenfifying the name of the class
  103957. * @returns "Engine" string
  103958. */
  103959. getClassName(): string;
  103960. /**
  103961. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  103962. */
  103963. get isStencilEnable(): boolean;
  103964. /** @hidden */
  103965. _prepareWorkingCanvas(): void;
  103966. /**
  103967. * Reset the texture cache to empty state
  103968. */
  103969. resetTextureCache(): void;
  103970. /**
  103971. * Gets an object containing information about the current webGL context
  103972. * @returns an object containing the vender, the renderer and the version of the current webGL context
  103973. */
  103974. getGlInfo(): {
  103975. vendor: string;
  103976. renderer: string;
  103977. version: string;
  103978. };
  103979. /**
  103980. * Defines the hardware scaling level.
  103981. * By default the hardware scaling level is computed from the window device ratio.
  103982. * 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.
  103983. * @param level defines the level to use
  103984. */
  103985. setHardwareScalingLevel(level: number): void;
  103986. /**
  103987. * Gets the current hardware scaling level.
  103988. * By default the hardware scaling level is computed from the window device ratio.
  103989. * 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.
  103990. * @returns a number indicating the current hardware scaling level
  103991. */
  103992. getHardwareScalingLevel(): number;
  103993. /**
  103994. * Gets the list of loaded textures
  103995. * @returns an array containing all loaded textures
  103996. */
  103997. getLoadedTexturesCache(): InternalTexture[];
  103998. /**
  103999. * Gets the object containing all engine capabilities
  104000. * @returns the EngineCapabilities object
  104001. */
  104002. getCaps(): EngineCapabilities;
  104003. /**
  104004. * stop executing a render loop function and remove it from the execution array
  104005. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  104006. */
  104007. stopRenderLoop(renderFunction?: () => void): void;
  104008. /** @hidden */
  104009. _renderLoop(): void;
  104010. /**
  104011. * Gets the HTML canvas attached with the current webGL context
  104012. * @returns a HTML canvas
  104013. */
  104014. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  104015. /**
  104016. * Gets host window
  104017. * @returns the host window object
  104018. */
  104019. getHostWindow(): Nullable<Window>;
  104020. /**
  104021. * Gets the current render width
  104022. * @param useScreen defines if screen size must be used (or the current render target if any)
  104023. * @returns a number defining the current render width
  104024. */
  104025. getRenderWidth(useScreen?: boolean): number;
  104026. /**
  104027. * Gets the current render height
  104028. * @param useScreen defines if screen size must be used (or the current render target if any)
  104029. * @returns a number defining the current render height
  104030. */
  104031. getRenderHeight(useScreen?: boolean): number;
  104032. /**
  104033. * Can be used to override the current requestAnimationFrame requester.
  104034. * @hidden
  104035. */
  104036. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  104037. /**
  104038. * Register and execute a render loop. The engine can have more than one render function
  104039. * @param renderFunction defines the function to continuously execute
  104040. */
  104041. runRenderLoop(renderFunction: () => void): void;
  104042. /**
  104043. * Clear the current render buffer or the current render target (if any is set up)
  104044. * @param color defines the color to use
  104045. * @param backBuffer defines if the back buffer must be cleared
  104046. * @param depth defines if the depth buffer must be cleared
  104047. * @param stencil defines if the stencil buffer must be cleared
  104048. */
  104049. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104050. private _viewportCached;
  104051. /** @hidden */
  104052. _viewport(x: number, y: number, width: number, height: number): void;
  104053. /**
  104054. * Set the WebGL's viewport
  104055. * @param viewport defines the viewport element to be used
  104056. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  104057. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  104058. */
  104059. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  104060. /**
  104061. * Begin a new frame
  104062. */
  104063. beginFrame(): void;
  104064. /**
  104065. * Enf the current frame
  104066. */
  104067. endFrame(): void;
  104068. /**
  104069. * Resize the view according to the canvas' size
  104070. */
  104071. resize(): void;
  104072. /**
  104073. * Force a specific size of the canvas
  104074. * @param width defines the new canvas' width
  104075. * @param height defines the new canvas' height
  104076. */
  104077. setSize(width: number, height: number): void;
  104078. /**
  104079. * Binds the frame buffer to the specified texture.
  104080. * @param texture The texture to render to or null for the default canvas
  104081. * @param faceIndex The face of the texture to render to in case of cube texture
  104082. * @param requiredWidth The width of the target to render to
  104083. * @param requiredHeight The height of the target to render to
  104084. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  104085. * @param lodLevel defines the lod level to bind to the frame buffer
  104086. * @param layer defines the 2d array index to bind to frame buffer to
  104087. */
  104088. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  104089. /** @hidden */
  104090. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  104091. /**
  104092. * Unbind the current render target texture from the webGL context
  104093. * @param texture defines the render target texture to unbind
  104094. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104095. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104096. */
  104097. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  104098. /**
  104099. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  104100. */
  104101. flushFramebuffer(): void;
  104102. /**
  104103. * Unbind the current render target and bind the default framebuffer
  104104. */
  104105. restoreDefaultFramebuffer(): void;
  104106. /** @hidden */
  104107. protected _resetVertexBufferBinding(): void;
  104108. /**
  104109. * Creates a vertex buffer
  104110. * @param data the data for the vertex buffer
  104111. * @returns the new WebGL static buffer
  104112. */
  104113. createVertexBuffer(data: DataArray): DataBuffer;
  104114. private _createVertexBuffer;
  104115. /**
  104116. * Creates a dynamic vertex buffer
  104117. * @param data the data for the dynamic vertex buffer
  104118. * @returns the new WebGL dynamic buffer
  104119. */
  104120. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  104121. protected _resetIndexBufferBinding(): void;
  104122. /**
  104123. * Creates a new index buffer
  104124. * @param indices defines the content of the index buffer
  104125. * @param updatable defines if the index buffer must be updatable
  104126. * @returns a new webGL buffer
  104127. */
  104128. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  104129. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  104130. /**
  104131. * Bind a webGL buffer to the webGL context
  104132. * @param buffer defines the buffer to bind
  104133. */
  104134. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  104135. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  104136. private bindBuffer;
  104137. /**
  104138. * update the bound buffer with the given data
  104139. * @param data defines the data to update
  104140. */
  104141. updateArrayBuffer(data: Float32Array): void;
  104142. private _vertexAttribPointer;
  104143. /** @hidden */
  104144. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  104145. private _bindVertexBuffersAttributes;
  104146. /**
  104147. * Records a vertex array object
  104148. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104149. * @param vertexBuffers defines the list of vertex buffers to store
  104150. * @param indexBuffer defines the index buffer to store
  104151. * @param effect defines the effect to store
  104152. * @returns the new vertex array object
  104153. */
  104154. recordVertexArrayObject(vertexBuffers: {
  104155. [key: string]: VertexBuffer;
  104156. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  104157. /**
  104158. * Bind a specific vertex array object
  104159. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104160. * @param vertexArrayObject defines the vertex array object to bind
  104161. * @param indexBuffer defines the index buffer to bind
  104162. */
  104163. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  104164. /**
  104165. * Bind webGl buffers directly to the webGL context
  104166. * @param vertexBuffer defines the vertex buffer to bind
  104167. * @param indexBuffer defines the index buffer to bind
  104168. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  104169. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  104170. * @param effect defines the effect associated with the vertex buffer
  104171. */
  104172. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  104173. private _unbindVertexArrayObject;
  104174. /**
  104175. * Bind a list of vertex buffers to the webGL context
  104176. * @param vertexBuffers defines the list of vertex buffers to bind
  104177. * @param indexBuffer defines the index buffer to bind
  104178. * @param effect defines the effect associated with the vertex buffers
  104179. */
  104180. bindBuffers(vertexBuffers: {
  104181. [key: string]: Nullable<VertexBuffer>;
  104182. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  104183. /**
  104184. * Unbind all instance attributes
  104185. */
  104186. unbindInstanceAttributes(): void;
  104187. /**
  104188. * Release and free the memory of a vertex array object
  104189. * @param vao defines the vertex array object to delete
  104190. */
  104191. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  104192. /** @hidden */
  104193. _releaseBuffer(buffer: DataBuffer): boolean;
  104194. protected _deleteBuffer(buffer: DataBuffer): void;
  104195. /**
  104196. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  104197. * @param instancesBuffer defines the webGL buffer to update and bind
  104198. * @param data defines the data to store in the buffer
  104199. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  104200. */
  104201. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  104202. /**
  104203. * Bind the content of a webGL buffer used with instantiation
  104204. * @param instancesBuffer defines the webGL buffer to bind
  104205. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  104206. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  104207. */
  104208. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  104209. /**
  104210. * Disable the instance attribute corresponding to the name in parameter
  104211. * @param name defines the name of the attribute to disable
  104212. */
  104213. disableInstanceAttributeByName(name: string): void;
  104214. /**
  104215. * Disable the instance attribute corresponding to the location in parameter
  104216. * @param attributeLocation defines the attribute location of the attribute to disable
  104217. */
  104218. disableInstanceAttribute(attributeLocation: number): void;
  104219. /**
  104220. * Disable the attribute corresponding to the location in parameter
  104221. * @param attributeLocation defines the attribute location of the attribute to disable
  104222. */
  104223. disableAttributeByIndex(attributeLocation: number): void;
  104224. /**
  104225. * Send a draw order
  104226. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104227. * @param indexStart defines the starting index
  104228. * @param indexCount defines the number of index to draw
  104229. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104230. */
  104231. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  104232. /**
  104233. * Draw a list of points
  104234. * @param verticesStart defines the index of first vertex to draw
  104235. * @param verticesCount defines the count of vertices to draw
  104236. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104237. */
  104238. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104239. /**
  104240. * Draw a list of unindexed primitives
  104241. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104242. * @param verticesStart defines the index of first vertex to draw
  104243. * @param verticesCount defines the count of vertices to draw
  104244. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104245. */
  104246. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104247. /**
  104248. * Draw a list of indexed primitives
  104249. * @param fillMode defines the primitive to use
  104250. * @param indexStart defines the starting index
  104251. * @param indexCount defines the number of index to draw
  104252. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104253. */
  104254. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  104255. /**
  104256. * Draw a list of unindexed primitives
  104257. * @param fillMode defines the primitive to use
  104258. * @param verticesStart defines the index of first vertex to draw
  104259. * @param verticesCount defines the count of vertices to draw
  104260. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104261. */
  104262. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104263. private _drawMode;
  104264. /** @hidden */
  104265. protected _reportDrawCall(): void;
  104266. /** @hidden */
  104267. _releaseEffect(effect: Effect): void;
  104268. /** @hidden */
  104269. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  104270. /**
  104271. * Create a new effect (used to store vertex/fragment shaders)
  104272. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  104273. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  104274. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  104275. * @param samplers defines an array of string used to represent textures
  104276. * @param defines defines the string containing the defines to use to compile the shaders
  104277. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  104278. * @param onCompiled defines a function to call when the effect creation is successful
  104279. * @param onError defines a function to call when the effect creation has failed
  104280. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  104281. * @returns the new Effect
  104282. */
  104283. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  104284. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  104285. private _compileShader;
  104286. private _compileRawShader;
  104287. /**
  104288. * Directly creates a webGL program
  104289. * @param pipelineContext defines the pipeline context to attach to
  104290. * @param vertexCode defines the vertex shader code to use
  104291. * @param fragmentCode defines the fragment shader code to use
  104292. * @param context defines the webGL context to use (if not set, the current one will be used)
  104293. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104294. * @returns the new webGL program
  104295. */
  104296. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104297. /**
  104298. * Creates a webGL program
  104299. * @param pipelineContext defines the pipeline context to attach to
  104300. * @param vertexCode defines the vertex shader code to use
  104301. * @param fragmentCode defines the fragment shader code to use
  104302. * @param defines defines the string containing the defines to use to compile the shaders
  104303. * @param context defines the webGL context to use (if not set, the current one will be used)
  104304. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104305. * @returns the new webGL program
  104306. */
  104307. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104308. /**
  104309. * Creates a new pipeline context
  104310. * @returns the new pipeline
  104311. */
  104312. createPipelineContext(): IPipelineContext;
  104313. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104314. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  104315. /** @hidden */
  104316. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  104317. /** @hidden */
  104318. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  104319. /** @hidden */
  104320. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  104321. /**
  104322. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  104323. * @param pipelineContext defines the pipeline context to use
  104324. * @param uniformsNames defines the list of uniform names
  104325. * @returns an array of webGL uniform locations
  104326. */
  104327. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  104328. /**
  104329. * Gets the lsit of active attributes for a given webGL program
  104330. * @param pipelineContext defines the pipeline context to use
  104331. * @param attributesNames defines the list of attribute names to get
  104332. * @returns an array of indices indicating the offset of each attribute
  104333. */
  104334. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  104335. /**
  104336. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  104337. * @param effect defines the effect to activate
  104338. */
  104339. enableEffect(effect: Nullable<Effect>): void;
  104340. /**
  104341. * Set the value of an uniform to a number (int)
  104342. * @param uniform defines the webGL uniform location where to store the value
  104343. * @param value defines the int number to store
  104344. */
  104345. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  104346. /**
  104347. * Set the value of an uniform to an array of int32
  104348. * @param uniform defines the webGL uniform location where to store the value
  104349. * @param array defines the array of int32 to store
  104350. */
  104351. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104352. /**
  104353. * Set the value of an uniform to an array of int32 (stored as vec2)
  104354. * @param uniform defines the webGL uniform location where to store the value
  104355. * @param array defines the array of int32 to store
  104356. */
  104357. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104358. /**
  104359. * Set the value of an uniform to an array of int32 (stored as vec3)
  104360. * @param uniform defines the webGL uniform location where to store the value
  104361. * @param array defines the array of int32 to store
  104362. */
  104363. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104364. /**
  104365. * Set the value of an uniform to an array of int32 (stored as vec4)
  104366. * @param uniform defines the webGL uniform location where to store the value
  104367. * @param array defines the array of int32 to store
  104368. */
  104369. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104370. /**
  104371. * Set the value of an uniform to an array of number
  104372. * @param uniform defines the webGL uniform location where to store the value
  104373. * @param array defines the array of number to store
  104374. */
  104375. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104376. /**
  104377. * Set the value of an uniform to an array of number (stored as vec2)
  104378. * @param uniform defines the webGL uniform location where to store the value
  104379. * @param array defines the array of number to store
  104380. */
  104381. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104382. /**
  104383. * Set the value of an uniform to an array of number (stored as vec3)
  104384. * @param uniform defines the webGL uniform location where to store the value
  104385. * @param array defines the array of number to store
  104386. */
  104387. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104388. /**
  104389. * Set the value of an uniform to an array of number (stored as vec4)
  104390. * @param uniform defines the webGL uniform location where to store the value
  104391. * @param array defines the array of number to store
  104392. */
  104393. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104394. /**
  104395. * Set the value of an uniform to an array of float32 (stored as matrices)
  104396. * @param uniform defines the webGL uniform location where to store the value
  104397. * @param matrices defines the array of float32 to store
  104398. */
  104399. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  104400. /**
  104401. * Set the value of an uniform to a matrix (3x3)
  104402. * @param uniform defines the webGL uniform location where to store the value
  104403. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  104404. */
  104405. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  104406. /**
  104407. * Set the value of an uniform to a matrix (2x2)
  104408. * @param uniform defines the webGL uniform location where to store the value
  104409. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  104410. */
  104411. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  104412. /**
  104413. * Set the value of an uniform to a number (float)
  104414. * @param uniform defines the webGL uniform location where to store the value
  104415. * @param value defines the float number to store
  104416. */
  104417. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  104418. /**
  104419. * Set the value of an uniform to a vec2
  104420. * @param uniform defines the webGL uniform location where to store the value
  104421. * @param x defines the 1st component of the value
  104422. * @param y defines the 2nd component of the value
  104423. */
  104424. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  104425. /**
  104426. * Set the value of an uniform to a vec3
  104427. * @param uniform defines the webGL uniform location where to store the value
  104428. * @param x defines the 1st component of the value
  104429. * @param y defines the 2nd component of the value
  104430. * @param z defines the 3rd component of the value
  104431. */
  104432. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  104433. /**
  104434. * Set the value of an uniform to a vec4
  104435. * @param uniform defines the webGL uniform location where to store the value
  104436. * @param x defines the 1st component of the value
  104437. * @param y defines the 2nd component of the value
  104438. * @param z defines the 3rd component of the value
  104439. * @param w defines the 4th component of the value
  104440. */
  104441. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  104442. /**
  104443. * Apply all cached states (depth, culling, stencil and alpha)
  104444. */
  104445. applyStates(): void;
  104446. /**
  104447. * Enable or disable color writing
  104448. * @param enable defines the state to set
  104449. */
  104450. setColorWrite(enable: boolean): void;
  104451. /**
  104452. * Gets a boolean indicating if color writing is enabled
  104453. * @returns the current color writing state
  104454. */
  104455. getColorWrite(): boolean;
  104456. /**
  104457. * Gets the depth culling state manager
  104458. */
  104459. get depthCullingState(): DepthCullingState;
  104460. /**
  104461. * Gets the alpha state manager
  104462. */
  104463. get alphaState(): AlphaState;
  104464. /**
  104465. * Gets the stencil state manager
  104466. */
  104467. get stencilState(): StencilState;
  104468. /**
  104469. * Clears the list of texture accessible through engine.
  104470. * This can help preventing texture load conflict due to name collision.
  104471. */
  104472. clearInternalTexturesCache(): void;
  104473. /**
  104474. * Force the entire cache to be cleared
  104475. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  104476. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  104477. */
  104478. wipeCaches(bruteForce?: boolean): void;
  104479. /** @hidden */
  104480. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  104481. min: number;
  104482. mag: number;
  104483. };
  104484. /** @hidden */
  104485. _createTexture(): WebGLTexture;
  104486. /**
  104487. * Usually called from Texture.ts.
  104488. * Passed information to create a WebGLTexture
  104489. * @param urlArg defines a value which contains one of the following:
  104490. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  104491. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  104492. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  104493. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  104494. * @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)
  104495. * @param scene needed for loading to the correct scene
  104496. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  104497. * @param onLoad optional callback to be called upon successful completion
  104498. * @param onError optional callback to be called upon failure
  104499. * @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
  104500. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  104501. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  104502. * @param forcedExtension defines the extension to use to pick the right loader
  104503. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  104504. * @param mimeType defines an optional mime type
  104505. * @returns a InternalTexture for assignment back into BABYLON.Texture
  104506. */
  104507. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  104508. /**
  104509. * Loads an image as an HTMLImageElement.
  104510. * @param input url string, ArrayBuffer, or Blob to load
  104511. * @param onLoad callback called when the image successfully loads
  104512. * @param onError callback called when the image fails to load
  104513. * @param offlineProvider offline provider for caching
  104514. * @param mimeType optional mime type
  104515. * @returns the HTMLImageElement of the loaded image
  104516. * @hidden
  104517. */
  104518. static _FileToolsLoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  104519. /**
  104520. * @hidden
  104521. */
  104522. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  104523. /**
  104524. * Creates a raw texture
  104525. * @param data defines the data to store in the texture
  104526. * @param width defines the width of the texture
  104527. * @param height defines the height of the texture
  104528. * @param format defines the format of the data
  104529. * @param generateMipMaps defines if the engine should generate the mip levels
  104530. * @param invertY defines if data must be stored with Y axis inverted
  104531. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  104532. * @param compression defines the compression used (null by default)
  104533. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  104534. * @returns the raw texture inside an InternalTexture
  104535. */
  104536. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  104537. /**
  104538. * Creates a new raw cube texture
  104539. * @param data defines the array of data to use to create each face
  104540. * @param size defines the size of the textures
  104541. * @param format defines the format of the data
  104542. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  104543. * @param generateMipMaps defines if the engine should generate the mip levels
  104544. * @param invertY defines if data must be stored with Y axis inverted
  104545. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  104546. * @param compression defines the compression used (null by default)
  104547. * @returns the cube texture as an InternalTexture
  104548. */
  104549. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  104550. /**
  104551. * Creates a new raw 3D texture
  104552. * @param data defines the data used to create the texture
  104553. * @param width defines the width of the texture
  104554. * @param height defines the height of the texture
  104555. * @param depth defines the depth of the texture
  104556. * @param format defines the format of the texture
  104557. * @param generateMipMaps defines if the engine must generate mip levels
  104558. * @param invertY defines if data must be stored with Y axis inverted
  104559. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  104560. * @param compression defines the compressed used (can be null)
  104561. * @param textureType defines the compressed used (can be null)
  104562. * @returns a new raw 3D texture (stored in an InternalTexture)
  104563. */
  104564. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  104565. /**
  104566. * Creates a new raw 2D array texture
  104567. * @param data defines the data used to create the texture
  104568. * @param width defines the width of the texture
  104569. * @param height defines the height of the texture
  104570. * @param depth defines the number of layers of the texture
  104571. * @param format defines the format of the texture
  104572. * @param generateMipMaps defines if the engine must generate mip levels
  104573. * @param invertY defines if data must be stored with Y axis inverted
  104574. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  104575. * @param compression defines the compressed used (can be null)
  104576. * @param textureType defines the compressed used (can be null)
  104577. * @returns a new raw 2D array texture (stored in an InternalTexture)
  104578. */
  104579. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  104580. private _unpackFlipYCached;
  104581. /**
  104582. * In case you are sharing the context with other applications, it might
  104583. * be interested to not cache the unpack flip y state to ensure a consistent
  104584. * value would be set.
  104585. */
  104586. enableUnpackFlipYCached: boolean;
  104587. /** @hidden */
  104588. _unpackFlipY(value: boolean): void;
  104589. /** @hidden */
  104590. _getUnpackAlignement(): number;
  104591. private _getTextureTarget;
  104592. /**
  104593. * Update the sampling mode of a given texture
  104594. * @param samplingMode defines the required sampling mode
  104595. * @param texture defines the texture to update
  104596. * @param generateMipMaps defines whether to generate mipmaps for the texture
  104597. */
  104598. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  104599. /**
  104600. * Update the sampling mode of a given texture
  104601. * @param texture defines the texture to update
  104602. * @param wrapU defines the texture wrap mode of the u coordinates
  104603. * @param wrapV defines the texture wrap mode of the v coordinates
  104604. * @param wrapR defines the texture wrap mode of the r coordinates
  104605. */
  104606. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  104607. /** @hidden */
  104608. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  104609. width: number;
  104610. height: number;
  104611. layers?: number;
  104612. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  104613. /** @hidden */
  104614. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104615. /** @hidden */
  104616. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  104617. /**
  104618. * Update a portion of an internal texture
  104619. * @param texture defines the texture to update
  104620. * @param imageData defines the data to store into the texture
  104621. * @param xOffset defines the x coordinates of the update rectangle
  104622. * @param yOffset defines the y coordinates of the update rectangle
  104623. * @param width defines the width of the update rectangle
  104624. * @param height defines the height of the update rectangle
  104625. * @param faceIndex defines the face index if texture is a cube (0 by default)
  104626. * @param lod defines the lod level to update (0 by default)
  104627. */
  104628. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  104629. /** @hidden */
  104630. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104631. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  104632. private _prepareWebGLTexture;
  104633. /** @hidden */
  104634. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  104635. private _getDepthStencilBuffer;
  104636. /** @hidden */
  104637. _releaseFramebufferObjects(texture: InternalTexture): void;
  104638. /** @hidden */
  104639. _releaseTexture(texture: InternalTexture): void;
  104640. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  104641. protected _setProgram(program: WebGLProgram): void;
  104642. protected _boundUniforms: {
  104643. [key: number]: WebGLUniformLocation;
  104644. };
  104645. /**
  104646. * Binds an effect to the webGL context
  104647. * @param effect defines the effect to bind
  104648. */
  104649. bindSamplers(effect: Effect): void;
  104650. private _activateCurrentTexture;
  104651. /** @hidden */
  104652. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  104653. /** @hidden */
  104654. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  104655. /**
  104656. * Unbind all textures from the webGL context
  104657. */
  104658. unbindAllTextures(): void;
  104659. /**
  104660. * Sets a texture to the according uniform.
  104661. * @param channel The texture channel
  104662. * @param uniform The uniform to set
  104663. * @param texture The texture to apply
  104664. */
  104665. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  104666. private _bindSamplerUniformToChannel;
  104667. private _getTextureWrapMode;
  104668. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  104669. /**
  104670. * Sets an array of texture to the webGL context
  104671. * @param channel defines the channel where the texture array must be set
  104672. * @param uniform defines the associated uniform location
  104673. * @param textures defines the array of textures to bind
  104674. */
  104675. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  104676. /** @hidden */
  104677. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  104678. private _setTextureParameterFloat;
  104679. private _setTextureParameterInteger;
  104680. /**
  104681. * Unbind all vertex attributes from the webGL context
  104682. */
  104683. unbindAllAttributes(): void;
  104684. /**
  104685. * 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
  104686. */
  104687. releaseEffects(): void;
  104688. /**
  104689. * Dispose and release all associated resources
  104690. */
  104691. dispose(): void;
  104692. /**
  104693. * Attach a new callback raised when context lost event is fired
  104694. * @param callback defines the callback to call
  104695. */
  104696. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  104697. /**
  104698. * Attach a new callback raised when context restored event is fired
  104699. * @param callback defines the callback to call
  104700. */
  104701. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  104702. /**
  104703. * Get the current error code of the webGL context
  104704. * @returns the error code
  104705. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  104706. */
  104707. getError(): number;
  104708. private _canRenderToFloatFramebuffer;
  104709. private _canRenderToHalfFloatFramebuffer;
  104710. private _canRenderToFramebuffer;
  104711. /** @hidden */
  104712. _getWebGLTextureType(type: number): number;
  104713. /** @hidden */
  104714. _getInternalFormat(format: number): number;
  104715. /** @hidden */
  104716. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  104717. /** @hidden */
  104718. _getRGBAMultiSampleBufferFormat(type: number): number;
  104719. /** @hidden */
  104720. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  104721. /**
  104722. * Loads a file from a url
  104723. * @param url url to load
  104724. * @param onSuccess callback called when the file successfully loads
  104725. * @param onProgress callback called while file is loading (if the server supports this mode)
  104726. * @param offlineProvider defines the offline provider for caching
  104727. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  104728. * @param onError callback called when the file fails to load
  104729. * @returns a file request object
  104730. * @hidden
  104731. */
  104732. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  104733. /**
  104734. * Reads pixels from the current frame buffer. Please note that this function can be slow
  104735. * @param x defines the x coordinate of the rectangle where pixels must be read
  104736. * @param y defines the y coordinate of the rectangle where pixels must be read
  104737. * @param width defines the width of the rectangle where pixels must be read
  104738. * @param height defines the height of the rectangle where pixels must be read
  104739. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  104740. * @returns a Uint8Array containing RGBA colors
  104741. */
  104742. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  104743. private static _isSupported;
  104744. /**
  104745. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  104746. * @returns true if the engine can be created
  104747. * @ignorenaming
  104748. */
  104749. static isSupported(): boolean;
  104750. /**
  104751. * Find the next highest power of two.
  104752. * @param x Number to start search from.
  104753. * @return Next highest power of two.
  104754. */
  104755. static CeilingPOT(x: number): number;
  104756. /**
  104757. * Find the next lowest power of two.
  104758. * @param x Number to start search from.
  104759. * @return Next lowest power of two.
  104760. */
  104761. static FloorPOT(x: number): number;
  104762. /**
  104763. * Find the nearest power of two.
  104764. * @param x Number to start search from.
  104765. * @return Next nearest power of two.
  104766. */
  104767. static NearestPOT(x: number): number;
  104768. /**
  104769. * Get the closest exponent of two
  104770. * @param value defines the value to approximate
  104771. * @param max defines the maximum value to return
  104772. * @param mode defines how to define the closest value
  104773. * @returns closest exponent of two of the given value
  104774. */
  104775. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  104776. /**
  104777. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  104778. * @param func - the function to be called
  104779. * @param requester - the object that will request the next frame. Falls back to window.
  104780. * @returns frame number
  104781. */
  104782. static QueueNewFrame(func: () => void, requester?: any): number;
  104783. /**
  104784. * Gets host document
  104785. * @returns the host document object
  104786. */
  104787. getHostDocument(): Nullable<Document>;
  104788. }
  104789. }
  104790. declare module BABYLON {
  104791. /**
  104792. * Class representing spherical harmonics coefficients to the 3rd degree
  104793. */
  104794. export class SphericalHarmonics {
  104795. /**
  104796. * Defines whether or not the harmonics have been prescaled for rendering.
  104797. */
  104798. preScaled: boolean;
  104799. /**
  104800. * The l0,0 coefficients of the spherical harmonics
  104801. */
  104802. l00: Vector3;
  104803. /**
  104804. * The l1,-1 coefficients of the spherical harmonics
  104805. */
  104806. l1_1: Vector3;
  104807. /**
  104808. * The l1,0 coefficients of the spherical harmonics
  104809. */
  104810. l10: Vector3;
  104811. /**
  104812. * The l1,1 coefficients of the spherical harmonics
  104813. */
  104814. l11: Vector3;
  104815. /**
  104816. * The l2,-2 coefficients of the spherical harmonics
  104817. */
  104818. l2_2: Vector3;
  104819. /**
  104820. * The l2,-1 coefficients of the spherical harmonics
  104821. */
  104822. l2_1: Vector3;
  104823. /**
  104824. * The l2,0 coefficients of the spherical harmonics
  104825. */
  104826. l20: Vector3;
  104827. /**
  104828. * The l2,1 coefficients of the spherical harmonics
  104829. */
  104830. l21: Vector3;
  104831. /**
  104832. * The l2,2 coefficients of the spherical harmonics
  104833. */
  104834. l22: Vector3;
  104835. /**
  104836. * Adds a light to the spherical harmonics
  104837. * @param direction the direction of the light
  104838. * @param color the color of the light
  104839. * @param deltaSolidAngle the delta solid angle of the light
  104840. */
  104841. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  104842. /**
  104843. * Scales the spherical harmonics by the given amount
  104844. * @param scale the amount to scale
  104845. */
  104846. scaleInPlace(scale: number): void;
  104847. /**
  104848. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  104849. *
  104850. * ```
  104851. * E_lm = A_l * L_lm
  104852. * ```
  104853. *
  104854. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  104855. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  104856. * the scaling factors are given in equation 9.
  104857. */
  104858. convertIncidentRadianceToIrradiance(): void;
  104859. /**
  104860. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  104861. *
  104862. * ```
  104863. * L = (1/pi) * E * rho
  104864. * ```
  104865. *
  104866. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  104867. */
  104868. convertIrradianceToLambertianRadiance(): void;
  104869. /**
  104870. * Integrates the reconstruction coefficients directly in to the SH preventing further
  104871. * required operations at run time.
  104872. *
  104873. * This is simply done by scaling back the SH with Ylm constants parameter.
  104874. * The trigonometric part being applied by the shader at run time.
  104875. */
  104876. preScaleForRendering(): void;
  104877. /**
  104878. * Constructs a spherical harmonics from an array.
  104879. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  104880. * @returns the spherical harmonics
  104881. */
  104882. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  104883. /**
  104884. * Gets the spherical harmonics from polynomial
  104885. * @param polynomial the spherical polynomial
  104886. * @returns the spherical harmonics
  104887. */
  104888. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  104889. }
  104890. /**
  104891. * Class representing spherical polynomial coefficients to the 3rd degree
  104892. */
  104893. export class SphericalPolynomial {
  104894. private _harmonics;
  104895. /**
  104896. * The spherical harmonics used to create the polynomials.
  104897. */
  104898. get preScaledHarmonics(): SphericalHarmonics;
  104899. /**
  104900. * The x coefficients of the spherical polynomial
  104901. */
  104902. x: Vector3;
  104903. /**
  104904. * The y coefficients of the spherical polynomial
  104905. */
  104906. y: Vector3;
  104907. /**
  104908. * The z coefficients of the spherical polynomial
  104909. */
  104910. z: Vector3;
  104911. /**
  104912. * The xx coefficients of the spherical polynomial
  104913. */
  104914. xx: Vector3;
  104915. /**
  104916. * The yy coefficients of the spherical polynomial
  104917. */
  104918. yy: Vector3;
  104919. /**
  104920. * The zz coefficients of the spherical polynomial
  104921. */
  104922. zz: Vector3;
  104923. /**
  104924. * The xy coefficients of the spherical polynomial
  104925. */
  104926. xy: Vector3;
  104927. /**
  104928. * The yz coefficients of the spherical polynomial
  104929. */
  104930. yz: Vector3;
  104931. /**
  104932. * The zx coefficients of the spherical polynomial
  104933. */
  104934. zx: Vector3;
  104935. /**
  104936. * Adds an ambient color to the spherical polynomial
  104937. * @param color the color to add
  104938. */
  104939. addAmbient(color: Color3): void;
  104940. /**
  104941. * Scales the spherical polynomial by the given amount
  104942. * @param scale the amount to scale
  104943. */
  104944. scaleInPlace(scale: number): void;
  104945. /**
  104946. * Gets the spherical polynomial from harmonics
  104947. * @param harmonics the spherical harmonics
  104948. * @returns the spherical polynomial
  104949. */
  104950. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  104951. /**
  104952. * Constructs a spherical polynomial from an array.
  104953. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  104954. * @returns the spherical polynomial
  104955. */
  104956. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  104957. }
  104958. }
  104959. declare module BABYLON {
  104960. /**
  104961. * Defines the source of the internal texture
  104962. */
  104963. export enum InternalTextureSource {
  104964. /**
  104965. * The source of the texture data is unknown
  104966. */
  104967. Unknown = 0,
  104968. /**
  104969. * Texture data comes from an URL
  104970. */
  104971. Url = 1,
  104972. /**
  104973. * Texture data is only used for temporary storage
  104974. */
  104975. Temp = 2,
  104976. /**
  104977. * Texture data comes from raw data (ArrayBuffer)
  104978. */
  104979. Raw = 3,
  104980. /**
  104981. * Texture content is dynamic (video or dynamic texture)
  104982. */
  104983. Dynamic = 4,
  104984. /**
  104985. * Texture content is generated by rendering to it
  104986. */
  104987. RenderTarget = 5,
  104988. /**
  104989. * Texture content is part of a multi render target process
  104990. */
  104991. MultiRenderTarget = 6,
  104992. /**
  104993. * Texture data comes from a cube data file
  104994. */
  104995. Cube = 7,
  104996. /**
  104997. * Texture data comes from a raw cube data
  104998. */
  104999. CubeRaw = 8,
  105000. /**
  105001. * Texture data come from a prefiltered cube data file
  105002. */
  105003. CubePrefiltered = 9,
  105004. /**
  105005. * Texture content is raw 3D data
  105006. */
  105007. Raw3D = 10,
  105008. /**
  105009. * Texture content is raw 2D array data
  105010. */
  105011. Raw2DArray = 11,
  105012. /**
  105013. * Texture content is a depth texture
  105014. */
  105015. Depth = 12,
  105016. /**
  105017. * Texture data comes from a raw cube data encoded with RGBD
  105018. */
  105019. CubeRawRGBD = 13
  105020. }
  105021. /**
  105022. * Class used to store data associated with WebGL texture data for the engine
  105023. * This class should not be used directly
  105024. */
  105025. export class InternalTexture {
  105026. /** @hidden */
  105027. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  105028. /**
  105029. * Defines if the texture is ready
  105030. */
  105031. isReady: boolean;
  105032. /**
  105033. * Defines if the texture is a cube texture
  105034. */
  105035. isCube: boolean;
  105036. /**
  105037. * Defines if the texture contains 3D data
  105038. */
  105039. is3D: boolean;
  105040. /**
  105041. * Defines if the texture contains 2D array data
  105042. */
  105043. is2DArray: boolean;
  105044. /**
  105045. * Defines if the texture contains multiview data
  105046. */
  105047. isMultiview: boolean;
  105048. /**
  105049. * Gets the URL used to load this texture
  105050. */
  105051. url: string;
  105052. /**
  105053. * Gets the sampling mode of the texture
  105054. */
  105055. samplingMode: number;
  105056. /**
  105057. * Gets a boolean indicating if the texture needs mipmaps generation
  105058. */
  105059. generateMipMaps: boolean;
  105060. /**
  105061. * Gets the number of samples used by the texture (WebGL2+ only)
  105062. */
  105063. samples: number;
  105064. /**
  105065. * Gets the type of the texture (int, float...)
  105066. */
  105067. type: number;
  105068. /**
  105069. * Gets the format of the texture (RGB, RGBA...)
  105070. */
  105071. format: number;
  105072. /**
  105073. * Observable called when the texture is loaded
  105074. */
  105075. onLoadedObservable: Observable<InternalTexture>;
  105076. /**
  105077. * Gets the width of the texture
  105078. */
  105079. width: number;
  105080. /**
  105081. * Gets the height of the texture
  105082. */
  105083. height: number;
  105084. /**
  105085. * Gets the depth of the texture
  105086. */
  105087. depth: number;
  105088. /**
  105089. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  105090. */
  105091. baseWidth: number;
  105092. /**
  105093. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  105094. */
  105095. baseHeight: number;
  105096. /**
  105097. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  105098. */
  105099. baseDepth: number;
  105100. /**
  105101. * Gets a boolean indicating if the texture is inverted on Y axis
  105102. */
  105103. invertY: boolean;
  105104. /** @hidden */
  105105. _invertVScale: boolean;
  105106. /** @hidden */
  105107. _associatedChannel: number;
  105108. /** @hidden */
  105109. _source: InternalTextureSource;
  105110. /** @hidden */
  105111. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  105112. /** @hidden */
  105113. _bufferView: Nullable<ArrayBufferView>;
  105114. /** @hidden */
  105115. _bufferViewArray: Nullable<ArrayBufferView[]>;
  105116. /** @hidden */
  105117. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  105118. /** @hidden */
  105119. _size: number;
  105120. /** @hidden */
  105121. _extension: string;
  105122. /** @hidden */
  105123. _files: Nullable<string[]>;
  105124. /** @hidden */
  105125. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  105126. /** @hidden */
  105127. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  105128. /** @hidden */
  105129. _framebuffer: Nullable<WebGLFramebuffer>;
  105130. /** @hidden */
  105131. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  105132. /** @hidden */
  105133. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  105134. /** @hidden */
  105135. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  105136. /** @hidden */
  105137. _attachments: Nullable<number[]>;
  105138. /** @hidden */
  105139. _cachedCoordinatesMode: Nullable<number>;
  105140. /** @hidden */
  105141. _cachedWrapU: Nullable<number>;
  105142. /** @hidden */
  105143. _cachedWrapV: Nullable<number>;
  105144. /** @hidden */
  105145. _cachedWrapR: Nullable<number>;
  105146. /** @hidden */
  105147. _cachedAnisotropicFilteringLevel: Nullable<number>;
  105148. /** @hidden */
  105149. _isDisabled: boolean;
  105150. /** @hidden */
  105151. _compression: Nullable<string>;
  105152. /** @hidden */
  105153. _generateStencilBuffer: boolean;
  105154. /** @hidden */
  105155. _generateDepthBuffer: boolean;
  105156. /** @hidden */
  105157. _comparisonFunction: number;
  105158. /** @hidden */
  105159. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  105160. /** @hidden */
  105161. _lodGenerationScale: number;
  105162. /** @hidden */
  105163. _lodGenerationOffset: number;
  105164. /** @hidden */
  105165. _depthStencilTexture: Nullable<InternalTexture>;
  105166. /** @hidden */
  105167. _colorTextureArray: Nullable<WebGLTexture>;
  105168. /** @hidden */
  105169. _depthStencilTextureArray: Nullable<WebGLTexture>;
  105170. /** @hidden */
  105171. _lodTextureHigh: Nullable<BaseTexture>;
  105172. /** @hidden */
  105173. _lodTextureMid: Nullable<BaseTexture>;
  105174. /** @hidden */
  105175. _lodTextureLow: Nullable<BaseTexture>;
  105176. /** @hidden */
  105177. _isRGBD: boolean;
  105178. /** @hidden */
  105179. _linearSpecularLOD: boolean;
  105180. /** @hidden */
  105181. _irradianceTexture: Nullable<BaseTexture>;
  105182. /** @hidden */
  105183. _webGLTexture: Nullable<WebGLTexture>;
  105184. /** @hidden */
  105185. _references: number;
  105186. private _engine;
  105187. /**
  105188. * Gets the Engine the texture belongs to.
  105189. * @returns The babylon engine
  105190. */
  105191. getEngine(): ThinEngine;
  105192. /**
  105193. * Gets the data source type of the texture
  105194. */
  105195. get source(): InternalTextureSource;
  105196. /**
  105197. * Creates a new InternalTexture
  105198. * @param engine defines the engine to use
  105199. * @param source defines the type of data that will be used
  105200. * @param delayAllocation if the texture allocation should be delayed (default: false)
  105201. */
  105202. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  105203. /**
  105204. * Increments the number of references (ie. the number of Texture that point to it)
  105205. */
  105206. incrementReferences(): void;
  105207. /**
  105208. * Change the size of the texture (not the size of the content)
  105209. * @param width defines the new width
  105210. * @param height defines the new height
  105211. * @param depth defines the new depth (1 by default)
  105212. */
  105213. updateSize(width: int, height: int, depth?: int): void;
  105214. /** @hidden */
  105215. _rebuild(): void;
  105216. /** @hidden */
  105217. _swapAndDie(target: InternalTexture): void;
  105218. /**
  105219. * Dispose the current allocated resources
  105220. */
  105221. dispose(): void;
  105222. }
  105223. }
  105224. declare module BABYLON {
  105225. /**
  105226. * Class used to work with sound analyzer using fast fourier transform (FFT)
  105227. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105228. */
  105229. export class Analyser {
  105230. /**
  105231. * Gets or sets the smoothing
  105232. * @ignorenaming
  105233. */
  105234. SMOOTHING: number;
  105235. /**
  105236. * Gets or sets the FFT table size
  105237. * @ignorenaming
  105238. */
  105239. FFT_SIZE: number;
  105240. /**
  105241. * Gets or sets the bar graph amplitude
  105242. * @ignorenaming
  105243. */
  105244. BARGRAPHAMPLITUDE: number;
  105245. /**
  105246. * Gets or sets the position of the debug canvas
  105247. * @ignorenaming
  105248. */
  105249. DEBUGCANVASPOS: {
  105250. x: number;
  105251. y: number;
  105252. };
  105253. /**
  105254. * Gets or sets the debug canvas size
  105255. * @ignorenaming
  105256. */
  105257. DEBUGCANVASSIZE: {
  105258. width: number;
  105259. height: number;
  105260. };
  105261. private _byteFreqs;
  105262. private _byteTime;
  105263. private _floatFreqs;
  105264. private _webAudioAnalyser;
  105265. private _debugCanvas;
  105266. private _debugCanvasContext;
  105267. private _scene;
  105268. private _registerFunc;
  105269. private _audioEngine;
  105270. /**
  105271. * Creates a new analyser
  105272. * @param scene defines hosting scene
  105273. */
  105274. constructor(scene: Scene);
  105275. /**
  105276. * Get the number of data values you will have to play with for the visualization
  105277. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  105278. * @returns a number
  105279. */
  105280. getFrequencyBinCount(): number;
  105281. /**
  105282. * Gets the current frequency data as a byte array
  105283. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105284. * @returns a Uint8Array
  105285. */
  105286. getByteFrequencyData(): Uint8Array;
  105287. /**
  105288. * Gets the current waveform as a byte array
  105289. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  105290. * @returns a Uint8Array
  105291. */
  105292. getByteTimeDomainData(): Uint8Array;
  105293. /**
  105294. * Gets the current frequency data as a float array
  105295. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105296. * @returns a Float32Array
  105297. */
  105298. getFloatFrequencyData(): Float32Array;
  105299. /**
  105300. * Renders the debug canvas
  105301. */
  105302. drawDebugCanvas(): void;
  105303. /**
  105304. * Stops rendering the debug canvas and removes it
  105305. */
  105306. stopDebugCanvas(): void;
  105307. /**
  105308. * Connects two audio nodes
  105309. * @param inputAudioNode defines first node to connect
  105310. * @param outputAudioNode defines second node to connect
  105311. */
  105312. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  105313. /**
  105314. * Releases all associated resources
  105315. */
  105316. dispose(): void;
  105317. }
  105318. }
  105319. declare module BABYLON {
  105320. /**
  105321. * This represents an audio engine and it is responsible
  105322. * to play, synchronize and analyse sounds throughout the application.
  105323. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105324. */
  105325. export interface IAudioEngine extends IDisposable {
  105326. /**
  105327. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  105328. */
  105329. readonly canUseWebAudio: boolean;
  105330. /**
  105331. * Gets the current AudioContext if available.
  105332. */
  105333. readonly audioContext: Nullable<AudioContext>;
  105334. /**
  105335. * The master gain node defines the global audio volume of your audio engine.
  105336. */
  105337. readonly masterGain: GainNode;
  105338. /**
  105339. * Gets whether or not mp3 are supported by your browser.
  105340. */
  105341. readonly isMP3supported: boolean;
  105342. /**
  105343. * Gets whether or not ogg are supported by your browser.
  105344. */
  105345. readonly isOGGsupported: boolean;
  105346. /**
  105347. * Defines if Babylon should emit a warning if WebAudio is not supported.
  105348. * @ignoreNaming
  105349. */
  105350. WarnedWebAudioUnsupported: boolean;
  105351. /**
  105352. * Defines if the audio engine relies on a custom unlocked button.
  105353. * In this case, the embedded button will not be displayed.
  105354. */
  105355. useCustomUnlockedButton: boolean;
  105356. /**
  105357. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  105358. */
  105359. readonly unlocked: boolean;
  105360. /**
  105361. * Event raised when audio has been unlocked on the browser.
  105362. */
  105363. onAudioUnlockedObservable: Observable<AudioEngine>;
  105364. /**
  105365. * Event raised when audio has been locked on the browser.
  105366. */
  105367. onAudioLockedObservable: Observable<AudioEngine>;
  105368. /**
  105369. * Flags the audio engine in Locked state.
  105370. * This happens due to new browser policies preventing audio to autoplay.
  105371. */
  105372. lock(): void;
  105373. /**
  105374. * Unlocks the audio engine once a user action has been done on the dom.
  105375. * This is helpful to resume play once browser policies have been satisfied.
  105376. */
  105377. unlock(): void;
  105378. }
  105379. /**
  105380. * This represents the default audio engine used in babylon.
  105381. * It is responsible to play, synchronize and analyse sounds throughout the application.
  105382. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105383. */
  105384. export class AudioEngine implements IAudioEngine {
  105385. private _audioContext;
  105386. private _audioContextInitialized;
  105387. private _muteButton;
  105388. private _hostElement;
  105389. /**
  105390. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  105391. */
  105392. canUseWebAudio: boolean;
  105393. /**
  105394. * The master gain node defines the global audio volume of your audio engine.
  105395. */
  105396. masterGain: GainNode;
  105397. /**
  105398. * Defines if Babylon should emit a warning if WebAudio is not supported.
  105399. * @ignoreNaming
  105400. */
  105401. WarnedWebAudioUnsupported: boolean;
  105402. /**
  105403. * Gets whether or not mp3 are supported by your browser.
  105404. */
  105405. isMP3supported: boolean;
  105406. /**
  105407. * Gets whether or not ogg are supported by your browser.
  105408. */
  105409. isOGGsupported: boolean;
  105410. /**
  105411. * Gets whether audio has been unlocked on the device.
  105412. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  105413. * a user interaction has happened.
  105414. */
  105415. unlocked: boolean;
  105416. /**
  105417. * Defines if the audio engine relies on a custom unlocked button.
  105418. * In this case, the embedded button will not be displayed.
  105419. */
  105420. useCustomUnlockedButton: boolean;
  105421. /**
  105422. * Event raised when audio has been unlocked on the browser.
  105423. */
  105424. onAudioUnlockedObservable: Observable<AudioEngine>;
  105425. /**
  105426. * Event raised when audio has been locked on the browser.
  105427. */
  105428. onAudioLockedObservable: Observable<AudioEngine>;
  105429. /**
  105430. * Gets the current AudioContext if available.
  105431. */
  105432. get audioContext(): Nullable<AudioContext>;
  105433. private _connectedAnalyser;
  105434. /**
  105435. * Instantiates a new audio engine.
  105436. *
  105437. * There should be only one per page as some browsers restrict the number
  105438. * of audio contexts you can create.
  105439. * @param hostElement defines the host element where to display the mute icon if necessary
  105440. */
  105441. constructor(hostElement?: Nullable<HTMLElement>);
  105442. /**
  105443. * Flags the audio engine in Locked state.
  105444. * This happens due to new browser policies preventing audio to autoplay.
  105445. */
  105446. lock(): void;
  105447. /**
  105448. * Unlocks the audio engine once a user action has been done on the dom.
  105449. * This is helpful to resume play once browser policies have been satisfied.
  105450. */
  105451. unlock(): void;
  105452. private _resumeAudioContext;
  105453. private _initializeAudioContext;
  105454. private _tryToRun;
  105455. private _triggerRunningState;
  105456. private _triggerSuspendedState;
  105457. private _displayMuteButton;
  105458. private _moveButtonToTopLeft;
  105459. private _onResize;
  105460. private _hideMuteButton;
  105461. /**
  105462. * Destroy and release the resources associated with the audio ccontext.
  105463. */
  105464. dispose(): void;
  105465. /**
  105466. * Gets the global volume sets on the master gain.
  105467. * @returns the global volume if set or -1 otherwise
  105468. */
  105469. getGlobalVolume(): number;
  105470. /**
  105471. * Sets the global volume of your experience (sets on the master gain).
  105472. * @param newVolume Defines the new global volume of the application
  105473. */
  105474. setGlobalVolume(newVolume: number): void;
  105475. /**
  105476. * Connect the audio engine to an audio analyser allowing some amazing
  105477. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  105478. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  105479. * @param analyser The analyser to connect to the engine
  105480. */
  105481. connectToAnalyser(analyser: Analyser): void;
  105482. }
  105483. }
  105484. declare module BABYLON {
  105485. /**
  105486. * Interface used to present a loading screen while loading a scene
  105487. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105488. */
  105489. export interface ILoadingScreen {
  105490. /**
  105491. * Function called to display the loading screen
  105492. */
  105493. displayLoadingUI: () => void;
  105494. /**
  105495. * Function called to hide the loading screen
  105496. */
  105497. hideLoadingUI: () => void;
  105498. /**
  105499. * Gets or sets the color to use for the background
  105500. */
  105501. loadingUIBackgroundColor: string;
  105502. /**
  105503. * Gets or sets the text to display while loading
  105504. */
  105505. loadingUIText: string;
  105506. }
  105507. /**
  105508. * Class used for the default loading screen
  105509. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105510. */
  105511. export class DefaultLoadingScreen implements ILoadingScreen {
  105512. private _renderingCanvas;
  105513. private _loadingText;
  105514. private _loadingDivBackgroundColor;
  105515. private _loadingDiv;
  105516. private _loadingTextDiv;
  105517. /** Gets or sets the logo url to use for the default loading screen */
  105518. static DefaultLogoUrl: string;
  105519. /** Gets or sets the spinner url to use for the default loading screen */
  105520. static DefaultSpinnerUrl: string;
  105521. /**
  105522. * Creates a new default loading screen
  105523. * @param _renderingCanvas defines the canvas used to render the scene
  105524. * @param _loadingText defines the default text to display
  105525. * @param _loadingDivBackgroundColor defines the default background color
  105526. */
  105527. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  105528. /**
  105529. * Function called to display the loading screen
  105530. */
  105531. displayLoadingUI(): void;
  105532. /**
  105533. * Function called to hide the loading screen
  105534. */
  105535. hideLoadingUI(): void;
  105536. /**
  105537. * Gets or sets the text to display while loading
  105538. */
  105539. set loadingUIText(text: string);
  105540. get loadingUIText(): string;
  105541. /**
  105542. * Gets or sets the color to use for the background
  105543. */
  105544. get loadingUIBackgroundColor(): string;
  105545. set loadingUIBackgroundColor(color: string);
  105546. private _resizeLoadingUI;
  105547. }
  105548. }
  105549. declare module BABYLON {
  105550. /**
  105551. * Interface for any object that can request an animation frame
  105552. */
  105553. export interface ICustomAnimationFrameRequester {
  105554. /**
  105555. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  105556. */
  105557. renderFunction?: Function;
  105558. /**
  105559. * Called to request the next frame to render to
  105560. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  105561. */
  105562. requestAnimationFrame: Function;
  105563. /**
  105564. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  105565. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  105566. */
  105567. requestID?: number;
  105568. }
  105569. }
  105570. declare module BABYLON {
  105571. /**
  105572. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  105573. */
  105574. export class PerformanceMonitor {
  105575. private _enabled;
  105576. private _rollingFrameTime;
  105577. private _lastFrameTimeMs;
  105578. /**
  105579. * constructor
  105580. * @param frameSampleSize The number of samples required to saturate the sliding window
  105581. */
  105582. constructor(frameSampleSize?: number);
  105583. /**
  105584. * Samples current frame
  105585. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  105586. */
  105587. sampleFrame(timeMs?: number): void;
  105588. /**
  105589. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  105590. */
  105591. get averageFrameTime(): number;
  105592. /**
  105593. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  105594. */
  105595. get averageFrameTimeVariance(): number;
  105596. /**
  105597. * Returns the frame time of the most recent frame
  105598. */
  105599. get instantaneousFrameTime(): number;
  105600. /**
  105601. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  105602. */
  105603. get averageFPS(): number;
  105604. /**
  105605. * Returns the average framerate in frames per second using the most recent frame time
  105606. */
  105607. get instantaneousFPS(): number;
  105608. /**
  105609. * Returns true if enough samples have been taken to completely fill the sliding window
  105610. */
  105611. get isSaturated(): boolean;
  105612. /**
  105613. * Enables contributions to the sliding window sample set
  105614. */
  105615. enable(): void;
  105616. /**
  105617. * Disables contributions to the sliding window sample set
  105618. * Samples will not be interpolated over the disabled period
  105619. */
  105620. disable(): void;
  105621. /**
  105622. * Returns true if sampling is enabled
  105623. */
  105624. get isEnabled(): boolean;
  105625. /**
  105626. * Resets performance monitor
  105627. */
  105628. reset(): void;
  105629. }
  105630. /**
  105631. * RollingAverage
  105632. *
  105633. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  105634. */
  105635. export class RollingAverage {
  105636. /**
  105637. * Current average
  105638. */
  105639. average: number;
  105640. /**
  105641. * Current variance
  105642. */
  105643. variance: number;
  105644. protected _samples: Array<number>;
  105645. protected _sampleCount: number;
  105646. protected _pos: number;
  105647. protected _m2: number;
  105648. /**
  105649. * constructor
  105650. * @param length The number of samples required to saturate the sliding window
  105651. */
  105652. constructor(length: number);
  105653. /**
  105654. * Adds a sample to the sample set
  105655. * @param v The sample value
  105656. */
  105657. add(v: number): void;
  105658. /**
  105659. * Returns previously added values or null if outside of history or outside the sliding window domain
  105660. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  105661. * @return Value previously recorded with add() or null if outside of range
  105662. */
  105663. history(i: number): number;
  105664. /**
  105665. * Returns true if enough samples have been taken to completely fill the sliding window
  105666. * @return true if sample-set saturated
  105667. */
  105668. isSaturated(): boolean;
  105669. /**
  105670. * Resets the rolling average (equivalent to 0 samples taken so far)
  105671. */
  105672. reset(): void;
  105673. /**
  105674. * Wraps a value around the sample range boundaries
  105675. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  105676. * @return Wrapped position in sample range
  105677. */
  105678. protected _wrapPosition(i: number): number;
  105679. }
  105680. }
  105681. declare module BABYLON {
  105682. /**
  105683. * This class is used to track a performance counter which is number based.
  105684. * The user has access to many properties which give statistics of different nature.
  105685. *
  105686. * The implementer can track two kinds of Performance Counter: time and count.
  105687. * 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.
  105688. * 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.
  105689. */
  105690. export class PerfCounter {
  105691. /**
  105692. * Gets or sets a global boolean to turn on and off all the counters
  105693. */
  105694. static Enabled: boolean;
  105695. /**
  105696. * Returns the smallest value ever
  105697. */
  105698. get min(): number;
  105699. /**
  105700. * Returns the biggest value ever
  105701. */
  105702. get max(): number;
  105703. /**
  105704. * Returns the average value since the performance counter is running
  105705. */
  105706. get average(): number;
  105707. /**
  105708. * Returns the average value of the last second the counter was monitored
  105709. */
  105710. get lastSecAverage(): number;
  105711. /**
  105712. * Returns the current value
  105713. */
  105714. get current(): number;
  105715. /**
  105716. * Gets the accumulated total
  105717. */
  105718. get total(): number;
  105719. /**
  105720. * Gets the total value count
  105721. */
  105722. get count(): number;
  105723. /**
  105724. * Creates a new counter
  105725. */
  105726. constructor();
  105727. /**
  105728. * Call this method to start monitoring a new frame.
  105729. * 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.
  105730. */
  105731. fetchNewFrame(): void;
  105732. /**
  105733. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  105734. * @param newCount the count value to add to the monitored count
  105735. * @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.
  105736. */
  105737. addCount(newCount: number, fetchResult: boolean): void;
  105738. /**
  105739. * Start monitoring this performance counter
  105740. */
  105741. beginMonitoring(): void;
  105742. /**
  105743. * Compute the time lapsed since the previous beginMonitoring() call.
  105744. * @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
  105745. */
  105746. endMonitoring(newFrame?: boolean): void;
  105747. private _fetchResult;
  105748. private _startMonitoringTime;
  105749. private _min;
  105750. private _max;
  105751. private _average;
  105752. private _current;
  105753. private _totalValueCount;
  105754. private _totalAccumulated;
  105755. private _lastSecAverage;
  105756. private _lastSecAccumulated;
  105757. private _lastSecTime;
  105758. private _lastSecValueCount;
  105759. }
  105760. }
  105761. declare module BABYLON {
  105762. interface ThinEngine {
  105763. /**
  105764. * Sets alpha constants used by some alpha blending modes
  105765. * @param r defines the red component
  105766. * @param g defines the green component
  105767. * @param b defines the blue component
  105768. * @param a defines the alpha component
  105769. */
  105770. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  105771. /**
  105772. * Sets the current alpha mode
  105773. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  105774. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  105775. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  105776. */
  105777. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  105778. /**
  105779. * Gets the current alpha mode
  105780. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  105781. * @returns the current alpha mode
  105782. */
  105783. getAlphaMode(): number;
  105784. /**
  105785. * Sets the current alpha equation
  105786. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  105787. */
  105788. setAlphaEquation(equation: number): void;
  105789. /**
  105790. * Gets the current alpha equation.
  105791. * @returns the current alpha equation
  105792. */
  105793. getAlphaEquation(): number;
  105794. }
  105795. }
  105796. declare module BABYLON {
  105797. /**
  105798. * Defines the interface used by display changed events
  105799. */
  105800. export interface IDisplayChangedEventArgs {
  105801. /** Gets the vrDisplay object (if any) */
  105802. vrDisplay: Nullable<any>;
  105803. /** Gets a boolean indicating if webVR is supported */
  105804. vrSupported: boolean;
  105805. }
  105806. /**
  105807. * Defines the interface used by objects containing a viewport (like a camera)
  105808. */
  105809. interface IViewportOwnerLike {
  105810. /**
  105811. * Gets or sets the viewport
  105812. */
  105813. viewport: IViewportLike;
  105814. }
  105815. /**
  105816. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  105817. */
  105818. export class Engine extends ThinEngine {
  105819. /** Defines that alpha blending is disabled */
  105820. static readonly ALPHA_DISABLE: number;
  105821. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  105822. static readonly ALPHA_ADD: number;
  105823. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  105824. static readonly ALPHA_COMBINE: number;
  105825. /** Defines that alpha blending to DEST - SRC * DEST */
  105826. static readonly ALPHA_SUBTRACT: number;
  105827. /** Defines that alpha blending to SRC * DEST */
  105828. static readonly ALPHA_MULTIPLY: number;
  105829. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  105830. static readonly ALPHA_MAXIMIZED: number;
  105831. /** Defines that alpha blending to SRC + DEST */
  105832. static readonly ALPHA_ONEONE: number;
  105833. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  105834. static readonly ALPHA_PREMULTIPLIED: number;
  105835. /**
  105836. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  105837. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  105838. */
  105839. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  105840. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  105841. static readonly ALPHA_INTERPOLATE: number;
  105842. /**
  105843. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  105844. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  105845. */
  105846. static readonly ALPHA_SCREENMODE: number;
  105847. /** Defines that the ressource is not delayed*/
  105848. static readonly DELAYLOADSTATE_NONE: number;
  105849. /** Defines that the ressource was successfully delay loaded */
  105850. static readonly DELAYLOADSTATE_LOADED: number;
  105851. /** Defines that the ressource is currently delay loading */
  105852. static readonly DELAYLOADSTATE_LOADING: number;
  105853. /** Defines that the ressource is delayed and has not started loading */
  105854. static readonly DELAYLOADSTATE_NOTLOADED: number;
  105855. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  105856. static readonly NEVER: number;
  105857. /** 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 */
  105858. static readonly ALWAYS: number;
  105859. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  105860. static readonly LESS: number;
  105861. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  105862. static readonly EQUAL: number;
  105863. /** 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 */
  105864. static readonly LEQUAL: number;
  105865. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  105866. static readonly GREATER: number;
  105867. /** 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 */
  105868. static readonly GEQUAL: number;
  105869. /** 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 */
  105870. static readonly NOTEQUAL: number;
  105871. /** Passed to stencilOperation to specify that stencil value must be kept */
  105872. static readonly KEEP: number;
  105873. /** Passed to stencilOperation to specify that stencil value must be replaced */
  105874. static readonly REPLACE: number;
  105875. /** Passed to stencilOperation to specify that stencil value must be incremented */
  105876. static readonly INCR: number;
  105877. /** Passed to stencilOperation to specify that stencil value must be decremented */
  105878. static readonly DECR: number;
  105879. /** Passed to stencilOperation to specify that stencil value must be inverted */
  105880. static readonly INVERT: number;
  105881. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  105882. static readonly INCR_WRAP: number;
  105883. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  105884. static readonly DECR_WRAP: number;
  105885. /** Texture is not repeating outside of 0..1 UVs */
  105886. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  105887. /** Texture is repeating outside of 0..1 UVs */
  105888. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  105889. /** Texture is repeating and mirrored */
  105890. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  105891. /** ALPHA */
  105892. static readonly TEXTUREFORMAT_ALPHA: number;
  105893. /** LUMINANCE */
  105894. static readonly TEXTUREFORMAT_LUMINANCE: number;
  105895. /** LUMINANCE_ALPHA */
  105896. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  105897. /** RGB */
  105898. static readonly TEXTUREFORMAT_RGB: number;
  105899. /** RGBA */
  105900. static readonly TEXTUREFORMAT_RGBA: number;
  105901. /** RED */
  105902. static readonly TEXTUREFORMAT_RED: number;
  105903. /** RED (2nd reference) */
  105904. static readonly TEXTUREFORMAT_R: number;
  105905. /** RG */
  105906. static readonly TEXTUREFORMAT_RG: number;
  105907. /** RED_INTEGER */
  105908. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  105909. /** RED_INTEGER (2nd reference) */
  105910. static readonly TEXTUREFORMAT_R_INTEGER: number;
  105911. /** RG_INTEGER */
  105912. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  105913. /** RGB_INTEGER */
  105914. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  105915. /** RGBA_INTEGER */
  105916. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  105917. /** UNSIGNED_BYTE */
  105918. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  105919. /** UNSIGNED_BYTE (2nd reference) */
  105920. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  105921. /** FLOAT */
  105922. static readonly TEXTURETYPE_FLOAT: number;
  105923. /** HALF_FLOAT */
  105924. static readonly TEXTURETYPE_HALF_FLOAT: number;
  105925. /** BYTE */
  105926. static readonly TEXTURETYPE_BYTE: number;
  105927. /** SHORT */
  105928. static readonly TEXTURETYPE_SHORT: number;
  105929. /** UNSIGNED_SHORT */
  105930. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  105931. /** INT */
  105932. static readonly TEXTURETYPE_INT: number;
  105933. /** UNSIGNED_INT */
  105934. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  105935. /** UNSIGNED_SHORT_4_4_4_4 */
  105936. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  105937. /** UNSIGNED_SHORT_5_5_5_1 */
  105938. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  105939. /** UNSIGNED_SHORT_5_6_5 */
  105940. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  105941. /** UNSIGNED_INT_2_10_10_10_REV */
  105942. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  105943. /** UNSIGNED_INT_24_8 */
  105944. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  105945. /** UNSIGNED_INT_10F_11F_11F_REV */
  105946. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  105947. /** UNSIGNED_INT_5_9_9_9_REV */
  105948. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  105949. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  105950. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  105951. /** nearest is mag = nearest and min = nearest and mip = linear */
  105952. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  105953. /** Bilinear is mag = linear and min = linear and mip = nearest */
  105954. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  105955. /** Trilinear is mag = linear and min = linear and mip = linear */
  105956. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  105957. /** nearest is mag = nearest and min = nearest and mip = linear */
  105958. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  105959. /** Bilinear is mag = linear and min = linear and mip = nearest */
  105960. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  105961. /** Trilinear is mag = linear and min = linear and mip = linear */
  105962. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  105963. /** mag = nearest and min = nearest and mip = nearest */
  105964. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  105965. /** mag = nearest and min = linear and mip = nearest */
  105966. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  105967. /** mag = nearest and min = linear and mip = linear */
  105968. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  105969. /** mag = nearest and min = linear and mip = none */
  105970. static readonly TEXTURE_NEAREST_LINEAR: number;
  105971. /** mag = nearest and min = nearest and mip = none */
  105972. static readonly TEXTURE_NEAREST_NEAREST: number;
  105973. /** mag = linear and min = nearest and mip = nearest */
  105974. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  105975. /** mag = linear and min = nearest and mip = linear */
  105976. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  105977. /** mag = linear and min = linear and mip = none */
  105978. static readonly TEXTURE_LINEAR_LINEAR: number;
  105979. /** mag = linear and min = nearest and mip = none */
  105980. static readonly TEXTURE_LINEAR_NEAREST: number;
  105981. /** Explicit coordinates mode */
  105982. static readonly TEXTURE_EXPLICIT_MODE: number;
  105983. /** Spherical coordinates mode */
  105984. static readonly TEXTURE_SPHERICAL_MODE: number;
  105985. /** Planar coordinates mode */
  105986. static readonly TEXTURE_PLANAR_MODE: number;
  105987. /** Cubic coordinates mode */
  105988. static readonly TEXTURE_CUBIC_MODE: number;
  105989. /** Projection coordinates mode */
  105990. static readonly TEXTURE_PROJECTION_MODE: number;
  105991. /** Skybox coordinates mode */
  105992. static readonly TEXTURE_SKYBOX_MODE: number;
  105993. /** Inverse Cubic coordinates mode */
  105994. static readonly TEXTURE_INVCUBIC_MODE: number;
  105995. /** Equirectangular coordinates mode */
  105996. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  105997. /** Equirectangular Fixed coordinates mode */
  105998. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  105999. /** Equirectangular Fixed Mirrored coordinates mode */
  106000. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  106001. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  106002. static readonly SCALEMODE_FLOOR: number;
  106003. /** Defines that texture rescaling will look for the nearest power of 2 size */
  106004. static readonly SCALEMODE_NEAREST: number;
  106005. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  106006. static readonly SCALEMODE_CEILING: number;
  106007. /**
  106008. * Returns the current npm package of the sdk
  106009. */
  106010. static get NpmPackage(): string;
  106011. /**
  106012. * Returns the current version of the framework
  106013. */
  106014. static get Version(): string;
  106015. /** Gets the list of created engines */
  106016. static get Instances(): Engine[];
  106017. /**
  106018. * Gets the latest created engine
  106019. */
  106020. static get LastCreatedEngine(): Nullable<Engine>;
  106021. /**
  106022. * Gets the latest created scene
  106023. */
  106024. static get LastCreatedScene(): Nullable<Scene>;
  106025. /**
  106026. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  106027. * @param flag defines which part of the materials must be marked as dirty
  106028. * @param predicate defines a predicate used to filter which materials should be affected
  106029. */
  106030. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  106031. /**
  106032. * Method called to create the default loading screen.
  106033. * This can be overriden in your own app.
  106034. * @param canvas The rendering canvas element
  106035. * @returns The loading screen
  106036. */
  106037. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  106038. /**
  106039. * Method called to create the default rescale post process on each engine.
  106040. */
  106041. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  106042. /**
  106043. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  106044. **/
  106045. enableOfflineSupport: boolean;
  106046. /**
  106047. * 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)
  106048. **/
  106049. disableManifestCheck: boolean;
  106050. /**
  106051. * Gets the list of created scenes
  106052. */
  106053. scenes: Scene[];
  106054. /**
  106055. * Event raised when a new scene is created
  106056. */
  106057. onNewSceneAddedObservable: Observable<Scene>;
  106058. /**
  106059. * Gets the list of created postprocesses
  106060. */
  106061. postProcesses: PostProcess[];
  106062. /**
  106063. * Gets a boolean indicating if the pointer is currently locked
  106064. */
  106065. isPointerLock: boolean;
  106066. /**
  106067. * Observable event triggered each time the rendering canvas is resized
  106068. */
  106069. onResizeObservable: Observable<Engine>;
  106070. /**
  106071. * Observable event triggered each time the canvas loses focus
  106072. */
  106073. onCanvasBlurObservable: Observable<Engine>;
  106074. /**
  106075. * Observable event triggered each time the canvas gains focus
  106076. */
  106077. onCanvasFocusObservable: Observable<Engine>;
  106078. /**
  106079. * Observable event triggered each time the canvas receives pointerout event
  106080. */
  106081. onCanvasPointerOutObservable: Observable<PointerEvent>;
  106082. /**
  106083. * Observable raised when the engine begins a new frame
  106084. */
  106085. onBeginFrameObservable: Observable<Engine>;
  106086. /**
  106087. * If set, will be used to request the next animation frame for the render loop
  106088. */
  106089. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  106090. /**
  106091. * Observable raised when the engine ends the current frame
  106092. */
  106093. onEndFrameObservable: Observable<Engine>;
  106094. /**
  106095. * Observable raised when the engine is about to compile a shader
  106096. */
  106097. onBeforeShaderCompilationObservable: Observable<Engine>;
  106098. /**
  106099. * Observable raised when the engine has jsut compiled a shader
  106100. */
  106101. onAfterShaderCompilationObservable: Observable<Engine>;
  106102. /**
  106103. * Gets the audio engine
  106104. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106105. * @ignorenaming
  106106. */
  106107. static audioEngine: IAudioEngine;
  106108. /**
  106109. * Default AudioEngine factory responsible of creating the Audio Engine.
  106110. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  106111. */
  106112. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  106113. /**
  106114. * Default offline support factory responsible of creating a tool used to store data locally.
  106115. * By default, this will create a Database object if the workload has been embedded.
  106116. */
  106117. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  106118. private _loadingScreen;
  106119. private _pointerLockRequested;
  106120. private _dummyFramebuffer;
  106121. private _rescalePostProcess;
  106122. private _deterministicLockstep;
  106123. private _lockstepMaxSteps;
  106124. private _timeStep;
  106125. protected get _supportsHardwareTextureRescaling(): boolean;
  106126. private _fps;
  106127. private _deltaTime;
  106128. /** @hidden */
  106129. _drawCalls: PerfCounter;
  106130. /** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */
  106131. canvasTabIndex: number;
  106132. /**
  106133. * Turn this value on if you want to pause FPS computation when in background
  106134. */
  106135. disablePerformanceMonitorInBackground: boolean;
  106136. private _performanceMonitor;
  106137. /**
  106138. * Gets the performance monitor attached to this engine
  106139. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106140. */
  106141. get performanceMonitor(): PerformanceMonitor;
  106142. private _onFocus;
  106143. private _onBlur;
  106144. private _onCanvasPointerOut;
  106145. private _onCanvasBlur;
  106146. private _onCanvasFocus;
  106147. private _onFullscreenChange;
  106148. private _onPointerLockChange;
  106149. /**
  106150. * Gets the HTML element used to attach event listeners
  106151. * @returns a HTML element
  106152. */
  106153. getInputElement(): Nullable<HTMLElement>;
  106154. /**
  106155. * Creates a new engine
  106156. * @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
  106157. * @param antialias defines enable antialiasing (default: false)
  106158. * @param options defines further options to be sent to the getContext() function
  106159. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  106160. */
  106161. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  106162. /**
  106163. * Gets current aspect ratio
  106164. * @param viewportOwner defines the camera to use to get the aspect ratio
  106165. * @param useScreen defines if screen size must be used (or the current render target if any)
  106166. * @returns a number defining the aspect ratio
  106167. */
  106168. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  106169. /**
  106170. * Gets current screen aspect ratio
  106171. * @returns a number defining the aspect ratio
  106172. */
  106173. getScreenAspectRatio(): number;
  106174. /**
  106175. * Gets the client rect of the HTML canvas attached with the current webGL context
  106176. * @returns a client rectanglee
  106177. */
  106178. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  106179. /**
  106180. * Gets the client rect of the HTML element used for events
  106181. * @returns a client rectanglee
  106182. */
  106183. getInputElementClientRect(): Nullable<ClientRect>;
  106184. /**
  106185. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  106186. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106187. * @returns true if engine is in deterministic lock step mode
  106188. */
  106189. isDeterministicLockStep(): boolean;
  106190. /**
  106191. * Gets the max steps when engine is running in deterministic lock step
  106192. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106193. * @returns the max steps
  106194. */
  106195. getLockstepMaxSteps(): number;
  106196. /**
  106197. * Returns the time in ms between steps when using deterministic lock step.
  106198. * @returns time step in (ms)
  106199. */
  106200. getTimeStep(): number;
  106201. /**
  106202. * Force the mipmap generation for the given render target texture
  106203. * @param texture defines the render target texture to use
  106204. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  106205. */
  106206. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  106207. /** States */
  106208. /**
  106209. * Set various states to the webGL context
  106210. * @param culling defines backface culling state
  106211. * @param zOffset defines the value to apply to zOffset (0 by default)
  106212. * @param force defines if states must be applied even if cache is up to date
  106213. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  106214. */
  106215. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  106216. /**
  106217. * Set the z offset to apply to current rendering
  106218. * @param value defines the offset to apply
  106219. */
  106220. setZOffset(value: number): void;
  106221. /**
  106222. * Gets the current value of the zOffset
  106223. * @returns the current zOffset state
  106224. */
  106225. getZOffset(): number;
  106226. /**
  106227. * Enable or disable depth buffering
  106228. * @param enable defines the state to set
  106229. */
  106230. setDepthBuffer(enable: boolean): void;
  106231. /**
  106232. * Gets a boolean indicating if depth writing is enabled
  106233. * @returns the current depth writing state
  106234. */
  106235. getDepthWrite(): boolean;
  106236. /**
  106237. * Enable or disable depth writing
  106238. * @param enable defines the state to set
  106239. */
  106240. setDepthWrite(enable: boolean): void;
  106241. /**
  106242. * Gets a boolean indicating if stencil buffer is enabled
  106243. * @returns the current stencil buffer state
  106244. */
  106245. getStencilBuffer(): boolean;
  106246. /**
  106247. * Enable or disable the stencil buffer
  106248. * @param enable defines if the stencil buffer must be enabled or disabled
  106249. */
  106250. setStencilBuffer(enable: boolean): void;
  106251. /**
  106252. * Gets the current stencil mask
  106253. * @returns a number defining the new stencil mask to use
  106254. */
  106255. getStencilMask(): number;
  106256. /**
  106257. * Sets the current stencil mask
  106258. * @param mask defines the new stencil mask to use
  106259. */
  106260. setStencilMask(mask: number): void;
  106261. /**
  106262. * Gets the current stencil function
  106263. * @returns a number defining the stencil function to use
  106264. */
  106265. getStencilFunction(): number;
  106266. /**
  106267. * Gets the current stencil reference value
  106268. * @returns a number defining the stencil reference value to use
  106269. */
  106270. getStencilFunctionReference(): number;
  106271. /**
  106272. * Gets the current stencil mask
  106273. * @returns a number defining the stencil mask to use
  106274. */
  106275. getStencilFunctionMask(): number;
  106276. /**
  106277. * Sets the current stencil function
  106278. * @param stencilFunc defines the new stencil function to use
  106279. */
  106280. setStencilFunction(stencilFunc: number): void;
  106281. /**
  106282. * Sets the current stencil reference
  106283. * @param reference defines the new stencil reference to use
  106284. */
  106285. setStencilFunctionReference(reference: number): void;
  106286. /**
  106287. * Sets the current stencil mask
  106288. * @param mask defines the new stencil mask to use
  106289. */
  106290. setStencilFunctionMask(mask: number): void;
  106291. /**
  106292. * Gets the current stencil operation when stencil fails
  106293. * @returns a number defining stencil operation to use when stencil fails
  106294. */
  106295. getStencilOperationFail(): number;
  106296. /**
  106297. * Gets the current stencil operation when depth fails
  106298. * @returns a number defining stencil operation to use when depth fails
  106299. */
  106300. getStencilOperationDepthFail(): number;
  106301. /**
  106302. * Gets the current stencil operation when stencil passes
  106303. * @returns a number defining stencil operation to use when stencil passes
  106304. */
  106305. getStencilOperationPass(): number;
  106306. /**
  106307. * Sets the stencil operation to use when stencil fails
  106308. * @param operation defines the stencil operation to use when stencil fails
  106309. */
  106310. setStencilOperationFail(operation: number): void;
  106311. /**
  106312. * Sets the stencil operation to use when depth fails
  106313. * @param operation defines the stencil operation to use when depth fails
  106314. */
  106315. setStencilOperationDepthFail(operation: number): void;
  106316. /**
  106317. * Sets the stencil operation to use when stencil passes
  106318. * @param operation defines the stencil operation to use when stencil passes
  106319. */
  106320. setStencilOperationPass(operation: number): void;
  106321. /**
  106322. * Sets a boolean indicating if the dithering state is enabled or disabled
  106323. * @param value defines the dithering state
  106324. */
  106325. setDitheringState(value: boolean): void;
  106326. /**
  106327. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  106328. * @param value defines the rasterizer state
  106329. */
  106330. setRasterizerState(value: boolean): void;
  106331. /**
  106332. * Gets the current depth function
  106333. * @returns a number defining the depth function
  106334. */
  106335. getDepthFunction(): Nullable<number>;
  106336. /**
  106337. * Sets the current depth function
  106338. * @param depthFunc defines the function to use
  106339. */
  106340. setDepthFunction(depthFunc: number): void;
  106341. /**
  106342. * Sets the current depth function to GREATER
  106343. */
  106344. setDepthFunctionToGreater(): void;
  106345. /**
  106346. * Sets the current depth function to GEQUAL
  106347. */
  106348. setDepthFunctionToGreaterOrEqual(): void;
  106349. /**
  106350. * Sets the current depth function to LESS
  106351. */
  106352. setDepthFunctionToLess(): void;
  106353. /**
  106354. * Sets the current depth function to LEQUAL
  106355. */
  106356. setDepthFunctionToLessOrEqual(): void;
  106357. private _cachedStencilBuffer;
  106358. private _cachedStencilFunction;
  106359. private _cachedStencilMask;
  106360. private _cachedStencilOperationPass;
  106361. private _cachedStencilOperationFail;
  106362. private _cachedStencilOperationDepthFail;
  106363. private _cachedStencilReference;
  106364. /**
  106365. * Caches the the state of the stencil buffer
  106366. */
  106367. cacheStencilState(): void;
  106368. /**
  106369. * Restores the state of the stencil buffer
  106370. */
  106371. restoreStencilState(): void;
  106372. /**
  106373. * Directly set the WebGL Viewport
  106374. * @param x defines the x coordinate of the viewport (in screen space)
  106375. * @param y defines the y coordinate of the viewport (in screen space)
  106376. * @param width defines the width of the viewport (in screen space)
  106377. * @param height defines the height of the viewport (in screen space)
  106378. * @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
  106379. */
  106380. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  106381. /**
  106382. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  106383. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  106384. * @param y defines the y-coordinate of the corner of the clear rectangle
  106385. * @param width defines the width of the clear rectangle
  106386. * @param height defines the height of the clear rectangle
  106387. * @param clearColor defines the clear color
  106388. */
  106389. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  106390. /**
  106391. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  106392. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  106393. * @param y defines the y-coordinate of the corner of the clear rectangle
  106394. * @param width defines the width of the clear rectangle
  106395. * @param height defines the height of the clear rectangle
  106396. */
  106397. enableScissor(x: number, y: number, width: number, height: number): void;
  106398. /**
  106399. * Disable previously set scissor test rectangle
  106400. */
  106401. disableScissor(): void;
  106402. protected _reportDrawCall(): void;
  106403. /**
  106404. * Initializes a webVR display and starts listening to display change events
  106405. * The onVRDisplayChangedObservable will be notified upon these changes
  106406. * @returns The onVRDisplayChangedObservable
  106407. */
  106408. initWebVR(): Observable<IDisplayChangedEventArgs>;
  106409. /** @hidden */
  106410. _prepareVRComponent(): void;
  106411. /** @hidden */
  106412. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  106413. /** @hidden */
  106414. _submitVRFrame(): void;
  106415. /**
  106416. * Call this function to leave webVR mode
  106417. * Will do nothing if webVR is not supported or if there is no webVR device
  106418. * @see http://doc.babylonjs.com/how_to/webvr_camera
  106419. */
  106420. disableVR(): void;
  106421. /**
  106422. * Gets a boolean indicating that the system is in VR mode and is presenting
  106423. * @returns true if VR mode is engaged
  106424. */
  106425. isVRPresenting(): boolean;
  106426. /** @hidden */
  106427. _requestVRFrame(): void;
  106428. /** @hidden */
  106429. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  106430. /**
  106431. * Gets the source code of the vertex shader associated with a specific webGL program
  106432. * @param program defines the program to use
  106433. * @returns a string containing the source code of the vertex shader associated with the program
  106434. */
  106435. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  106436. /**
  106437. * Gets the source code of the fragment shader associated with a specific webGL program
  106438. * @param program defines the program to use
  106439. * @returns a string containing the source code of the fragment shader associated with the program
  106440. */
  106441. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  106442. /**
  106443. * Sets a depth stencil texture from a render target to the according uniform.
  106444. * @param channel The texture channel
  106445. * @param uniform The uniform to set
  106446. * @param texture The render target texture containing the depth stencil texture to apply
  106447. */
  106448. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  106449. /**
  106450. * Sets a texture to the webGL context from a postprocess
  106451. * @param channel defines the channel to use
  106452. * @param postProcess defines the source postprocess
  106453. */
  106454. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  106455. /**
  106456. * Binds the output of the passed in post process to the texture channel specified
  106457. * @param channel The channel the texture should be bound to
  106458. * @param postProcess The post process which's output should be bound
  106459. */
  106460. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  106461. /** @hidden */
  106462. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  106463. protected _rebuildBuffers(): void;
  106464. /** @hidden */
  106465. _renderFrame(): void;
  106466. _renderLoop(): void;
  106467. /** @hidden */
  106468. _renderViews(): boolean;
  106469. /**
  106470. * Toggle full screen mode
  106471. * @param requestPointerLock defines if a pointer lock should be requested from the user
  106472. */
  106473. switchFullscreen(requestPointerLock: boolean): void;
  106474. /**
  106475. * Enters full screen mode
  106476. * @param requestPointerLock defines if a pointer lock should be requested from the user
  106477. */
  106478. enterFullscreen(requestPointerLock: boolean): void;
  106479. /**
  106480. * Exits full screen mode
  106481. */
  106482. exitFullscreen(): void;
  106483. /**
  106484. * Enters Pointerlock mode
  106485. */
  106486. enterPointerlock(): void;
  106487. /**
  106488. * Exits Pointerlock mode
  106489. */
  106490. exitPointerlock(): void;
  106491. /**
  106492. * Begin a new frame
  106493. */
  106494. beginFrame(): void;
  106495. /**
  106496. * Enf the current frame
  106497. */
  106498. endFrame(): void;
  106499. resize(): void;
  106500. /**
  106501. * Set the compressed texture format to use, based on the formats you have, and the formats
  106502. * supported by the hardware / browser.
  106503. *
  106504. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  106505. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  106506. * to API arguments needed to compressed textures. This puts the burden on the container
  106507. * generator to house the arcane code for determining these for current & future formats.
  106508. *
  106509. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  106510. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  106511. *
  106512. * Note: The result of this call is not taken into account when a texture is base64.
  106513. *
  106514. * @param formatsAvailable defines the list of those format families you have created
  106515. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  106516. *
  106517. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  106518. * @returns The extension selected.
  106519. */
  106520. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  106521. /**
  106522. * Set the compressed texture extensions or file names to skip.
  106523. *
  106524. * @param skippedFiles defines the list of those texture files you want to skip
  106525. * Example: [".dds", ".env", "myfile.png"]
  106526. */
  106527. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  106528. /**
  106529. * Force a specific size of the canvas
  106530. * @param width defines the new canvas' width
  106531. * @param height defines the new canvas' height
  106532. */
  106533. setSize(width: number, height: number): void;
  106534. /**
  106535. * Updates a dynamic vertex buffer.
  106536. * @param vertexBuffer the vertex buffer to update
  106537. * @param data the data used to update the vertex buffer
  106538. * @param byteOffset the byte offset of the data
  106539. * @param byteLength the byte length of the data
  106540. */
  106541. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  106542. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  106543. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106544. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106545. _releaseTexture(texture: InternalTexture): void;
  106546. /**
  106547. * @hidden
  106548. * Rescales a texture
  106549. * @param source input texutre
  106550. * @param destination destination texture
  106551. * @param scene scene to use to render the resize
  106552. * @param internalFormat format to use when resizing
  106553. * @param onComplete callback to be called when resize has completed
  106554. */
  106555. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  106556. /**
  106557. * Gets the current framerate
  106558. * @returns a number representing the framerate
  106559. */
  106560. getFps(): number;
  106561. /**
  106562. * Gets the time spent between current and previous frame
  106563. * @returns a number representing the delta time in ms
  106564. */
  106565. getDeltaTime(): number;
  106566. private _measureFps;
  106567. /** @hidden */
  106568. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  106569. /**
  106570. * Update a dynamic index buffer
  106571. * @param indexBuffer defines the target index buffer
  106572. * @param indices defines the data to update
  106573. * @param offset defines the offset in the target index buffer where update should start
  106574. */
  106575. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  106576. /**
  106577. * Updates the sample count of a render target texture
  106578. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  106579. * @param texture defines the texture to update
  106580. * @param samples defines the sample count to set
  106581. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  106582. */
  106583. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  106584. /**
  106585. * Updates a depth texture Comparison Mode and Function.
  106586. * If the comparison Function is equal to 0, the mode will be set to none.
  106587. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  106588. * @param texture The texture to set the comparison function for
  106589. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  106590. */
  106591. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  106592. /**
  106593. * Creates a webGL buffer to use with instanciation
  106594. * @param capacity defines the size of the buffer
  106595. * @returns the webGL buffer
  106596. */
  106597. createInstancesBuffer(capacity: number): DataBuffer;
  106598. /**
  106599. * Delete a webGL buffer used with instanciation
  106600. * @param buffer defines the webGL buffer to delete
  106601. */
  106602. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  106603. /** @hidden */
  106604. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  106605. dispose(): void;
  106606. private _disableTouchAction;
  106607. /**
  106608. * Display the loading screen
  106609. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106610. */
  106611. displayLoadingUI(): void;
  106612. /**
  106613. * Hide the loading screen
  106614. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106615. */
  106616. hideLoadingUI(): void;
  106617. /**
  106618. * Gets the current loading screen object
  106619. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106620. */
  106621. get loadingScreen(): ILoadingScreen;
  106622. /**
  106623. * Sets the current loading screen object
  106624. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106625. */
  106626. set loadingScreen(loadingScreen: ILoadingScreen);
  106627. /**
  106628. * Sets the current loading screen text
  106629. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106630. */
  106631. set loadingUIText(text: string);
  106632. /**
  106633. * Sets the current loading screen background color
  106634. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106635. */
  106636. set loadingUIBackgroundColor(color: string);
  106637. /** Pointerlock and fullscreen */
  106638. /**
  106639. * Ask the browser to promote the current element to pointerlock mode
  106640. * @param element defines the DOM element to promote
  106641. */
  106642. static _RequestPointerlock(element: HTMLElement): void;
  106643. /**
  106644. * Asks the browser to exit pointerlock mode
  106645. */
  106646. static _ExitPointerlock(): void;
  106647. /**
  106648. * Ask the browser to promote the current element to fullscreen rendering mode
  106649. * @param element defines the DOM element to promote
  106650. */
  106651. static _RequestFullscreen(element: HTMLElement): void;
  106652. /**
  106653. * Asks the browser to exit fullscreen mode
  106654. */
  106655. static _ExitFullscreen(): void;
  106656. }
  106657. }
  106658. declare module BABYLON {
  106659. /**
  106660. * The engine store class is responsible to hold all the instances of Engine and Scene created
  106661. * during the life time of the application.
  106662. */
  106663. export class EngineStore {
  106664. /** Gets the list of created engines */
  106665. static Instances: Engine[];
  106666. /** @hidden */
  106667. static _LastCreatedScene: Nullable<Scene>;
  106668. /**
  106669. * Gets the latest created engine
  106670. */
  106671. static get LastCreatedEngine(): Nullable<Engine>;
  106672. /**
  106673. * Gets the latest created scene
  106674. */
  106675. static get LastCreatedScene(): Nullable<Scene>;
  106676. /**
  106677. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  106678. * @ignorenaming
  106679. */
  106680. static UseFallbackTexture: boolean;
  106681. /**
  106682. * Texture content used if a texture cannot loaded
  106683. * @ignorenaming
  106684. */
  106685. static FallbackTexture: string;
  106686. }
  106687. }
  106688. declare module BABYLON {
  106689. /**
  106690. * Helper class that provides a small promise polyfill
  106691. */
  106692. export class PromisePolyfill {
  106693. /**
  106694. * Static function used to check if the polyfill is required
  106695. * If this is the case then the function will inject the polyfill to window.Promise
  106696. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  106697. */
  106698. static Apply(force?: boolean): void;
  106699. }
  106700. }
  106701. declare module BABYLON {
  106702. /**
  106703. * Interface for screenshot methods with describe argument called `size` as object with options
  106704. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  106705. */
  106706. export interface IScreenshotSize {
  106707. /**
  106708. * number in pixels for canvas height
  106709. */
  106710. height?: number;
  106711. /**
  106712. * multiplier allowing render at a higher or lower resolution
  106713. * If value is defined then height and width will be ignored and taken from camera
  106714. */
  106715. precision?: number;
  106716. /**
  106717. * number in pixels for canvas width
  106718. */
  106719. width?: number;
  106720. }
  106721. }
  106722. declare module BABYLON {
  106723. interface IColor4Like {
  106724. r: float;
  106725. g: float;
  106726. b: float;
  106727. a: float;
  106728. }
  106729. /**
  106730. * Class containing a set of static utilities functions
  106731. */
  106732. export class Tools {
  106733. /**
  106734. * Gets or sets the base URL to use to load assets
  106735. */
  106736. static get BaseUrl(): string;
  106737. static set BaseUrl(value: string);
  106738. /**
  106739. * Enable/Disable Custom HTTP Request Headers globally.
  106740. * default = false
  106741. * @see CustomRequestHeaders
  106742. */
  106743. static UseCustomRequestHeaders: boolean;
  106744. /**
  106745. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  106746. * i.e. when loading files, where the server/service expects an Authorization header
  106747. */
  106748. static CustomRequestHeaders: {
  106749. [key: string]: string;
  106750. };
  106751. /**
  106752. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  106753. */
  106754. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  106755. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  106756. /**
  106757. * Default behaviour for cors in the application.
  106758. * It can be a string if the expected behavior is identical in the entire app.
  106759. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  106760. */
  106761. static CorsBehavior: string | ((url: string | string[]) => string);
  106762. /**
  106763. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  106764. * @ignorenaming
  106765. */
  106766. static get UseFallbackTexture(): boolean;
  106767. static set UseFallbackTexture(value: boolean);
  106768. /**
  106769. * Use this object to register external classes like custom textures or material
  106770. * to allow the laoders to instantiate them
  106771. */
  106772. static get RegisteredExternalClasses(): {
  106773. [key: string]: Object;
  106774. };
  106775. static set RegisteredExternalClasses(classes: {
  106776. [key: string]: Object;
  106777. });
  106778. /**
  106779. * Texture content used if a texture cannot loaded
  106780. * @ignorenaming
  106781. */
  106782. static get fallbackTexture(): string;
  106783. static set fallbackTexture(value: string);
  106784. /**
  106785. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  106786. * @param u defines the coordinate on X axis
  106787. * @param v defines the coordinate on Y axis
  106788. * @param width defines the width of the source data
  106789. * @param height defines the height of the source data
  106790. * @param pixels defines the source byte array
  106791. * @param color defines the output color
  106792. */
  106793. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  106794. /**
  106795. * Interpolates between a and b via alpha
  106796. * @param a The lower value (returned when alpha = 0)
  106797. * @param b The upper value (returned when alpha = 1)
  106798. * @param alpha The interpolation-factor
  106799. * @return The mixed value
  106800. */
  106801. static Mix(a: number, b: number, alpha: number): number;
  106802. /**
  106803. * Tries to instantiate a new object from a given class name
  106804. * @param className defines the class name to instantiate
  106805. * @returns the new object or null if the system was not able to do the instantiation
  106806. */
  106807. static Instantiate(className: string): any;
  106808. /**
  106809. * Provides a slice function that will work even on IE
  106810. * @param data defines the array to slice
  106811. * @param start defines the start of the data (optional)
  106812. * @param end defines the end of the data (optional)
  106813. * @returns the new sliced array
  106814. */
  106815. static Slice<T>(data: T, start?: number, end?: number): T;
  106816. /**
  106817. * Polyfill for setImmediate
  106818. * @param action defines the action to execute after the current execution block
  106819. */
  106820. static SetImmediate(action: () => void): void;
  106821. /**
  106822. * Function indicating if a number is an exponent of 2
  106823. * @param value defines the value to test
  106824. * @returns true if the value is an exponent of 2
  106825. */
  106826. static IsExponentOfTwo(value: number): boolean;
  106827. private static _tmpFloatArray;
  106828. /**
  106829. * Returns the nearest 32-bit single precision float representation of a Number
  106830. * @param value A Number. If the parameter is of a different type, it will get converted
  106831. * to a number or to NaN if it cannot be converted
  106832. * @returns number
  106833. */
  106834. static FloatRound(value: number): number;
  106835. /**
  106836. * Extracts the filename from a path
  106837. * @param path defines the path to use
  106838. * @returns the filename
  106839. */
  106840. static GetFilename(path: string): string;
  106841. /**
  106842. * Extracts the "folder" part of a path (everything before the filename).
  106843. * @param uri The URI to extract the info from
  106844. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  106845. * @returns The "folder" part of the path
  106846. */
  106847. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  106848. /**
  106849. * Extracts text content from a DOM element hierarchy
  106850. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  106851. */
  106852. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  106853. /**
  106854. * Convert an angle in radians to degrees
  106855. * @param angle defines the angle to convert
  106856. * @returns the angle in degrees
  106857. */
  106858. static ToDegrees(angle: number): number;
  106859. /**
  106860. * Convert an angle in degrees to radians
  106861. * @param angle defines the angle to convert
  106862. * @returns the angle in radians
  106863. */
  106864. static ToRadians(angle: number): number;
  106865. /**
  106866. * Returns an array if obj is not an array
  106867. * @param obj defines the object to evaluate as an array
  106868. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  106869. * @returns either obj directly if obj is an array or a new array containing obj
  106870. */
  106871. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  106872. /**
  106873. * Gets the pointer prefix to use
  106874. * @returns "pointer" if touch is enabled. Else returns "mouse"
  106875. */
  106876. static GetPointerPrefix(): string;
  106877. /**
  106878. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  106879. * @param url define the url we are trying
  106880. * @param element define the dom element where to configure the cors policy
  106881. */
  106882. static SetCorsBehavior(url: string | string[], element: {
  106883. crossOrigin: string | null;
  106884. }): void;
  106885. /**
  106886. * Removes unwanted characters from an url
  106887. * @param url defines the url to clean
  106888. * @returns the cleaned url
  106889. */
  106890. static CleanUrl(url: string): string;
  106891. /**
  106892. * Gets or sets a function used to pre-process url before using them to load assets
  106893. */
  106894. static get PreprocessUrl(): (url: string) => string;
  106895. static set PreprocessUrl(processor: (url: string) => string);
  106896. /**
  106897. * Loads an image as an HTMLImageElement.
  106898. * @param input url string, ArrayBuffer, or Blob to load
  106899. * @param onLoad callback called when the image successfully loads
  106900. * @param onError callback called when the image fails to load
  106901. * @param offlineProvider offline provider for caching
  106902. * @param mimeType optional mime type
  106903. * @returns the HTMLImageElement of the loaded image
  106904. */
  106905. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  106906. /**
  106907. * Loads a file from a url
  106908. * @param url url string, ArrayBuffer, or Blob to load
  106909. * @param onSuccess callback called when the file successfully loads
  106910. * @param onProgress callback called while file is loading (if the server supports this mode)
  106911. * @param offlineProvider defines the offline provider for caching
  106912. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  106913. * @param onError callback called when the file fails to load
  106914. * @returns a file request object
  106915. */
  106916. 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;
  106917. /**
  106918. * Loads a file from a url
  106919. * @param url the file url to load
  106920. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  106921. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  106922. */
  106923. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  106924. /**
  106925. * Load a script (identified by an url). When the url returns, the
  106926. * content of this file is added into a new script element, attached to the DOM (body element)
  106927. * @param scriptUrl defines the url of the script to laod
  106928. * @param onSuccess defines the callback called when the script is loaded
  106929. * @param onError defines the callback to call if an error occurs
  106930. * @param scriptId defines the id of the script element
  106931. */
  106932. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  106933. /**
  106934. * Load an asynchronous script (identified by an url). When the url returns, the
  106935. * content of this file is added into a new script element, attached to the DOM (body element)
  106936. * @param scriptUrl defines the url of the script to laod
  106937. * @param scriptId defines the id of the script element
  106938. * @returns a promise request object
  106939. */
  106940. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  106941. /**
  106942. * Loads a file from a blob
  106943. * @param fileToLoad defines the blob to use
  106944. * @param callback defines the callback to call when data is loaded
  106945. * @param progressCallback defines the callback to call during loading process
  106946. * @returns a file request object
  106947. */
  106948. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  106949. /**
  106950. * Reads a file from a File object
  106951. * @param file defines the file to load
  106952. * @param onSuccess defines the callback to call when data is loaded
  106953. * @param onProgress defines the callback to call during loading process
  106954. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  106955. * @param onError defines the callback to call when an error occurs
  106956. * @returns a file request object
  106957. */
  106958. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  106959. /**
  106960. * Creates a data url from a given string content
  106961. * @param content defines the content to convert
  106962. * @returns the new data url link
  106963. */
  106964. static FileAsURL(content: string): string;
  106965. /**
  106966. * Format the given number to a specific decimal format
  106967. * @param value defines the number to format
  106968. * @param decimals defines the number of decimals to use
  106969. * @returns the formatted string
  106970. */
  106971. static Format(value: number, decimals?: number): string;
  106972. /**
  106973. * Tries to copy an object by duplicating every property
  106974. * @param source defines the source object
  106975. * @param destination defines the target object
  106976. * @param doNotCopyList defines a list of properties to avoid
  106977. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  106978. */
  106979. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  106980. /**
  106981. * Gets a boolean indicating if the given object has no own property
  106982. * @param obj defines the object to test
  106983. * @returns true if object has no own property
  106984. */
  106985. static IsEmpty(obj: any): boolean;
  106986. /**
  106987. * Function used to register events at window level
  106988. * @param windowElement defines the Window object to use
  106989. * @param events defines the events to register
  106990. */
  106991. static RegisterTopRootEvents(windowElement: Window, events: {
  106992. name: string;
  106993. handler: Nullable<(e: FocusEvent) => any>;
  106994. }[]): void;
  106995. /**
  106996. * Function used to unregister events from window level
  106997. * @param windowElement defines the Window object to use
  106998. * @param events defines the events to unregister
  106999. */
  107000. static UnregisterTopRootEvents(windowElement: Window, events: {
  107001. name: string;
  107002. handler: Nullable<(e: FocusEvent) => any>;
  107003. }[]): void;
  107004. /**
  107005. * @ignore
  107006. */
  107007. static _ScreenshotCanvas: HTMLCanvasElement;
  107008. /**
  107009. * Dumps the current bound framebuffer
  107010. * @param width defines the rendering width
  107011. * @param height defines the rendering height
  107012. * @param engine defines the hosting engine
  107013. * @param successCallback defines the callback triggered once the data are available
  107014. * @param mimeType defines the mime type of the result
  107015. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  107016. */
  107017. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107018. /**
  107019. * Converts the canvas data to blob.
  107020. * This acts as a polyfill for browsers not supporting the to blob function.
  107021. * @param canvas Defines the canvas to extract the data from
  107022. * @param successCallback Defines the callback triggered once the data are available
  107023. * @param mimeType Defines the mime type of the result
  107024. */
  107025. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  107026. /**
  107027. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  107028. * @param successCallback defines the callback triggered once the data are available
  107029. * @param mimeType defines the mime type of the result
  107030. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  107031. */
  107032. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107033. /**
  107034. * Downloads a blob in the browser
  107035. * @param blob defines the blob to download
  107036. * @param fileName defines the name of the downloaded file
  107037. */
  107038. static Download(blob: Blob, fileName: string): void;
  107039. /**
  107040. * Captures a screenshot of the current rendering
  107041. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107042. * @param engine defines the rendering engine
  107043. * @param camera defines the source camera
  107044. * @param size This parameter can be set to a single number or to an object with the
  107045. * following (optional) properties: precision, width, height. If a single number is passed,
  107046. * it will be used for both width and height. If an object is passed, the screenshot size
  107047. * will be derived from the parameters. The precision property is a multiplier allowing
  107048. * rendering at a higher or lower resolution
  107049. * @param successCallback defines the callback receives a single parameter which contains the
  107050. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107051. * src parameter of an <img> to display it
  107052. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107053. * Check your browser for supported MIME types
  107054. */
  107055. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  107056. /**
  107057. * Captures a screenshot of the current rendering
  107058. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107059. * @param engine defines the rendering engine
  107060. * @param camera defines the source camera
  107061. * @param size This parameter can be set to a single number or to an object with the
  107062. * following (optional) properties: precision, width, height. If a single number is passed,
  107063. * it will be used for both width and height. If an object is passed, the screenshot size
  107064. * will be derived from the parameters. The precision property is a multiplier allowing
  107065. * rendering at a higher or lower resolution
  107066. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107067. * Check your browser for supported MIME types
  107068. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107069. * to the src parameter of an <img> to display it
  107070. */
  107071. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  107072. /**
  107073. * Generates an image screenshot from the specified camera.
  107074. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107075. * @param engine The engine to use for rendering
  107076. * @param camera The camera to use for rendering
  107077. * @param size This parameter can be set to a single number or to an object with the
  107078. * following (optional) properties: precision, width, height. If a single number is passed,
  107079. * it will be used for both width and height. If an object is passed, the screenshot size
  107080. * will be derived from the parameters. The precision property is a multiplier allowing
  107081. * rendering at a higher or lower resolution
  107082. * @param successCallback The callback receives a single parameter which contains the
  107083. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107084. * src parameter of an <img> to display it
  107085. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107086. * Check your browser for supported MIME types
  107087. * @param samples Texture samples (default: 1)
  107088. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107089. * @param fileName A name for for the downloaded file.
  107090. */
  107091. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  107092. /**
  107093. * Generates an image screenshot from the specified camera.
  107094. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107095. * @param engine The engine to use for rendering
  107096. * @param camera The camera to use for rendering
  107097. * @param size This parameter can be set to a single number or to an object with the
  107098. * following (optional) properties: precision, width, height. If a single number is passed,
  107099. * it will be used for both width and height. If an object is passed, the screenshot size
  107100. * will be derived from the parameters. The precision property is a multiplier allowing
  107101. * rendering at a higher or lower resolution
  107102. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107103. * Check your browser for supported MIME types
  107104. * @param samples Texture samples (default: 1)
  107105. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107106. * @param fileName A name for for the downloaded file.
  107107. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107108. * to the src parameter of an <img> to display it
  107109. */
  107110. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  107111. /**
  107112. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  107113. * Be aware Math.random() could cause collisions, but:
  107114. * "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"
  107115. * @returns a pseudo random id
  107116. */
  107117. static RandomId(): string;
  107118. /**
  107119. * Test if the given uri is a base64 string
  107120. * @param uri The uri to test
  107121. * @return True if the uri is a base64 string or false otherwise
  107122. */
  107123. static IsBase64(uri: string): boolean;
  107124. /**
  107125. * Decode the given base64 uri.
  107126. * @param uri The uri to decode
  107127. * @return The decoded base64 data.
  107128. */
  107129. static DecodeBase64(uri: string): ArrayBuffer;
  107130. /**
  107131. * Gets the absolute url.
  107132. * @param url the input url
  107133. * @return the absolute url
  107134. */
  107135. static GetAbsoluteUrl(url: string): string;
  107136. /**
  107137. * No log
  107138. */
  107139. static readonly NoneLogLevel: number;
  107140. /**
  107141. * Only message logs
  107142. */
  107143. static readonly MessageLogLevel: number;
  107144. /**
  107145. * Only warning logs
  107146. */
  107147. static readonly WarningLogLevel: number;
  107148. /**
  107149. * Only error logs
  107150. */
  107151. static readonly ErrorLogLevel: number;
  107152. /**
  107153. * All logs
  107154. */
  107155. static readonly AllLogLevel: number;
  107156. /**
  107157. * Gets a value indicating the number of loading errors
  107158. * @ignorenaming
  107159. */
  107160. static get errorsCount(): number;
  107161. /**
  107162. * Callback called when a new log is added
  107163. */
  107164. static OnNewCacheEntry: (entry: string) => void;
  107165. /**
  107166. * Log a message to the console
  107167. * @param message defines the message to log
  107168. */
  107169. static Log(message: string): void;
  107170. /**
  107171. * Write a warning message to the console
  107172. * @param message defines the message to log
  107173. */
  107174. static Warn(message: string): void;
  107175. /**
  107176. * Write an error message to the console
  107177. * @param message defines the message to log
  107178. */
  107179. static Error(message: string): void;
  107180. /**
  107181. * Gets current log cache (list of logs)
  107182. */
  107183. static get LogCache(): string;
  107184. /**
  107185. * Clears the log cache
  107186. */
  107187. static ClearLogCache(): void;
  107188. /**
  107189. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  107190. */
  107191. static set LogLevels(level: number);
  107192. /**
  107193. * Checks if the window object exists
  107194. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  107195. */
  107196. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  107197. /**
  107198. * No performance log
  107199. */
  107200. static readonly PerformanceNoneLogLevel: number;
  107201. /**
  107202. * Use user marks to log performance
  107203. */
  107204. static readonly PerformanceUserMarkLogLevel: number;
  107205. /**
  107206. * Log performance to the console
  107207. */
  107208. static readonly PerformanceConsoleLogLevel: number;
  107209. private static _performance;
  107210. /**
  107211. * Sets the current performance log level
  107212. */
  107213. static set PerformanceLogLevel(level: number);
  107214. private static _StartPerformanceCounterDisabled;
  107215. private static _EndPerformanceCounterDisabled;
  107216. private static _StartUserMark;
  107217. private static _EndUserMark;
  107218. private static _StartPerformanceConsole;
  107219. private static _EndPerformanceConsole;
  107220. /**
  107221. * Starts a performance counter
  107222. */
  107223. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107224. /**
  107225. * Ends a specific performance coutner
  107226. */
  107227. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107228. /**
  107229. * Gets either window.performance.now() if supported or Date.now() else
  107230. */
  107231. static get Now(): number;
  107232. /**
  107233. * This method will return the name of the class used to create the instance of the given object.
  107234. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  107235. * @param object the object to get the class name from
  107236. * @param isType defines if the object is actually a type
  107237. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  107238. */
  107239. static GetClassName(object: any, isType?: boolean): string;
  107240. /**
  107241. * Gets the first element of an array satisfying a given predicate
  107242. * @param array defines the array to browse
  107243. * @param predicate defines the predicate to use
  107244. * @returns null if not found or the element
  107245. */
  107246. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  107247. /**
  107248. * This method will return the name of the full name of the class, including its owning module (if any).
  107249. * 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).
  107250. * @param object the object to get the class name from
  107251. * @param isType defines if the object is actually a type
  107252. * @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.
  107253. * @ignorenaming
  107254. */
  107255. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  107256. /**
  107257. * Returns a promise that resolves after the given amount of time.
  107258. * @param delay Number of milliseconds to delay
  107259. * @returns Promise that resolves after the given amount of time
  107260. */
  107261. static DelayAsync(delay: number): Promise<void>;
  107262. /**
  107263. * Utility function to detect if the current user agent is Safari
  107264. * @returns whether or not the current user agent is safari
  107265. */
  107266. static IsSafari(): boolean;
  107267. }
  107268. /**
  107269. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  107270. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  107271. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  107272. * @param name The name of the class, case should be preserved
  107273. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  107274. */
  107275. export function className(name: string, module?: string): (target: Object) => void;
  107276. /**
  107277. * An implementation of a loop for asynchronous functions.
  107278. */
  107279. export class AsyncLoop {
  107280. /**
  107281. * Defines the number of iterations for the loop
  107282. */
  107283. iterations: number;
  107284. /**
  107285. * Defines the current index of the loop.
  107286. */
  107287. index: number;
  107288. private _done;
  107289. private _fn;
  107290. private _successCallback;
  107291. /**
  107292. * Constructor.
  107293. * @param iterations the number of iterations.
  107294. * @param func the function to run each iteration
  107295. * @param successCallback the callback that will be called upon succesful execution
  107296. * @param offset starting offset.
  107297. */
  107298. constructor(
  107299. /**
  107300. * Defines the number of iterations for the loop
  107301. */
  107302. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  107303. /**
  107304. * Execute the next iteration. Must be called after the last iteration was finished.
  107305. */
  107306. executeNext(): void;
  107307. /**
  107308. * Break the loop and run the success callback.
  107309. */
  107310. breakLoop(): void;
  107311. /**
  107312. * Create and run an async loop.
  107313. * @param iterations the number of iterations.
  107314. * @param fn the function to run each iteration
  107315. * @param successCallback the callback that will be called upon succesful execution
  107316. * @param offset starting offset.
  107317. * @returns the created async loop object
  107318. */
  107319. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  107320. /**
  107321. * A for-loop that will run a given number of iterations synchronous and the rest async.
  107322. * @param iterations total number of iterations
  107323. * @param syncedIterations number of synchronous iterations in each async iteration.
  107324. * @param fn the function to call each iteration.
  107325. * @param callback a success call back that will be called when iterating stops.
  107326. * @param breakFunction a break condition (optional)
  107327. * @param timeout timeout settings for the setTimeout function. default - 0.
  107328. * @returns the created async loop object
  107329. */
  107330. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  107331. }
  107332. }
  107333. declare module BABYLON {
  107334. /**
  107335. * This class implement a typical dictionary using a string as key and the generic type T as value.
  107336. * The underlying implementation relies on an associative array to ensure the best performances.
  107337. * The value can be anything including 'null' but except 'undefined'
  107338. */
  107339. export class StringDictionary<T> {
  107340. /**
  107341. * This will clear this dictionary and copy the content from the 'source' one.
  107342. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  107343. * @param source the dictionary to take the content from and copy to this dictionary
  107344. */
  107345. copyFrom(source: StringDictionary<T>): void;
  107346. /**
  107347. * Get a value based from its key
  107348. * @param key the given key to get the matching value from
  107349. * @return the value if found, otherwise undefined is returned
  107350. */
  107351. get(key: string): T | undefined;
  107352. /**
  107353. * Get a value from its key or add it if it doesn't exist.
  107354. * This method will ensure you that a given key/data will be present in the dictionary.
  107355. * @param key the given key to get the matching value from
  107356. * @param factory the factory that will create the value if the key is not present in the dictionary.
  107357. * The factory will only be invoked if there's no data for the given key.
  107358. * @return the value corresponding to the key.
  107359. */
  107360. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  107361. /**
  107362. * Get a value from its key if present in the dictionary otherwise add it
  107363. * @param key the key to get the value from
  107364. * @param val if there's no such key/value pair in the dictionary add it with this value
  107365. * @return the value corresponding to the key
  107366. */
  107367. getOrAdd(key: string, val: T): T;
  107368. /**
  107369. * Check if there's a given key in the dictionary
  107370. * @param key the key to check for
  107371. * @return true if the key is present, false otherwise
  107372. */
  107373. contains(key: string): boolean;
  107374. /**
  107375. * Add a new key and its corresponding value
  107376. * @param key the key to add
  107377. * @param value the value corresponding to the key
  107378. * @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
  107379. */
  107380. add(key: string, value: T): boolean;
  107381. /**
  107382. * Update a specific value associated to a key
  107383. * @param key defines the key to use
  107384. * @param value defines the value to store
  107385. * @returns true if the value was updated (or false if the key was not found)
  107386. */
  107387. set(key: string, value: T): boolean;
  107388. /**
  107389. * Get the element of the given key and remove it from the dictionary
  107390. * @param key defines the key to search
  107391. * @returns the value associated with the key or null if not found
  107392. */
  107393. getAndRemove(key: string): Nullable<T>;
  107394. /**
  107395. * Remove a key/value from the dictionary.
  107396. * @param key the key to remove
  107397. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  107398. */
  107399. remove(key: string): boolean;
  107400. /**
  107401. * Clear the whole content of the dictionary
  107402. */
  107403. clear(): void;
  107404. /**
  107405. * Gets the current count
  107406. */
  107407. get count(): number;
  107408. /**
  107409. * Execute a callback on each key/val of the dictionary.
  107410. * Note that you can remove any element in this dictionary in the callback implementation
  107411. * @param callback the callback to execute on a given key/value pair
  107412. */
  107413. forEach(callback: (key: string, val: T) => void): void;
  107414. /**
  107415. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  107416. * If the callback returns null or undefined the method will iterate to the next key/value pair
  107417. * Note that you can remove any element in this dictionary in the callback implementation
  107418. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  107419. * @returns the first item
  107420. */
  107421. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  107422. private _count;
  107423. private _data;
  107424. }
  107425. }
  107426. declare module BABYLON {
  107427. /** @hidden */
  107428. export interface ICollisionCoordinator {
  107429. createCollider(): Collider;
  107430. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  107431. init(scene: Scene): void;
  107432. }
  107433. /** @hidden */
  107434. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  107435. private _scene;
  107436. private _scaledPosition;
  107437. private _scaledVelocity;
  107438. private _finalPosition;
  107439. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  107440. createCollider(): Collider;
  107441. init(scene: Scene): void;
  107442. private _collideWithWorld;
  107443. }
  107444. }
  107445. declare module BABYLON {
  107446. /**
  107447. * Class used to manage all inputs for the scene.
  107448. */
  107449. export class InputManager {
  107450. /** The distance in pixel that you have to move to prevent some events */
  107451. static DragMovementThreshold: number;
  107452. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  107453. static LongPressDelay: number;
  107454. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  107455. static DoubleClickDelay: number;
  107456. /** If you need to check double click without raising a single click at first click, enable this flag */
  107457. static ExclusiveDoubleClickMode: boolean;
  107458. private _wheelEventName;
  107459. private _onPointerMove;
  107460. private _onPointerDown;
  107461. private _onPointerUp;
  107462. private _initClickEvent;
  107463. private _initActionManager;
  107464. private _delayedSimpleClick;
  107465. private _delayedSimpleClickTimeout;
  107466. private _previousDelayedSimpleClickTimeout;
  107467. private _meshPickProceed;
  107468. private _previousButtonPressed;
  107469. private _currentPickResult;
  107470. private _previousPickResult;
  107471. private _totalPointersPressed;
  107472. private _doubleClickOccured;
  107473. private _pointerOverMesh;
  107474. private _pickedDownMesh;
  107475. private _pickedUpMesh;
  107476. private _pointerX;
  107477. private _pointerY;
  107478. private _unTranslatedPointerX;
  107479. private _unTranslatedPointerY;
  107480. private _startingPointerPosition;
  107481. private _previousStartingPointerPosition;
  107482. private _startingPointerTime;
  107483. private _previousStartingPointerTime;
  107484. private _pointerCaptures;
  107485. private _onKeyDown;
  107486. private _onKeyUp;
  107487. private _onCanvasFocusObserver;
  107488. private _onCanvasBlurObserver;
  107489. private _scene;
  107490. /**
  107491. * Creates a new InputManager
  107492. * @param scene defines the hosting scene
  107493. */
  107494. constructor(scene: Scene);
  107495. /**
  107496. * Gets the mesh that is currently under the pointer
  107497. */
  107498. get meshUnderPointer(): Nullable<AbstractMesh>;
  107499. /**
  107500. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  107501. */
  107502. get unTranslatedPointer(): Vector2;
  107503. /**
  107504. * Gets or sets the current on-screen X position of the pointer
  107505. */
  107506. get pointerX(): number;
  107507. set pointerX(value: number);
  107508. /**
  107509. * Gets or sets the current on-screen Y position of the pointer
  107510. */
  107511. get pointerY(): number;
  107512. set pointerY(value: number);
  107513. private _updatePointerPosition;
  107514. private _processPointerMove;
  107515. private _setRayOnPointerInfo;
  107516. private _checkPrePointerObservable;
  107517. /**
  107518. * Use this method to simulate a pointer move on a mesh
  107519. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107520. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107521. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107522. */
  107523. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  107524. /**
  107525. * Use this method to simulate a pointer down on a mesh
  107526. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107527. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107528. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107529. */
  107530. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  107531. private _processPointerDown;
  107532. /** @hidden */
  107533. _isPointerSwiping(): boolean;
  107534. /**
  107535. * Use this method to simulate a pointer up on a mesh
  107536. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107537. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107538. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107539. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  107540. */
  107541. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  107542. private _processPointerUp;
  107543. /**
  107544. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  107545. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  107546. * @returns true if the pointer was captured
  107547. */
  107548. isPointerCaptured(pointerId?: number): boolean;
  107549. /**
  107550. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  107551. * @param attachUp defines if you want to attach events to pointerup
  107552. * @param attachDown defines if you want to attach events to pointerdown
  107553. * @param attachMove defines if you want to attach events to pointermove
  107554. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  107555. */
  107556. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  107557. /**
  107558. * Detaches all event handlers
  107559. */
  107560. detachControl(): void;
  107561. /**
  107562. * Force the value of meshUnderPointer
  107563. * @param mesh defines the mesh to use
  107564. */
  107565. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  107566. /**
  107567. * Gets the mesh under the pointer
  107568. * @returns a Mesh or null if no mesh is under the pointer
  107569. */
  107570. getPointerOverMesh(): Nullable<AbstractMesh>;
  107571. }
  107572. }
  107573. declare module BABYLON {
  107574. /**
  107575. * Helper class used to generate session unique ID
  107576. */
  107577. export class UniqueIdGenerator {
  107578. private static _UniqueIdCounter;
  107579. /**
  107580. * Gets an unique (relatively to the current scene) Id
  107581. */
  107582. static get UniqueId(): number;
  107583. }
  107584. }
  107585. declare module BABYLON {
  107586. /**
  107587. * This class defines the direct association between an animation and a target
  107588. */
  107589. export class TargetedAnimation {
  107590. /**
  107591. * Animation to perform
  107592. */
  107593. animation: Animation;
  107594. /**
  107595. * Target to animate
  107596. */
  107597. target: any;
  107598. /**
  107599. * Serialize the object
  107600. * @returns the JSON object representing the current entity
  107601. */
  107602. serialize(): any;
  107603. }
  107604. /**
  107605. * Use this class to create coordinated animations on multiple targets
  107606. */
  107607. export class AnimationGroup implements IDisposable {
  107608. /** The name of the animation group */
  107609. name: string;
  107610. private _scene;
  107611. private _targetedAnimations;
  107612. private _animatables;
  107613. private _from;
  107614. private _to;
  107615. private _isStarted;
  107616. private _isPaused;
  107617. private _speedRatio;
  107618. private _loopAnimation;
  107619. /**
  107620. * Gets or sets the unique id of the node
  107621. */
  107622. uniqueId: number;
  107623. /**
  107624. * This observable will notify when one animation have ended
  107625. */
  107626. onAnimationEndObservable: Observable<TargetedAnimation>;
  107627. /**
  107628. * Observer raised when one animation loops
  107629. */
  107630. onAnimationLoopObservable: Observable<TargetedAnimation>;
  107631. /**
  107632. * Observer raised when all animations have looped
  107633. */
  107634. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  107635. /**
  107636. * This observable will notify when all animations have ended.
  107637. */
  107638. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  107639. /**
  107640. * This observable will notify when all animations have paused.
  107641. */
  107642. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  107643. /**
  107644. * This observable will notify when all animations are playing.
  107645. */
  107646. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  107647. /**
  107648. * Gets the first frame
  107649. */
  107650. get from(): number;
  107651. /**
  107652. * Gets the last frame
  107653. */
  107654. get to(): number;
  107655. /**
  107656. * Define if the animations are started
  107657. */
  107658. get isStarted(): boolean;
  107659. /**
  107660. * Gets a value indicating that the current group is playing
  107661. */
  107662. get isPlaying(): boolean;
  107663. /**
  107664. * Gets or sets the speed ratio to use for all animations
  107665. */
  107666. get speedRatio(): number;
  107667. /**
  107668. * Gets or sets the speed ratio to use for all animations
  107669. */
  107670. set speedRatio(value: number);
  107671. /**
  107672. * Gets or sets if all animations should loop or not
  107673. */
  107674. get loopAnimation(): boolean;
  107675. set loopAnimation(value: boolean);
  107676. /**
  107677. * Gets the targeted animations for this animation group
  107678. */
  107679. get targetedAnimations(): Array<TargetedAnimation>;
  107680. /**
  107681. * returning the list of animatables controlled by this animation group.
  107682. */
  107683. get animatables(): Array<Animatable>;
  107684. /**
  107685. * Instantiates a new Animation Group.
  107686. * This helps managing several animations at once.
  107687. * @see http://doc.babylonjs.com/how_to/group
  107688. * @param name Defines the name of the group
  107689. * @param scene Defines the scene the group belongs to
  107690. */
  107691. constructor(
  107692. /** The name of the animation group */
  107693. name: string, scene?: Nullable<Scene>);
  107694. /**
  107695. * Add an animation (with its target) in the group
  107696. * @param animation defines the animation we want to add
  107697. * @param target defines the target of the animation
  107698. * @returns the TargetedAnimation object
  107699. */
  107700. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  107701. /**
  107702. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  107703. * It can add constant keys at begin or end
  107704. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  107705. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  107706. * @returns the animation group
  107707. */
  107708. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  107709. private _animationLoopCount;
  107710. private _animationLoopFlags;
  107711. private _processLoop;
  107712. /**
  107713. * Start all animations on given targets
  107714. * @param loop defines if animations must loop
  107715. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  107716. * @param from defines the from key (optional)
  107717. * @param to defines the to key (optional)
  107718. * @returns the current animation group
  107719. */
  107720. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  107721. /**
  107722. * Pause all animations
  107723. * @returns the animation group
  107724. */
  107725. pause(): AnimationGroup;
  107726. /**
  107727. * Play all animations to initial state
  107728. * This function will start() the animations if they were not started or will restart() them if they were paused
  107729. * @param loop defines if animations must loop
  107730. * @returns the animation group
  107731. */
  107732. play(loop?: boolean): AnimationGroup;
  107733. /**
  107734. * Reset all animations to initial state
  107735. * @returns the animation group
  107736. */
  107737. reset(): AnimationGroup;
  107738. /**
  107739. * Restart animations from key 0
  107740. * @returns the animation group
  107741. */
  107742. restart(): AnimationGroup;
  107743. /**
  107744. * Stop all animations
  107745. * @returns the animation group
  107746. */
  107747. stop(): AnimationGroup;
  107748. /**
  107749. * Set animation weight for all animatables
  107750. * @param weight defines the weight to use
  107751. * @return the animationGroup
  107752. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  107753. */
  107754. setWeightForAllAnimatables(weight: number): AnimationGroup;
  107755. /**
  107756. * Synchronize and normalize all animatables with a source animatable
  107757. * @param root defines the root animatable to synchronize with
  107758. * @return the animationGroup
  107759. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  107760. */
  107761. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  107762. /**
  107763. * Goes to a specific frame in this animation group
  107764. * @param frame the frame number to go to
  107765. * @return the animationGroup
  107766. */
  107767. goToFrame(frame: number): AnimationGroup;
  107768. /**
  107769. * Dispose all associated resources
  107770. */
  107771. dispose(): void;
  107772. private _checkAnimationGroupEnded;
  107773. /**
  107774. * Clone the current animation group and returns a copy
  107775. * @param newName defines the name of the new group
  107776. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  107777. * @returns the new aniamtion group
  107778. */
  107779. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  107780. /**
  107781. * Serializes the animationGroup to an object
  107782. * @returns Serialized object
  107783. */
  107784. serialize(): any;
  107785. /**
  107786. * Returns a new AnimationGroup object parsed from the source provided.
  107787. * @param parsedAnimationGroup defines the source
  107788. * @param scene defines the scene that will receive the animationGroup
  107789. * @returns a new AnimationGroup
  107790. */
  107791. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  107792. /**
  107793. * Returns the string "AnimationGroup"
  107794. * @returns "AnimationGroup"
  107795. */
  107796. getClassName(): string;
  107797. /**
  107798. * Creates a detailled string about the object
  107799. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  107800. * @returns a string representing the object
  107801. */
  107802. toString(fullDetails?: boolean): string;
  107803. }
  107804. }
  107805. declare module BABYLON {
  107806. /**
  107807. * Define an interface for all classes that will hold resources
  107808. */
  107809. export interface IDisposable {
  107810. /**
  107811. * Releases all held resources
  107812. */
  107813. dispose(): void;
  107814. }
  107815. /** Interface defining initialization parameters for Scene class */
  107816. export interface SceneOptions {
  107817. /**
  107818. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  107819. * It will improve performance when the number of geometries becomes important.
  107820. */
  107821. useGeometryUniqueIdsMap?: boolean;
  107822. /**
  107823. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  107824. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  107825. */
  107826. useMaterialMeshMap?: boolean;
  107827. /**
  107828. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  107829. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  107830. */
  107831. useClonedMeshMap?: boolean;
  107832. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  107833. virtual?: boolean;
  107834. }
  107835. /**
  107836. * Represents a scene to be rendered by the engine.
  107837. * @see http://doc.babylonjs.com/features/scene
  107838. */
  107839. export class Scene extends AbstractScene implements IAnimatable {
  107840. /** The fog is deactivated */
  107841. static readonly FOGMODE_NONE: number;
  107842. /** The fog density is following an exponential function */
  107843. static readonly FOGMODE_EXP: number;
  107844. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  107845. static readonly FOGMODE_EXP2: number;
  107846. /** The fog density is following a linear function. */
  107847. static readonly FOGMODE_LINEAR: number;
  107848. /**
  107849. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  107850. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107851. */
  107852. static MinDeltaTime: number;
  107853. /**
  107854. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  107855. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107856. */
  107857. static MaxDeltaTime: number;
  107858. /**
  107859. * Factory used to create the default material.
  107860. * @param name The name of the material to create
  107861. * @param scene The scene to create the material for
  107862. * @returns The default material
  107863. */
  107864. static DefaultMaterialFactory(scene: Scene): Material;
  107865. /**
  107866. * Factory used to create the a collision coordinator.
  107867. * @returns The collision coordinator
  107868. */
  107869. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  107870. /** @hidden */
  107871. _inputManager: InputManager;
  107872. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  107873. cameraToUseForPointers: Nullable<Camera>;
  107874. /** @hidden */
  107875. readonly _isScene: boolean;
  107876. /**
  107877. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  107878. */
  107879. autoClear: boolean;
  107880. /**
  107881. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  107882. */
  107883. autoClearDepthAndStencil: boolean;
  107884. /**
  107885. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  107886. */
  107887. clearColor: Color4;
  107888. /**
  107889. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  107890. */
  107891. ambientColor: Color3;
  107892. /**
  107893. * This is use to store the default BRDF lookup for PBR materials in your scene.
  107894. * It should only be one of the following (if not the default embedded one):
  107895. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  107896. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  107897. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  107898. * The material properties need to be setup according to the type of texture in use.
  107899. */
  107900. environmentBRDFTexture: BaseTexture;
  107901. /** @hidden */
  107902. protected _environmentTexture: Nullable<BaseTexture>;
  107903. /**
  107904. * Texture used in all pbr material as the reflection texture.
  107905. * As in the majority of the scene they are the same (exception for multi room and so on),
  107906. * this is easier to reference from here than from all the materials.
  107907. */
  107908. get environmentTexture(): Nullable<BaseTexture>;
  107909. /**
  107910. * Texture used in all pbr material as the reflection texture.
  107911. * As in the majority of the scene they are the same (exception for multi room and so on),
  107912. * this is easier to set here than in all the materials.
  107913. */
  107914. set environmentTexture(value: Nullable<BaseTexture>);
  107915. /** @hidden */
  107916. protected _environmentIntensity: number;
  107917. /**
  107918. * Intensity of the environment in all pbr material.
  107919. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  107920. * As in the majority of the scene they are the same (exception for multi room and so on),
  107921. * this is easier to reference from here than from all the materials.
  107922. */
  107923. get environmentIntensity(): number;
  107924. /**
  107925. * Intensity of the environment in all pbr material.
  107926. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  107927. * As in the majority of the scene they are the same (exception for multi room and so on),
  107928. * this is easier to set here than in all the materials.
  107929. */
  107930. set environmentIntensity(value: number);
  107931. /** @hidden */
  107932. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107933. /**
  107934. * Default image processing configuration used either in the rendering
  107935. * Forward main pass or through the imageProcessingPostProcess if present.
  107936. * As in the majority of the scene they are the same (exception for multi camera),
  107937. * this is easier to reference from here than from all the materials and post process.
  107938. *
  107939. * No setter as we it is a shared configuration, you can set the values instead.
  107940. */
  107941. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  107942. private _forceWireframe;
  107943. /**
  107944. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  107945. */
  107946. set forceWireframe(value: boolean);
  107947. get forceWireframe(): boolean;
  107948. private _skipFrustumClipping;
  107949. /**
  107950. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  107951. */
  107952. set skipFrustumClipping(value: boolean);
  107953. get skipFrustumClipping(): boolean;
  107954. private _forcePointsCloud;
  107955. /**
  107956. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  107957. */
  107958. set forcePointsCloud(value: boolean);
  107959. get forcePointsCloud(): boolean;
  107960. /**
  107961. * Gets or sets the active clipplane 1
  107962. */
  107963. clipPlane: Nullable<Plane>;
  107964. /**
  107965. * Gets or sets the active clipplane 2
  107966. */
  107967. clipPlane2: Nullable<Plane>;
  107968. /**
  107969. * Gets or sets the active clipplane 3
  107970. */
  107971. clipPlane3: Nullable<Plane>;
  107972. /**
  107973. * Gets or sets the active clipplane 4
  107974. */
  107975. clipPlane4: Nullable<Plane>;
  107976. /**
  107977. * Gets or sets the active clipplane 5
  107978. */
  107979. clipPlane5: Nullable<Plane>;
  107980. /**
  107981. * Gets or sets the active clipplane 6
  107982. */
  107983. clipPlane6: Nullable<Plane>;
  107984. /**
  107985. * Gets or sets a boolean indicating if animations are enabled
  107986. */
  107987. animationsEnabled: boolean;
  107988. private _animationPropertiesOverride;
  107989. /**
  107990. * Gets or sets the animation properties override
  107991. */
  107992. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  107993. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  107994. /**
  107995. * Gets or sets a boolean indicating if a constant deltatime has to be used
  107996. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  107997. */
  107998. useConstantAnimationDeltaTime: boolean;
  107999. /**
  108000. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  108001. * Please note that it requires to run a ray cast through the scene on every frame
  108002. */
  108003. constantlyUpdateMeshUnderPointer: boolean;
  108004. /**
  108005. * Defines the HTML cursor to use when hovering over interactive elements
  108006. */
  108007. hoverCursor: string;
  108008. /**
  108009. * Defines the HTML default cursor to use (empty by default)
  108010. */
  108011. defaultCursor: string;
  108012. /**
  108013. * Defines whether cursors are handled by the scene.
  108014. */
  108015. doNotHandleCursors: boolean;
  108016. /**
  108017. * This is used to call preventDefault() on pointer down
  108018. * in order to block unwanted artifacts like system double clicks
  108019. */
  108020. preventDefaultOnPointerDown: boolean;
  108021. /**
  108022. * This is used to call preventDefault() on pointer up
  108023. * in order to block unwanted artifacts like system double clicks
  108024. */
  108025. preventDefaultOnPointerUp: boolean;
  108026. /**
  108027. * Gets or sets user defined metadata
  108028. */
  108029. metadata: any;
  108030. /**
  108031. * For internal use only. Please do not use.
  108032. */
  108033. reservedDataStore: any;
  108034. /**
  108035. * Gets the name of the plugin used to load this scene (null by default)
  108036. */
  108037. loadingPluginName: string;
  108038. /**
  108039. * Use this array to add regular expressions used to disable offline support for specific urls
  108040. */
  108041. disableOfflineSupportExceptionRules: RegExp[];
  108042. /**
  108043. * An event triggered when the scene is disposed.
  108044. */
  108045. onDisposeObservable: Observable<Scene>;
  108046. private _onDisposeObserver;
  108047. /** Sets a function to be executed when this scene is disposed. */
  108048. set onDispose(callback: () => void);
  108049. /**
  108050. * An event triggered before rendering the scene (right after animations and physics)
  108051. */
  108052. onBeforeRenderObservable: Observable<Scene>;
  108053. private _onBeforeRenderObserver;
  108054. /** Sets a function to be executed before rendering this scene */
  108055. set beforeRender(callback: Nullable<() => void>);
  108056. /**
  108057. * An event triggered after rendering the scene
  108058. */
  108059. onAfterRenderObservable: Observable<Scene>;
  108060. /**
  108061. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  108062. */
  108063. onAfterRenderCameraObservable: Observable<Camera>;
  108064. private _onAfterRenderObserver;
  108065. /** Sets a function to be executed after rendering this scene */
  108066. set afterRender(callback: Nullable<() => void>);
  108067. /**
  108068. * An event triggered before animating the scene
  108069. */
  108070. onBeforeAnimationsObservable: Observable<Scene>;
  108071. /**
  108072. * An event triggered after animations processing
  108073. */
  108074. onAfterAnimationsObservable: Observable<Scene>;
  108075. /**
  108076. * An event triggered before draw calls are ready to be sent
  108077. */
  108078. onBeforeDrawPhaseObservable: Observable<Scene>;
  108079. /**
  108080. * An event triggered after draw calls have been sent
  108081. */
  108082. onAfterDrawPhaseObservable: Observable<Scene>;
  108083. /**
  108084. * An event triggered when the scene is ready
  108085. */
  108086. onReadyObservable: Observable<Scene>;
  108087. /**
  108088. * An event triggered before rendering a camera
  108089. */
  108090. onBeforeCameraRenderObservable: Observable<Camera>;
  108091. private _onBeforeCameraRenderObserver;
  108092. /** Sets a function to be executed before rendering a camera*/
  108093. set beforeCameraRender(callback: () => void);
  108094. /**
  108095. * An event triggered after rendering a camera
  108096. */
  108097. onAfterCameraRenderObservable: Observable<Camera>;
  108098. private _onAfterCameraRenderObserver;
  108099. /** Sets a function to be executed after rendering a camera*/
  108100. set afterCameraRender(callback: () => void);
  108101. /**
  108102. * An event triggered when active meshes evaluation is about to start
  108103. */
  108104. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  108105. /**
  108106. * An event triggered when active meshes evaluation is done
  108107. */
  108108. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  108109. /**
  108110. * An event triggered when particles rendering is about to start
  108111. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108112. */
  108113. onBeforeParticlesRenderingObservable: Observable<Scene>;
  108114. /**
  108115. * An event triggered when particles rendering is done
  108116. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108117. */
  108118. onAfterParticlesRenderingObservable: Observable<Scene>;
  108119. /**
  108120. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  108121. */
  108122. onDataLoadedObservable: Observable<Scene>;
  108123. /**
  108124. * An event triggered when a camera is created
  108125. */
  108126. onNewCameraAddedObservable: Observable<Camera>;
  108127. /**
  108128. * An event triggered when a camera is removed
  108129. */
  108130. onCameraRemovedObservable: Observable<Camera>;
  108131. /**
  108132. * An event triggered when a light is created
  108133. */
  108134. onNewLightAddedObservable: Observable<Light>;
  108135. /**
  108136. * An event triggered when a light is removed
  108137. */
  108138. onLightRemovedObservable: Observable<Light>;
  108139. /**
  108140. * An event triggered when a geometry is created
  108141. */
  108142. onNewGeometryAddedObservable: Observable<Geometry>;
  108143. /**
  108144. * An event triggered when a geometry is removed
  108145. */
  108146. onGeometryRemovedObservable: Observable<Geometry>;
  108147. /**
  108148. * An event triggered when a transform node is created
  108149. */
  108150. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  108151. /**
  108152. * An event triggered when a transform node is removed
  108153. */
  108154. onTransformNodeRemovedObservable: Observable<TransformNode>;
  108155. /**
  108156. * An event triggered when a mesh is created
  108157. */
  108158. onNewMeshAddedObservable: Observable<AbstractMesh>;
  108159. /**
  108160. * An event triggered when a mesh is removed
  108161. */
  108162. onMeshRemovedObservable: Observable<AbstractMesh>;
  108163. /**
  108164. * An event triggered when a skeleton is created
  108165. */
  108166. onNewSkeletonAddedObservable: Observable<Skeleton>;
  108167. /**
  108168. * An event triggered when a skeleton is removed
  108169. */
  108170. onSkeletonRemovedObservable: Observable<Skeleton>;
  108171. /**
  108172. * An event triggered when a material is created
  108173. */
  108174. onNewMaterialAddedObservable: Observable<Material>;
  108175. /**
  108176. * An event triggered when a material is removed
  108177. */
  108178. onMaterialRemovedObservable: Observable<Material>;
  108179. /**
  108180. * An event triggered when a texture is created
  108181. */
  108182. onNewTextureAddedObservable: Observable<BaseTexture>;
  108183. /**
  108184. * An event triggered when a texture is removed
  108185. */
  108186. onTextureRemovedObservable: Observable<BaseTexture>;
  108187. /**
  108188. * An event triggered when render targets are about to be rendered
  108189. * Can happen multiple times per frame.
  108190. */
  108191. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  108192. /**
  108193. * An event triggered when render targets were rendered.
  108194. * Can happen multiple times per frame.
  108195. */
  108196. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  108197. /**
  108198. * An event triggered before calculating deterministic simulation step
  108199. */
  108200. onBeforeStepObservable: Observable<Scene>;
  108201. /**
  108202. * An event triggered after calculating deterministic simulation step
  108203. */
  108204. onAfterStepObservable: Observable<Scene>;
  108205. /**
  108206. * An event triggered when the activeCamera property is updated
  108207. */
  108208. onActiveCameraChanged: Observable<Scene>;
  108209. /**
  108210. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  108211. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108212. * 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)
  108213. */
  108214. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108215. /**
  108216. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  108217. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108218. * 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)
  108219. */
  108220. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108221. /**
  108222. * This Observable will when a mesh has been imported into the scene.
  108223. */
  108224. onMeshImportedObservable: Observable<AbstractMesh>;
  108225. /**
  108226. * This Observable will when an animation file has been imported into the scene.
  108227. */
  108228. onAnimationFileImportedObservable: Observable<Scene>;
  108229. /**
  108230. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  108231. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  108232. */
  108233. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  108234. /** @hidden */
  108235. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  108236. /**
  108237. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  108238. */
  108239. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  108240. /**
  108241. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  108242. */
  108243. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  108244. /**
  108245. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  108246. */
  108247. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  108248. /** Callback called when a pointer move is detected */
  108249. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108250. /** Callback called when a pointer down is detected */
  108251. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108252. /** Callback called when a pointer up is detected */
  108253. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  108254. /** Callback called when a pointer pick is detected */
  108255. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  108256. /**
  108257. * 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).
  108258. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  108259. */
  108260. onPrePointerObservable: Observable<PointerInfoPre>;
  108261. /**
  108262. * Observable event triggered each time an input event is received from the rendering canvas
  108263. */
  108264. onPointerObservable: Observable<PointerInfo>;
  108265. /**
  108266. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  108267. */
  108268. get unTranslatedPointer(): Vector2;
  108269. /**
  108270. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  108271. */
  108272. static get DragMovementThreshold(): number;
  108273. static set DragMovementThreshold(value: number);
  108274. /**
  108275. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  108276. */
  108277. static get LongPressDelay(): number;
  108278. static set LongPressDelay(value: number);
  108279. /**
  108280. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  108281. */
  108282. static get DoubleClickDelay(): number;
  108283. static set DoubleClickDelay(value: number);
  108284. /** If you need to check double click without raising a single click at first click, enable this flag */
  108285. static get ExclusiveDoubleClickMode(): boolean;
  108286. static set ExclusiveDoubleClickMode(value: boolean);
  108287. /** @hidden */
  108288. _mirroredCameraPosition: Nullable<Vector3>;
  108289. /**
  108290. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  108291. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  108292. */
  108293. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  108294. /**
  108295. * Observable event triggered each time an keyboard event is received from the hosting window
  108296. */
  108297. onKeyboardObservable: Observable<KeyboardInfo>;
  108298. private _useRightHandedSystem;
  108299. /**
  108300. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  108301. */
  108302. set useRightHandedSystem(value: boolean);
  108303. get useRightHandedSystem(): boolean;
  108304. private _timeAccumulator;
  108305. private _currentStepId;
  108306. private _currentInternalStep;
  108307. /**
  108308. * Sets the step Id used by deterministic lock step
  108309. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108310. * @param newStepId defines the step Id
  108311. */
  108312. setStepId(newStepId: number): void;
  108313. /**
  108314. * Gets the step Id used by deterministic lock step
  108315. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108316. * @returns the step Id
  108317. */
  108318. getStepId(): number;
  108319. /**
  108320. * Gets the internal step used by deterministic lock step
  108321. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108322. * @returns the internal step
  108323. */
  108324. getInternalStep(): number;
  108325. private _fogEnabled;
  108326. /**
  108327. * Gets or sets a boolean indicating if fog is enabled on this scene
  108328. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108329. * (Default is true)
  108330. */
  108331. set fogEnabled(value: boolean);
  108332. get fogEnabled(): boolean;
  108333. private _fogMode;
  108334. /**
  108335. * Gets or sets the fog mode to use
  108336. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108337. * | mode | value |
  108338. * | --- | --- |
  108339. * | FOGMODE_NONE | 0 |
  108340. * | FOGMODE_EXP | 1 |
  108341. * | FOGMODE_EXP2 | 2 |
  108342. * | FOGMODE_LINEAR | 3 |
  108343. */
  108344. set fogMode(value: number);
  108345. get fogMode(): number;
  108346. /**
  108347. * Gets or sets the fog color to use
  108348. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108349. * (Default is Color3(0.2, 0.2, 0.3))
  108350. */
  108351. fogColor: Color3;
  108352. /**
  108353. * Gets or sets the fog density to use
  108354. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108355. * (Default is 0.1)
  108356. */
  108357. fogDensity: number;
  108358. /**
  108359. * Gets or sets the fog start distance to use
  108360. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108361. * (Default is 0)
  108362. */
  108363. fogStart: number;
  108364. /**
  108365. * Gets or sets the fog end distance to use
  108366. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108367. * (Default is 1000)
  108368. */
  108369. fogEnd: number;
  108370. private _shadowsEnabled;
  108371. /**
  108372. * Gets or sets a boolean indicating if shadows are enabled on this scene
  108373. */
  108374. set shadowsEnabled(value: boolean);
  108375. get shadowsEnabled(): boolean;
  108376. private _lightsEnabled;
  108377. /**
  108378. * Gets or sets a boolean indicating if lights are enabled on this scene
  108379. */
  108380. set lightsEnabled(value: boolean);
  108381. get lightsEnabled(): boolean;
  108382. /** All of the active cameras added to this scene. */
  108383. activeCameras: Camera[];
  108384. /** @hidden */
  108385. _activeCamera: Nullable<Camera>;
  108386. /** Gets or sets the current active camera */
  108387. get activeCamera(): Nullable<Camera>;
  108388. set activeCamera(value: Nullable<Camera>);
  108389. private _defaultMaterial;
  108390. /** The default material used on meshes when no material is affected */
  108391. get defaultMaterial(): Material;
  108392. /** The default material used on meshes when no material is affected */
  108393. set defaultMaterial(value: Material);
  108394. private _texturesEnabled;
  108395. /**
  108396. * Gets or sets a boolean indicating if textures are enabled on this scene
  108397. */
  108398. set texturesEnabled(value: boolean);
  108399. get texturesEnabled(): boolean;
  108400. /**
  108401. * Gets or sets a boolean indicating if particles are enabled on this scene
  108402. */
  108403. particlesEnabled: boolean;
  108404. /**
  108405. * Gets or sets a boolean indicating if sprites are enabled on this scene
  108406. */
  108407. spritesEnabled: boolean;
  108408. private _skeletonsEnabled;
  108409. /**
  108410. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  108411. */
  108412. set skeletonsEnabled(value: boolean);
  108413. get skeletonsEnabled(): boolean;
  108414. /**
  108415. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  108416. */
  108417. lensFlaresEnabled: boolean;
  108418. /**
  108419. * Gets or sets a boolean indicating if collisions are enabled on this scene
  108420. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108421. */
  108422. collisionsEnabled: boolean;
  108423. private _collisionCoordinator;
  108424. /** @hidden */
  108425. get collisionCoordinator(): ICollisionCoordinator;
  108426. /**
  108427. * Defines the gravity applied to this scene (used only for collisions)
  108428. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108429. */
  108430. gravity: Vector3;
  108431. /**
  108432. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  108433. */
  108434. postProcessesEnabled: boolean;
  108435. /**
  108436. * The list of postprocesses added to the scene
  108437. */
  108438. postProcesses: PostProcess[];
  108439. /**
  108440. * Gets the current postprocess manager
  108441. */
  108442. postProcessManager: PostProcessManager;
  108443. /**
  108444. * Gets or sets a boolean indicating if render targets are enabled on this scene
  108445. */
  108446. renderTargetsEnabled: boolean;
  108447. /**
  108448. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  108449. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  108450. */
  108451. dumpNextRenderTargets: boolean;
  108452. /**
  108453. * The list of user defined render targets added to the scene
  108454. */
  108455. customRenderTargets: RenderTargetTexture[];
  108456. /**
  108457. * Defines if texture loading must be delayed
  108458. * If true, textures will only be loaded when they need to be rendered
  108459. */
  108460. useDelayedTextureLoading: boolean;
  108461. /**
  108462. * Gets the list of meshes imported to the scene through SceneLoader
  108463. */
  108464. importedMeshesFiles: String[];
  108465. /**
  108466. * Gets or sets a boolean indicating if probes are enabled on this scene
  108467. */
  108468. probesEnabled: boolean;
  108469. /**
  108470. * Gets or sets the current offline provider to use to store scene data
  108471. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  108472. */
  108473. offlineProvider: IOfflineProvider;
  108474. /**
  108475. * Gets or sets the action manager associated with the scene
  108476. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  108477. */
  108478. actionManager: AbstractActionManager;
  108479. private _meshesForIntersections;
  108480. /**
  108481. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  108482. */
  108483. proceduralTexturesEnabled: boolean;
  108484. private _engine;
  108485. private _totalVertices;
  108486. /** @hidden */
  108487. _activeIndices: PerfCounter;
  108488. /** @hidden */
  108489. _activeParticles: PerfCounter;
  108490. /** @hidden */
  108491. _activeBones: PerfCounter;
  108492. private _animationRatio;
  108493. /** @hidden */
  108494. _animationTimeLast: number;
  108495. /** @hidden */
  108496. _animationTime: number;
  108497. /**
  108498. * Gets or sets a general scale for animation speed
  108499. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  108500. */
  108501. animationTimeScale: number;
  108502. /** @hidden */
  108503. _cachedMaterial: Nullable<Material>;
  108504. /** @hidden */
  108505. _cachedEffect: Nullable<Effect>;
  108506. /** @hidden */
  108507. _cachedVisibility: Nullable<number>;
  108508. private _renderId;
  108509. private _frameId;
  108510. private _executeWhenReadyTimeoutId;
  108511. private _intermediateRendering;
  108512. private _viewUpdateFlag;
  108513. private _projectionUpdateFlag;
  108514. /** @hidden */
  108515. _toBeDisposed: Nullable<IDisposable>[];
  108516. private _activeRequests;
  108517. /** @hidden */
  108518. _pendingData: any[];
  108519. private _isDisposed;
  108520. /**
  108521. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  108522. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  108523. */
  108524. dispatchAllSubMeshesOfActiveMeshes: boolean;
  108525. private _activeMeshes;
  108526. private _processedMaterials;
  108527. private _renderTargets;
  108528. /** @hidden */
  108529. _activeParticleSystems: SmartArray<IParticleSystem>;
  108530. private _activeSkeletons;
  108531. private _softwareSkinnedMeshes;
  108532. private _renderingManager;
  108533. /** @hidden */
  108534. _activeAnimatables: Animatable[];
  108535. private _transformMatrix;
  108536. private _sceneUbo;
  108537. /** @hidden */
  108538. _viewMatrix: Matrix;
  108539. private _projectionMatrix;
  108540. /** @hidden */
  108541. _forcedViewPosition: Nullable<Vector3>;
  108542. /** @hidden */
  108543. _frustumPlanes: Plane[];
  108544. /**
  108545. * Gets the list of frustum planes (built from the active camera)
  108546. */
  108547. get frustumPlanes(): Plane[];
  108548. /**
  108549. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  108550. * This is useful if there are more lights that the maximum simulteanous authorized
  108551. */
  108552. requireLightSorting: boolean;
  108553. /** @hidden */
  108554. readonly useMaterialMeshMap: boolean;
  108555. /** @hidden */
  108556. readonly useClonedMeshMap: boolean;
  108557. private _externalData;
  108558. private _uid;
  108559. /**
  108560. * @hidden
  108561. * Backing store of defined scene components.
  108562. */
  108563. _components: ISceneComponent[];
  108564. /**
  108565. * @hidden
  108566. * Backing store of defined scene components.
  108567. */
  108568. _serializableComponents: ISceneSerializableComponent[];
  108569. /**
  108570. * List of components to register on the next registration step.
  108571. */
  108572. private _transientComponents;
  108573. /**
  108574. * Registers the transient components if needed.
  108575. */
  108576. private _registerTransientComponents;
  108577. /**
  108578. * @hidden
  108579. * Add a component to the scene.
  108580. * Note that the ccomponent could be registered on th next frame if this is called after
  108581. * the register component stage.
  108582. * @param component Defines the component to add to the scene
  108583. */
  108584. _addComponent(component: ISceneComponent): void;
  108585. /**
  108586. * @hidden
  108587. * Gets a component from the scene.
  108588. * @param name defines the name of the component to retrieve
  108589. * @returns the component or null if not present
  108590. */
  108591. _getComponent(name: string): Nullable<ISceneComponent>;
  108592. /**
  108593. * @hidden
  108594. * Defines the actions happening before camera updates.
  108595. */
  108596. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  108597. /**
  108598. * @hidden
  108599. * Defines the actions happening before clear the canvas.
  108600. */
  108601. _beforeClearStage: Stage<SimpleStageAction>;
  108602. /**
  108603. * @hidden
  108604. * Defines the actions when collecting render targets for the frame.
  108605. */
  108606. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  108607. /**
  108608. * @hidden
  108609. * Defines the actions happening for one camera in the frame.
  108610. */
  108611. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  108612. /**
  108613. * @hidden
  108614. * Defines the actions happening during the per mesh ready checks.
  108615. */
  108616. _isReadyForMeshStage: Stage<MeshStageAction>;
  108617. /**
  108618. * @hidden
  108619. * Defines the actions happening before evaluate active mesh checks.
  108620. */
  108621. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  108622. /**
  108623. * @hidden
  108624. * Defines the actions happening during the evaluate sub mesh checks.
  108625. */
  108626. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  108627. /**
  108628. * @hidden
  108629. * Defines the actions happening during the active mesh stage.
  108630. */
  108631. _activeMeshStage: Stage<ActiveMeshStageAction>;
  108632. /**
  108633. * @hidden
  108634. * Defines the actions happening during the per camera render target step.
  108635. */
  108636. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  108637. /**
  108638. * @hidden
  108639. * Defines the actions happening just before the active camera is drawing.
  108640. */
  108641. _beforeCameraDrawStage: Stage<CameraStageAction>;
  108642. /**
  108643. * @hidden
  108644. * Defines the actions happening just before a render target is drawing.
  108645. */
  108646. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  108647. /**
  108648. * @hidden
  108649. * Defines the actions happening just before a rendering group is drawing.
  108650. */
  108651. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  108652. /**
  108653. * @hidden
  108654. * Defines the actions happening just before a mesh is drawing.
  108655. */
  108656. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  108657. /**
  108658. * @hidden
  108659. * Defines the actions happening just after a mesh has been drawn.
  108660. */
  108661. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  108662. /**
  108663. * @hidden
  108664. * Defines the actions happening just after a rendering group has been drawn.
  108665. */
  108666. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  108667. /**
  108668. * @hidden
  108669. * Defines the actions happening just after the active camera has been drawn.
  108670. */
  108671. _afterCameraDrawStage: Stage<CameraStageAction>;
  108672. /**
  108673. * @hidden
  108674. * Defines the actions happening just after a render target has been drawn.
  108675. */
  108676. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  108677. /**
  108678. * @hidden
  108679. * Defines the actions happening just after rendering all cameras and computing intersections.
  108680. */
  108681. _afterRenderStage: Stage<SimpleStageAction>;
  108682. /**
  108683. * @hidden
  108684. * Defines the actions happening when a pointer move event happens.
  108685. */
  108686. _pointerMoveStage: Stage<PointerMoveStageAction>;
  108687. /**
  108688. * @hidden
  108689. * Defines the actions happening when a pointer down event happens.
  108690. */
  108691. _pointerDownStage: Stage<PointerUpDownStageAction>;
  108692. /**
  108693. * @hidden
  108694. * Defines the actions happening when a pointer up event happens.
  108695. */
  108696. _pointerUpStage: Stage<PointerUpDownStageAction>;
  108697. /**
  108698. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  108699. */
  108700. private geometriesByUniqueId;
  108701. /**
  108702. * Creates a new Scene
  108703. * @param engine defines the engine to use to render this scene
  108704. * @param options defines the scene options
  108705. */
  108706. constructor(engine: Engine, options?: SceneOptions);
  108707. /**
  108708. * Gets a string idenfifying the name of the class
  108709. * @returns "Scene" string
  108710. */
  108711. getClassName(): string;
  108712. private _defaultMeshCandidates;
  108713. /**
  108714. * @hidden
  108715. */
  108716. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  108717. private _defaultSubMeshCandidates;
  108718. /**
  108719. * @hidden
  108720. */
  108721. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  108722. /**
  108723. * Sets the default candidate providers for the scene.
  108724. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  108725. * and getCollidingSubMeshCandidates to their default function
  108726. */
  108727. setDefaultCandidateProviders(): void;
  108728. /**
  108729. * Gets the mesh that is currently under the pointer
  108730. */
  108731. get meshUnderPointer(): Nullable<AbstractMesh>;
  108732. /**
  108733. * Gets or sets the current on-screen X position of the pointer
  108734. */
  108735. get pointerX(): number;
  108736. set pointerX(value: number);
  108737. /**
  108738. * Gets or sets the current on-screen Y position of the pointer
  108739. */
  108740. get pointerY(): number;
  108741. set pointerY(value: number);
  108742. /**
  108743. * Gets the cached material (ie. the latest rendered one)
  108744. * @returns the cached material
  108745. */
  108746. getCachedMaterial(): Nullable<Material>;
  108747. /**
  108748. * Gets the cached effect (ie. the latest rendered one)
  108749. * @returns the cached effect
  108750. */
  108751. getCachedEffect(): Nullable<Effect>;
  108752. /**
  108753. * Gets the cached visibility state (ie. the latest rendered one)
  108754. * @returns the cached visibility state
  108755. */
  108756. getCachedVisibility(): Nullable<number>;
  108757. /**
  108758. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  108759. * @param material defines the current material
  108760. * @param effect defines the current effect
  108761. * @param visibility defines the current visibility state
  108762. * @returns true if one parameter is not cached
  108763. */
  108764. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  108765. /**
  108766. * Gets the engine associated with the scene
  108767. * @returns an Engine
  108768. */
  108769. getEngine(): Engine;
  108770. /**
  108771. * Gets the total number of vertices rendered per frame
  108772. * @returns the total number of vertices rendered per frame
  108773. */
  108774. getTotalVertices(): number;
  108775. /**
  108776. * Gets the performance counter for total vertices
  108777. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  108778. */
  108779. get totalVerticesPerfCounter(): PerfCounter;
  108780. /**
  108781. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  108782. * @returns the total number of active indices rendered per frame
  108783. */
  108784. getActiveIndices(): number;
  108785. /**
  108786. * Gets the performance counter for active indices
  108787. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  108788. */
  108789. get totalActiveIndicesPerfCounter(): PerfCounter;
  108790. /**
  108791. * Gets the total number of active particles rendered per frame
  108792. * @returns the total number of active particles rendered per frame
  108793. */
  108794. getActiveParticles(): number;
  108795. /**
  108796. * Gets the performance counter for active particles
  108797. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  108798. */
  108799. get activeParticlesPerfCounter(): PerfCounter;
  108800. /**
  108801. * Gets the total number of active bones rendered per frame
  108802. * @returns the total number of active bones rendered per frame
  108803. */
  108804. getActiveBones(): number;
  108805. /**
  108806. * Gets the performance counter for active bones
  108807. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  108808. */
  108809. get activeBonesPerfCounter(): PerfCounter;
  108810. /**
  108811. * Gets the array of active meshes
  108812. * @returns an array of AbstractMesh
  108813. */
  108814. getActiveMeshes(): SmartArray<AbstractMesh>;
  108815. /**
  108816. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  108817. * @returns a number
  108818. */
  108819. getAnimationRatio(): number;
  108820. /**
  108821. * Gets an unique Id for the current render phase
  108822. * @returns a number
  108823. */
  108824. getRenderId(): number;
  108825. /**
  108826. * Gets an unique Id for the current frame
  108827. * @returns a number
  108828. */
  108829. getFrameId(): number;
  108830. /** Call this function if you want to manually increment the render Id*/
  108831. incrementRenderId(): void;
  108832. private _createUbo;
  108833. /**
  108834. * Use this method to simulate a pointer move on a mesh
  108835. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108836. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108837. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108838. * @returns the current scene
  108839. */
  108840. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  108841. /**
  108842. * Use this method to simulate a pointer down on a mesh
  108843. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108844. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108845. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108846. * @returns the current scene
  108847. */
  108848. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  108849. /**
  108850. * Use this method to simulate a pointer up on a mesh
  108851. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108852. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108853. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108854. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  108855. * @returns the current scene
  108856. */
  108857. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  108858. /**
  108859. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  108860. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  108861. * @returns true if the pointer was captured
  108862. */
  108863. isPointerCaptured(pointerId?: number): boolean;
  108864. /**
  108865. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  108866. * @param attachUp defines if you want to attach events to pointerup
  108867. * @param attachDown defines if you want to attach events to pointerdown
  108868. * @param attachMove defines if you want to attach events to pointermove
  108869. */
  108870. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  108871. /** Detaches all event handlers*/
  108872. detachControl(): void;
  108873. /**
  108874. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  108875. * Delay loaded resources are not taking in account
  108876. * @return true if all required resources are ready
  108877. */
  108878. isReady(): boolean;
  108879. /** Resets all cached information relative to material (including effect and visibility) */
  108880. resetCachedMaterial(): void;
  108881. /**
  108882. * Registers a function to be called before every frame render
  108883. * @param func defines the function to register
  108884. */
  108885. registerBeforeRender(func: () => void): void;
  108886. /**
  108887. * Unregisters a function called before every frame render
  108888. * @param func defines the function to unregister
  108889. */
  108890. unregisterBeforeRender(func: () => void): void;
  108891. /**
  108892. * Registers a function to be called after every frame render
  108893. * @param func defines the function to register
  108894. */
  108895. registerAfterRender(func: () => void): void;
  108896. /**
  108897. * Unregisters a function called after every frame render
  108898. * @param func defines the function to unregister
  108899. */
  108900. unregisterAfterRender(func: () => void): void;
  108901. private _executeOnceBeforeRender;
  108902. /**
  108903. * The provided function will run before render once and will be disposed afterwards.
  108904. * A timeout delay can be provided so that the function will be executed in N ms.
  108905. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  108906. * @param func The function to be executed.
  108907. * @param timeout optional delay in ms
  108908. */
  108909. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  108910. /** @hidden */
  108911. _addPendingData(data: any): void;
  108912. /** @hidden */
  108913. _removePendingData(data: any): void;
  108914. /**
  108915. * Returns the number of items waiting to be loaded
  108916. * @returns the number of items waiting to be loaded
  108917. */
  108918. getWaitingItemsCount(): number;
  108919. /**
  108920. * Returns a boolean indicating if the scene is still loading data
  108921. */
  108922. get isLoading(): boolean;
  108923. /**
  108924. * Registers a function to be executed when the scene is ready
  108925. * @param {Function} func - the function to be executed
  108926. */
  108927. executeWhenReady(func: () => void): void;
  108928. /**
  108929. * Returns a promise that resolves when the scene is ready
  108930. * @returns A promise that resolves when the scene is ready
  108931. */
  108932. whenReadyAsync(): Promise<void>;
  108933. /** @hidden */
  108934. _checkIsReady(): void;
  108935. /**
  108936. * Gets all animatable attached to the scene
  108937. */
  108938. get animatables(): Animatable[];
  108939. /**
  108940. * Resets the last animation time frame.
  108941. * Useful to override when animations start running when loading a scene for the first time.
  108942. */
  108943. resetLastAnimationTimeFrame(): void;
  108944. /**
  108945. * Gets the current view matrix
  108946. * @returns a Matrix
  108947. */
  108948. getViewMatrix(): Matrix;
  108949. /**
  108950. * Gets the current projection matrix
  108951. * @returns a Matrix
  108952. */
  108953. getProjectionMatrix(): Matrix;
  108954. /**
  108955. * Gets the current transform matrix
  108956. * @returns a Matrix made of View * Projection
  108957. */
  108958. getTransformMatrix(): Matrix;
  108959. /**
  108960. * Sets the current transform matrix
  108961. * @param viewL defines the View matrix to use
  108962. * @param projectionL defines the Projection matrix to use
  108963. * @param viewR defines the right View matrix to use (if provided)
  108964. * @param projectionR defines the right Projection matrix to use (if provided)
  108965. */
  108966. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  108967. /**
  108968. * Gets the uniform buffer used to store scene data
  108969. * @returns a UniformBuffer
  108970. */
  108971. getSceneUniformBuffer(): UniformBuffer;
  108972. /**
  108973. * Gets an unique (relatively to the current scene) Id
  108974. * @returns an unique number for the scene
  108975. */
  108976. getUniqueId(): number;
  108977. /**
  108978. * Add a mesh to the list of scene's meshes
  108979. * @param newMesh defines the mesh to add
  108980. * @param recursive if all child meshes should also be added to the scene
  108981. */
  108982. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  108983. /**
  108984. * Remove a mesh for the list of scene's meshes
  108985. * @param toRemove defines the mesh to remove
  108986. * @param recursive if all child meshes should also be removed from the scene
  108987. * @returns the index where the mesh was in the mesh list
  108988. */
  108989. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  108990. /**
  108991. * Add a transform node to the list of scene's transform nodes
  108992. * @param newTransformNode defines the transform node to add
  108993. */
  108994. addTransformNode(newTransformNode: TransformNode): void;
  108995. /**
  108996. * Remove a transform node for the list of scene's transform nodes
  108997. * @param toRemove defines the transform node to remove
  108998. * @returns the index where the transform node was in the transform node list
  108999. */
  109000. removeTransformNode(toRemove: TransformNode): number;
  109001. /**
  109002. * Remove a skeleton for the list of scene's skeletons
  109003. * @param toRemove defines the skeleton to remove
  109004. * @returns the index where the skeleton was in the skeleton list
  109005. */
  109006. removeSkeleton(toRemove: Skeleton): number;
  109007. /**
  109008. * Remove a morph target for the list of scene's morph targets
  109009. * @param toRemove defines the morph target to remove
  109010. * @returns the index where the morph target was in the morph target list
  109011. */
  109012. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  109013. /**
  109014. * Remove a light for the list of scene's lights
  109015. * @param toRemove defines the light to remove
  109016. * @returns the index where the light was in the light list
  109017. */
  109018. removeLight(toRemove: Light): number;
  109019. /**
  109020. * Remove a camera for the list of scene's cameras
  109021. * @param toRemove defines the camera to remove
  109022. * @returns the index where the camera was in the camera list
  109023. */
  109024. removeCamera(toRemove: Camera): number;
  109025. /**
  109026. * Remove a particle system for the list of scene's particle systems
  109027. * @param toRemove defines the particle system to remove
  109028. * @returns the index where the particle system was in the particle system list
  109029. */
  109030. removeParticleSystem(toRemove: IParticleSystem): number;
  109031. /**
  109032. * Remove a animation for the list of scene's animations
  109033. * @param toRemove defines the animation to remove
  109034. * @returns the index where the animation was in the animation list
  109035. */
  109036. removeAnimation(toRemove: Animation): number;
  109037. /**
  109038. * Will stop the animation of the given target
  109039. * @param target - the target
  109040. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  109041. * @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)
  109042. */
  109043. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  109044. /**
  109045. * Removes the given animation group from this scene.
  109046. * @param toRemove The animation group to remove
  109047. * @returns The index of the removed animation group
  109048. */
  109049. removeAnimationGroup(toRemove: AnimationGroup): number;
  109050. /**
  109051. * Removes the given multi-material from this scene.
  109052. * @param toRemove The multi-material to remove
  109053. * @returns The index of the removed multi-material
  109054. */
  109055. removeMultiMaterial(toRemove: MultiMaterial): number;
  109056. /**
  109057. * Removes the given material from this scene.
  109058. * @param toRemove The material to remove
  109059. * @returns The index of the removed material
  109060. */
  109061. removeMaterial(toRemove: Material): number;
  109062. /**
  109063. * Removes the given action manager from this scene.
  109064. * @param toRemove The action manager to remove
  109065. * @returns The index of the removed action manager
  109066. */
  109067. removeActionManager(toRemove: AbstractActionManager): number;
  109068. /**
  109069. * Removes the given texture from this scene.
  109070. * @param toRemove The texture to remove
  109071. * @returns The index of the removed texture
  109072. */
  109073. removeTexture(toRemove: BaseTexture): number;
  109074. /**
  109075. * Adds the given light to this scene
  109076. * @param newLight The light to add
  109077. */
  109078. addLight(newLight: Light): void;
  109079. /**
  109080. * Sorts the list list based on light priorities
  109081. */
  109082. sortLightsByPriority(): void;
  109083. /**
  109084. * Adds the given camera to this scene
  109085. * @param newCamera The camera to add
  109086. */
  109087. addCamera(newCamera: Camera): void;
  109088. /**
  109089. * Adds the given skeleton to this scene
  109090. * @param newSkeleton The skeleton to add
  109091. */
  109092. addSkeleton(newSkeleton: Skeleton): void;
  109093. /**
  109094. * Adds the given particle system to this scene
  109095. * @param newParticleSystem The particle system to add
  109096. */
  109097. addParticleSystem(newParticleSystem: IParticleSystem): void;
  109098. /**
  109099. * Adds the given animation to this scene
  109100. * @param newAnimation The animation to add
  109101. */
  109102. addAnimation(newAnimation: Animation): void;
  109103. /**
  109104. * Adds the given animation group to this scene.
  109105. * @param newAnimationGroup The animation group to add
  109106. */
  109107. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  109108. /**
  109109. * Adds the given multi-material to this scene
  109110. * @param newMultiMaterial The multi-material to add
  109111. */
  109112. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  109113. /**
  109114. * Adds the given material to this scene
  109115. * @param newMaterial The material to add
  109116. */
  109117. addMaterial(newMaterial: Material): void;
  109118. /**
  109119. * Adds the given morph target to this scene
  109120. * @param newMorphTargetManager The morph target to add
  109121. */
  109122. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  109123. /**
  109124. * Adds the given geometry to this scene
  109125. * @param newGeometry The geometry to add
  109126. */
  109127. addGeometry(newGeometry: Geometry): void;
  109128. /**
  109129. * Adds the given action manager to this scene
  109130. * @param newActionManager The action manager to add
  109131. */
  109132. addActionManager(newActionManager: AbstractActionManager): void;
  109133. /**
  109134. * Adds the given texture to this scene.
  109135. * @param newTexture The texture to add
  109136. */
  109137. addTexture(newTexture: BaseTexture): void;
  109138. /**
  109139. * Switch active camera
  109140. * @param newCamera defines the new active camera
  109141. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  109142. */
  109143. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  109144. /**
  109145. * sets the active camera of the scene using its ID
  109146. * @param id defines the camera's ID
  109147. * @return the new active camera or null if none found.
  109148. */
  109149. setActiveCameraByID(id: string): Nullable<Camera>;
  109150. /**
  109151. * sets the active camera of the scene using its name
  109152. * @param name defines the camera's name
  109153. * @returns the new active camera or null if none found.
  109154. */
  109155. setActiveCameraByName(name: string): Nullable<Camera>;
  109156. /**
  109157. * get an animation group using its name
  109158. * @param name defines the material's name
  109159. * @return the animation group or null if none found.
  109160. */
  109161. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  109162. /**
  109163. * Get a material using its unique id
  109164. * @param uniqueId defines the material's unique id
  109165. * @return the material or null if none found.
  109166. */
  109167. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  109168. /**
  109169. * get a material using its id
  109170. * @param id defines the material's ID
  109171. * @return the material or null if none found.
  109172. */
  109173. getMaterialByID(id: string): Nullable<Material>;
  109174. /**
  109175. * Gets a the last added material using a given id
  109176. * @param id defines the material's ID
  109177. * @return the last material with the given id or null if none found.
  109178. */
  109179. getLastMaterialByID(id: string): Nullable<Material>;
  109180. /**
  109181. * Gets a material using its name
  109182. * @param name defines the material's name
  109183. * @return the material or null if none found.
  109184. */
  109185. getMaterialByName(name: string): Nullable<Material>;
  109186. /**
  109187. * Get a texture using its unique id
  109188. * @param uniqueId defines the texture's unique id
  109189. * @return the texture or null if none found.
  109190. */
  109191. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  109192. /**
  109193. * Gets a camera using its id
  109194. * @param id defines the id to look for
  109195. * @returns the camera or null if not found
  109196. */
  109197. getCameraByID(id: string): Nullable<Camera>;
  109198. /**
  109199. * Gets a camera using its unique id
  109200. * @param uniqueId defines the unique id to look for
  109201. * @returns the camera or null if not found
  109202. */
  109203. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  109204. /**
  109205. * Gets a camera using its name
  109206. * @param name defines the camera's name
  109207. * @return the camera or null if none found.
  109208. */
  109209. getCameraByName(name: string): Nullable<Camera>;
  109210. /**
  109211. * Gets a bone using its id
  109212. * @param id defines the bone's id
  109213. * @return the bone or null if not found
  109214. */
  109215. getBoneByID(id: string): Nullable<Bone>;
  109216. /**
  109217. * Gets a bone using its id
  109218. * @param name defines the bone's name
  109219. * @return the bone or null if not found
  109220. */
  109221. getBoneByName(name: string): Nullable<Bone>;
  109222. /**
  109223. * Gets a light node using its name
  109224. * @param name defines the the light's name
  109225. * @return the light or null if none found.
  109226. */
  109227. getLightByName(name: string): Nullable<Light>;
  109228. /**
  109229. * Gets a light node using its id
  109230. * @param id defines the light's id
  109231. * @return the light or null if none found.
  109232. */
  109233. getLightByID(id: string): Nullable<Light>;
  109234. /**
  109235. * Gets a light node using its scene-generated unique ID
  109236. * @param uniqueId defines the light's unique id
  109237. * @return the light or null if none found.
  109238. */
  109239. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  109240. /**
  109241. * Gets a particle system by id
  109242. * @param id defines the particle system id
  109243. * @return the corresponding system or null if none found
  109244. */
  109245. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  109246. /**
  109247. * Gets a geometry using its ID
  109248. * @param id defines the geometry's id
  109249. * @return the geometry or null if none found.
  109250. */
  109251. getGeometryByID(id: string): Nullable<Geometry>;
  109252. private _getGeometryByUniqueID;
  109253. /**
  109254. * Add a new geometry to this scene
  109255. * @param geometry defines the geometry to be added to the scene.
  109256. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  109257. * @return a boolean defining if the geometry was added or not
  109258. */
  109259. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  109260. /**
  109261. * Removes an existing geometry
  109262. * @param geometry defines the geometry to be removed from the scene
  109263. * @return a boolean defining if the geometry was removed or not
  109264. */
  109265. removeGeometry(geometry: Geometry): boolean;
  109266. /**
  109267. * Gets the list of geometries attached to the scene
  109268. * @returns an array of Geometry
  109269. */
  109270. getGeometries(): Geometry[];
  109271. /**
  109272. * Gets the first added mesh found of a given ID
  109273. * @param id defines the id to search for
  109274. * @return the mesh found or null if not found at all
  109275. */
  109276. getMeshByID(id: string): Nullable<AbstractMesh>;
  109277. /**
  109278. * Gets a list of meshes using their id
  109279. * @param id defines the id to search for
  109280. * @returns a list of meshes
  109281. */
  109282. getMeshesByID(id: string): Array<AbstractMesh>;
  109283. /**
  109284. * Gets the first added transform node found of a given ID
  109285. * @param id defines the id to search for
  109286. * @return the found transform node or null if not found at all.
  109287. */
  109288. getTransformNodeByID(id: string): Nullable<TransformNode>;
  109289. /**
  109290. * Gets a transform node with its auto-generated unique id
  109291. * @param uniqueId efines the unique id to search for
  109292. * @return the found transform node or null if not found at all.
  109293. */
  109294. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  109295. /**
  109296. * Gets a list of transform nodes using their id
  109297. * @param id defines the id to search for
  109298. * @returns a list of transform nodes
  109299. */
  109300. getTransformNodesByID(id: string): Array<TransformNode>;
  109301. /**
  109302. * Gets a mesh with its auto-generated unique id
  109303. * @param uniqueId defines the unique id to search for
  109304. * @return the found mesh or null if not found at all.
  109305. */
  109306. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  109307. /**
  109308. * Gets a the last added mesh using a given id
  109309. * @param id defines the id to search for
  109310. * @return the found mesh or null if not found at all.
  109311. */
  109312. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  109313. /**
  109314. * Gets a the last added node (Mesh, Camera, Light) using a given id
  109315. * @param id defines the id to search for
  109316. * @return the found node or null if not found at all
  109317. */
  109318. getLastEntryByID(id: string): Nullable<Node>;
  109319. /**
  109320. * Gets a node (Mesh, Camera, Light) using a given id
  109321. * @param id defines the id to search for
  109322. * @return the found node or null if not found at all
  109323. */
  109324. getNodeByID(id: string): Nullable<Node>;
  109325. /**
  109326. * Gets a node (Mesh, Camera, Light) using a given name
  109327. * @param name defines the name to search for
  109328. * @return the found node or null if not found at all.
  109329. */
  109330. getNodeByName(name: string): Nullable<Node>;
  109331. /**
  109332. * Gets a mesh using a given name
  109333. * @param name defines the name to search for
  109334. * @return the found mesh or null if not found at all.
  109335. */
  109336. getMeshByName(name: string): Nullable<AbstractMesh>;
  109337. /**
  109338. * Gets a transform node using a given name
  109339. * @param name defines the name to search for
  109340. * @return the found transform node or null if not found at all.
  109341. */
  109342. getTransformNodeByName(name: string): Nullable<TransformNode>;
  109343. /**
  109344. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  109345. * @param id defines the id to search for
  109346. * @return the found skeleton or null if not found at all.
  109347. */
  109348. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  109349. /**
  109350. * Gets a skeleton using a given auto generated unique id
  109351. * @param uniqueId defines the unique id to search for
  109352. * @return the found skeleton or null if not found at all.
  109353. */
  109354. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  109355. /**
  109356. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  109357. * @param id defines the id to search for
  109358. * @return the found skeleton or null if not found at all.
  109359. */
  109360. getSkeletonById(id: string): Nullable<Skeleton>;
  109361. /**
  109362. * Gets a skeleton using a given name
  109363. * @param name defines the name to search for
  109364. * @return the found skeleton or null if not found at all.
  109365. */
  109366. getSkeletonByName(name: string): Nullable<Skeleton>;
  109367. /**
  109368. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  109369. * @param id defines the id to search for
  109370. * @return the found morph target manager or null if not found at all.
  109371. */
  109372. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  109373. /**
  109374. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  109375. * @param id defines the id to search for
  109376. * @return the found morph target or null if not found at all.
  109377. */
  109378. getMorphTargetById(id: string): Nullable<MorphTarget>;
  109379. /**
  109380. * Gets a boolean indicating if the given mesh is active
  109381. * @param mesh defines the mesh to look for
  109382. * @returns true if the mesh is in the active list
  109383. */
  109384. isActiveMesh(mesh: AbstractMesh): boolean;
  109385. /**
  109386. * Return a unique id as a string which can serve as an identifier for the scene
  109387. */
  109388. get uid(): string;
  109389. /**
  109390. * Add an externaly attached data from its key.
  109391. * This method call will fail and return false, if such key already exists.
  109392. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  109393. * @param key the unique key that identifies the data
  109394. * @param data the data object to associate to the key for this Engine instance
  109395. * @return true if no such key were already present and the data was added successfully, false otherwise
  109396. */
  109397. addExternalData<T>(key: string, data: T): boolean;
  109398. /**
  109399. * Get an externaly attached data from its key
  109400. * @param key the unique key that identifies the data
  109401. * @return the associated data, if present (can be null), or undefined if not present
  109402. */
  109403. getExternalData<T>(key: string): Nullable<T>;
  109404. /**
  109405. * Get an externaly attached data from its key, create it using a factory if it's not already present
  109406. * @param key the unique key that identifies the data
  109407. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  109408. * @return the associated data, can be null if the factory returned null.
  109409. */
  109410. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  109411. /**
  109412. * Remove an externaly attached data from the Engine instance
  109413. * @param key the unique key that identifies the data
  109414. * @return true if the data was successfully removed, false if it doesn't exist
  109415. */
  109416. removeExternalData(key: string): boolean;
  109417. private _evaluateSubMesh;
  109418. /**
  109419. * Clear the processed materials smart array preventing retention point in material dispose.
  109420. */
  109421. freeProcessedMaterials(): void;
  109422. private _preventFreeActiveMeshesAndRenderingGroups;
  109423. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  109424. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  109425. * when disposing several meshes in a row or a hierarchy of meshes.
  109426. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  109427. */
  109428. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  109429. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  109430. /**
  109431. * Clear the active meshes smart array preventing retention point in mesh dispose.
  109432. */
  109433. freeActiveMeshes(): void;
  109434. /**
  109435. * Clear the info related to rendering groups preventing retention points during dispose.
  109436. */
  109437. freeRenderingGroups(): void;
  109438. /** @hidden */
  109439. _isInIntermediateRendering(): boolean;
  109440. /**
  109441. * Lambda returning the list of potentially active meshes.
  109442. */
  109443. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  109444. /**
  109445. * Lambda returning the list of potentially active sub meshes.
  109446. */
  109447. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  109448. /**
  109449. * Lambda returning the list of potentially intersecting sub meshes.
  109450. */
  109451. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  109452. /**
  109453. * Lambda returning the list of potentially colliding sub meshes.
  109454. */
  109455. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  109456. private _activeMeshesFrozen;
  109457. private _skipEvaluateActiveMeshesCompletely;
  109458. /**
  109459. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  109460. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  109461. * @returns the current scene
  109462. */
  109463. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  109464. /**
  109465. * Use this function to restart evaluating active meshes on every frame
  109466. * @returns the current scene
  109467. */
  109468. unfreezeActiveMeshes(): Scene;
  109469. private _evaluateActiveMeshes;
  109470. private _activeMesh;
  109471. /**
  109472. * Update the transform matrix to update from the current active camera
  109473. * @param force defines a boolean used to force the update even if cache is up to date
  109474. */
  109475. updateTransformMatrix(force?: boolean): void;
  109476. private _bindFrameBuffer;
  109477. /** @hidden */
  109478. _allowPostProcessClearColor: boolean;
  109479. /** @hidden */
  109480. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  109481. private _processSubCameras;
  109482. private _checkIntersections;
  109483. /** @hidden */
  109484. _advancePhysicsEngineStep(step: number): void;
  109485. /**
  109486. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  109487. */
  109488. getDeterministicFrameTime: () => number;
  109489. /** @hidden */
  109490. _animate(): void;
  109491. /** Execute all animations (for a frame) */
  109492. animate(): void;
  109493. /**
  109494. * Render the scene
  109495. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  109496. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  109497. */
  109498. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  109499. /**
  109500. * Freeze all materials
  109501. * A frozen material will not be updatable but should be faster to render
  109502. */
  109503. freezeMaterials(): void;
  109504. /**
  109505. * Unfreeze all materials
  109506. * A frozen material will not be updatable but should be faster to render
  109507. */
  109508. unfreezeMaterials(): void;
  109509. /**
  109510. * Releases all held ressources
  109511. */
  109512. dispose(): void;
  109513. /**
  109514. * Gets if the scene is already disposed
  109515. */
  109516. get isDisposed(): boolean;
  109517. /**
  109518. * Call this function to reduce memory footprint of the scene.
  109519. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  109520. */
  109521. clearCachedVertexData(): void;
  109522. /**
  109523. * This function will remove the local cached buffer data from texture.
  109524. * It will save memory but will prevent the texture from being rebuilt
  109525. */
  109526. cleanCachedTextureBuffer(): void;
  109527. /**
  109528. * Get the world extend vectors with an optional filter
  109529. *
  109530. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  109531. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  109532. */
  109533. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  109534. min: Vector3;
  109535. max: Vector3;
  109536. };
  109537. /**
  109538. * Creates a ray that can be used to pick in the scene
  109539. * @param x defines the x coordinate of the origin (on-screen)
  109540. * @param y defines the y coordinate of the origin (on-screen)
  109541. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  109542. * @param camera defines the camera to use for the picking
  109543. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  109544. * @returns a Ray
  109545. */
  109546. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  109547. /**
  109548. * Creates a ray that can be used to pick in the scene
  109549. * @param x defines the x coordinate of the origin (on-screen)
  109550. * @param y defines the y coordinate of the origin (on-screen)
  109551. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  109552. * @param result defines the ray where to store the picking ray
  109553. * @param camera defines the camera to use for the picking
  109554. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  109555. * @returns the current scene
  109556. */
  109557. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  109558. /**
  109559. * Creates a ray that can be used to pick in the scene
  109560. * @param x defines the x coordinate of the origin (on-screen)
  109561. * @param y defines the y coordinate of the origin (on-screen)
  109562. * @param camera defines the camera to use for the picking
  109563. * @returns a Ray
  109564. */
  109565. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  109566. /**
  109567. * Creates a ray that can be used to pick in the scene
  109568. * @param x defines the x coordinate of the origin (on-screen)
  109569. * @param y defines the y coordinate of the origin (on-screen)
  109570. * @param result defines the ray where to store the picking ray
  109571. * @param camera defines the camera to use for the picking
  109572. * @returns the current scene
  109573. */
  109574. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  109575. /** Launch a ray to try to pick a mesh in the scene
  109576. * @param x position on screen
  109577. * @param y position on screen
  109578. * @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
  109579. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  109580. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  109581. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109582. * @returns a PickingInfo
  109583. */
  109584. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  109585. /** Use the given ray to pick a mesh in the scene
  109586. * @param ray The ray to use to pick meshes
  109587. * @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
  109588. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  109589. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109590. * @returns a PickingInfo
  109591. */
  109592. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  109593. /**
  109594. * Launch a ray to try to pick a mesh in the scene
  109595. * @param x X position on screen
  109596. * @param y Y position on screen
  109597. * @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
  109598. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  109599. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109600. * @returns an array of PickingInfo
  109601. */
  109602. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  109603. /**
  109604. * Launch a ray to try to pick a mesh in the scene
  109605. * @param ray Ray to use
  109606. * @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
  109607. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109608. * @returns an array of PickingInfo
  109609. */
  109610. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  109611. /**
  109612. * Force the value of meshUnderPointer
  109613. * @param mesh defines the mesh to use
  109614. */
  109615. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  109616. /**
  109617. * Gets the mesh under the pointer
  109618. * @returns a Mesh or null if no mesh is under the pointer
  109619. */
  109620. getPointerOverMesh(): Nullable<AbstractMesh>;
  109621. /** @hidden */
  109622. _rebuildGeometries(): void;
  109623. /** @hidden */
  109624. _rebuildTextures(): void;
  109625. private _getByTags;
  109626. /**
  109627. * Get a list of meshes by tags
  109628. * @param tagsQuery defines the tags query to use
  109629. * @param forEach defines a predicate used to filter results
  109630. * @returns an array of Mesh
  109631. */
  109632. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  109633. /**
  109634. * Get a list of cameras by tags
  109635. * @param tagsQuery defines the tags query to use
  109636. * @param forEach defines a predicate used to filter results
  109637. * @returns an array of Camera
  109638. */
  109639. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  109640. /**
  109641. * Get a list of lights by tags
  109642. * @param tagsQuery defines the tags query to use
  109643. * @param forEach defines a predicate used to filter results
  109644. * @returns an array of Light
  109645. */
  109646. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  109647. /**
  109648. * Get a list of materials by tags
  109649. * @param tagsQuery defines the tags query to use
  109650. * @param forEach defines a predicate used to filter results
  109651. * @returns an array of Material
  109652. */
  109653. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  109654. /**
  109655. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  109656. * This allowed control for front to back rendering or reversly depending of the special needs.
  109657. *
  109658. * @param renderingGroupId The rendering group id corresponding to its index
  109659. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  109660. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  109661. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  109662. */
  109663. 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;
  109664. /**
  109665. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  109666. *
  109667. * @param renderingGroupId The rendering group id corresponding to its index
  109668. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  109669. * @param depth Automatically clears depth between groups if true and autoClear is true.
  109670. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  109671. */
  109672. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  109673. /**
  109674. * Gets the current auto clear configuration for one rendering group of the rendering
  109675. * manager.
  109676. * @param index the rendering group index to get the information for
  109677. * @returns The auto clear setup for the requested rendering group
  109678. */
  109679. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  109680. private _blockMaterialDirtyMechanism;
  109681. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  109682. get blockMaterialDirtyMechanism(): boolean;
  109683. set blockMaterialDirtyMechanism(value: boolean);
  109684. /**
  109685. * Will flag all materials as dirty to trigger new shader compilation
  109686. * @param flag defines the flag used to specify which material part must be marked as dirty
  109687. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  109688. */
  109689. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  109690. /** @hidden */
  109691. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  109692. /** @hidden */
  109693. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  109694. /** @hidden */
  109695. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  109696. /** @hidden */
  109697. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  109698. /** @hidden */
  109699. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  109700. /** @hidden */
  109701. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  109702. }
  109703. }
  109704. declare module BABYLON {
  109705. /**
  109706. * Set of assets to keep when moving a scene into an asset container.
  109707. */
  109708. export class KeepAssets extends AbstractScene {
  109709. }
  109710. /**
  109711. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  109712. */
  109713. export class InstantiatedEntries {
  109714. /**
  109715. * List of new root nodes (eg. nodes with no parent)
  109716. */
  109717. rootNodes: TransformNode[];
  109718. /**
  109719. * List of new skeletons
  109720. */
  109721. skeletons: Skeleton[];
  109722. /**
  109723. * List of new animation groups
  109724. */
  109725. animationGroups: AnimationGroup[];
  109726. }
  109727. /**
  109728. * Container with a set of assets that can be added or removed from a scene.
  109729. */
  109730. export class AssetContainer extends AbstractScene {
  109731. /**
  109732. * The scene the AssetContainer belongs to.
  109733. */
  109734. scene: Scene;
  109735. /**
  109736. * Instantiates an AssetContainer.
  109737. * @param scene The scene the AssetContainer belongs to.
  109738. */
  109739. constructor(scene: Scene);
  109740. /**
  109741. * Instantiate or clone all meshes and add the new ones to the scene.
  109742. * Skeletons and animation groups will all be cloned
  109743. * @param nameFunction defines an optional function used to get new names for clones
  109744. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  109745. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  109746. */
  109747. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  109748. /**
  109749. * Adds all the assets from the container to the scene.
  109750. */
  109751. addAllToScene(): void;
  109752. /**
  109753. * Removes all the assets in the container from the scene
  109754. */
  109755. removeAllFromScene(): void;
  109756. /**
  109757. * Disposes all the assets in the container
  109758. */
  109759. dispose(): void;
  109760. private _moveAssets;
  109761. /**
  109762. * Removes all the assets contained in the scene and adds them to the container.
  109763. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  109764. */
  109765. moveAllFromScene(keepAssets?: KeepAssets): void;
  109766. /**
  109767. * 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.
  109768. * @returns the root mesh
  109769. */
  109770. createRootMesh(): Mesh;
  109771. /**
  109772. * Merge animations from this asset container into a scene
  109773. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  109774. * @param animatables set of animatables to retarget to a node from the scene
  109775. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  109776. */
  109777. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  109778. }
  109779. }
  109780. declare module BABYLON {
  109781. /**
  109782. * Defines how the parser contract is defined.
  109783. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  109784. */
  109785. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  109786. /**
  109787. * Defines how the individual parser contract is defined.
  109788. * These parser can parse an individual asset
  109789. */
  109790. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  109791. /**
  109792. * Base class of the scene acting as a container for the different elements composing a scene.
  109793. * This class is dynamically extended by the different components of the scene increasing
  109794. * flexibility and reducing coupling
  109795. */
  109796. export abstract class AbstractScene {
  109797. /**
  109798. * Stores the list of available parsers in the application.
  109799. */
  109800. private static _BabylonFileParsers;
  109801. /**
  109802. * Stores the list of available individual parsers in the application.
  109803. */
  109804. private static _IndividualBabylonFileParsers;
  109805. /**
  109806. * Adds a parser in the list of available ones
  109807. * @param name Defines the name of the parser
  109808. * @param parser Defines the parser to add
  109809. */
  109810. static AddParser(name: string, parser: BabylonFileParser): void;
  109811. /**
  109812. * Gets a general parser from the list of avaialble ones
  109813. * @param name Defines the name of the parser
  109814. * @returns the requested parser or null
  109815. */
  109816. static GetParser(name: string): Nullable<BabylonFileParser>;
  109817. /**
  109818. * Adds n individual parser in the list of available ones
  109819. * @param name Defines the name of the parser
  109820. * @param parser Defines the parser to add
  109821. */
  109822. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  109823. /**
  109824. * Gets an individual parser from the list of avaialble ones
  109825. * @param name Defines the name of the parser
  109826. * @returns the requested parser or null
  109827. */
  109828. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  109829. /**
  109830. * Parser json data and populate both a scene and its associated container object
  109831. * @param jsonData Defines the data to parse
  109832. * @param scene Defines the scene to parse the data for
  109833. * @param container Defines the container attached to the parsing sequence
  109834. * @param rootUrl Defines the root url of the data
  109835. */
  109836. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  109837. /**
  109838. * Gets the list of root nodes (ie. nodes with no parent)
  109839. */
  109840. rootNodes: Node[];
  109841. /** All of the cameras added to this scene
  109842. * @see http://doc.babylonjs.com/babylon101/cameras
  109843. */
  109844. cameras: Camera[];
  109845. /**
  109846. * All of the lights added to this scene
  109847. * @see http://doc.babylonjs.com/babylon101/lights
  109848. */
  109849. lights: Light[];
  109850. /**
  109851. * All of the (abstract) meshes added to this scene
  109852. */
  109853. meshes: AbstractMesh[];
  109854. /**
  109855. * The list of skeletons added to the scene
  109856. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  109857. */
  109858. skeletons: Skeleton[];
  109859. /**
  109860. * All of the particle systems added to this scene
  109861. * @see http://doc.babylonjs.com/babylon101/particles
  109862. */
  109863. particleSystems: IParticleSystem[];
  109864. /**
  109865. * Gets a list of Animations associated with the scene
  109866. */
  109867. animations: Animation[];
  109868. /**
  109869. * All of the animation groups added to this scene
  109870. * @see http://doc.babylonjs.com/how_to/group
  109871. */
  109872. animationGroups: AnimationGroup[];
  109873. /**
  109874. * All of the multi-materials added to this scene
  109875. * @see http://doc.babylonjs.com/how_to/multi_materials
  109876. */
  109877. multiMaterials: MultiMaterial[];
  109878. /**
  109879. * All of the materials added to this scene
  109880. * In the context of a Scene, it is not supposed to be modified manually.
  109881. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  109882. * Note also that the order of the Material within the array is not significant and might change.
  109883. * @see http://doc.babylonjs.com/babylon101/materials
  109884. */
  109885. materials: Material[];
  109886. /**
  109887. * The list of morph target managers added to the scene
  109888. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  109889. */
  109890. morphTargetManagers: MorphTargetManager[];
  109891. /**
  109892. * The list of geometries used in the scene.
  109893. */
  109894. geometries: Geometry[];
  109895. /**
  109896. * All of the tranform nodes added to this scene
  109897. * In the context of a Scene, it is not supposed to be modified manually.
  109898. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  109899. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  109900. * @see http://doc.babylonjs.com/how_to/transformnode
  109901. */
  109902. transformNodes: TransformNode[];
  109903. /**
  109904. * ActionManagers available on the scene.
  109905. */
  109906. actionManagers: AbstractActionManager[];
  109907. /**
  109908. * Textures to keep.
  109909. */
  109910. textures: BaseTexture[];
  109911. /**
  109912. * Environment texture for the scene
  109913. */
  109914. environmentTexture: Nullable<BaseTexture>;
  109915. /**
  109916. * @returns all meshes, lights, cameras, transformNodes and bones
  109917. */
  109918. getNodes(): Array<Node>;
  109919. }
  109920. }
  109921. declare module BABYLON {
  109922. /**
  109923. * Interface used to define options for Sound class
  109924. */
  109925. export interface ISoundOptions {
  109926. /**
  109927. * Does the sound autoplay once loaded.
  109928. */
  109929. autoplay?: boolean;
  109930. /**
  109931. * Does the sound loop after it finishes playing once.
  109932. */
  109933. loop?: boolean;
  109934. /**
  109935. * Sound's volume
  109936. */
  109937. volume?: number;
  109938. /**
  109939. * Is it a spatial sound?
  109940. */
  109941. spatialSound?: boolean;
  109942. /**
  109943. * Maximum distance to hear that sound
  109944. */
  109945. maxDistance?: number;
  109946. /**
  109947. * Uses user defined attenuation function
  109948. */
  109949. useCustomAttenuation?: boolean;
  109950. /**
  109951. * Define the roll off factor of spatial sounds.
  109952. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109953. */
  109954. rolloffFactor?: number;
  109955. /**
  109956. * Define the reference distance the sound should be heard perfectly.
  109957. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109958. */
  109959. refDistance?: number;
  109960. /**
  109961. * Define the distance attenuation model the sound will follow.
  109962. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  109963. */
  109964. distanceModel?: string;
  109965. /**
  109966. * Defines the playback speed (1 by default)
  109967. */
  109968. playbackRate?: number;
  109969. /**
  109970. * Defines if the sound is from a streaming source
  109971. */
  109972. streaming?: boolean;
  109973. /**
  109974. * Defines an optional length (in seconds) inside the sound file
  109975. */
  109976. length?: number;
  109977. /**
  109978. * Defines an optional offset (in seconds) inside the sound file
  109979. */
  109980. offset?: number;
  109981. /**
  109982. * If true, URLs will not be required to state the audio file codec to use.
  109983. */
  109984. skipCodecCheck?: boolean;
  109985. }
  109986. /**
  109987. * Defines a sound that can be played in the application.
  109988. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  109989. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  109990. */
  109991. export class Sound {
  109992. /**
  109993. * The name of the sound in the scene.
  109994. */
  109995. name: string;
  109996. /**
  109997. * Does the sound autoplay once loaded.
  109998. */
  109999. autoplay: boolean;
  110000. /**
  110001. * Does the sound loop after it finishes playing once.
  110002. */
  110003. loop: boolean;
  110004. /**
  110005. * Does the sound use a custom attenuation curve to simulate the falloff
  110006. * happening when the source gets further away from the camera.
  110007. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110008. */
  110009. useCustomAttenuation: boolean;
  110010. /**
  110011. * The sound track id this sound belongs to.
  110012. */
  110013. soundTrackId: number;
  110014. /**
  110015. * Is this sound currently played.
  110016. */
  110017. isPlaying: boolean;
  110018. /**
  110019. * Is this sound currently paused.
  110020. */
  110021. isPaused: boolean;
  110022. /**
  110023. * Does this sound enables spatial sound.
  110024. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110025. */
  110026. spatialSound: boolean;
  110027. /**
  110028. * Define the reference distance the sound should be heard perfectly.
  110029. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110030. */
  110031. refDistance: number;
  110032. /**
  110033. * Define the roll off factor of spatial sounds.
  110034. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110035. */
  110036. rolloffFactor: number;
  110037. /**
  110038. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  110039. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110040. */
  110041. maxDistance: number;
  110042. /**
  110043. * Define the distance attenuation model the sound will follow.
  110044. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110045. */
  110046. distanceModel: string;
  110047. /**
  110048. * @hidden
  110049. * Back Compat
  110050. **/
  110051. onended: () => any;
  110052. /**
  110053. * Observable event when the current playing sound finishes.
  110054. */
  110055. onEndedObservable: Observable<Sound>;
  110056. private _panningModel;
  110057. private _playbackRate;
  110058. private _streaming;
  110059. private _startTime;
  110060. private _startOffset;
  110061. private _position;
  110062. /** @hidden */
  110063. _positionInEmitterSpace: boolean;
  110064. private _localDirection;
  110065. private _volume;
  110066. private _isReadyToPlay;
  110067. private _isDirectional;
  110068. private _readyToPlayCallback;
  110069. private _audioBuffer;
  110070. private _soundSource;
  110071. private _streamingSource;
  110072. private _soundPanner;
  110073. private _soundGain;
  110074. private _inputAudioNode;
  110075. private _outputAudioNode;
  110076. private _coneInnerAngle;
  110077. private _coneOuterAngle;
  110078. private _coneOuterGain;
  110079. private _scene;
  110080. private _connectedTransformNode;
  110081. private _customAttenuationFunction;
  110082. private _registerFunc;
  110083. private _isOutputConnected;
  110084. private _htmlAudioElement;
  110085. private _urlType;
  110086. private _length?;
  110087. private _offset?;
  110088. /** @hidden */
  110089. static _SceneComponentInitialization: (scene: Scene) => void;
  110090. /**
  110091. * Create a sound and attach it to a scene
  110092. * @param name Name of your sound
  110093. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  110094. * @param scene defines the scene the sound belongs to
  110095. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  110096. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  110097. */
  110098. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  110099. /**
  110100. * Release the sound and its associated resources
  110101. */
  110102. dispose(): void;
  110103. /**
  110104. * Gets if the sounds is ready to be played or not.
  110105. * @returns true if ready, otherwise false
  110106. */
  110107. isReady(): boolean;
  110108. private _soundLoaded;
  110109. /**
  110110. * Sets the data of the sound from an audiobuffer
  110111. * @param audioBuffer The audioBuffer containing the data
  110112. */
  110113. setAudioBuffer(audioBuffer: AudioBuffer): void;
  110114. /**
  110115. * Updates the current sounds options such as maxdistance, loop...
  110116. * @param options A JSON object containing values named as the object properties
  110117. */
  110118. updateOptions(options: ISoundOptions): void;
  110119. private _createSpatialParameters;
  110120. private _updateSpatialParameters;
  110121. /**
  110122. * Switch the panning model to HRTF:
  110123. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110124. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110125. */
  110126. switchPanningModelToHRTF(): void;
  110127. /**
  110128. * Switch the panning model to Equal Power:
  110129. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110130. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110131. */
  110132. switchPanningModelToEqualPower(): void;
  110133. private _switchPanningModel;
  110134. /**
  110135. * Connect this sound to a sound track audio node like gain...
  110136. * @param soundTrackAudioNode the sound track audio node to connect to
  110137. */
  110138. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  110139. /**
  110140. * Transform this sound into a directional source
  110141. * @param coneInnerAngle Size of the inner cone in degree
  110142. * @param coneOuterAngle Size of the outer cone in degree
  110143. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  110144. */
  110145. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  110146. /**
  110147. * Gets or sets the inner angle for the directional cone.
  110148. */
  110149. get directionalConeInnerAngle(): number;
  110150. /**
  110151. * Gets or sets the inner angle for the directional cone.
  110152. */
  110153. set directionalConeInnerAngle(value: number);
  110154. /**
  110155. * Gets or sets the outer angle for the directional cone.
  110156. */
  110157. get directionalConeOuterAngle(): number;
  110158. /**
  110159. * Gets or sets the outer angle for the directional cone.
  110160. */
  110161. set directionalConeOuterAngle(value: number);
  110162. /**
  110163. * Sets the position of the emitter if spatial sound is enabled
  110164. * @param newPosition Defines the new posisiton
  110165. */
  110166. setPosition(newPosition: Vector3): void;
  110167. /**
  110168. * Sets the local direction of the emitter if spatial sound is enabled
  110169. * @param newLocalDirection Defines the new local direction
  110170. */
  110171. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  110172. private _updateDirection;
  110173. /** @hidden */
  110174. updateDistanceFromListener(): void;
  110175. /**
  110176. * Sets a new custom attenuation function for the sound.
  110177. * @param callback Defines the function used for the attenuation
  110178. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110179. */
  110180. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  110181. /**
  110182. * Play the sound
  110183. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  110184. * @param offset (optional) Start the sound at a specific time in seconds
  110185. * @param length (optional) Sound duration (in seconds)
  110186. */
  110187. play(time?: number, offset?: number, length?: number): void;
  110188. private _onended;
  110189. /**
  110190. * Stop the sound
  110191. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  110192. */
  110193. stop(time?: number): void;
  110194. /**
  110195. * Put the sound in pause
  110196. */
  110197. pause(): void;
  110198. /**
  110199. * Sets a dedicated volume for this sounds
  110200. * @param newVolume Define the new volume of the sound
  110201. * @param time Define time for gradual change to new volume
  110202. */
  110203. setVolume(newVolume: number, time?: number): void;
  110204. /**
  110205. * Set the sound play back rate
  110206. * @param newPlaybackRate Define the playback rate the sound should be played at
  110207. */
  110208. setPlaybackRate(newPlaybackRate: number): void;
  110209. /**
  110210. * Gets the volume of the sound.
  110211. * @returns the volume of the sound
  110212. */
  110213. getVolume(): number;
  110214. /**
  110215. * Attach the sound to a dedicated mesh
  110216. * @param transformNode The transform node to connect the sound with
  110217. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110218. */
  110219. attachToMesh(transformNode: TransformNode): void;
  110220. /**
  110221. * Detach the sound from the previously attached mesh
  110222. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110223. */
  110224. detachFromMesh(): void;
  110225. private _onRegisterAfterWorldMatrixUpdate;
  110226. /**
  110227. * Clone the current sound in the scene.
  110228. * @returns the new sound clone
  110229. */
  110230. clone(): Nullable<Sound>;
  110231. /**
  110232. * Gets the current underlying audio buffer containing the data
  110233. * @returns the audio buffer
  110234. */
  110235. getAudioBuffer(): Nullable<AudioBuffer>;
  110236. /**
  110237. * Serializes the Sound in a JSON representation
  110238. * @returns the JSON representation of the sound
  110239. */
  110240. serialize(): any;
  110241. /**
  110242. * Parse a JSON representation of a sound to innstantiate in a given scene
  110243. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  110244. * @param scene Define the scene the new parsed sound should be created in
  110245. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  110246. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  110247. * @returns the newly parsed sound
  110248. */
  110249. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  110250. }
  110251. }
  110252. declare module BABYLON {
  110253. /**
  110254. * This defines an action helpful to play a defined sound on a triggered action.
  110255. */
  110256. export class PlaySoundAction extends Action {
  110257. private _sound;
  110258. /**
  110259. * Instantiate the action
  110260. * @param triggerOptions defines the trigger options
  110261. * @param sound defines the sound to play
  110262. * @param condition defines the trigger related conditions
  110263. */
  110264. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110265. /** @hidden */
  110266. _prepare(): void;
  110267. /**
  110268. * Execute the action and play the sound.
  110269. */
  110270. execute(): void;
  110271. /**
  110272. * Serializes the actions and its related information.
  110273. * @param parent defines the object to serialize in
  110274. * @returns the serialized object
  110275. */
  110276. serialize(parent: any): any;
  110277. }
  110278. /**
  110279. * This defines an action helpful to stop a defined sound on a triggered action.
  110280. */
  110281. export class StopSoundAction extends Action {
  110282. private _sound;
  110283. /**
  110284. * Instantiate the action
  110285. * @param triggerOptions defines the trigger options
  110286. * @param sound defines the sound to stop
  110287. * @param condition defines the trigger related conditions
  110288. */
  110289. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110290. /** @hidden */
  110291. _prepare(): void;
  110292. /**
  110293. * Execute the action and stop the sound.
  110294. */
  110295. execute(): void;
  110296. /**
  110297. * Serializes the actions and its related information.
  110298. * @param parent defines the object to serialize in
  110299. * @returns the serialized object
  110300. */
  110301. serialize(parent: any): any;
  110302. }
  110303. }
  110304. declare module BABYLON {
  110305. /**
  110306. * This defines an action responsible to change the value of a property
  110307. * by interpolating between its current value and the newly set one once triggered.
  110308. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  110309. */
  110310. export class InterpolateValueAction extends Action {
  110311. /**
  110312. * Defines the path of the property where the value should be interpolated
  110313. */
  110314. propertyPath: string;
  110315. /**
  110316. * Defines the target value at the end of the interpolation.
  110317. */
  110318. value: any;
  110319. /**
  110320. * Defines the time it will take for the property to interpolate to the value.
  110321. */
  110322. duration: number;
  110323. /**
  110324. * Defines if the other scene animations should be stopped when the action has been triggered
  110325. */
  110326. stopOtherAnimations?: boolean;
  110327. /**
  110328. * Defines a callback raised once the interpolation animation has been done.
  110329. */
  110330. onInterpolationDone?: () => void;
  110331. /**
  110332. * Observable triggered once the interpolation animation has been done.
  110333. */
  110334. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  110335. private _target;
  110336. private _effectiveTarget;
  110337. private _property;
  110338. /**
  110339. * Instantiate the action
  110340. * @param triggerOptions defines the trigger options
  110341. * @param target defines the object containing the value to interpolate
  110342. * @param propertyPath defines the path to the property in the target object
  110343. * @param value defines the target value at the end of the interpolation
  110344. * @param duration deines the time it will take for the property to interpolate to the value.
  110345. * @param condition defines the trigger related conditions
  110346. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  110347. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  110348. */
  110349. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  110350. /** @hidden */
  110351. _prepare(): void;
  110352. /**
  110353. * Execute the action starts the value interpolation.
  110354. */
  110355. execute(): void;
  110356. /**
  110357. * Serializes the actions and its related information.
  110358. * @param parent defines the object to serialize in
  110359. * @returns the serialized object
  110360. */
  110361. serialize(parent: any): any;
  110362. }
  110363. }
  110364. declare module BABYLON {
  110365. /**
  110366. * Options allowed during the creation of a sound track.
  110367. */
  110368. export interface ISoundTrackOptions {
  110369. /**
  110370. * The volume the sound track should take during creation
  110371. */
  110372. volume?: number;
  110373. /**
  110374. * Define if the sound track is the main sound track of the scene
  110375. */
  110376. mainTrack?: boolean;
  110377. }
  110378. /**
  110379. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  110380. * It will be also used in a future release to apply effects on a specific track.
  110381. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  110382. */
  110383. export class SoundTrack {
  110384. /**
  110385. * The unique identifier of the sound track in the scene.
  110386. */
  110387. id: number;
  110388. /**
  110389. * The list of sounds included in the sound track.
  110390. */
  110391. soundCollection: Array<Sound>;
  110392. private _outputAudioNode;
  110393. private _scene;
  110394. private _connectedAnalyser;
  110395. private _options;
  110396. private _isInitialized;
  110397. /**
  110398. * Creates a new sound track.
  110399. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  110400. * @param scene Define the scene the sound track belongs to
  110401. * @param options
  110402. */
  110403. constructor(scene: Scene, options?: ISoundTrackOptions);
  110404. private _initializeSoundTrackAudioGraph;
  110405. /**
  110406. * Release the sound track and its associated resources
  110407. */
  110408. dispose(): void;
  110409. /**
  110410. * Adds a sound to this sound track
  110411. * @param sound define the cound to add
  110412. * @ignoreNaming
  110413. */
  110414. AddSound(sound: Sound): void;
  110415. /**
  110416. * Removes a sound to this sound track
  110417. * @param sound define the cound to remove
  110418. * @ignoreNaming
  110419. */
  110420. RemoveSound(sound: Sound): void;
  110421. /**
  110422. * Set a global volume for the full sound track.
  110423. * @param newVolume Define the new volume of the sound track
  110424. */
  110425. setVolume(newVolume: number): void;
  110426. /**
  110427. * Switch the panning model to HRTF:
  110428. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110429. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110430. */
  110431. switchPanningModelToHRTF(): void;
  110432. /**
  110433. * Switch the panning model to Equal Power:
  110434. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110435. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110436. */
  110437. switchPanningModelToEqualPower(): void;
  110438. /**
  110439. * Connect the sound track to an audio analyser allowing some amazing
  110440. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  110441. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  110442. * @param analyser The analyser to connect to the engine
  110443. */
  110444. connectToAnalyser(analyser: Analyser): void;
  110445. }
  110446. }
  110447. declare module BABYLON {
  110448. interface AbstractScene {
  110449. /**
  110450. * The list of sounds used in the scene.
  110451. */
  110452. sounds: Nullable<Array<Sound>>;
  110453. }
  110454. interface Scene {
  110455. /**
  110456. * @hidden
  110457. * Backing field
  110458. */
  110459. _mainSoundTrack: SoundTrack;
  110460. /**
  110461. * The main sound track played by the scene.
  110462. * It cotains your primary collection of sounds.
  110463. */
  110464. mainSoundTrack: SoundTrack;
  110465. /**
  110466. * The list of sound tracks added to the scene
  110467. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110468. */
  110469. soundTracks: Nullable<Array<SoundTrack>>;
  110470. /**
  110471. * Gets a sound using a given name
  110472. * @param name defines the name to search for
  110473. * @return the found sound or null if not found at all.
  110474. */
  110475. getSoundByName(name: string): Nullable<Sound>;
  110476. /**
  110477. * Gets or sets if audio support is enabled
  110478. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110479. */
  110480. audioEnabled: boolean;
  110481. /**
  110482. * Gets or sets if audio will be output to headphones
  110483. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110484. */
  110485. headphone: boolean;
  110486. /**
  110487. * Gets or sets custom audio listener position provider
  110488. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110489. */
  110490. audioListenerPositionProvider: Nullable<() => Vector3>;
  110491. /**
  110492. * Gets or sets a refresh rate when using 3D audio positioning
  110493. */
  110494. audioPositioningRefreshRate: number;
  110495. }
  110496. /**
  110497. * Defines the sound scene component responsible to manage any sounds
  110498. * in a given scene.
  110499. */
  110500. export class AudioSceneComponent implements ISceneSerializableComponent {
  110501. /**
  110502. * The component name helpfull to identify the component in the list of scene components.
  110503. */
  110504. readonly name: string;
  110505. /**
  110506. * The scene the component belongs to.
  110507. */
  110508. scene: Scene;
  110509. private _audioEnabled;
  110510. /**
  110511. * Gets whether audio is enabled or not.
  110512. * Please use related enable/disable method to switch state.
  110513. */
  110514. get audioEnabled(): boolean;
  110515. private _headphone;
  110516. /**
  110517. * Gets whether audio is outputing to headphone or not.
  110518. * Please use the according Switch methods to change output.
  110519. */
  110520. get headphone(): boolean;
  110521. /**
  110522. * Gets or sets a refresh rate when using 3D audio positioning
  110523. */
  110524. audioPositioningRefreshRate: number;
  110525. private _audioListenerPositionProvider;
  110526. /**
  110527. * Gets the current audio listener position provider
  110528. */
  110529. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  110530. /**
  110531. * Sets a custom listener position for all sounds in the scene
  110532. * By default, this is the position of the first active camera
  110533. */
  110534. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  110535. /**
  110536. * Creates a new instance of the component for the given scene
  110537. * @param scene Defines the scene to register the component in
  110538. */
  110539. constructor(scene: Scene);
  110540. /**
  110541. * Registers the component in a given scene
  110542. */
  110543. register(): void;
  110544. /**
  110545. * Rebuilds the elements related to this component in case of
  110546. * context lost for instance.
  110547. */
  110548. rebuild(): void;
  110549. /**
  110550. * Serializes the component data to the specified json object
  110551. * @param serializationObject The object to serialize to
  110552. */
  110553. serialize(serializationObject: any): void;
  110554. /**
  110555. * Adds all the elements from the container to the scene
  110556. * @param container the container holding the elements
  110557. */
  110558. addFromContainer(container: AbstractScene): void;
  110559. /**
  110560. * Removes all the elements in the container from the scene
  110561. * @param container contains the elements to remove
  110562. * @param dispose if the removed element should be disposed (default: false)
  110563. */
  110564. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110565. /**
  110566. * Disposes the component and the associated ressources.
  110567. */
  110568. dispose(): void;
  110569. /**
  110570. * Disables audio in the associated scene.
  110571. */
  110572. disableAudio(): void;
  110573. /**
  110574. * Enables audio in the associated scene.
  110575. */
  110576. enableAudio(): void;
  110577. /**
  110578. * Switch audio to headphone output.
  110579. */
  110580. switchAudioModeForHeadphones(): void;
  110581. /**
  110582. * Switch audio to normal speakers.
  110583. */
  110584. switchAudioModeForNormalSpeakers(): void;
  110585. private _cachedCameraDirection;
  110586. private _cachedCameraPosition;
  110587. private _lastCheck;
  110588. private _afterRender;
  110589. }
  110590. }
  110591. declare module BABYLON {
  110592. /**
  110593. * Wraps one or more Sound objects and selects one with random weight for playback.
  110594. */
  110595. export class WeightedSound {
  110596. /** When true a Sound will be selected and played when the current playing Sound completes. */
  110597. loop: boolean;
  110598. private _coneInnerAngle;
  110599. private _coneOuterAngle;
  110600. private _volume;
  110601. /** A Sound is currently playing. */
  110602. isPlaying: boolean;
  110603. /** A Sound is currently paused. */
  110604. isPaused: boolean;
  110605. private _sounds;
  110606. private _weights;
  110607. private _currentIndex?;
  110608. /**
  110609. * Creates a new WeightedSound from the list of sounds given.
  110610. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  110611. * @param sounds Array of Sounds that will be selected from.
  110612. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  110613. */
  110614. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  110615. /**
  110616. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  110617. */
  110618. get directionalConeInnerAngle(): number;
  110619. /**
  110620. * The size of cone in degress for a directional sound in which there will be no attenuation.
  110621. */
  110622. set directionalConeInnerAngle(value: number);
  110623. /**
  110624. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  110625. * Listener angles between innerAngle and outerAngle will falloff linearly.
  110626. */
  110627. get directionalConeOuterAngle(): number;
  110628. /**
  110629. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  110630. * Listener angles between innerAngle and outerAngle will falloff linearly.
  110631. */
  110632. set directionalConeOuterAngle(value: number);
  110633. /**
  110634. * Playback volume.
  110635. */
  110636. get volume(): number;
  110637. /**
  110638. * Playback volume.
  110639. */
  110640. set volume(value: number);
  110641. private _onended;
  110642. /**
  110643. * Suspend playback
  110644. */
  110645. pause(): void;
  110646. /**
  110647. * Stop playback
  110648. */
  110649. stop(): void;
  110650. /**
  110651. * Start playback.
  110652. * @param startOffset Position the clip head at a specific time in seconds.
  110653. */
  110654. play(startOffset?: number): void;
  110655. }
  110656. }
  110657. declare module BABYLON {
  110658. /**
  110659. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  110660. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  110661. */
  110662. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  110663. /**
  110664. * Gets the name of the behavior.
  110665. */
  110666. get name(): string;
  110667. /**
  110668. * The easing function used by animations
  110669. */
  110670. static EasingFunction: BackEase;
  110671. /**
  110672. * The easing mode used by animations
  110673. */
  110674. static EasingMode: number;
  110675. /**
  110676. * The duration of the animation, in milliseconds
  110677. */
  110678. transitionDuration: number;
  110679. /**
  110680. * Length of the distance animated by the transition when lower radius is reached
  110681. */
  110682. lowerRadiusTransitionRange: number;
  110683. /**
  110684. * Length of the distance animated by the transition when upper radius is reached
  110685. */
  110686. upperRadiusTransitionRange: number;
  110687. private _autoTransitionRange;
  110688. /**
  110689. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  110690. */
  110691. get autoTransitionRange(): boolean;
  110692. /**
  110693. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  110694. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  110695. */
  110696. set autoTransitionRange(value: boolean);
  110697. private _attachedCamera;
  110698. private _onAfterCheckInputsObserver;
  110699. private _onMeshTargetChangedObserver;
  110700. /**
  110701. * Initializes the behavior.
  110702. */
  110703. init(): void;
  110704. /**
  110705. * Attaches the behavior to its arc rotate camera.
  110706. * @param camera Defines the camera to attach the behavior to
  110707. */
  110708. attach(camera: ArcRotateCamera): void;
  110709. /**
  110710. * Detaches the behavior from its current arc rotate camera.
  110711. */
  110712. detach(): void;
  110713. private _radiusIsAnimating;
  110714. private _radiusBounceTransition;
  110715. private _animatables;
  110716. private _cachedWheelPrecision;
  110717. /**
  110718. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  110719. * @param radiusLimit The limit to check against.
  110720. * @return Bool to indicate if at limit.
  110721. */
  110722. private _isRadiusAtLimit;
  110723. /**
  110724. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  110725. * @param radiusDelta The delta by which to animate to. Can be negative.
  110726. */
  110727. private _applyBoundRadiusAnimation;
  110728. /**
  110729. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  110730. */
  110731. protected _clearAnimationLocks(): void;
  110732. /**
  110733. * Stops and removes all animations that have been applied to the camera
  110734. */
  110735. stopAllAnimations(): void;
  110736. }
  110737. }
  110738. declare module BABYLON {
  110739. /**
  110740. * 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.
  110741. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  110742. */
  110743. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  110744. /**
  110745. * Gets the name of the behavior.
  110746. */
  110747. get name(): string;
  110748. private _mode;
  110749. private _radiusScale;
  110750. private _positionScale;
  110751. private _defaultElevation;
  110752. private _elevationReturnTime;
  110753. private _elevationReturnWaitTime;
  110754. private _zoomStopsAnimation;
  110755. private _framingTime;
  110756. /**
  110757. * The easing function used by animations
  110758. */
  110759. static EasingFunction: ExponentialEase;
  110760. /**
  110761. * The easing mode used by animations
  110762. */
  110763. static EasingMode: number;
  110764. /**
  110765. * Sets the current mode used by the behavior
  110766. */
  110767. set mode(mode: number);
  110768. /**
  110769. * Gets current mode used by the behavior.
  110770. */
  110771. get mode(): number;
  110772. /**
  110773. * Sets the scale applied to the radius (1 by default)
  110774. */
  110775. set radiusScale(radius: number);
  110776. /**
  110777. * Gets the scale applied to the radius
  110778. */
  110779. get radiusScale(): number;
  110780. /**
  110781. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  110782. */
  110783. set positionScale(scale: number);
  110784. /**
  110785. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  110786. */
  110787. get positionScale(): number;
  110788. /**
  110789. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  110790. * behaviour is triggered, in radians.
  110791. */
  110792. set defaultElevation(elevation: number);
  110793. /**
  110794. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  110795. * behaviour is triggered, in radians.
  110796. */
  110797. get defaultElevation(): number;
  110798. /**
  110799. * Sets the time (in milliseconds) taken to return to the default beta position.
  110800. * Negative value indicates camera should not return to default.
  110801. */
  110802. set elevationReturnTime(speed: number);
  110803. /**
  110804. * Gets the time (in milliseconds) taken to return to the default beta position.
  110805. * Negative value indicates camera should not return to default.
  110806. */
  110807. get elevationReturnTime(): number;
  110808. /**
  110809. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  110810. */
  110811. set elevationReturnWaitTime(time: number);
  110812. /**
  110813. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  110814. */
  110815. get elevationReturnWaitTime(): number;
  110816. /**
  110817. * Sets the flag that indicates if user zooming should stop animation.
  110818. */
  110819. set zoomStopsAnimation(flag: boolean);
  110820. /**
  110821. * Gets the flag that indicates if user zooming should stop animation.
  110822. */
  110823. get zoomStopsAnimation(): boolean;
  110824. /**
  110825. * Sets the transition time when framing the mesh, in milliseconds
  110826. */
  110827. set framingTime(time: number);
  110828. /**
  110829. * Gets the transition time when framing the mesh, in milliseconds
  110830. */
  110831. get framingTime(): number;
  110832. /**
  110833. * Define if the behavior should automatically change the configured
  110834. * camera limits and sensibilities.
  110835. */
  110836. autoCorrectCameraLimitsAndSensibility: boolean;
  110837. private _onPrePointerObservableObserver;
  110838. private _onAfterCheckInputsObserver;
  110839. private _onMeshTargetChangedObserver;
  110840. private _attachedCamera;
  110841. private _isPointerDown;
  110842. private _lastInteractionTime;
  110843. /**
  110844. * Initializes the behavior.
  110845. */
  110846. init(): void;
  110847. /**
  110848. * Attaches the behavior to its arc rotate camera.
  110849. * @param camera Defines the camera to attach the behavior to
  110850. */
  110851. attach(camera: ArcRotateCamera): void;
  110852. /**
  110853. * Detaches the behavior from its current arc rotate camera.
  110854. */
  110855. detach(): void;
  110856. private _animatables;
  110857. private _betaIsAnimating;
  110858. private _betaTransition;
  110859. private _radiusTransition;
  110860. private _vectorTransition;
  110861. /**
  110862. * Targets the given mesh and updates zoom level accordingly.
  110863. * @param mesh The mesh to target.
  110864. * @param radius Optional. If a cached radius position already exists, overrides default.
  110865. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  110866. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  110867. * @param onAnimationEnd Callback triggered at the end of the framing animation
  110868. */
  110869. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  110870. /**
  110871. * Targets the given mesh with its children and updates zoom level accordingly.
  110872. * @param mesh The mesh to target.
  110873. * @param radius Optional. If a cached radius position already exists, overrides default.
  110874. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  110875. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  110876. * @param onAnimationEnd Callback triggered at the end of the framing animation
  110877. */
  110878. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  110879. /**
  110880. * Targets the given meshes with their children and updates zoom level accordingly.
  110881. * @param meshes The mesh to target.
  110882. * @param radius Optional. If a cached radius position already exists, overrides default.
  110883. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  110884. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  110885. * @param onAnimationEnd Callback triggered at the end of the framing animation
  110886. */
  110887. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  110888. /**
  110889. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  110890. * @param minimumWorld Determines the smaller position of the bounding box extend
  110891. * @param maximumWorld Determines the bigger position of the bounding box extend
  110892. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  110893. * @param onAnimationEnd Callback triggered at the end of the framing animation
  110894. */
  110895. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  110896. /**
  110897. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  110898. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  110899. * frustum width.
  110900. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  110901. * to fully enclose the mesh in the viewing frustum.
  110902. */
  110903. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  110904. /**
  110905. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  110906. * is automatically returned to its default position (expected to be above ground plane).
  110907. */
  110908. private _maintainCameraAboveGround;
  110909. /**
  110910. * Returns the frustum slope based on the canvas ratio and camera FOV
  110911. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  110912. */
  110913. private _getFrustumSlope;
  110914. /**
  110915. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  110916. */
  110917. private _clearAnimationLocks;
  110918. /**
  110919. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  110920. */
  110921. private _applyUserInteraction;
  110922. /**
  110923. * Stops and removes all animations that have been applied to the camera
  110924. */
  110925. stopAllAnimations(): void;
  110926. /**
  110927. * Gets a value indicating if the user is moving the camera
  110928. */
  110929. get isUserIsMoving(): boolean;
  110930. /**
  110931. * The camera can move all the way towards the mesh.
  110932. */
  110933. static IgnoreBoundsSizeMode: number;
  110934. /**
  110935. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  110936. */
  110937. static FitFrustumSidesMode: number;
  110938. }
  110939. }
  110940. declare module BABYLON {
  110941. /**
  110942. * Base class for Camera Pointer Inputs.
  110943. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  110944. * for example usage.
  110945. */
  110946. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  110947. /**
  110948. * Defines the camera the input is attached to.
  110949. */
  110950. abstract camera: Camera;
  110951. /**
  110952. * Whether keyboard modifier keys are pressed at time of last mouse event.
  110953. */
  110954. protected _altKey: boolean;
  110955. protected _ctrlKey: boolean;
  110956. protected _metaKey: boolean;
  110957. protected _shiftKey: boolean;
  110958. /**
  110959. * Which mouse buttons were pressed at time of last mouse event.
  110960. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  110961. */
  110962. protected _buttonsPressed: number;
  110963. /**
  110964. * Defines the buttons associated with the input to handle camera move.
  110965. */
  110966. buttons: number[];
  110967. /**
  110968. * Attach the input controls to a specific dom element to get the input from.
  110969. * @param element Defines the element the controls should be listened from
  110970. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110971. */
  110972. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110973. /**
  110974. * Detach the current controls from the specified dom element.
  110975. * @param element Defines the element to stop listening the inputs from
  110976. */
  110977. detachControl(element: Nullable<HTMLElement>): void;
  110978. /**
  110979. * Gets the class name of the current input.
  110980. * @returns the class name
  110981. */
  110982. getClassName(): string;
  110983. /**
  110984. * Get the friendly name associated with the input class.
  110985. * @returns the input friendly name
  110986. */
  110987. getSimpleName(): string;
  110988. /**
  110989. * Called on pointer POINTERDOUBLETAP event.
  110990. * Override this method to provide functionality on POINTERDOUBLETAP event.
  110991. */
  110992. protected onDoubleTap(type: string): void;
  110993. /**
  110994. * Called on pointer POINTERMOVE event if only a single touch is active.
  110995. * Override this method to provide functionality.
  110996. */
  110997. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  110998. /**
  110999. * Called on pointer POINTERMOVE event if multiple touches are active.
  111000. * Override this method to provide functionality.
  111001. */
  111002. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111003. /**
  111004. * Called on JS contextmenu event.
  111005. * Override this method to provide functionality.
  111006. */
  111007. protected onContextMenu(evt: PointerEvent): void;
  111008. /**
  111009. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111010. * press.
  111011. * Override this method to provide functionality.
  111012. */
  111013. protected onButtonDown(evt: PointerEvent): void;
  111014. /**
  111015. * Called each time a new POINTERUP event occurs. Ie, for each button
  111016. * release.
  111017. * Override this method to provide functionality.
  111018. */
  111019. protected onButtonUp(evt: PointerEvent): void;
  111020. /**
  111021. * Called when window becomes inactive.
  111022. * Override this method to provide functionality.
  111023. */
  111024. protected onLostFocus(): void;
  111025. private _pointerInput;
  111026. private _observer;
  111027. private _onLostFocus;
  111028. private pointA;
  111029. private pointB;
  111030. }
  111031. }
  111032. declare module BABYLON {
  111033. /**
  111034. * Manage the pointers inputs to control an arc rotate camera.
  111035. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111036. */
  111037. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  111038. /**
  111039. * Defines the camera the input is attached to.
  111040. */
  111041. camera: ArcRotateCamera;
  111042. /**
  111043. * Gets the class name of the current input.
  111044. * @returns the class name
  111045. */
  111046. getClassName(): string;
  111047. /**
  111048. * Defines the buttons associated with the input to handle camera move.
  111049. */
  111050. buttons: number[];
  111051. /**
  111052. * Defines the pointer angular sensibility along the X axis or how fast is
  111053. * the camera rotating.
  111054. */
  111055. angularSensibilityX: number;
  111056. /**
  111057. * Defines the pointer angular sensibility along the Y axis or how fast is
  111058. * the camera rotating.
  111059. */
  111060. angularSensibilityY: number;
  111061. /**
  111062. * Defines the pointer pinch precision or how fast is the camera zooming.
  111063. */
  111064. pinchPrecision: number;
  111065. /**
  111066. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  111067. * from 0.
  111068. * It defines the percentage of current camera.radius to use as delta when
  111069. * pinch zoom is used.
  111070. */
  111071. pinchDeltaPercentage: number;
  111072. /**
  111073. * Defines the pointer panning sensibility or how fast is the camera moving.
  111074. */
  111075. panningSensibility: number;
  111076. /**
  111077. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  111078. */
  111079. multiTouchPanning: boolean;
  111080. /**
  111081. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  111082. * zoom (pinch) through multitouch.
  111083. */
  111084. multiTouchPanAndZoom: boolean;
  111085. /**
  111086. * Revers pinch action direction.
  111087. */
  111088. pinchInwards: boolean;
  111089. private _isPanClick;
  111090. private _twoFingerActivityCount;
  111091. private _isPinching;
  111092. /**
  111093. * Called on pointer POINTERMOVE event if only a single touch is active.
  111094. */
  111095. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111096. /**
  111097. * Called on pointer POINTERDOUBLETAP event.
  111098. */
  111099. protected onDoubleTap(type: string): void;
  111100. /**
  111101. * Called on pointer POINTERMOVE event if multiple touches are active.
  111102. */
  111103. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111104. /**
  111105. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111106. * press.
  111107. */
  111108. protected onButtonDown(evt: PointerEvent): void;
  111109. /**
  111110. * Called each time a new POINTERUP event occurs. Ie, for each button
  111111. * release.
  111112. */
  111113. protected onButtonUp(evt: PointerEvent): void;
  111114. /**
  111115. * Called when window becomes inactive.
  111116. */
  111117. protected onLostFocus(): void;
  111118. }
  111119. }
  111120. declare module BABYLON {
  111121. /**
  111122. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  111123. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111124. */
  111125. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  111126. /**
  111127. * Defines the camera the input is attached to.
  111128. */
  111129. camera: ArcRotateCamera;
  111130. /**
  111131. * Defines the list of key codes associated with the up action (increase alpha)
  111132. */
  111133. keysUp: number[];
  111134. /**
  111135. * Defines the list of key codes associated with the down action (decrease alpha)
  111136. */
  111137. keysDown: number[];
  111138. /**
  111139. * Defines the list of key codes associated with the left action (increase beta)
  111140. */
  111141. keysLeft: number[];
  111142. /**
  111143. * Defines the list of key codes associated with the right action (decrease beta)
  111144. */
  111145. keysRight: number[];
  111146. /**
  111147. * Defines the list of key codes associated with the reset action.
  111148. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  111149. */
  111150. keysReset: number[];
  111151. /**
  111152. * Defines the panning sensibility of the inputs.
  111153. * (How fast is the camera panning)
  111154. */
  111155. panningSensibility: number;
  111156. /**
  111157. * Defines the zooming sensibility of the inputs.
  111158. * (How fast is the camera zooming)
  111159. */
  111160. zoomingSensibility: number;
  111161. /**
  111162. * Defines whether maintaining the alt key down switch the movement mode from
  111163. * orientation to zoom.
  111164. */
  111165. useAltToZoom: boolean;
  111166. /**
  111167. * Rotation speed of the camera
  111168. */
  111169. angularSpeed: number;
  111170. private _keys;
  111171. private _ctrlPressed;
  111172. private _altPressed;
  111173. private _onCanvasBlurObserver;
  111174. private _onKeyboardObserver;
  111175. private _engine;
  111176. private _scene;
  111177. /**
  111178. * Attach the input controls to a specific dom element to get the input from.
  111179. * @param element Defines the element the controls should be listened from
  111180. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111181. */
  111182. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111183. /**
  111184. * Detach the current controls from the specified dom element.
  111185. * @param element Defines the element to stop listening the inputs from
  111186. */
  111187. detachControl(element: Nullable<HTMLElement>): void;
  111188. /**
  111189. * Update the current camera state depending on the inputs that have been used this frame.
  111190. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111191. */
  111192. checkInputs(): void;
  111193. /**
  111194. * Gets the class name of the current intput.
  111195. * @returns the class name
  111196. */
  111197. getClassName(): string;
  111198. /**
  111199. * Get the friendly name associated with the input class.
  111200. * @returns the input friendly name
  111201. */
  111202. getSimpleName(): string;
  111203. }
  111204. }
  111205. declare module BABYLON {
  111206. /**
  111207. * Manage the mouse wheel inputs to control an arc rotate camera.
  111208. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111209. */
  111210. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  111211. /**
  111212. * Defines the camera the input is attached to.
  111213. */
  111214. camera: ArcRotateCamera;
  111215. /**
  111216. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  111217. */
  111218. wheelPrecision: number;
  111219. /**
  111220. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  111221. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  111222. */
  111223. wheelDeltaPercentage: number;
  111224. private _wheel;
  111225. private _observer;
  111226. private computeDeltaFromMouseWheelLegacyEvent;
  111227. /**
  111228. * Attach the input controls to a specific dom element to get the input from.
  111229. * @param element Defines the element the controls should be listened from
  111230. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111231. */
  111232. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111233. /**
  111234. * Detach the current controls from the specified dom element.
  111235. * @param element Defines the element to stop listening the inputs from
  111236. */
  111237. detachControl(element: Nullable<HTMLElement>): void;
  111238. /**
  111239. * Gets the class name of the current intput.
  111240. * @returns the class name
  111241. */
  111242. getClassName(): string;
  111243. /**
  111244. * Get the friendly name associated with the input class.
  111245. * @returns the input friendly name
  111246. */
  111247. getSimpleName(): string;
  111248. }
  111249. }
  111250. declare module BABYLON {
  111251. /**
  111252. * Default Inputs manager for the ArcRotateCamera.
  111253. * It groups all the default supported inputs for ease of use.
  111254. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111255. */
  111256. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  111257. /**
  111258. * Instantiates a new ArcRotateCameraInputsManager.
  111259. * @param camera Defines the camera the inputs belong to
  111260. */
  111261. constructor(camera: ArcRotateCamera);
  111262. /**
  111263. * Add mouse wheel input support to the input manager.
  111264. * @returns the current input manager
  111265. */
  111266. addMouseWheel(): ArcRotateCameraInputsManager;
  111267. /**
  111268. * Add pointers input support to the input manager.
  111269. * @returns the current input manager
  111270. */
  111271. addPointers(): ArcRotateCameraInputsManager;
  111272. /**
  111273. * Add keyboard input support to the input manager.
  111274. * @returns the current input manager
  111275. */
  111276. addKeyboard(): ArcRotateCameraInputsManager;
  111277. }
  111278. }
  111279. declare module BABYLON {
  111280. /**
  111281. * This represents an orbital type of camera.
  111282. *
  111283. * 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.
  111284. * 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.
  111285. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  111286. */
  111287. export class ArcRotateCamera extends TargetCamera {
  111288. /**
  111289. * Defines the rotation angle of the camera along the longitudinal axis.
  111290. */
  111291. alpha: number;
  111292. /**
  111293. * Defines the rotation angle of the camera along the latitudinal axis.
  111294. */
  111295. beta: number;
  111296. /**
  111297. * Defines the radius of the camera from it s target point.
  111298. */
  111299. radius: number;
  111300. protected _target: Vector3;
  111301. protected _targetHost: Nullable<AbstractMesh>;
  111302. /**
  111303. * Defines the target point of the camera.
  111304. * The camera looks towards it form the radius distance.
  111305. */
  111306. get target(): Vector3;
  111307. set target(value: Vector3);
  111308. /**
  111309. * Define the current local position of the camera in the scene
  111310. */
  111311. get position(): Vector3;
  111312. set position(newPosition: Vector3);
  111313. protected _upVector: Vector3;
  111314. protected _upToYMatrix: Matrix;
  111315. protected _YToUpMatrix: Matrix;
  111316. /**
  111317. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  111318. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  111319. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  111320. */
  111321. set upVector(vec: Vector3);
  111322. get upVector(): Vector3;
  111323. /**
  111324. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  111325. */
  111326. setMatUp(): void;
  111327. /**
  111328. * Current inertia value on the longitudinal axis.
  111329. * The bigger this number the longer it will take for the camera to stop.
  111330. */
  111331. inertialAlphaOffset: number;
  111332. /**
  111333. * Current inertia value on the latitudinal axis.
  111334. * The bigger this number the longer it will take for the camera to stop.
  111335. */
  111336. inertialBetaOffset: number;
  111337. /**
  111338. * Current inertia value on the radius axis.
  111339. * The bigger this number the longer it will take for the camera to stop.
  111340. */
  111341. inertialRadiusOffset: number;
  111342. /**
  111343. * Minimum allowed angle on the longitudinal axis.
  111344. * This can help limiting how the Camera is able to move in the scene.
  111345. */
  111346. lowerAlphaLimit: Nullable<number>;
  111347. /**
  111348. * Maximum allowed angle on the longitudinal axis.
  111349. * This can help limiting how the Camera is able to move in the scene.
  111350. */
  111351. upperAlphaLimit: Nullable<number>;
  111352. /**
  111353. * Minimum allowed angle on the latitudinal axis.
  111354. * This can help limiting how the Camera is able to move in the scene.
  111355. */
  111356. lowerBetaLimit: number;
  111357. /**
  111358. * Maximum allowed angle on the latitudinal axis.
  111359. * This can help limiting how the Camera is able to move in the scene.
  111360. */
  111361. upperBetaLimit: number;
  111362. /**
  111363. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  111364. * This can help limiting how the Camera is able to move in the scene.
  111365. */
  111366. lowerRadiusLimit: Nullable<number>;
  111367. /**
  111368. * Maximum allowed distance of the camera to the target (The camera can not get further).
  111369. * This can help limiting how the Camera is able to move in the scene.
  111370. */
  111371. upperRadiusLimit: Nullable<number>;
  111372. /**
  111373. * Defines the current inertia value used during panning of the camera along the X axis.
  111374. */
  111375. inertialPanningX: number;
  111376. /**
  111377. * Defines the current inertia value used during panning of the camera along the Y axis.
  111378. */
  111379. inertialPanningY: number;
  111380. /**
  111381. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  111382. * Basically if your fingers moves away from more than this distance you will be considered
  111383. * in pinch mode.
  111384. */
  111385. pinchToPanMaxDistance: number;
  111386. /**
  111387. * Defines the maximum distance the camera can pan.
  111388. * This could help keeping the cammera always in your scene.
  111389. */
  111390. panningDistanceLimit: Nullable<number>;
  111391. /**
  111392. * Defines the target of the camera before paning.
  111393. */
  111394. panningOriginTarget: Vector3;
  111395. /**
  111396. * Defines the value of the inertia used during panning.
  111397. * 0 would mean stop inertia and one would mean no decelleration at all.
  111398. */
  111399. panningInertia: number;
  111400. /**
  111401. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  111402. */
  111403. get angularSensibilityX(): number;
  111404. set angularSensibilityX(value: number);
  111405. /**
  111406. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  111407. */
  111408. get angularSensibilityY(): number;
  111409. set angularSensibilityY(value: number);
  111410. /**
  111411. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  111412. */
  111413. get pinchPrecision(): number;
  111414. set pinchPrecision(value: number);
  111415. /**
  111416. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  111417. * It will be used instead of pinchDeltaPrecision if different from 0.
  111418. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  111419. */
  111420. get pinchDeltaPercentage(): number;
  111421. set pinchDeltaPercentage(value: number);
  111422. /**
  111423. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  111424. */
  111425. get panningSensibility(): number;
  111426. set panningSensibility(value: number);
  111427. /**
  111428. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  111429. */
  111430. get keysUp(): number[];
  111431. set keysUp(value: number[]);
  111432. /**
  111433. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  111434. */
  111435. get keysDown(): number[];
  111436. set keysDown(value: number[]);
  111437. /**
  111438. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  111439. */
  111440. get keysLeft(): number[];
  111441. set keysLeft(value: number[]);
  111442. /**
  111443. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  111444. */
  111445. get keysRight(): number[];
  111446. set keysRight(value: number[]);
  111447. /**
  111448. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  111449. */
  111450. get wheelPrecision(): number;
  111451. set wheelPrecision(value: number);
  111452. /**
  111453. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  111454. * It will be used instead of pinchDeltaPrecision if different from 0.
  111455. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  111456. */
  111457. get wheelDeltaPercentage(): number;
  111458. set wheelDeltaPercentage(value: number);
  111459. /**
  111460. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  111461. */
  111462. zoomOnFactor: number;
  111463. /**
  111464. * Defines a screen offset for the camera position.
  111465. */
  111466. targetScreenOffset: Vector2;
  111467. /**
  111468. * Allows the camera to be completely reversed.
  111469. * If false the camera can not arrive upside down.
  111470. */
  111471. allowUpsideDown: boolean;
  111472. /**
  111473. * Define if double tap/click is used to restore the previously saved state of the camera.
  111474. */
  111475. useInputToRestoreState: boolean;
  111476. /** @hidden */
  111477. _viewMatrix: Matrix;
  111478. /** @hidden */
  111479. _useCtrlForPanning: boolean;
  111480. /** @hidden */
  111481. _panningMouseButton: number;
  111482. /**
  111483. * Defines the input associated to the camera.
  111484. */
  111485. inputs: ArcRotateCameraInputsManager;
  111486. /** @hidden */
  111487. _reset: () => void;
  111488. /**
  111489. * Defines the allowed panning axis.
  111490. */
  111491. panningAxis: Vector3;
  111492. protected _localDirection: Vector3;
  111493. protected _transformedDirection: Vector3;
  111494. private _bouncingBehavior;
  111495. /**
  111496. * Gets the bouncing behavior of the camera if it has been enabled.
  111497. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111498. */
  111499. get bouncingBehavior(): Nullable<BouncingBehavior>;
  111500. /**
  111501. * Defines if the bouncing behavior of the camera is enabled on the camera.
  111502. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111503. */
  111504. get useBouncingBehavior(): boolean;
  111505. set useBouncingBehavior(value: boolean);
  111506. private _framingBehavior;
  111507. /**
  111508. * Gets the framing behavior of the camera if it has been enabled.
  111509. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111510. */
  111511. get framingBehavior(): Nullable<FramingBehavior>;
  111512. /**
  111513. * Defines if the framing behavior of the camera is enabled on the camera.
  111514. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111515. */
  111516. get useFramingBehavior(): boolean;
  111517. set useFramingBehavior(value: boolean);
  111518. private _autoRotationBehavior;
  111519. /**
  111520. * Gets the auto rotation behavior of the camera if it has been enabled.
  111521. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  111522. */
  111523. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  111524. /**
  111525. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  111526. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  111527. */
  111528. get useAutoRotationBehavior(): boolean;
  111529. set useAutoRotationBehavior(value: boolean);
  111530. /**
  111531. * Observable triggered when the mesh target has been changed on the camera.
  111532. */
  111533. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  111534. /**
  111535. * Event raised when the camera is colliding with a mesh.
  111536. */
  111537. onCollide: (collidedMesh: AbstractMesh) => void;
  111538. /**
  111539. * Defines whether the camera should check collision with the objects oh the scene.
  111540. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  111541. */
  111542. checkCollisions: boolean;
  111543. /**
  111544. * Defines the collision radius of the camera.
  111545. * This simulates a sphere around the camera.
  111546. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  111547. */
  111548. collisionRadius: Vector3;
  111549. protected _collider: Collider;
  111550. protected _previousPosition: Vector3;
  111551. protected _collisionVelocity: Vector3;
  111552. protected _newPosition: Vector3;
  111553. protected _previousAlpha: number;
  111554. protected _previousBeta: number;
  111555. protected _previousRadius: number;
  111556. protected _collisionTriggered: boolean;
  111557. protected _targetBoundingCenter: Nullable<Vector3>;
  111558. private _computationVector;
  111559. /**
  111560. * Instantiates a new ArcRotateCamera in a given scene
  111561. * @param name Defines the name of the camera
  111562. * @param alpha Defines the camera rotation along the logitudinal axis
  111563. * @param beta Defines the camera rotation along the latitudinal axis
  111564. * @param radius Defines the camera distance from its target
  111565. * @param target Defines the camera target
  111566. * @param scene Defines the scene the camera belongs to
  111567. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  111568. */
  111569. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  111570. /** @hidden */
  111571. _initCache(): void;
  111572. /** @hidden */
  111573. _updateCache(ignoreParentClass?: boolean): void;
  111574. protected _getTargetPosition(): Vector3;
  111575. private _storedAlpha;
  111576. private _storedBeta;
  111577. private _storedRadius;
  111578. private _storedTarget;
  111579. private _storedTargetScreenOffset;
  111580. /**
  111581. * Stores the current state of the camera (alpha, beta, radius and target)
  111582. * @returns the camera itself
  111583. */
  111584. storeState(): Camera;
  111585. /**
  111586. * @hidden
  111587. * Restored camera state. You must call storeState() first
  111588. */
  111589. _restoreStateValues(): boolean;
  111590. /** @hidden */
  111591. _isSynchronizedViewMatrix(): boolean;
  111592. /**
  111593. * Attached controls to the current camera.
  111594. * @param element Defines the element the controls should be listened from
  111595. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111596. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  111597. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  111598. */
  111599. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  111600. /**
  111601. * Detach the current controls from the camera.
  111602. * The camera will stop reacting to inputs.
  111603. * @param element Defines the element to stop listening the inputs from
  111604. */
  111605. detachControl(element: HTMLElement): void;
  111606. /** @hidden */
  111607. _checkInputs(): void;
  111608. protected _checkLimits(): void;
  111609. /**
  111610. * Rebuilds angles (alpha, beta) and radius from the give position and target
  111611. */
  111612. rebuildAnglesAndRadius(): void;
  111613. /**
  111614. * Use a position to define the current camera related information like alpha, beta and radius
  111615. * @param position Defines the position to set the camera at
  111616. */
  111617. setPosition(position: Vector3): void;
  111618. /**
  111619. * Defines the target the camera should look at.
  111620. * This will automatically adapt alpha beta and radius to fit within the new target.
  111621. * @param target Defines the new target as a Vector or a mesh
  111622. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  111623. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  111624. */
  111625. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  111626. /** @hidden */
  111627. _getViewMatrix(): Matrix;
  111628. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  111629. /**
  111630. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  111631. * @param meshes Defines the mesh to zoom on
  111632. * @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)
  111633. */
  111634. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  111635. /**
  111636. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  111637. * The target will be changed but the radius
  111638. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  111639. * @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)
  111640. */
  111641. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  111642. min: Vector3;
  111643. max: Vector3;
  111644. distance: number;
  111645. }, doNotUpdateMaxZ?: boolean): void;
  111646. /**
  111647. * @override
  111648. * Override Camera.createRigCamera
  111649. */
  111650. createRigCamera(name: string, cameraIndex: number): Camera;
  111651. /**
  111652. * @hidden
  111653. * @override
  111654. * Override Camera._updateRigCameras
  111655. */
  111656. _updateRigCameras(): void;
  111657. /**
  111658. * Destroy the camera and release the current resources hold by it.
  111659. */
  111660. dispose(): void;
  111661. /**
  111662. * Gets the current object class name.
  111663. * @return the class name
  111664. */
  111665. getClassName(): string;
  111666. }
  111667. }
  111668. declare module BABYLON {
  111669. /**
  111670. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  111671. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  111672. */
  111673. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  111674. /**
  111675. * Gets the name of the behavior.
  111676. */
  111677. get name(): string;
  111678. private _zoomStopsAnimation;
  111679. private _idleRotationSpeed;
  111680. private _idleRotationWaitTime;
  111681. private _idleRotationSpinupTime;
  111682. /**
  111683. * Sets the flag that indicates if user zooming should stop animation.
  111684. */
  111685. set zoomStopsAnimation(flag: boolean);
  111686. /**
  111687. * Gets the flag that indicates if user zooming should stop animation.
  111688. */
  111689. get zoomStopsAnimation(): boolean;
  111690. /**
  111691. * Sets the default speed at which the camera rotates around the model.
  111692. */
  111693. set idleRotationSpeed(speed: number);
  111694. /**
  111695. * Gets the default speed at which the camera rotates around the model.
  111696. */
  111697. get idleRotationSpeed(): number;
  111698. /**
  111699. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  111700. */
  111701. set idleRotationWaitTime(time: number);
  111702. /**
  111703. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  111704. */
  111705. get idleRotationWaitTime(): number;
  111706. /**
  111707. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  111708. */
  111709. set idleRotationSpinupTime(time: number);
  111710. /**
  111711. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  111712. */
  111713. get idleRotationSpinupTime(): number;
  111714. /**
  111715. * Gets a value indicating if the camera is currently rotating because of this behavior
  111716. */
  111717. get rotationInProgress(): boolean;
  111718. private _onPrePointerObservableObserver;
  111719. private _onAfterCheckInputsObserver;
  111720. private _attachedCamera;
  111721. private _isPointerDown;
  111722. private _lastFrameTime;
  111723. private _lastInteractionTime;
  111724. private _cameraRotationSpeed;
  111725. /**
  111726. * Initializes the behavior.
  111727. */
  111728. init(): void;
  111729. /**
  111730. * Attaches the behavior to its arc rotate camera.
  111731. * @param camera Defines the camera to attach the behavior to
  111732. */
  111733. attach(camera: ArcRotateCamera): void;
  111734. /**
  111735. * Detaches the behavior from its current arc rotate camera.
  111736. */
  111737. detach(): void;
  111738. /**
  111739. * Returns true if user is scrolling.
  111740. * @return true if user is scrolling.
  111741. */
  111742. private _userIsZooming;
  111743. private _lastFrameRadius;
  111744. private _shouldAnimationStopForInteraction;
  111745. /**
  111746. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  111747. */
  111748. private _applyUserInteraction;
  111749. private _userIsMoving;
  111750. }
  111751. }
  111752. declare module BABYLON {
  111753. /**
  111754. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  111755. */
  111756. export class AttachToBoxBehavior implements Behavior<Mesh> {
  111757. private ui;
  111758. /**
  111759. * The name of the behavior
  111760. */
  111761. name: string;
  111762. /**
  111763. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  111764. */
  111765. distanceAwayFromFace: number;
  111766. /**
  111767. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  111768. */
  111769. distanceAwayFromBottomOfFace: number;
  111770. private _faceVectors;
  111771. private _target;
  111772. private _scene;
  111773. private _onRenderObserver;
  111774. private _tmpMatrix;
  111775. private _tmpVector;
  111776. /**
  111777. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  111778. * @param ui The transform node that should be attched to the mesh
  111779. */
  111780. constructor(ui: TransformNode);
  111781. /**
  111782. * Initializes the behavior
  111783. */
  111784. init(): void;
  111785. private _closestFace;
  111786. private _zeroVector;
  111787. private _lookAtTmpMatrix;
  111788. private _lookAtToRef;
  111789. /**
  111790. * Attaches the AttachToBoxBehavior to the passed in mesh
  111791. * @param target The mesh that the specified node will be attached to
  111792. */
  111793. attach(target: Mesh): void;
  111794. /**
  111795. * Detaches the behavior from the mesh
  111796. */
  111797. detach(): void;
  111798. }
  111799. }
  111800. declare module BABYLON {
  111801. /**
  111802. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  111803. */
  111804. export class FadeInOutBehavior implements Behavior<Mesh> {
  111805. /**
  111806. * Time in milliseconds to delay before fading in (Default: 0)
  111807. */
  111808. delay: number;
  111809. /**
  111810. * Time in milliseconds for the mesh to fade in (Default: 300)
  111811. */
  111812. fadeInTime: number;
  111813. private _millisecondsPerFrame;
  111814. private _hovered;
  111815. private _hoverValue;
  111816. private _ownerNode;
  111817. /**
  111818. * Instatiates the FadeInOutBehavior
  111819. */
  111820. constructor();
  111821. /**
  111822. * The name of the behavior
  111823. */
  111824. get name(): string;
  111825. /**
  111826. * Initializes the behavior
  111827. */
  111828. init(): void;
  111829. /**
  111830. * Attaches the fade behavior on the passed in mesh
  111831. * @param ownerNode The mesh that will be faded in/out once attached
  111832. */
  111833. attach(ownerNode: Mesh): void;
  111834. /**
  111835. * Detaches the behavior from the mesh
  111836. */
  111837. detach(): void;
  111838. /**
  111839. * Triggers the mesh to begin fading in or out
  111840. * @param value if the object should fade in or out (true to fade in)
  111841. */
  111842. fadeIn(value: boolean): void;
  111843. private _update;
  111844. private _setAllVisibility;
  111845. }
  111846. }
  111847. declare module BABYLON {
  111848. /**
  111849. * Class containing a set of static utilities functions for managing Pivots
  111850. * @hidden
  111851. */
  111852. export class PivotTools {
  111853. private static _PivotCached;
  111854. private static _OldPivotPoint;
  111855. private static _PivotTranslation;
  111856. private static _PivotTmpVector;
  111857. /** @hidden */
  111858. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  111859. /** @hidden */
  111860. static _RestorePivotPoint(mesh: AbstractMesh): void;
  111861. }
  111862. }
  111863. declare module BABYLON {
  111864. /**
  111865. * Class containing static functions to help procedurally build meshes
  111866. */
  111867. export class PlaneBuilder {
  111868. /**
  111869. * Creates a plane mesh
  111870. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  111871. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  111872. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  111873. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111874. * * 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
  111875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111876. * @param name defines the name of the mesh
  111877. * @param options defines the options used to create the mesh
  111878. * @param scene defines the hosting scene
  111879. * @returns the plane mesh
  111880. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  111881. */
  111882. static CreatePlane(name: string, options: {
  111883. size?: number;
  111884. width?: number;
  111885. height?: number;
  111886. sideOrientation?: number;
  111887. frontUVs?: Vector4;
  111888. backUVs?: Vector4;
  111889. updatable?: boolean;
  111890. sourcePlane?: Plane;
  111891. }, scene?: Nullable<Scene>): Mesh;
  111892. }
  111893. }
  111894. declare module BABYLON {
  111895. /**
  111896. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  111897. */
  111898. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  111899. private static _AnyMouseID;
  111900. /**
  111901. * Abstract mesh the behavior is set on
  111902. */
  111903. attachedNode: AbstractMesh;
  111904. private _dragPlane;
  111905. private _scene;
  111906. private _pointerObserver;
  111907. private _beforeRenderObserver;
  111908. private static _planeScene;
  111909. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  111910. /**
  111911. * 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)
  111912. */
  111913. maxDragAngle: number;
  111914. /**
  111915. * @hidden
  111916. */
  111917. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  111918. /**
  111919. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  111920. */
  111921. currentDraggingPointerID: number;
  111922. /**
  111923. * The last position where the pointer hit the drag plane in world space
  111924. */
  111925. lastDragPosition: Vector3;
  111926. /**
  111927. * If the behavior is currently in a dragging state
  111928. */
  111929. dragging: boolean;
  111930. /**
  111931. * 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)
  111932. */
  111933. dragDeltaRatio: number;
  111934. /**
  111935. * If the drag plane orientation should be updated during the dragging (Default: true)
  111936. */
  111937. updateDragPlane: boolean;
  111938. private _debugMode;
  111939. private _moving;
  111940. /**
  111941. * Fires each time the attached mesh is dragged with the pointer
  111942. * * delta between last drag position and current drag position in world space
  111943. * * dragDistance along the drag axis
  111944. * * dragPlaneNormal normal of the current drag plane used during the drag
  111945. * * dragPlanePoint in world space where the drag intersects the drag plane
  111946. */
  111947. onDragObservable: Observable<{
  111948. delta: Vector3;
  111949. dragPlanePoint: Vector3;
  111950. dragPlaneNormal: Vector3;
  111951. dragDistance: number;
  111952. pointerId: number;
  111953. }>;
  111954. /**
  111955. * Fires each time a drag begins (eg. mouse down on mesh)
  111956. */
  111957. onDragStartObservable: Observable<{
  111958. dragPlanePoint: Vector3;
  111959. pointerId: number;
  111960. }>;
  111961. /**
  111962. * Fires each time a drag ends (eg. mouse release after drag)
  111963. */
  111964. onDragEndObservable: Observable<{
  111965. dragPlanePoint: Vector3;
  111966. pointerId: number;
  111967. }>;
  111968. /**
  111969. * If the attached mesh should be moved when dragged
  111970. */
  111971. moveAttached: boolean;
  111972. /**
  111973. * If the drag behavior will react to drag events (Default: true)
  111974. */
  111975. enabled: boolean;
  111976. /**
  111977. * If pointer events should start and release the drag (Default: true)
  111978. */
  111979. startAndReleaseDragOnPointerEvents: boolean;
  111980. /**
  111981. * If camera controls should be detached during the drag
  111982. */
  111983. detachCameraControls: boolean;
  111984. /**
  111985. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  111986. */
  111987. useObjectOrientationForDragging: boolean;
  111988. private _options;
  111989. /**
  111990. * Gets the options used by the behavior
  111991. */
  111992. get options(): {
  111993. dragAxis?: Vector3;
  111994. dragPlaneNormal?: Vector3;
  111995. };
  111996. /**
  111997. * Sets the options used by the behavior
  111998. */
  111999. set options(options: {
  112000. dragAxis?: Vector3;
  112001. dragPlaneNormal?: Vector3;
  112002. });
  112003. /**
  112004. * Creates a pointer drag behavior that can be attached to a mesh
  112005. * @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)
  112006. */
  112007. constructor(options?: {
  112008. dragAxis?: Vector3;
  112009. dragPlaneNormal?: Vector3;
  112010. });
  112011. /**
  112012. * Predicate to determine if it is valid to move the object to a new position when it is moved
  112013. */
  112014. validateDrag: (targetPosition: Vector3) => boolean;
  112015. /**
  112016. * The name of the behavior
  112017. */
  112018. get name(): string;
  112019. /**
  112020. * Initializes the behavior
  112021. */
  112022. init(): void;
  112023. private _tmpVector;
  112024. private _alternatePickedPoint;
  112025. private _worldDragAxis;
  112026. private _targetPosition;
  112027. private _attachedElement;
  112028. /**
  112029. * Attaches the drag behavior the passed in mesh
  112030. * @param ownerNode The mesh that will be dragged around once attached
  112031. * @param predicate Predicate to use for pick filtering
  112032. */
  112033. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  112034. /**
  112035. * Force relase the drag action by code.
  112036. */
  112037. releaseDrag(): void;
  112038. private _startDragRay;
  112039. private _lastPointerRay;
  112040. /**
  112041. * Simulates the start of a pointer drag event on the behavior
  112042. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  112043. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  112044. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  112045. */
  112046. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  112047. private _startDrag;
  112048. private _dragDelta;
  112049. private _moveDrag;
  112050. private _pickWithRayOnDragPlane;
  112051. private _pointA;
  112052. private _pointB;
  112053. private _pointC;
  112054. private _lineA;
  112055. private _lineB;
  112056. private _localAxis;
  112057. private _lookAt;
  112058. private _updateDragPlanePosition;
  112059. /**
  112060. * Detaches the behavior from the mesh
  112061. */
  112062. detach(): void;
  112063. }
  112064. }
  112065. declare module BABYLON {
  112066. /**
  112067. * A behavior that when attached to a mesh will allow the mesh to be scaled
  112068. */
  112069. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  112070. private _dragBehaviorA;
  112071. private _dragBehaviorB;
  112072. private _startDistance;
  112073. private _initialScale;
  112074. private _targetScale;
  112075. private _ownerNode;
  112076. private _sceneRenderObserver;
  112077. /**
  112078. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  112079. */
  112080. constructor();
  112081. /**
  112082. * The name of the behavior
  112083. */
  112084. get name(): string;
  112085. /**
  112086. * Initializes the behavior
  112087. */
  112088. init(): void;
  112089. private _getCurrentDistance;
  112090. /**
  112091. * Attaches the scale behavior the passed in mesh
  112092. * @param ownerNode The mesh that will be scaled around once attached
  112093. */
  112094. attach(ownerNode: Mesh): void;
  112095. /**
  112096. * Detaches the behavior from the mesh
  112097. */
  112098. detach(): void;
  112099. }
  112100. }
  112101. declare module BABYLON {
  112102. /**
  112103. * 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
  112104. */
  112105. export class SixDofDragBehavior implements Behavior<Mesh> {
  112106. private static _virtualScene;
  112107. private _ownerNode;
  112108. private _sceneRenderObserver;
  112109. private _scene;
  112110. private _targetPosition;
  112111. private _virtualOriginMesh;
  112112. private _virtualDragMesh;
  112113. private _pointerObserver;
  112114. private _moving;
  112115. private _startingOrientation;
  112116. /**
  112117. * 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)
  112118. */
  112119. private zDragFactor;
  112120. /**
  112121. * If the object should rotate to face the drag origin
  112122. */
  112123. rotateDraggedObject: boolean;
  112124. /**
  112125. * If the behavior is currently in a dragging state
  112126. */
  112127. dragging: boolean;
  112128. /**
  112129. * 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)
  112130. */
  112131. dragDeltaRatio: number;
  112132. /**
  112133. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112134. */
  112135. currentDraggingPointerID: number;
  112136. /**
  112137. * If camera controls should be detached during the drag
  112138. */
  112139. detachCameraControls: boolean;
  112140. /**
  112141. * Fires each time a drag starts
  112142. */
  112143. onDragStartObservable: Observable<{}>;
  112144. /**
  112145. * Fires each time a drag ends (eg. mouse release after drag)
  112146. */
  112147. onDragEndObservable: Observable<{}>;
  112148. /**
  112149. * 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
  112150. */
  112151. constructor();
  112152. /**
  112153. * The name of the behavior
  112154. */
  112155. get name(): string;
  112156. /**
  112157. * Initializes the behavior
  112158. */
  112159. init(): void;
  112160. /**
  112161. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  112162. */
  112163. private get _pointerCamera();
  112164. /**
  112165. * Attaches the scale behavior the passed in mesh
  112166. * @param ownerNode The mesh that will be scaled around once attached
  112167. */
  112168. attach(ownerNode: Mesh): void;
  112169. /**
  112170. * Detaches the behavior from the mesh
  112171. */
  112172. detach(): void;
  112173. }
  112174. }
  112175. declare module BABYLON {
  112176. /**
  112177. * Class used to apply inverse kinematics to bones
  112178. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  112179. */
  112180. export class BoneIKController {
  112181. private static _tmpVecs;
  112182. private static _tmpQuat;
  112183. private static _tmpMats;
  112184. /**
  112185. * Gets or sets the target mesh
  112186. */
  112187. targetMesh: AbstractMesh;
  112188. /** Gets or sets the mesh used as pole */
  112189. poleTargetMesh: AbstractMesh;
  112190. /**
  112191. * Gets or sets the bone used as pole
  112192. */
  112193. poleTargetBone: Nullable<Bone>;
  112194. /**
  112195. * Gets or sets the target position
  112196. */
  112197. targetPosition: Vector3;
  112198. /**
  112199. * Gets or sets the pole target position
  112200. */
  112201. poleTargetPosition: Vector3;
  112202. /**
  112203. * Gets or sets the pole target local offset
  112204. */
  112205. poleTargetLocalOffset: Vector3;
  112206. /**
  112207. * Gets or sets the pole angle
  112208. */
  112209. poleAngle: number;
  112210. /**
  112211. * Gets or sets the mesh associated with the controller
  112212. */
  112213. mesh: AbstractMesh;
  112214. /**
  112215. * 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)
  112216. */
  112217. slerpAmount: number;
  112218. private _bone1Quat;
  112219. private _bone1Mat;
  112220. private _bone2Ang;
  112221. private _bone1;
  112222. private _bone2;
  112223. private _bone1Length;
  112224. private _bone2Length;
  112225. private _maxAngle;
  112226. private _maxReach;
  112227. private _rightHandedSystem;
  112228. private _bendAxis;
  112229. private _slerping;
  112230. private _adjustRoll;
  112231. /**
  112232. * Gets or sets maximum allowed angle
  112233. */
  112234. get maxAngle(): number;
  112235. set maxAngle(value: number);
  112236. /**
  112237. * Creates a new BoneIKController
  112238. * @param mesh defines the mesh to control
  112239. * @param bone defines the bone to control
  112240. * @param options defines options to set up the controller
  112241. */
  112242. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  112243. targetMesh?: AbstractMesh;
  112244. poleTargetMesh?: AbstractMesh;
  112245. poleTargetBone?: Bone;
  112246. poleTargetLocalOffset?: Vector3;
  112247. poleAngle?: number;
  112248. bendAxis?: Vector3;
  112249. maxAngle?: number;
  112250. slerpAmount?: number;
  112251. });
  112252. private _setMaxAngle;
  112253. /**
  112254. * Force the controller to update the bones
  112255. */
  112256. update(): void;
  112257. }
  112258. }
  112259. declare module BABYLON {
  112260. /**
  112261. * Class used to make a bone look toward a point in space
  112262. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  112263. */
  112264. export class BoneLookController {
  112265. private static _tmpVecs;
  112266. private static _tmpQuat;
  112267. private static _tmpMats;
  112268. /**
  112269. * The target Vector3 that the bone will look at
  112270. */
  112271. target: Vector3;
  112272. /**
  112273. * The mesh that the bone is attached to
  112274. */
  112275. mesh: AbstractMesh;
  112276. /**
  112277. * The bone that will be looking to the target
  112278. */
  112279. bone: Bone;
  112280. /**
  112281. * The up axis of the coordinate system that is used when the bone is rotated
  112282. */
  112283. upAxis: Vector3;
  112284. /**
  112285. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  112286. */
  112287. upAxisSpace: Space;
  112288. /**
  112289. * Used to make an adjustment to the yaw of the bone
  112290. */
  112291. adjustYaw: number;
  112292. /**
  112293. * Used to make an adjustment to the pitch of the bone
  112294. */
  112295. adjustPitch: number;
  112296. /**
  112297. * Used to make an adjustment to the roll of the bone
  112298. */
  112299. adjustRoll: number;
  112300. /**
  112301. * 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)
  112302. */
  112303. slerpAmount: number;
  112304. private _minYaw;
  112305. private _maxYaw;
  112306. private _minPitch;
  112307. private _maxPitch;
  112308. private _minYawSin;
  112309. private _minYawCos;
  112310. private _maxYawSin;
  112311. private _maxYawCos;
  112312. private _midYawConstraint;
  112313. private _minPitchTan;
  112314. private _maxPitchTan;
  112315. private _boneQuat;
  112316. private _slerping;
  112317. private _transformYawPitch;
  112318. private _transformYawPitchInv;
  112319. private _firstFrameSkipped;
  112320. private _yawRange;
  112321. private _fowardAxis;
  112322. /**
  112323. * Gets or sets the minimum yaw angle that the bone can look to
  112324. */
  112325. get minYaw(): number;
  112326. set minYaw(value: number);
  112327. /**
  112328. * Gets or sets the maximum yaw angle that the bone can look to
  112329. */
  112330. get maxYaw(): number;
  112331. set maxYaw(value: number);
  112332. /**
  112333. * Gets or sets the minimum pitch angle that the bone can look to
  112334. */
  112335. get minPitch(): number;
  112336. set minPitch(value: number);
  112337. /**
  112338. * Gets or sets the maximum pitch angle that the bone can look to
  112339. */
  112340. get maxPitch(): number;
  112341. set maxPitch(value: number);
  112342. /**
  112343. * Create a BoneLookController
  112344. * @param mesh the mesh that the bone belongs to
  112345. * @param bone the bone that will be looking to the target
  112346. * @param target the target Vector3 to look at
  112347. * @param options optional settings:
  112348. * * maxYaw: the maximum angle the bone will yaw to
  112349. * * minYaw: the minimum angle the bone will yaw to
  112350. * * maxPitch: the maximum angle the bone will pitch to
  112351. * * minPitch: the minimum angle the bone will yaw to
  112352. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  112353. * * upAxis: the up axis of the coordinate system
  112354. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  112355. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  112356. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  112357. * * adjustYaw: used to make an adjustment to the yaw of the bone
  112358. * * adjustPitch: used to make an adjustment to the pitch of the bone
  112359. * * adjustRoll: used to make an adjustment to the roll of the bone
  112360. **/
  112361. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  112362. maxYaw?: number;
  112363. minYaw?: number;
  112364. maxPitch?: number;
  112365. minPitch?: number;
  112366. slerpAmount?: number;
  112367. upAxis?: Vector3;
  112368. upAxisSpace?: Space;
  112369. yawAxis?: Vector3;
  112370. pitchAxis?: Vector3;
  112371. adjustYaw?: number;
  112372. adjustPitch?: number;
  112373. adjustRoll?: number;
  112374. });
  112375. /**
  112376. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  112377. */
  112378. update(): void;
  112379. private _getAngleDiff;
  112380. private _getAngleBetween;
  112381. private _isAngleBetween;
  112382. }
  112383. }
  112384. declare module BABYLON {
  112385. /**
  112386. * Manage the gamepad inputs to control an arc rotate camera.
  112387. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112388. */
  112389. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  112390. /**
  112391. * Defines the camera the input is attached to.
  112392. */
  112393. camera: ArcRotateCamera;
  112394. /**
  112395. * Defines the gamepad the input is gathering event from.
  112396. */
  112397. gamepad: Nullable<Gamepad>;
  112398. /**
  112399. * Defines the gamepad rotation sensiblity.
  112400. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  112401. */
  112402. gamepadRotationSensibility: number;
  112403. /**
  112404. * Defines the gamepad move sensiblity.
  112405. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  112406. */
  112407. gamepadMoveSensibility: number;
  112408. private _yAxisScale;
  112409. /**
  112410. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  112411. */
  112412. get invertYAxis(): boolean;
  112413. set invertYAxis(value: boolean);
  112414. private _onGamepadConnectedObserver;
  112415. private _onGamepadDisconnectedObserver;
  112416. /**
  112417. * Attach the input controls to a specific dom element to get the input from.
  112418. * @param element Defines the element the controls should be listened from
  112419. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112420. */
  112421. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112422. /**
  112423. * Detach the current controls from the specified dom element.
  112424. * @param element Defines the element to stop listening the inputs from
  112425. */
  112426. detachControl(element: Nullable<HTMLElement>): void;
  112427. /**
  112428. * Update the current camera state depending on the inputs that have been used this frame.
  112429. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112430. */
  112431. checkInputs(): void;
  112432. /**
  112433. * Gets the class name of the current intput.
  112434. * @returns the class name
  112435. */
  112436. getClassName(): string;
  112437. /**
  112438. * Get the friendly name associated with the input class.
  112439. * @returns the input friendly name
  112440. */
  112441. getSimpleName(): string;
  112442. }
  112443. }
  112444. declare module BABYLON {
  112445. interface ArcRotateCameraInputsManager {
  112446. /**
  112447. * Add orientation input support to the input manager.
  112448. * @returns the current input manager
  112449. */
  112450. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  112451. }
  112452. /**
  112453. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  112454. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112455. */
  112456. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  112457. /**
  112458. * Defines the camera the input is attached to.
  112459. */
  112460. camera: ArcRotateCamera;
  112461. /**
  112462. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  112463. */
  112464. alphaCorrection: number;
  112465. /**
  112466. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  112467. */
  112468. gammaCorrection: number;
  112469. private _alpha;
  112470. private _gamma;
  112471. private _dirty;
  112472. private _deviceOrientationHandler;
  112473. /**
  112474. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  112475. */
  112476. constructor();
  112477. /**
  112478. * Attach the input controls to a specific dom element to get the input from.
  112479. * @param element Defines the element the controls should be listened from
  112480. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112481. */
  112482. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112483. /** @hidden */
  112484. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  112485. /**
  112486. * Update the current camera state depending on the inputs that have been used this frame.
  112487. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112488. */
  112489. checkInputs(): void;
  112490. /**
  112491. * Detach the current controls from the specified dom element.
  112492. * @param element Defines the element to stop listening the inputs from
  112493. */
  112494. detachControl(element: Nullable<HTMLElement>): void;
  112495. /**
  112496. * Gets the class name of the current intput.
  112497. * @returns the class name
  112498. */
  112499. getClassName(): string;
  112500. /**
  112501. * Get the friendly name associated with the input class.
  112502. * @returns the input friendly name
  112503. */
  112504. getSimpleName(): string;
  112505. }
  112506. }
  112507. declare module BABYLON {
  112508. /**
  112509. * Listen to mouse events to control the camera.
  112510. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112511. */
  112512. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  112513. /**
  112514. * Defines the camera the input is attached to.
  112515. */
  112516. camera: FlyCamera;
  112517. /**
  112518. * Defines if touch is enabled. (Default is true.)
  112519. */
  112520. touchEnabled: boolean;
  112521. /**
  112522. * Defines the buttons associated with the input to handle camera rotation.
  112523. */
  112524. buttons: number[];
  112525. /**
  112526. * Assign buttons for Yaw control.
  112527. */
  112528. buttonsYaw: number[];
  112529. /**
  112530. * Assign buttons for Pitch control.
  112531. */
  112532. buttonsPitch: number[];
  112533. /**
  112534. * Assign buttons for Roll control.
  112535. */
  112536. buttonsRoll: number[];
  112537. /**
  112538. * Detect if any button is being pressed while mouse is moved.
  112539. * -1 = Mouse locked.
  112540. * 0 = Left button.
  112541. * 1 = Middle Button.
  112542. * 2 = Right Button.
  112543. */
  112544. activeButton: number;
  112545. /**
  112546. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  112547. * Higher values reduce its sensitivity.
  112548. */
  112549. angularSensibility: number;
  112550. private _mousemoveCallback;
  112551. private _observer;
  112552. private _rollObserver;
  112553. private previousPosition;
  112554. private noPreventDefault;
  112555. private element;
  112556. /**
  112557. * Listen to mouse events to control the camera.
  112558. * @param touchEnabled Define if touch is enabled. (Default is true.)
  112559. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112560. */
  112561. constructor(touchEnabled?: boolean);
  112562. /**
  112563. * Attach the mouse control to the HTML DOM element.
  112564. * @param element Defines the element that listens to the input events.
  112565. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  112566. */
  112567. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112568. /**
  112569. * Detach the current controls from the specified dom element.
  112570. * @param element Defines the element to stop listening the inputs from
  112571. */
  112572. detachControl(element: Nullable<HTMLElement>): void;
  112573. /**
  112574. * Gets the class name of the current input.
  112575. * @returns the class name.
  112576. */
  112577. getClassName(): string;
  112578. /**
  112579. * Get the friendly name associated with the input class.
  112580. * @returns the input's friendly name.
  112581. */
  112582. getSimpleName(): string;
  112583. private _pointerInput;
  112584. private _onMouseMove;
  112585. /**
  112586. * Rotate camera by mouse offset.
  112587. */
  112588. private rotateCamera;
  112589. }
  112590. }
  112591. declare module BABYLON {
  112592. /**
  112593. * Default Inputs manager for the FlyCamera.
  112594. * It groups all the default supported inputs for ease of use.
  112595. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112596. */
  112597. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  112598. /**
  112599. * Instantiates a new FlyCameraInputsManager.
  112600. * @param camera Defines the camera the inputs belong to.
  112601. */
  112602. constructor(camera: FlyCamera);
  112603. /**
  112604. * Add keyboard input support to the input manager.
  112605. * @returns the new FlyCameraKeyboardMoveInput().
  112606. */
  112607. addKeyboard(): FlyCameraInputsManager;
  112608. /**
  112609. * Add mouse input support to the input manager.
  112610. * @param touchEnabled Enable touch screen support.
  112611. * @returns the new FlyCameraMouseInput().
  112612. */
  112613. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  112614. }
  112615. }
  112616. declare module BABYLON {
  112617. /**
  112618. * This is a flying camera, designed for 3D movement and rotation in all directions,
  112619. * such as in a 3D Space Shooter or a Flight Simulator.
  112620. */
  112621. export class FlyCamera extends TargetCamera {
  112622. /**
  112623. * Define the collision ellipsoid of the camera.
  112624. * This is helpful for simulating a camera body, like a player's body.
  112625. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  112626. */
  112627. ellipsoid: Vector3;
  112628. /**
  112629. * Define an offset for the position of the ellipsoid around the camera.
  112630. * This can be helpful if the camera is attached away from the player's body center,
  112631. * such as at its head.
  112632. */
  112633. ellipsoidOffset: Vector3;
  112634. /**
  112635. * Enable or disable collisions of the camera with the rest of the scene objects.
  112636. */
  112637. checkCollisions: boolean;
  112638. /**
  112639. * Enable or disable gravity on the camera.
  112640. */
  112641. applyGravity: boolean;
  112642. /**
  112643. * Define the current direction the camera is moving to.
  112644. */
  112645. cameraDirection: Vector3;
  112646. /**
  112647. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  112648. * This overrides and empties cameraRotation.
  112649. */
  112650. rotationQuaternion: Quaternion;
  112651. /**
  112652. * Track Roll to maintain the wanted Rolling when looking around.
  112653. */
  112654. _trackRoll: number;
  112655. /**
  112656. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  112657. */
  112658. rollCorrect: number;
  112659. /**
  112660. * Mimic a banked turn, Rolling the camera when Yawing.
  112661. * It's recommended to use rollCorrect = 10 for faster banking correction.
  112662. */
  112663. bankedTurn: boolean;
  112664. /**
  112665. * Limit in radians for how much Roll banking will add. (Default: 90°)
  112666. */
  112667. bankedTurnLimit: number;
  112668. /**
  112669. * Value of 0 disables the banked Roll.
  112670. * Value of 1 is equal to the Yaw angle in radians.
  112671. */
  112672. bankedTurnMultiplier: number;
  112673. /**
  112674. * The inputs manager loads all the input sources, such as keyboard and mouse.
  112675. */
  112676. inputs: FlyCameraInputsManager;
  112677. /**
  112678. * Gets the input sensibility for mouse input.
  112679. * Higher values reduce sensitivity.
  112680. */
  112681. get angularSensibility(): number;
  112682. /**
  112683. * Sets the input sensibility for a mouse input.
  112684. * Higher values reduce sensitivity.
  112685. */
  112686. set angularSensibility(value: number);
  112687. /**
  112688. * Get the keys for camera movement forward.
  112689. */
  112690. get keysForward(): number[];
  112691. /**
  112692. * Set the keys for camera movement forward.
  112693. */
  112694. set keysForward(value: number[]);
  112695. /**
  112696. * Get the keys for camera movement backward.
  112697. */
  112698. get keysBackward(): number[];
  112699. set keysBackward(value: number[]);
  112700. /**
  112701. * Get the keys for camera movement up.
  112702. */
  112703. get keysUp(): number[];
  112704. /**
  112705. * Set the keys for camera movement up.
  112706. */
  112707. set keysUp(value: number[]);
  112708. /**
  112709. * Get the keys for camera movement down.
  112710. */
  112711. get keysDown(): number[];
  112712. /**
  112713. * Set the keys for camera movement down.
  112714. */
  112715. set keysDown(value: number[]);
  112716. /**
  112717. * Get the keys for camera movement left.
  112718. */
  112719. get keysLeft(): number[];
  112720. /**
  112721. * Set the keys for camera movement left.
  112722. */
  112723. set keysLeft(value: number[]);
  112724. /**
  112725. * Set the keys for camera movement right.
  112726. */
  112727. get keysRight(): number[];
  112728. /**
  112729. * Set the keys for camera movement right.
  112730. */
  112731. set keysRight(value: number[]);
  112732. /**
  112733. * Event raised when the camera collides with a mesh in the scene.
  112734. */
  112735. onCollide: (collidedMesh: AbstractMesh) => void;
  112736. private _collider;
  112737. private _needMoveForGravity;
  112738. private _oldPosition;
  112739. private _diffPosition;
  112740. private _newPosition;
  112741. /** @hidden */
  112742. _localDirection: Vector3;
  112743. /** @hidden */
  112744. _transformedDirection: Vector3;
  112745. /**
  112746. * Instantiates a FlyCamera.
  112747. * This is a flying camera, designed for 3D movement and rotation in all directions,
  112748. * such as in a 3D Space Shooter or a Flight Simulator.
  112749. * @param name Define the name of the camera in the scene.
  112750. * @param position Define the starting position of the camera in the scene.
  112751. * @param scene Define the scene the camera belongs to.
  112752. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  112753. */
  112754. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  112755. /**
  112756. * Attach a control to the HTML DOM element.
  112757. * @param element Defines the element that listens to the input events.
  112758. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  112759. */
  112760. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112761. /**
  112762. * Detach a control from the HTML DOM element.
  112763. * The camera will stop reacting to that input.
  112764. * @param element Defines the element that listens to the input events.
  112765. */
  112766. detachControl(element: HTMLElement): void;
  112767. private _collisionMask;
  112768. /**
  112769. * Get the mask that the camera ignores in collision events.
  112770. */
  112771. get collisionMask(): number;
  112772. /**
  112773. * Set the mask that the camera ignores in collision events.
  112774. */
  112775. set collisionMask(mask: number);
  112776. /** @hidden */
  112777. _collideWithWorld(displacement: Vector3): void;
  112778. /** @hidden */
  112779. private _onCollisionPositionChange;
  112780. /** @hidden */
  112781. _checkInputs(): void;
  112782. /** @hidden */
  112783. _decideIfNeedsToMove(): boolean;
  112784. /** @hidden */
  112785. _updatePosition(): void;
  112786. /**
  112787. * Restore the Roll to its target value at the rate specified.
  112788. * @param rate - Higher means slower restoring.
  112789. * @hidden
  112790. */
  112791. restoreRoll(rate: number): void;
  112792. /**
  112793. * Destroy the camera and release the current resources held by it.
  112794. */
  112795. dispose(): void;
  112796. /**
  112797. * Get the current object class name.
  112798. * @returns the class name.
  112799. */
  112800. getClassName(): string;
  112801. }
  112802. }
  112803. declare module BABYLON {
  112804. /**
  112805. * Listen to keyboard events to control the camera.
  112806. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112807. */
  112808. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  112809. /**
  112810. * Defines the camera the input is attached to.
  112811. */
  112812. camera: FlyCamera;
  112813. /**
  112814. * The list of keyboard keys used to control the forward move of the camera.
  112815. */
  112816. keysForward: number[];
  112817. /**
  112818. * The list of keyboard keys used to control the backward move of the camera.
  112819. */
  112820. keysBackward: number[];
  112821. /**
  112822. * The list of keyboard keys used to control the forward move of the camera.
  112823. */
  112824. keysUp: number[];
  112825. /**
  112826. * The list of keyboard keys used to control the backward move of the camera.
  112827. */
  112828. keysDown: number[];
  112829. /**
  112830. * The list of keyboard keys used to control the right strafe move of the camera.
  112831. */
  112832. keysRight: number[];
  112833. /**
  112834. * The list of keyboard keys used to control the left strafe move of the camera.
  112835. */
  112836. keysLeft: number[];
  112837. private _keys;
  112838. private _onCanvasBlurObserver;
  112839. private _onKeyboardObserver;
  112840. private _engine;
  112841. private _scene;
  112842. /**
  112843. * Attach the input controls to a specific dom element to get the input from.
  112844. * @param element Defines the element the controls should be listened from
  112845. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112846. */
  112847. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112848. /**
  112849. * Detach the current controls from the specified dom element.
  112850. * @param element Defines the element to stop listening the inputs from
  112851. */
  112852. detachControl(element: Nullable<HTMLElement>): void;
  112853. /**
  112854. * Gets the class name of the current intput.
  112855. * @returns the class name
  112856. */
  112857. getClassName(): string;
  112858. /** @hidden */
  112859. _onLostFocus(e: FocusEvent): void;
  112860. /**
  112861. * Get the friendly name associated with the input class.
  112862. * @returns the input friendly name
  112863. */
  112864. getSimpleName(): string;
  112865. /**
  112866. * Update the current camera state depending on the inputs that have been used this frame.
  112867. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112868. */
  112869. checkInputs(): void;
  112870. }
  112871. }
  112872. declare module BABYLON {
  112873. /**
  112874. * Manage the mouse wheel inputs to control a follow camera.
  112875. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112876. */
  112877. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  112878. /**
  112879. * Defines the camera the input is attached to.
  112880. */
  112881. camera: FollowCamera;
  112882. /**
  112883. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  112884. */
  112885. axisControlRadius: boolean;
  112886. /**
  112887. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  112888. */
  112889. axisControlHeight: boolean;
  112890. /**
  112891. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  112892. */
  112893. axisControlRotation: boolean;
  112894. /**
  112895. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  112896. * relation to mouseWheel events.
  112897. */
  112898. wheelPrecision: number;
  112899. /**
  112900. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  112901. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  112902. */
  112903. wheelDeltaPercentage: number;
  112904. private _wheel;
  112905. private _observer;
  112906. /**
  112907. * Attach the input controls to a specific dom element to get the input from.
  112908. * @param element Defines the element the controls should be listened from
  112909. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112910. */
  112911. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112912. /**
  112913. * Detach the current controls from the specified dom element.
  112914. * @param element Defines the element to stop listening the inputs from
  112915. */
  112916. detachControl(element: Nullable<HTMLElement>): void;
  112917. /**
  112918. * Gets the class name of the current intput.
  112919. * @returns the class name
  112920. */
  112921. getClassName(): string;
  112922. /**
  112923. * Get the friendly name associated with the input class.
  112924. * @returns the input friendly name
  112925. */
  112926. getSimpleName(): string;
  112927. }
  112928. }
  112929. declare module BABYLON {
  112930. /**
  112931. * Manage the pointers inputs to control an follow camera.
  112932. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112933. */
  112934. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  112935. /**
  112936. * Defines the camera the input is attached to.
  112937. */
  112938. camera: FollowCamera;
  112939. /**
  112940. * Gets the class name of the current input.
  112941. * @returns the class name
  112942. */
  112943. getClassName(): string;
  112944. /**
  112945. * Defines the pointer angular sensibility along the X axis or how fast is
  112946. * the camera rotating.
  112947. * A negative number will reverse the axis direction.
  112948. */
  112949. angularSensibilityX: number;
  112950. /**
  112951. * Defines the pointer angular sensibility along the Y axis or how fast is
  112952. * the camera rotating.
  112953. * A negative number will reverse the axis direction.
  112954. */
  112955. angularSensibilityY: number;
  112956. /**
  112957. * Defines the pointer pinch precision or how fast is the camera zooming.
  112958. * A negative number will reverse the axis direction.
  112959. */
  112960. pinchPrecision: number;
  112961. /**
  112962. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  112963. * from 0.
  112964. * It defines the percentage of current camera.radius to use as delta when
  112965. * pinch zoom is used.
  112966. */
  112967. pinchDeltaPercentage: number;
  112968. /**
  112969. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  112970. */
  112971. axisXControlRadius: boolean;
  112972. /**
  112973. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  112974. */
  112975. axisXControlHeight: boolean;
  112976. /**
  112977. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  112978. */
  112979. axisXControlRotation: boolean;
  112980. /**
  112981. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  112982. */
  112983. axisYControlRadius: boolean;
  112984. /**
  112985. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  112986. */
  112987. axisYControlHeight: boolean;
  112988. /**
  112989. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  112990. */
  112991. axisYControlRotation: boolean;
  112992. /**
  112993. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  112994. */
  112995. axisPinchControlRadius: boolean;
  112996. /**
  112997. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  112998. */
  112999. axisPinchControlHeight: boolean;
  113000. /**
  113001. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  113002. */
  113003. axisPinchControlRotation: boolean;
  113004. /**
  113005. * Log error messages if basic misconfiguration has occurred.
  113006. */
  113007. warningEnable: boolean;
  113008. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  113009. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  113010. private _warningCounter;
  113011. private _warning;
  113012. }
  113013. }
  113014. declare module BABYLON {
  113015. /**
  113016. * Default Inputs manager for the FollowCamera.
  113017. * It groups all the default supported inputs for ease of use.
  113018. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113019. */
  113020. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  113021. /**
  113022. * Instantiates a new FollowCameraInputsManager.
  113023. * @param camera Defines the camera the inputs belong to
  113024. */
  113025. constructor(camera: FollowCamera);
  113026. /**
  113027. * Add keyboard input support to the input manager.
  113028. * @returns the current input manager
  113029. */
  113030. addKeyboard(): FollowCameraInputsManager;
  113031. /**
  113032. * Add mouse wheel input support to the input manager.
  113033. * @returns the current input manager
  113034. */
  113035. addMouseWheel(): FollowCameraInputsManager;
  113036. /**
  113037. * Add pointers input support to the input manager.
  113038. * @returns the current input manager
  113039. */
  113040. addPointers(): FollowCameraInputsManager;
  113041. /**
  113042. * Add orientation input support to the input manager.
  113043. * @returns the current input manager
  113044. */
  113045. addVRDeviceOrientation(): FollowCameraInputsManager;
  113046. }
  113047. }
  113048. declare module BABYLON {
  113049. /**
  113050. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  113051. * an arc rotate version arcFollowCamera are available.
  113052. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113053. */
  113054. export class FollowCamera extends TargetCamera {
  113055. /**
  113056. * Distance the follow camera should follow an object at
  113057. */
  113058. radius: number;
  113059. /**
  113060. * Minimum allowed distance of the camera to the axis of rotation
  113061. * (The camera can not get closer).
  113062. * This can help limiting how the Camera is able to move in the scene.
  113063. */
  113064. lowerRadiusLimit: Nullable<number>;
  113065. /**
  113066. * Maximum allowed distance of the camera to the axis of rotation
  113067. * (The camera can not get further).
  113068. * This can help limiting how the Camera is able to move in the scene.
  113069. */
  113070. upperRadiusLimit: Nullable<number>;
  113071. /**
  113072. * Define a rotation offset between the camera and the object it follows
  113073. */
  113074. rotationOffset: number;
  113075. /**
  113076. * Minimum allowed angle to camera position relative to target object.
  113077. * This can help limiting how the Camera is able to move in the scene.
  113078. */
  113079. lowerRotationOffsetLimit: Nullable<number>;
  113080. /**
  113081. * Maximum allowed angle to camera position relative to target object.
  113082. * This can help limiting how the Camera is able to move in the scene.
  113083. */
  113084. upperRotationOffsetLimit: Nullable<number>;
  113085. /**
  113086. * Define a height offset between the camera and the object it follows.
  113087. * It can help following an object from the top (like a car chaing a plane)
  113088. */
  113089. heightOffset: number;
  113090. /**
  113091. * Minimum allowed height of camera position relative to target object.
  113092. * This can help limiting how the Camera is able to move in the scene.
  113093. */
  113094. lowerHeightOffsetLimit: Nullable<number>;
  113095. /**
  113096. * Maximum allowed height of camera position relative to target object.
  113097. * This can help limiting how the Camera is able to move in the scene.
  113098. */
  113099. upperHeightOffsetLimit: Nullable<number>;
  113100. /**
  113101. * Define how fast the camera can accelerate to follow it s target.
  113102. */
  113103. cameraAcceleration: number;
  113104. /**
  113105. * Define the speed limit of the camera following an object.
  113106. */
  113107. maxCameraSpeed: number;
  113108. /**
  113109. * Define the target of the camera.
  113110. */
  113111. lockedTarget: Nullable<AbstractMesh>;
  113112. /**
  113113. * Defines the input associated with the camera.
  113114. */
  113115. inputs: FollowCameraInputsManager;
  113116. /**
  113117. * Instantiates the follow camera.
  113118. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113119. * @param name Define the name of the camera in the scene
  113120. * @param position Define the position of the camera
  113121. * @param scene Define the scene the camera belong to
  113122. * @param lockedTarget Define the target of the camera
  113123. */
  113124. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  113125. private _follow;
  113126. /**
  113127. * Attached controls to the current camera.
  113128. * @param element Defines the element the controls should be listened from
  113129. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113130. */
  113131. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113132. /**
  113133. * Detach the current controls from the camera.
  113134. * The camera will stop reacting to inputs.
  113135. * @param element Defines the element to stop listening the inputs from
  113136. */
  113137. detachControl(element: HTMLElement): void;
  113138. /** @hidden */
  113139. _checkInputs(): void;
  113140. private _checkLimits;
  113141. /**
  113142. * Gets the camera class name.
  113143. * @returns the class name
  113144. */
  113145. getClassName(): string;
  113146. }
  113147. /**
  113148. * Arc Rotate version of the follow camera.
  113149. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  113150. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113151. */
  113152. export class ArcFollowCamera extends TargetCamera {
  113153. /** The longitudinal angle of the camera */
  113154. alpha: number;
  113155. /** The latitudinal angle of the camera */
  113156. beta: number;
  113157. /** The radius of the camera from its target */
  113158. radius: number;
  113159. /** Define the camera target (the messh it should follow) */
  113160. target: Nullable<AbstractMesh>;
  113161. private _cartesianCoordinates;
  113162. /**
  113163. * Instantiates a new ArcFollowCamera
  113164. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113165. * @param name Define the name of the camera
  113166. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  113167. * @param beta Define the rotation angle of the camera around the elevation axis
  113168. * @param radius Define the radius of the camera from its target point
  113169. * @param target Define the target of the camera
  113170. * @param scene Define the scene the camera belongs to
  113171. */
  113172. constructor(name: string,
  113173. /** The longitudinal angle of the camera */
  113174. alpha: number,
  113175. /** The latitudinal angle of the camera */
  113176. beta: number,
  113177. /** The radius of the camera from its target */
  113178. radius: number,
  113179. /** Define the camera target (the messh it should follow) */
  113180. target: Nullable<AbstractMesh>, scene: Scene);
  113181. private _follow;
  113182. /** @hidden */
  113183. _checkInputs(): void;
  113184. /**
  113185. * Returns the class name of the object.
  113186. * It is mostly used internally for serialization purposes.
  113187. */
  113188. getClassName(): string;
  113189. }
  113190. }
  113191. declare module BABYLON {
  113192. /**
  113193. * Manage the keyboard inputs to control the movement of a follow camera.
  113194. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113195. */
  113196. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  113197. /**
  113198. * Defines the camera the input is attached to.
  113199. */
  113200. camera: FollowCamera;
  113201. /**
  113202. * Defines the list of key codes associated with the up action (increase heightOffset)
  113203. */
  113204. keysHeightOffsetIncr: number[];
  113205. /**
  113206. * Defines the list of key codes associated with the down action (decrease heightOffset)
  113207. */
  113208. keysHeightOffsetDecr: number[];
  113209. /**
  113210. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  113211. */
  113212. keysHeightOffsetModifierAlt: boolean;
  113213. /**
  113214. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  113215. */
  113216. keysHeightOffsetModifierCtrl: boolean;
  113217. /**
  113218. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  113219. */
  113220. keysHeightOffsetModifierShift: boolean;
  113221. /**
  113222. * Defines the list of key codes associated with the left action (increase rotationOffset)
  113223. */
  113224. keysRotationOffsetIncr: number[];
  113225. /**
  113226. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  113227. */
  113228. keysRotationOffsetDecr: number[];
  113229. /**
  113230. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  113231. */
  113232. keysRotationOffsetModifierAlt: boolean;
  113233. /**
  113234. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  113235. */
  113236. keysRotationOffsetModifierCtrl: boolean;
  113237. /**
  113238. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  113239. */
  113240. keysRotationOffsetModifierShift: boolean;
  113241. /**
  113242. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  113243. */
  113244. keysRadiusIncr: number[];
  113245. /**
  113246. * Defines the list of key codes associated with the zoom-out action (increase radius)
  113247. */
  113248. keysRadiusDecr: number[];
  113249. /**
  113250. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  113251. */
  113252. keysRadiusModifierAlt: boolean;
  113253. /**
  113254. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  113255. */
  113256. keysRadiusModifierCtrl: boolean;
  113257. /**
  113258. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  113259. */
  113260. keysRadiusModifierShift: boolean;
  113261. /**
  113262. * Defines the rate of change of heightOffset.
  113263. */
  113264. heightSensibility: number;
  113265. /**
  113266. * Defines the rate of change of rotationOffset.
  113267. */
  113268. rotationSensibility: number;
  113269. /**
  113270. * Defines the rate of change of radius.
  113271. */
  113272. radiusSensibility: number;
  113273. private _keys;
  113274. private _ctrlPressed;
  113275. private _altPressed;
  113276. private _shiftPressed;
  113277. private _onCanvasBlurObserver;
  113278. private _onKeyboardObserver;
  113279. private _engine;
  113280. private _scene;
  113281. /**
  113282. * Attach the input controls to a specific dom element to get the input from.
  113283. * @param element Defines the element the controls should be listened from
  113284. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113285. */
  113286. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113287. /**
  113288. * Detach the current controls from the specified dom element.
  113289. * @param element Defines the element to stop listening the inputs from
  113290. */
  113291. detachControl(element: Nullable<HTMLElement>): void;
  113292. /**
  113293. * Update the current camera state depending on the inputs that have been used this frame.
  113294. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113295. */
  113296. checkInputs(): void;
  113297. /**
  113298. * Gets the class name of the current input.
  113299. * @returns the class name
  113300. */
  113301. getClassName(): string;
  113302. /**
  113303. * Get the friendly name associated with the input class.
  113304. * @returns the input friendly name
  113305. */
  113306. getSimpleName(): string;
  113307. /**
  113308. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113309. * allow modification of the heightOffset value.
  113310. */
  113311. private _modifierHeightOffset;
  113312. /**
  113313. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113314. * allow modification of the rotationOffset value.
  113315. */
  113316. private _modifierRotationOffset;
  113317. /**
  113318. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113319. * allow modification of the radius value.
  113320. */
  113321. private _modifierRadius;
  113322. }
  113323. }
  113324. declare module BABYLON {
  113325. interface FreeCameraInputsManager {
  113326. /**
  113327. * @hidden
  113328. */
  113329. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  113330. /**
  113331. * Add orientation input support to the input manager.
  113332. * @returns the current input manager
  113333. */
  113334. addDeviceOrientation(): FreeCameraInputsManager;
  113335. }
  113336. /**
  113337. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  113338. * Screen rotation is taken into account.
  113339. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113340. */
  113341. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  113342. private _camera;
  113343. private _screenOrientationAngle;
  113344. private _constantTranform;
  113345. private _screenQuaternion;
  113346. private _alpha;
  113347. private _beta;
  113348. private _gamma;
  113349. /**
  113350. * Can be used to detect if a device orientation sensor is available on a device
  113351. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  113352. * @returns a promise that will resolve on orientation change
  113353. */
  113354. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  113355. /**
  113356. * @hidden
  113357. */
  113358. _onDeviceOrientationChangedObservable: Observable<void>;
  113359. /**
  113360. * Instantiates a new input
  113361. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113362. */
  113363. constructor();
  113364. /**
  113365. * Define the camera controlled by the input.
  113366. */
  113367. get camera(): FreeCamera;
  113368. set camera(camera: FreeCamera);
  113369. /**
  113370. * Attach the input controls to a specific dom element to get the input from.
  113371. * @param element Defines the element the controls should be listened from
  113372. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113373. */
  113374. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113375. private _orientationChanged;
  113376. private _deviceOrientation;
  113377. /**
  113378. * Detach the current controls from the specified dom element.
  113379. * @param element Defines the element to stop listening the inputs from
  113380. */
  113381. detachControl(element: Nullable<HTMLElement>): void;
  113382. /**
  113383. * Update the current camera state depending on the inputs that have been used this frame.
  113384. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113385. */
  113386. checkInputs(): void;
  113387. /**
  113388. * Gets the class name of the current intput.
  113389. * @returns the class name
  113390. */
  113391. getClassName(): string;
  113392. /**
  113393. * Get the friendly name associated with the input class.
  113394. * @returns the input friendly name
  113395. */
  113396. getSimpleName(): string;
  113397. }
  113398. }
  113399. declare module BABYLON {
  113400. /**
  113401. * Manage the gamepad inputs to control a free camera.
  113402. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113403. */
  113404. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  113405. /**
  113406. * Define the camera the input is attached to.
  113407. */
  113408. camera: FreeCamera;
  113409. /**
  113410. * Define the Gamepad controlling the input
  113411. */
  113412. gamepad: Nullable<Gamepad>;
  113413. /**
  113414. * Defines the gamepad rotation sensiblity.
  113415. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  113416. */
  113417. gamepadAngularSensibility: number;
  113418. /**
  113419. * Defines the gamepad move sensiblity.
  113420. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  113421. */
  113422. gamepadMoveSensibility: number;
  113423. private _yAxisScale;
  113424. /**
  113425. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  113426. */
  113427. get invertYAxis(): boolean;
  113428. set invertYAxis(value: boolean);
  113429. private _onGamepadConnectedObserver;
  113430. private _onGamepadDisconnectedObserver;
  113431. private _cameraTransform;
  113432. private _deltaTransform;
  113433. private _vector3;
  113434. private _vector2;
  113435. /**
  113436. * Attach the input controls to a specific dom element to get the input from.
  113437. * @param element Defines the element the controls should be listened from
  113438. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113439. */
  113440. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113441. /**
  113442. * Detach the current controls from the specified dom element.
  113443. * @param element Defines the element to stop listening the inputs from
  113444. */
  113445. detachControl(element: Nullable<HTMLElement>): void;
  113446. /**
  113447. * Update the current camera state depending on the inputs that have been used this frame.
  113448. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113449. */
  113450. checkInputs(): void;
  113451. /**
  113452. * Gets the class name of the current intput.
  113453. * @returns the class name
  113454. */
  113455. getClassName(): string;
  113456. /**
  113457. * Get the friendly name associated with the input class.
  113458. * @returns the input friendly name
  113459. */
  113460. getSimpleName(): string;
  113461. }
  113462. }
  113463. declare module BABYLON {
  113464. /**
  113465. * Defines the potential axis of a Joystick
  113466. */
  113467. export enum JoystickAxis {
  113468. /** X axis */
  113469. X = 0,
  113470. /** Y axis */
  113471. Y = 1,
  113472. /** Z axis */
  113473. Z = 2
  113474. }
  113475. /**
  113476. * Class used to define virtual joystick (used in touch mode)
  113477. */
  113478. export class VirtualJoystick {
  113479. /**
  113480. * Gets or sets a boolean indicating that left and right values must be inverted
  113481. */
  113482. reverseLeftRight: boolean;
  113483. /**
  113484. * Gets or sets a boolean indicating that up and down values must be inverted
  113485. */
  113486. reverseUpDown: boolean;
  113487. /**
  113488. * Gets the offset value for the position (ie. the change of the position value)
  113489. */
  113490. deltaPosition: Vector3;
  113491. /**
  113492. * Gets a boolean indicating if the virtual joystick was pressed
  113493. */
  113494. pressed: boolean;
  113495. /**
  113496. * Canvas the virtual joystick will render onto, default z-index of this is 5
  113497. */
  113498. static Canvas: Nullable<HTMLCanvasElement>;
  113499. private static _globalJoystickIndex;
  113500. private static vjCanvasContext;
  113501. private static vjCanvasWidth;
  113502. private static vjCanvasHeight;
  113503. private static halfWidth;
  113504. private _action;
  113505. private _axisTargetedByLeftAndRight;
  113506. private _axisTargetedByUpAndDown;
  113507. private _joystickSensibility;
  113508. private _inversedSensibility;
  113509. private _joystickPointerID;
  113510. private _joystickColor;
  113511. private _joystickPointerPos;
  113512. private _joystickPreviousPointerPos;
  113513. private _joystickPointerStartPos;
  113514. private _deltaJoystickVector;
  113515. private _leftJoystick;
  113516. private _touches;
  113517. private _onPointerDownHandlerRef;
  113518. private _onPointerMoveHandlerRef;
  113519. private _onPointerUpHandlerRef;
  113520. private _onResize;
  113521. /**
  113522. * Creates a new virtual joystick
  113523. * @param leftJoystick defines that the joystick is for left hand (false by default)
  113524. */
  113525. constructor(leftJoystick?: boolean);
  113526. /**
  113527. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  113528. * @param newJoystickSensibility defines the new sensibility
  113529. */
  113530. setJoystickSensibility(newJoystickSensibility: number): void;
  113531. private _onPointerDown;
  113532. private _onPointerMove;
  113533. private _onPointerUp;
  113534. /**
  113535. * Change the color of the virtual joystick
  113536. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  113537. */
  113538. setJoystickColor(newColor: string): void;
  113539. /**
  113540. * Defines a callback to call when the joystick is touched
  113541. * @param action defines the callback
  113542. */
  113543. setActionOnTouch(action: () => any): void;
  113544. /**
  113545. * Defines which axis you'd like to control for left & right
  113546. * @param axis defines the axis to use
  113547. */
  113548. setAxisForLeftRight(axis: JoystickAxis): void;
  113549. /**
  113550. * Defines which axis you'd like to control for up & down
  113551. * @param axis defines the axis to use
  113552. */
  113553. setAxisForUpDown(axis: JoystickAxis): void;
  113554. private _drawVirtualJoystick;
  113555. /**
  113556. * Release internal HTML canvas
  113557. */
  113558. releaseCanvas(): void;
  113559. }
  113560. }
  113561. declare module BABYLON {
  113562. interface FreeCameraInputsManager {
  113563. /**
  113564. * Add virtual joystick input support to the input manager.
  113565. * @returns the current input manager
  113566. */
  113567. addVirtualJoystick(): FreeCameraInputsManager;
  113568. }
  113569. /**
  113570. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  113571. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113572. */
  113573. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  113574. /**
  113575. * Defines the camera the input is attached to.
  113576. */
  113577. camera: FreeCamera;
  113578. private _leftjoystick;
  113579. private _rightjoystick;
  113580. /**
  113581. * Gets the left stick of the virtual joystick.
  113582. * @returns The virtual Joystick
  113583. */
  113584. getLeftJoystick(): VirtualJoystick;
  113585. /**
  113586. * Gets the right stick of the virtual joystick.
  113587. * @returns The virtual Joystick
  113588. */
  113589. getRightJoystick(): VirtualJoystick;
  113590. /**
  113591. * Update the current camera state depending on the inputs that have been used this frame.
  113592. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113593. */
  113594. checkInputs(): void;
  113595. /**
  113596. * Attach the input controls to a specific dom element to get the input from.
  113597. * @param element Defines the element the controls should be listened from
  113598. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113599. */
  113600. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113601. /**
  113602. * Detach the current controls from the specified dom element.
  113603. * @param element Defines the element to stop listening the inputs from
  113604. */
  113605. detachControl(element: Nullable<HTMLElement>): void;
  113606. /**
  113607. * Gets the class name of the current intput.
  113608. * @returns the class name
  113609. */
  113610. getClassName(): string;
  113611. /**
  113612. * Get the friendly name associated with the input class.
  113613. * @returns the input friendly name
  113614. */
  113615. getSimpleName(): string;
  113616. }
  113617. }
  113618. declare module BABYLON {
  113619. /**
  113620. * This represents a FPS type of camera controlled by touch.
  113621. * This is like a universal camera minus the Gamepad controls.
  113622. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  113623. */
  113624. export class TouchCamera extends FreeCamera {
  113625. /**
  113626. * Defines the touch sensibility for rotation.
  113627. * The higher the faster.
  113628. */
  113629. get touchAngularSensibility(): number;
  113630. set touchAngularSensibility(value: number);
  113631. /**
  113632. * Defines the touch sensibility for move.
  113633. * The higher the faster.
  113634. */
  113635. get touchMoveSensibility(): number;
  113636. set touchMoveSensibility(value: number);
  113637. /**
  113638. * Instantiates a new touch camera.
  113639. * This represents a FPS type of camera controlled by touch.
  113640. * This is like a universal camera minus the Gamepad controls.
  113641. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  113642. * @param name Define the name of the camera in the scene
  113643. * @param position Define the start position of the camera in the scene
  113644. * @param scene Define the scene the camera belongs to
  113645. */
  113646. constructor(name: string, position: Vector3, scene: Scene);
  113647. /**
  113648. * Gets the current object class name.
  113649. * @return the class name
  113650. */
  113651. getClassName(): string;
  113652. /** @hidden */
  113653. _setupInputs(): void;
  113654. }
  113655. }
  113656. declare module BABYLON {
  113657. /**
  113658. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  113659. * being tilted forward or back and left or right.
  113660. */
  113661. export class DeviceOrientationCamera extends FreeCamera {
  113662. private _initialQuaternion;
  113663. private _quaternionCache;
  113664. private _tmpDragQuaternion;
  113665. private _disablePointerInputWhenUsingDeviceOrientation;
  113666. /**
  113667. * Creates a new device orientation camera
  113668. * @param name The name of the camera
  113669. * @param position The start position camera
  113670. * @param scene The scene the camera belongs to
  113671. */
  113672. constructor(name: string, position: Vector3, scene: Scene);
  113673. /**
  113674. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  113675. */
  113676. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  113677. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  113678. private _dragFactor;
  113679. /**
  113680. * Enabled turning on the y axis when the orientation sensor is active
  113681. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  113682. */
  113683. enableHorizontalDragging(dragFactor?: number): void;
  113684. /**
  113685. * Gets the current instance class name ("DeviceOrientationCamera").
  113686. * This helps avoiding instanceof at run time.
  113687. * @returns the class name
  113688. */
  113689. getClassName(): string;
  113690. /**
  113691. * @hidden
  113692. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  113693. */
  113694. _checkInputs(): void;
  113695. /**
  113696. * Reset the camera to its default orientation on the specified axis only.
  113697. * @param axis The axis to reset
  113698. */
  113699. resetToCurrentRotation(axis?: Axis): void;
  113700. }
  113701. }
  113702. declare module BABYLON {
  113703. /**
  113704. * Defines supported buttons for XBox360 compatible gamepads
  113705. */
  113706. export enum Xbox360Button {
  113707. /** A */
  113708. A = 0,
  113709. /** B */
  113710. B = 1,
  113711. /** X */
  113712. X = 2,
  113713. /** Y */
  113714. Y = 3,
  113715. /** Start */
  113716. Start = 4,
  113717. /** Back */
  113718. Back = 5,
  113719. /** Left button */
  113720. LB = 6,
  113721. /** Right button */
  113722. RB = 7,
  113723. /** Left stick */
  113724. LeftStick = 8,
  113725. /** Right stick */
  113726. RightStick = 9
  113727. }
  113728. /** Defines values for XBox360 DPad */
  113729. export enum Xbox360Dpad {
  113730. /** Up */
  113731. Up = 0,
  113732. /** Down */
  113733. Down = 1,
  113734. /** Left */
  113735. Left = 2,
  113736. /** Right */
  113737. Right = 3
  113738. }
  113739. /**
  113740. * Defines a XBox360 gamepad
  113741. */
  113742. export class Xbox360Pad extends Gamepad {
  113743. private _leftTrigger;
  113744. private _rightTrigger;
  113745. private _onlefttriggerchanged;
  113746. private _onrighttriggerchanged;
  113747. private _onbuttondown;
  113748. private _onbuttonup;
  113749. private _ondpaddown;
  113750. private _ondpadup;
  113751. /** Observable raised when a button is pressed */
  113752. onButtonDownObservable: Observable<Xbox360Button>;
  113753. /** Observable raised when a button is released */
  113754. onButtonUpObservable: Observable<Xbox360Button>;
  113755. /** Observable raised when a pad is pressed */
  113756. onPadDownObservable: Observable<Xbox360Dpad>;
  113757. /** Observable raised when a pad is released */
  113758. onPadUpObservable: Observable<Xbox360Dpad>;
  113759. private _buttonA;
  113760. private _buttonB;
  113761. private _buttonX;
  113762. private _buttonY;
  113763. private _buttonBack;
  113764. private _buttonStart;
  113765. private _buttonLB;
  113766. private _buttonRB;
  113767. private _buttonLeftStick;
  113768. private _buttonRightStick;
  113769. private _dPadUp;
  113770. private _dPadDown;
  113771. private _dPadLeft;
  113772. private _dPadRight;
  113773. private _isXboxOnePad;
  113774. /**
  113775. * Creates a new XBox360 gamepad object
  113776. * @param id defines the id of this gamepad
  113777. * @param index defines its index
  113778. * @param gamepad defines the internal HTML gamepad object
  113779. * @param xboxOne defines if it is a XBox One gamepad
  113780. */
  113781. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  113782. /**
  113783. * Defines the callback to call when left trigger is pressed
  113784. * @param callback defines the callback to use
  113785. */
  113786. onlefttriggerchanged(callback: (value: number) => void): void;
  113787. /**
  113788. * Defines the callback to call when right trigger is pressed
  113789. * @param callback defines the callback to use
  113790. */
  113791. onrighttriggerchanged(callback: (value: number) => void): void;
  113792. /**
  113793. * Gets the left trigger value
  113794. */
  113795. get leftTrigger(): number;
  113796. /**
  113797. * Sets the left trigger value
  113798. */
  113799. set leftTrigger(newValue: number);
  113800. /**
  113801. * Gets the right trigger value
  113802. */
  113803. get rightTrigger(): number;
  113804. /**
  113805. * Sets the right trigger value
  113806. */
  113807. set rightTrigger(newValue: number);
  113808. /**
  113809. * Defines the callback to call when a button is pressed
  113810. * @param callback defines the callback to use
  113811. */
  113812. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  113813. /**
  113814. * Defines the callback to call when a button is released
  113815. * @param callback defines the callback to use
  113816. */
  113817. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  113818. /**
  113819. * Defines the callback to call when a pad is pressed
  113820. * @param callback defines the callback to use
  113821. */
  113822. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  113823. /**
  113824. * Defines the callback to call when a pad is released
  113825. * @param callback defines the callback to use
  113826. */
  113827. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  113828. private _setButtonValue;
  113829. private _setDPadValue;
  113830. /**
  113831. * Gets the value of the `A` button
  113832. */
  113833. get buttonA(): number;
  113834. /**
  113835. * Sets the value of the `A` button
  113836. */
  113837. set buttonA(value: number);
  113838. /**
  113839. * Gets the value of the `B` button
  113840. */
  113841. get buttonB(): number;
  113842. /**
  113843. * Sets the value of the `B` button
  113844. */
  113845. set buttonB(value: number);
  113846. /**
  113847. * Gets the value of the `X` button
  113848. */
  113849. get buttonX(): number;
  113850. /**
  113851. * Sets the value of the `X` button
  113852. */
  113853. set buttonX(value: number);
  113854. /**
  113855. * Gets the value of the `Y` button
  113856. */
  113857. get buttonY(): number;
  113858. /**
  113859. * Sets the value of the `Y` button
  113860. */
  113861. set buttonY(value: number);
  113862. /**
  113863. * Gets the value of the `Start` button
  113864. */
  113865. get buttonStart(): number;
  113866. /**
  113867. * Sets the value of the `Start` button
  113868. */
  113869. set buttonStart(value: number);
  113870. /**
  113871. * Gets the value of the `Back` button
  113872. */
  113873. get buttonBack(): number;
  113874. /**
  113875. * Sets the value of the `Back` button
  113876. */
  113877. set buttonBack(value: number);
  113878. /**
  113879. * Gets the value of the `Left` button
  113880. */
  113881. get buttonLB(): number;
  113882. /**
  113883. * Sets the value of the `Left` button
  113884. */
  113885. set buttonLB(value: number);
  113886. /**
  113887. * Gets the value of the `Right` button
  113888. */
  113889. get buttonRB(): number;
  113890. /**
  113891. * Sets the value of the `Right` button
  113892. */
  113893. set buttonRB(value: number);
  113894. /**
  113895. * Gets the value of the Left joystick
  113896. */
  113897. get buttonLeftStick(): number;
  113898. /**
  113899. * Sets the value of the Left joystick
  113900. */
  113901. set buttonLeftStick(value: number);
  113902. /**
  113903. * Gets the value of the Right joystick
  113904. */
  113905. get buttonRightStick(): number;
  113906. /**
  113907. * Sets the value of the Right joystick
  113908. */
  113909. set buttonRightStick(value: number);
  113910. /**
  113911. * Gets the value of D-pad up
  113912. */
  113913. get dPadUp(): number;
  113914. /**
  113915. * Sets the value of D-pad up
  113916. */
  113917. set dPadUp(value: number);
  113918. /**
  113919. * Gets the value of D-pad down
  113920. */
  113921. get dPadDown(): number;
  113922. /**
  113923. * Sets the value of D-pad down
  113924. */
  113925. set dPadDown(value: number);
  113926. /**
  113927. * Gets the value of D-pad left
  113928. */
  113929. get dPadLeft(): number;
  113930. /**
  113931. * Sets the value of D-pad left
  113932. */
  113933. set dPadLeft(value: number);
  113934. /**
  113935. * Gets the value of D-pad right
  113936. */
  113937. get dPadRight(): number;
  113938. /**
  113939. * Sets the value of D-pad right
  113940. */
  113941. set dPadRight(value: number);
  113942. /**
  113943. * Force the gamepad to synchronize with device values
  113944. */
  113945. update(): void;
  113946. /**
  113947. * Disposes the gamepad
  113948. */
  113949. dispose(): void;
  113950. }
  113951. }
  113952. declare module BABYLON {
  113953. /**
  113954. * Defines supported buttons for DualShock compatible gamepads
  113955. */
  113956. export enum DualShockButton {
  113957. /** Cross */
  113958. Cross = 0,
  113959. /** Circle */
  113960. Circle = 1,
  113961. /** Square */
  113962. Square = 2,
  113963. /** Triangle */
  113964. Triangle = 3,
  113965. /** Options */
  113966. Options = 4,
  113967. /** Share */
  113968. Share = 5,
  113969. /** L1 */
  113970. L1 = 6,
  113971. /** R1 */
  113972. R1 = 7,
  113973. /** Left stick */
  113974. LeftStick = 8,
  113975. /** Right stick */
  113976. RightStick = 9
  113977. }
  113978. /** Defines values for DualShock DPad */
  113979. export enum DualShockDpad {
  113980. /** Up */
  113981. Up = 0,
  113982. /** Down */
  113983. Down = 1,
  113984. /** Left */
  113985. Left = 2,
  113986. /** Right */
  113987. Right = 3
  113988. }
  113989. /**
  113990. * Defines a DualShock gamepad
  113991. */
  113992. export class DualShockPad extends Gamepad {
  113993. private _leftTrigger;
  113994. private _rightTrigger;
  113995. private _onlefttriggerchanged;
  113996. private _onrighttriggerchanged;
  113997. private _onbuttondown;
  113998. private _onbuttonup;
  113999. private _ondpaddown;
  114000. private _ondpadup;
  114001. /** Observable raised when a button is pressed */
  114002. onButtonDownObservable: Observable<DualShockButton>;
  114003. /** Observable raised when a button is released */
  114004. onButtonUpObservable: Observable<DualShockButton>;
  114005. /** Observable raised when a pad is pressed */
  114006. onPadDownObservable: Observable<DualShockDpad>;
  114007. /** Observable raised when a pad is released */
  114008. onPadUpObservable: Observable<DualShockDpad>;
  114009. private _buttonCross;
  114010. private _buttonCircle;
  114011. private _buttonSquare;
  114012. private _buttonTriangle;
  114013. private _buttonShare;
  114014. private _buttonOptions;
  114015. private _buttonL1;
  114016. private _buttonR1;
  114017. private _buttonLeftStick;
  114018. private _buttonRightStick;
  114019. private _dPadUp;
  114020. private _dPadDown;
  114021. private _dPadLeft;
  114022. private _dPadRight;
  114023. /**
  114024. * Creates a new DualShock gamepad object
  114025. * @param id defines the id of this gamepad
  114026. * @param index defines its index
  114027. * @param gamepad defines the internal HTML gamepad object
  114028. */
  114029. constructor(id: string, index: number, gamepad: any);
  114030. /**
  114031. * Defines the callback to call when left trigger is pressed
  114032. * @param callback defines the callback to use
  114033. */
  114034. onlefttriggerchanged(callback: (value: number) => void): void;
  114035. /**
  114036. * Defines the callback to call when right trigger is pressed
  114037. * @param callback defines the callback to use
  114038. */
  114039. onrighttriggerchanged(callback: (value: number) => void): void;
  114040. /**
  114041. * Gets the left trigger value
  114042. */
  114043. get leftTrigger(): number;
  114044. /**
  114045. * Sets the left trigger value
  114046. */
  114047. set leftTrigger(newValue: number);
  114048. /**
  114049. * Gets the right trigger value
  114050. */
  114051. get rightTrigger(): number;
  114052. /**
  114053. * Sets the right trigger value
  114054. */
  114055. set rightTrigger(newValue: number);
  114056. /**
  114057. * Defines the callback to call when a button is pressed
  114058. * @param callback defines the callback to use
  114059. */
  114060. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  114061. /**
  114062. * Defines the callback to call when a button is released
  114063. * @param callback defines the callback to use
  114064. */
  114065. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  114066. /**
  114067. * Defines the callback to call when a pad is pressed
  114068. * @param callback defines the callback to use
  114069. */
  114070. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  114071. /**
  114072. * Defines the callback to call when a pad is released
  114073. * @param callback defines the callback to use
  114074. */
  114075. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  114076. private _setButtonValue;
  114077. private _setDPadValue;
  114078. /**
  114079. * Gets the value of the `Cross` button
  114080. */
  114081. get buttonCross(): number;
  114082. /**
  114083. * Sets the value of the `Cross` button
  114084. */
  114085. set buttonCross(value: number);
  114086. /**
  114087. * Gets the value of the `Circle` button
  114088. */
  114089. get buttonCircle(): number;
  114090. /**
  114091. * Sets the value of the `Circle` button
  114092. */
  114093. set buttonCircle(value: number);
  114094. /**
  114095. * Gets the value of the `Square` button
  114096. */
  114097. get buttonSquare(): number;
  114098. /**
  114099. * Sets the value of the `Square` button
  114100. */
  114101. set buttonSquare(value: number);
  114102. /**
  114103. * Gets the value of the `Triangle` button
  114104. */
  114105. get buttonTriangle(): number;
  114106. /**
  114107. * Sets the value of the `Triangle` button
  114108. */
  114109. set buttonTriangle(value: number);
  114110. /**
  114111. * Gets the value of the `Options` button
  114112. */
  114113. get buttonOptions(): number;
  114114. /**
  114115. * Sets the value of the `Options` button
  114116. */
  114117. set buttonOptions(value: number);
  114118. /**
  114119. * Gets the value of the `Share` button
  114120. */
  114121. get buttonShare(): number;
  114122. /**
  114123. * Sets the value of the `Share` button
  114124. */
  114125. set buttonShare(value: number);
  114126. /**
  114127. * Gets the value of the `L1` button
  114128. */
  114129. get buttonL1(): number;
  114130. /**
  114131. * Sets the value of the `L1` button
  114132. */
  114133. set buttonL1(value: number);
  114134. /**
  114135. * Gets the value of the `R1` button
  114136. */
  114137. get buttonR1(): number;
  114138. /**
  114139. * Sets the value of the `R1` button
  114140. */
  114141. set buttonR1(value: number);
  114142. /**
  114143. * Gets the value of the Left joystick
  114144. */
  114145. get buttonLeftStick(): number;
  114146. /**
  114147. * Sets the value of the Left joystick
  114148. */
  114149. set buttonLeftStick(value: number);
  114150. /**
  114151. * Gets the value of the Right joystick
  114152. */
  114153. get buttonRightStick(): number;
  114154. /**
  114155. * Sets the value of the Right joystick
  114156. */
  114157. set buttonRightStick(value: number);
  114158. /**
  114159. * Gets the value of D-pad up
  114160. */
  114161. get dPadUp(): number;
  114162. /**
  114163. * Sets the value of D-pad up
  114164. */
  114165. set dPadUp(value: number);
  114166. /**
  114167. * Gets the value of D-pad down
  114168. */
  114169. get dPadDown(): number;
  114170. /**
  114171. * Sets the value of D-pad down
  114172. */
  114173. set dPadDown(value: number);
  114174. /**
  114175. * Gets the value of D-pad left
  114176. */
  114177. get dPadLeft(): number;
  114178. /**
  114179. * Sets the value of D-pad left
  114180. */
  114181. set dPadLeft(value: number);
  114182. /**
  114183. * Gets the value of D-pad right
  114184. */
  114185. get dPadRight(): number;
  114186. /**
  114187. * Sets the value of D-pad right
  114188. */
  114189. set dPadRight(value: number);
  114190. /**
  114191. * Force the gamepad to synchronize with device values
  114192. */
  114193. update(): void;
  114194. /**
  114195. * Disposes the gamepad
  114196. */
  114197. dispose(): void;
  114198. }
  114199. }
  114200. declare module BABYLON {
  114201. /**
  114202. * Manager for handling gamepads
  114203. */
  114204. export class GamepadManager {
  114205. private _scene?;
  114206. private _babylonGamepads;
  114207. private _oneGamepadConnected;
  114208. /** @hidden */
  114209. _isMonitoring: boolean;
  114210. private _gamepadEventSupported;
  114211. private _gamepadSupport?;
  114212. /**
  114213. * observable to be triggered when the gamepad controller has been connected
  114214. */
  114215. onGamepadConnectedObservable: Observable<Gamepad>;
  114216. /**
  114217. * observable to be triggered when the gamepad controller has been disconnected
  114218. */
  114219. onGamepadDisconnectedObservable: Observable<Gamepad>;
  114220. private _onGamepadConnectedEvent;
  114221. private _onGamepadDisconnectedEvent;
  114222. /**
  114223. * Initializes the gamepad manager
  114224. * @param _scene BabylonJS scene
  114225. */
  114226. constructor(_scene?: Scene | undefined);
  114227. /**
  114228. * The gamepads in the game pad manager
  114229. */
  114230. get gamepads(): Gamepad[];
  114231. /**
  114232. * Get the gamepad controllers based on type
  114233. * @param type The type of gamepad controller
  114234. * @returns Nullable gamepad
  114235. */
  114236. getGamepadByType(type?: number): Nullable<Gamepad>;
  114237. /**
  114238. * Disposes the gamepad manager
  114239. */
  114240. dispose(): void;
  114241. private _addNewGamepad;
  114242. private _startMonitoringGamepads;
  114243. private _stopMonitoringGamepads;
  114244. /** @hidden */
  114245. _checkGamepadsStatus(): void;
  114246. private _updateGamepadObjects;
  114247. }
  114248. }
  114249. declare module BABYLON {
  114250. interface Scene {
  114251. /** @hidden */
  114252. _gamepadManager: Nullable<GamepadManager>;
  114253. /**
  114254. * Gets the gamepad manager associated with the scene
  114255. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  114256. */
  114257. gamepadManager: GamepadManager;
  114258. }
  114259. /**
  114260. * Interface representing a free camera inputs manager
  114261. */
  114262. interface FreeCameraInputsManager {
  114263. /**
  114264. * Adds gamepad input support to the FreeCameraInputsManager.
  114265. * @returns the FreeCameraInputsManager
  114266. */
  114267. addGamepad(): FreeCameraInputsManager;
  114268. }
  114269. /**
  114270. * Interface representing an arc rotate camera inputs manager
  114271. */
  114272. interface ArcRotateCameraInputsManager {
  114273. /**
  114274. * Adds gamepad input support to the ArcRotateCamera InputManager.
  114275. * @returns the camera inputs manager
  114276. */
  114277. addGamepad(): ArcRotateCameraInputsManager;
  114278. }
  114279. /**
  114280. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  114281. */
  114282. export class GamepadSystemSceneComponent implements ISceneComponent {
  114283. /**
  114284. * The component name helpfull to identify the component in the list of scene components.
  114285. */
  114286. readonly name: string;
  114287. /**
  114288. * The scene the component belongs to.
  114289. */
  114290. scene: Scene;
  114291. /**
  114292. * Creates a new instance of the component for the given scene
  114293. * @param scene Defines the scene to register the component in
  114294. */
  114295. constructor(scene: Scene);
  114296. /**
  114297. * Registers the component in a given scene
  114298. */
  114299. register(): void;
  114300. /**
  114301. * Rebuilds the elements related to this component in case of
  114302. * context lost for instance.
  114303. */
  114304. rebuild(): void;
  114305. /**
  114306. * Disposes the component and the associated ressources
  114307. */
  114308. dispose(): void;
  114309. private _beforeCameraUpdate;
  114310. }
  114311. }
  114312. declare module BABYLON {
  114313. /**
  114314. * 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,
  114315. * which still works and will still be found in many Playgrounds.
  114316. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114317. */
  114318. export class UniversalCamera extends TouchCamera {
  114319. /**
  114320. * Defines the gamepad rotation sensiblity.
  114321. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  114322. */
  114323. get gamepadAngularSensibility(): number;
  114324. set gamepadAngularSensibility(value: number);
  114325. /**
  114326. * Defines the gamepad move sensiblity.
  114327. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  114328. */
  114329. get gamepadMoveSensibility(): number;
  114330. set gamepadMoveSensibility(value: number);
  114331. /**
  114332. * 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,
  114333. * which still works and will still be found in many Playgrounds.
  114334. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114335. * @param name Define the name of the camera in the scene
  114336. * @param position Define the start position of the camera in the scene
  114337. * @param scene Define the scene the camera belongs to
  114338. */
  114339. constructor(name: string, position: Vector3, scene: Scene);
  114340. /**
  114341. * Gets the current object class name.
  114342. * @return the class name
  114343. */
  114344. getClassName(): string;
  114345. }
  114346. }
  114347. declare module BABYLON {
  114348. /**
  114349. * This represents a FPS type of camera. This is only here for back compat purpose.
  114350. * Please use the UniversalCamera instead as both are identical.
  114351. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114352. */
  114353. export class GamepadCamera extends UniversalCamera {
  114354. /**
  114355. * Instantiates a new Gamepad Camera
  114356. * This represents a FPS type of camera. This is only here for back compat purpose.
  114357. * Please use the UniversalCamera instead as both are identical.
  114358. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114359. * @param name Define the name of the camera in the scene
  114360. * @param position Define the start position of the camera in the scene
  114361. * @param scene Define the scene the camera belongs to
  114362. */
  114363. constructor(name: string, position: Vector3, scene: Scene);
  114364. /**
  114365. * Gets the current object class name.
  114366. * @return the class name
  114367. */
  114368. getClassName(): string;
  114369. }
  114370. }
  114371. declare module BABYLON {
  114372. /** @hidden */
  114373. export var passPixelShader: {
  114374. name: string;
  114375. shader: string;
  114376. };
  114377. }
  114378. declare module BABYLON {
  114379. /** @hidden */
  114380. export var passCubePixelShader: {
  114381. name: string;
  114382. shader: string;
  114383. };
  114384. }
  114385. declare module BABYLON {
  114386. /**
  114387. * PassPostProcess which produces an output the same as it's input
  114388. */
  114389. export class PassPostProcess extends PostProcess {
  114390. /**
  114391. * Creates the PassPostProcess
  114392. * @param name The name of the effect.
  114393. * @param options The required width/height ratio to downsize to before computing the render pass.
  114394. * @param camera The camera to apply the render pass to.
  114395. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114396. * @param engine The engine which the post process will be applied. (default: current engine)
  114397. * @param reusable If the post process can be reused on the same frame. (default: false)
  114398. * @param textureType The type of texture to be used when performing the post processing.
  114399. * @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)
  114400. */
  114401. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  114402. }
  114403. /**
  114404. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  114405. */
  114406. export class PassCubePostProcess extends PostProcess {
  114407. private _face;
  114408. /**
  114409. * Gets or sets the cube face to display.
  114410. * * 0 is +X
  114411. * * 1 is -X
  114412. * * 2 is +Y
  114413. * * 3 is -Y
  114414. * * 4 is +Z
  114415. * * 5 is -Z
  114416. */
  114417. get face(): number;
  114418. set face(value: number);
  114419. /**
  114420. * Creates the PassCubePostProcess
  114421. * @param name The name of the effect.
  114422. * @param options The required width/height ratio to downsize to before computing the render pass.
  114423. * @param camera The camera to apply the render pass to.
  114424. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114425. * @param engine The engine which the post process will be applied. (default: current engine)
  114426. * @param reusable If the post process can be reused on the same frame. (default: false)
  114427. * @param textureType The type of texture to be used when performing the post processing.
  114428. * @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)
  114429. */
  114430. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  114431. }
  114432. }
  114433. declare module BABYLON {
  114434. /** @hidden */
  114435. export var anaglyphPixelShader: {
  114436. name: string;
  114437. shader: string;
  114438. };
  114439. }
  114440. declare module BABYLON {
  114441. /**
  114442. * Postprocess used to generate anaglyphic rendering
  114443. */
  114444. export class AnaglyphPostProcess extends PostProcess {
  114445. private _passedProcess;
  114446. /**
  114447. * Creates a new AnaglyphPostProcess
  114448. * @param name defines postprocess name
  114449. * @param options defines creation options or target ratio scale
  114450. * @param rigCameras defines cameras using this postprocess
  114451. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  114452. * @param engine defines hosting engine
  114453. * @param reusable defines if the postprocess will be reused multiple times per frame
  114454. */
  114455. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  114456. }
  114457. }
  114458. declare module BABYLON {
  114459. /**
  114460. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  114461. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114462. */
  114463. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  114464. /**
  114465. * Creates a new AnaglyphArcRotateCamera
  114466. * @param name defines camera name
  114467. * @param alpha defines alpha angle (in radians)
  114468. * @param beta defines beta angle (in radians)
  114469. * @param radius defines radius
  114470. * @param target defines camera target
  114471. * @param interaxialDistance defines distance between each color axis
  114472. * @param scene defines the hosting scene
  114473. */
  114474. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  114475. /**
  114476. * Gets camera class name
  114477. * @returns AnaglyphArcRotateCamera
  114478. */
  114479. getClassName(): string;
  114480. }
  114481. }
  114482. declare module BABYLON {
  114483. /**
  114484. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  114485. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114486. */
  114487. export class AnaglyphFreeCamera extends FreeCamera {
  114488. /**
  114489. * Creates a new AnaglyphFreeCamera
  114490. * @param name defines camera name
  114491. * @param position defines initial position
  114492. * @param interaxialDistance defines distance between each color axis
  114493. * @param scene defines the hosting scene
  114494. */
  114495. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  114496. /**
  114497. * Gets camera class name
  114498. * @returns AnaglyphFreeCamera
  114499. */
  114500. getClassName(): string;
  114501. }
  114502. }
  114503. declare module BABYLON {
  114504. /**
  114505. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  114506. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114507. */
  114508. export class AnaglyphGamepadCamera extends GamepadCamera {
  114509. /**
  114510. * Creates a new AnaglyphGamepadCamera
  114511. * @param name defines camera name
  114512. * @param position defines initial position
  114513. * @param interaxialDistance defines distance between each color axis
  114514. * @param scene defines the hosting scene
  114515. */
  114516. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  114517. /**
  114518. * Gets camera class name
  114519. * @returns AnaglyphGamepadCamera
  114520. */
  114521. getClassName(): string;
  114522. }
  114523. }
  114524. declare module BABYLON {
  114525. /**
  114526. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  114527. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114528. */
  114529. export class AnaglyphUniversalCamera extends UniversalCamera {
  114530. /**
  114531. * Creates a new AnaglyphUniversalCamera
  114532. * @param name defines camera name
  114533. * @param position defines initial position
  114534. * @param interaxialDistance defines distance between each color axis
  114535. * @param scene defines the hosting scene
  114536. */
  114537. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  114538. /**
  114539. * Gets camera class name
  114540. * @returns AnaglyphUniversalCamera
  114541. */
  114542. getClassName(): string;
  114543. }
  114544. }
  114545. declare module BABYLON {
  114546. /** @hidden */
  114547. export var stereoscopicInterlacePixelShader: {
  114548. name: string;
  114549. shader: string;
  114550. };
  114551. }
  114552. declare module BABYLON {
  114553. /**
  114554. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  114555. */
  114556. export class StereoscopicInterlacePostProcessI extends PostProcess {
  114557. private _stepSize;
  114558. private _passedProcess;
  114559. /**
  114560. * Initializes a StereoscopicInterlacePostProcessI
  114561. * @param name The name of the effect.
  114562. * @param rigCameras The rig cameras to be appled to the post process
  114563. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  114564. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  114565. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114566. * @param engine The engine which the post process will be applied. (default: current engine)
  114567. * @param reusable If the post process can be reused on the same frame. (default: false)
  114568. */
  114569. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  114570. }
  114571. /**
  114572. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  114573. */
  114574. export class StereoscopicInterlacePostProcess extends PostProcess {
  114575. private _stepSize;
  114576. private _passedProcess;
  114577. /**
  114578. * Initializes a StereoscopicInterlacePostProcess
  114579. * @param name The name of the effect.
  114580. * @param rigCameras The rig cameras to be appled to the post process
  114581. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  114582. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114583. * @param engine The engine which the post process will be applied. (default: current engine)
  114584. * @param reusable If the post process can be reused on the same frame. (default: false)
  114585. */
  114586. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  114587. }
  114588. }
  114589. declare module BABYLON {
  114590. /**
  114591. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  114592. * @see http://doc.babylonjs.com/features/cameras
  114593. */
  114594. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  114595. /**
  114596. * Creates a new StereoscopicArcRotateCamera
  114597. * @param name defines camera name
  114598. * @param alpha defines alpha angle (in radians)
  114599. * @param beta defines beta angle (in radians)
  114600. * @param radius defines radius
  114601. * @param target defines camera target
  114602. * @param interaxialDistance defines distance between each color axis
  114603. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  114604. * @param scene defines the hosting scene
  114605. */
  114606. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  114607. /**
  114608. * Gets camera class name
  114609. * @returns StereoscopicArcRotateCamera
  114610. */
  114611. getClassName(): string;
  114612. }
  114613. }
  114614. declare module BABYLON {
  114615. /**
  114616. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  114617. * @see http://doc.babylonjs.com/features/cameras
  114618. */
  114619. export class StereoscopicFreeCamera extends FreeCamera {
  114620. /**
  114621. * Creates a new StereoscopicFreeCamera
  114622. * @param name defines camera name
  114623. * @param position defines initial position
  114624. * @param interaxialDistance defines distance between each color axis
  114625. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  114626. * @param scene defines the hosting scene
  114627. */
  114628. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  114629. /**
  114630. * Gets camera class name
  114631. * @returns StereoscopicFreeCamera
  114632. */
  114633. getClassName(): string;
  114634. }
  114635. }
  114636. declare module BABYLON {
  114637. /**
  114638. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  114639. * @see http://doc.babylonjs.com/features/cameras
  114640. */
  114641. export class StereoscopicGamepadCamera extends GamepadCamera {
  114642. /**
  114643. * Creates a new StereoscopicGamepadCamera
  114644. * @param name defines camera name
  114645. * @param position defines initial position
  114646. * @param interaxialDistance defines distance between each color axis
  114647. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  114648. * @param scene defines the hosting scene
  114649. */
  114650. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  114651. /**
  114652. * Gets camera class name
  114653. * @returns StereoscopicGamepadCamera
  114654. */
  114655. getClassName(): string;
  114656. }
  114657. }
  114658. declare module BABYLON {
  114659. /**
  114660. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  114661. * @see http://doc.babylonjs.com/features/cameras
  114662. */
  114663. export class StereoscopicUniversalCamera extends UniversalCamera {
  114664. /**
  114665. * Creates a new StereoscopicUniversalCamera
  114666. * @param name defines camera name
  114667. * @param position defines initial position
  114668. * @param interaxialDistance defines distance between each color axis
  114669. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  114670. * @param scene defines the hosting scene
  114671. */
  114672. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  114673. /**
  114674. * Gets camera class name
  114675. * @returns StereoscopicUniversalCamera
  114676. */
  114677. getClassName(): string;
  114678. }
  114679. }
  114680. declare module BABYLON {
  114681. /**
  114682. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  114683. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  114684. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  114685. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  114686. */
  114687. export class VirtualJoysticksCamera extends FreeCamera {
  114688. /**
  114689. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  114690. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  114691. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  114692. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  114693. * @param name Define the name of the camera in the scene
  114694. * @param position Define the start position of the camera in the scene
  114695. * @param scene Define the scene the camera belongs to
  114696. */
  114697. constructor(name: string, position: Vector3, scene: Scene);
  114698. /**
  114699. * Gets the current object class name.
  114700. * @return the class name
  114701. */
  114702. getClassName(): string;
  114703. }
  114704. }
  114705. declare module BABYLON {
  114706. /**
  114707. * This represents all the required metrics to create a VR camera.
  114708. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  114709. */
  114710. export class VRCameraMetrics {
  114711. /**
  114712. * Define the horizontal resolution off the screen.
  114713. */
  114714. hResolution: number;
  114715. /**
  114716. * Define the vertical resolution off the screen.
  114717. */
  114718. vResolution: number;
  114719. /**
  114720. * Define the horizontal screen size.
  114721. */
  114722. hScreenSize: number;
  114723. /**
  114724. * Define the vertical screen size.
  114725. */
  114726. vScreenSize: number;
  114727. /**
  114728. * Define the vertical screen center position.
  114729. */
  114730. vScreenCenter: number;
  114731. /**
  114732. * Define the distance of the eyes to the screen.
  114733. */
  114734. eyeToScreenDistance: number;
  114735. /**
  114736. * Define the distance between both lenses
  114737. */
  114738. lensSeparationDistance: number;
  114739. /**
  114740. * Define the distance between both viewer's eyes.
  114741. */
  114742. interpupillaryDistance: number;
  114743. /**
  114744. * Define the distortion factor of the VR postprocess.
  114745. * Please, touch with care.
  114746. */
  114747. distortionK: number[];
  114748. /**
  114749. * Define the chromatic aberration correction factors for the VR post process.
  114750. */
  114751. chromaAbCorrection: number[];
  114752. /**
  114753. * Define the scale factor of the post process.
  114754. * The smaller the better but the slower.
  114755. */
  114756. postProcessScaleFactor: number;
  114757. /**
  114758. * Define an offset for the lens center.
  114759. */
  114760. lensCenterOffset: number;
  114761. /**
  114762. * Define if the current vr camera should compensate the distortion of the lense or not.
  114763. */
  114764. compensateDistortion: boolean;
  114765. /**
  114766. * Defines if multiview should be enabled when rendering (Default: false)
  114767. */
  114768. multiviewEnabled: boolean;
  114769. /**
  114770. * Gets the rendering aspect ratio based on the provided resolutions.
  114771. */
  114772. get aspectRatio(): number;
  114773. /**
  114774. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  114775. */
  114776. get aspectRatioFov(): number;
  114777. /**
  114778. * @hidden
  114779. */
  114780. get leftHMatrix(): Matrix;
  114781. /**
  114782. * @hidden
  114783. */
  114784. get rightHMatrix(): Matrix;
  114785. /**
  114786. * @hidden
  114787. */
  114788. get leftPreViewMatrix(): Matrix;
  114789. /**
  114790. * @hidden
  114791. */
  114792. get rightPreViewMatrix(): Matrix;
  114793. /**
  114794. * Get the default VRMetrics based on the most generic setup.
  114795. * @returns the default vr metrics
  114796. */
  114797. static GetDefault(): VRCameraMetrics;
  114798. }
  114799. }
  114800. declare module BABYLON {
  114801. /** @hidden */
  114802. export var vrDistortionCorrectionPixelShader: {
  114803. name: string;
  114804. shader: string;
  114805. };
  114806. }
  114807. declare module BABYLON {
  114808. /**
  114809. * VRDistortionCorrectionPostProcess used for mobile VR
  114810. */
  114811. export class VRDistortionCorrectionPostProcess extends PostProcess {
  114812. private _isRightEye;
  114813. private _distortionFactors;
  114814. private _postProcessScaleFactor;
  114815. private _lensCenterOffset;
  114816. private _scaleIn;
  114817. private _scaleFactor;
  114818. private _lensCenter;
  114819. /**
  114820. * Initializes the VRDistortionCorrectionPostProcess
  114821. * @param name The name of the effect.
  114822. * @param camera The camera to apply the render pass to.
  114823. * @param isRightEye If this is for the right eye distortion
  114824. * @param vrMetrics All the required metrics for the VR camera
  114825. */
  114826. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  114827. }
  114828. }
  114829. declare module BABYLON {
  114830. /**
  114831. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  114832. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  114833. */
  114834. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  114835. /**
  114836. * Creates a new VRDeviceOrientationArcRotateCamera
  114837. * @param name defines camera name
  114838. * @param alpha defines the camera rotation along the logitudinal axis
  114839. * @param beta defines the camera rotation along the latitudinal axis
  114840. * @param radius defines the camera distance from its target
  114841. * @param target defines the camera target
  114842. * @param scene defines the scene the camera belongs to
  114843. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  114844. * @param vrCameraMetrics defines the vr metrics associated to the camera
  114845. */
  114846. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  114847. /**
  114848. * Gets camera class name
  114849. * @returns VRDeviceOrientationArcRotateCamera
  114850. */
  114851. getClassName(): string;
  114852. }
  114853. }
  114854. declare module BABYLON {
  114855. /**
  114856. * Camera used to simulate VR rendering (based on FreeCamera)
  114857. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  114858. */
  114859. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  114860. /**
  114861. * Creates a new VRDeviceOrientationFreeCamera
  114862. * @param name defines camera name
  114863. * @param position defines the start position of the camera
  114864. * @param scene defines the scene the camera belongs to
  114865. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  114866. * @param vrCameraMetrics defines the vr metrics associated to the camera
  114867. */
  114868. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  114869. /**
  114870. * Gets camera class name
  114871. * @returns VRDeviceOrientationFreeCamera
  114872. */
  114873. getClassName(): string;
  114874. }
  114875. }
  114876. declare module BABYLON {
  114877. /**
  114878. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  114879. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  114880. */
  114881. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  114882. /**
  114883. * Creates a new VRDeviceOrientationGamepadCamera
  114884. * @param name defines camera name
  114885. * @param position defines the start position of the camera
  114886. * @param scene defines the scene the camera belongs to
  114887. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  114888. * @param vrCameraMetrics defines the vr metrics associated to the camera
  114889. */
  114890. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  114891. /**
  114892. * Gets camera class name
  114893. * @returns VRDeviceOrientationGamepadCamera
  114894. */
  114895. getClassName(): string;
  114896. }
  114897. }
  114898. declare module BABYLON {
  114899. /** @hidden */
  114900. export var imageProcessingPixelShader: {
  114901. name: string;
  114902. shader: string;
  114903. };
  114904. }
  114905. declare module BABYLON {
  114906. /**
  114907. * ImageProcessingPostProcess
  114908. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  114909. */
  114910. export class ImageProcessingPostProcess extends PostProcess {
  114911. /**
  114912. * Default configuration related to image processing available in the PBR Material.
  114913. */
  114914. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114915. /**
  114916. * Gets the image processing configuration used either in this material.
  114917. */
  114918. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  114919. /**
  114920. * Sets the Default image processing configuration used either in the this material.
  114921. *
  114922. * If sets to null, the scene one is in use.
  114923. */
  114924. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  114925. /**
  114926. * Keep track of the image processing observer to allow dispose and replace.
  114927. */
  114928. private _imageProcessingObserver;
  114929. /**
  114930. * Attaches a new image processing configuration to the PBR Material.
  114931. * @param configuration
  114932. */
  114933. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  114934. /**
  114935. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  114936. */
  114937. get colorCurves(): Nullable<ColorCurves>;
  114938. /**
  114939. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  114940. */
  114941. set colorCurves(value: Nullable<ColorCurves>);
  114942. /**
  114943. * Gets wether the color curves effect is enabled.
  114944. */
  114945. get colorCurvesEnabled(): boolean;
  114946. /**
  114947. * Sets wether the color curves effect is enabled.
  114948. */
  114949. set colorCurvesEnabled(value: boolean);
  114950. /**
  114951. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  114952. */
  114953. get colorGradingTexture(): Nullable<BaseTexture>;
  114954. /**
  114955. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  114956. */
  114957. set colorGradingTexture(value: Nullable<BaseTexture>);
  114958. /**
  114959. * Gets wether the color grading effect is enabled.
  114960. */
  114961. get colorGradingEnabled(): boolean;
  114962. /**
  114963. * Gets wether the color grading effect is enabled.
  114964. */
  114965. set colorGradingEnabled(value: boolean);
  114966. /**
  114967. * Gets exposure used in the effect.
  114968. */
  114969. get exposure(): number;
  114970. /**
  114971. * Sets exposure used in the effect.
  114972. */
  114973. set exposure(value: number);
  114974. /**
  114975. * Gets wether tonemapping is enabled or not.
  114976. */
  114977. get toneMappingEnabled(): boolean;
  114978. /**
  114979. * Sets wether tonemapping is enabled or not
  114980. */
  114981. set toneMappingEnabled(value: boolean);
  114982. /**
  114983. * Gets the type of tone mapping effect.
  114984. */
  114985. get toneMappingType(): number;
  114986. /**
  114987. * Sets the type of tone mapping effect.
  114988. */
  114989. set toneMappingType(value: number);
  114990. /**
  114991. * Gets contrast used in the effect.
  114992. */
  114993. get contrast(): number;
  114994. /**
  114995. * Sets contrast used in the effect.
  114996. */
  114997. set contrast(value: number);
  114998. /**
  114999. * Gets Vignette stretch size.
  115000. */
  115001. get vignetteStretch(): number;
  115002. /**
  115003. * Sets Vignette stretch size.
  115004. */
  115005. set vignetteStretch(value: number);
  115006. /**
  115007. * Gets Vignette centre X Offset.
  115008. */
  115009. get vignetteCentreX(): number;
  115010. /**
  115011. * Sets Vignette centre X Offset.
  115012. */
  115013. set vignetteCentreX(value: number);
  115014. /**
  115015. * Gets Vignette centre Y Offset.
  115016. */
  115017. get vignetteCentreY(): number;
  115018. /**
  115019. * Sets Vignette centre Y Offset.
  115020. */
  115021. set vignetteCentreY(value: number);
  115022. /**
  115023. * Gets Vignette weight or intensity of the vignette effect.
  115024. */
  115025. get vignetteWeight(): number;
  115026. /**
  115027. * Sets Vignette weight or intensity of the vignette effect.
  115028. */
  115029. set vignetteWeight(value: number);
  115030. /**
  115031. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115032. * if vignetteEnabled is set to true.
  115033. */
  115034. get vignetteColor(): Color4;
  115035. /**
  115036. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115037. * if vignetteEnabled is set to true.
  115038. */
  115039. set vignetteColor(value: Color4);
  115040. /**
  115041. * Gets Camera field of view used by the Vignette effect.
  115042. */
  115043. get vignetteCameraFov(): number;
  115044. /**
  115045. * Sets Camera field of view used by the Vignette effect.
  115046. */
  115047. set vignetteCameraFov(value: number);
  115048. /**
  115049. * Gets the vignette blend mode allowing different kind of effect.
  115050. */
  115051. get vignetteBlendMode(): number;
  115052. /**
  115053. * Sets the vignette blend mode allowing different kind of effect.
  115054. */
  115055. set vignetteBlendMode(value: number);
  115056. /**
  115057. * Gets wether the vignette effect is enabled.
  115058. */
  115059. get vignetteEnabled(): boolean;
  115060. /**
  115061. * Sets wether the vignette effect is enabled.
  115062. */
  115063. set vignetteEnabled(value: boolean);
  115064. private _fromLinearSpace;
  115065. /**
  115066. * Gets wether the input of the processing is in Gamma or Linear Space.
  115067. */
  115068. get fromLinearSpace(): boolean;
  115069. /**
  115070. * Sets wether the input of the processing is in Gamma or Linear Space.
  115071. */
  115072. set fromLinearSpace(value: boolean);
  115073. /**
  115074. * Defines cache preventing GC.
  115075. */
  115076. private _defines;
  115077. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  115078. /**
  115079. * "ImageProcessingPostProcess"
  115080. * @returns "ImageProcessingPostProcess"
  115081. */
  115082. getClassName(): string;
  115083. protected _updateParameters(): void;
  115084. dispose(camera?: Camera): void;
  115085. }
  115086. }
  115087. declare module BABYLON {
  115088. /**
  115089. * Class containing static functions to help procedurally build meshes
  115090. */
  115091. export class GroundBuilder {
  115092. /**
  115093. * Creates a ground mesh
  115094. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  115095. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  115096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115097. * @param name defines the name of the mesh
  115098. * @param options defines the options used to create the mesh
  115099. * @param scene defines the hosting scene
  115100. * @returns the ground mesh
  115101. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  115102. */
  115103. static CreateGround(name: string, options: {
  115104. width?: number;
  115105. height?: number;
  115106. subdivisions?: number;
  115107. subdivisionsX?: number;
  115108. subdivisionsY?: number;
  115109. updatable?: boolean;
  115110. }, scene: any): Mesh;
  115111. /**
  115112. * Creates a tiled ground mesh
  115113. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  115114. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  115115. * * 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
  115116. * * 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
  115117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115118. * @param name defines the name of the mesh
  115119. * @param options defines the options used to create the mesh
  115120. * @param scene defines the hosting scene
  115121. * @returns the tiled ground mesh
  115122. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  115123. */
  115124. static CreateTiledGround(name: string, options: {
  115125. xmin: number;
  115126. zmin: number;
  115127. xmax: number;
  115128. zmax: number;
  115129. subdivisions?: {
  115130. w: number;
  115131. h: number;
  115132. };
  115133. precision?: {
  115134. w: number;
  115135. h: number;
  115136. };
  115137. updatable?: boolean;
  115138. }, scene?: Nullable<Scene>): Mesh;
  115139. /**
  115140. * Creates a ground mesh from a height map
  115141. * * The parameter `url` sets the URL of the height map image resource.
  115142. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  115143. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  115144. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  115145. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  115146. * * 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.
  115147. * * 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).
  115148. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  115149. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115150. * @param name defines the name of the mesh
  115151. * @param url defines the url to the height map
  115152. * @param options defines the options used to create the mesh
  115153. * @param scene defines the hosting scene
  115154. * @returns the ground mesh
  115155. * @see https://doc.babylonjs.com/babylon101/height_map
  115156. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  115157. */
  115158. static CreateGroundFromHeightMap(name: string, url: string, options: {
  115159. width?: number;
  115160. height?: number;
  115161. subdivisions?: number;
  115162. minHeight?: number;
  115163. maxHeight?: number;
  115164. colorFilter?: Color3;
  115165. alphaFilter?: number;
  115166. updatable?: boolean;
  115167. onReady?: (mesh: GroundMesh) => void;
  115168. }, scene?: Nullable<Scene>): GroundMesh;
  115169. }
  115170. }
  115171. declare module BABYLON {
  115172. /**
  115173. * Class containing static functions to help procedurally build meshes
  115174. */
  115175. export class TorusBuilder {
  115176. /**
  115177. * Creates a torus mesh
  115178. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  115179. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  115180. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  115181. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115182. * * 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
  115183. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115184. * @param name defines the name of the mesh
  115185. * @param options defines the options used to create the mesh
  115186. * @param scene defines the hosting scene
  115187. * @returns the torus mesh
  115188. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  115189. */
  115190. static CreateTorus(name: string, options: {
  115191. diameter?: number;
  115192. thickness?: number;
  115193. tessellation?: number;
  115194. updatable?: boolean;
  115195. sideOrientation?: number;
  115196. frontUVs?: Vector4;
  115197. backUVs?: Vector4;
  115198. }, scene: any): Mesh;
  115199. }
  115200. }
  115201. declare module BABYLON {
  115202. /**
  115203. * Class containing static functions to help procedurally build meshes
  115204. */
  115205. export class CylinderBuilder {
  115206. /**
  115207. * Creates a cylinder or a cone mesh
  115208. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  115209. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  115210. * * 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.
  115211. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  115212. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  115213. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  115214. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  115215. * * 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).
  115216. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  115217. * * 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).
  115218. * * 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
  115219. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  115220. * * 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
  115221. * * 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.
  115222. * * If `enclose` is false, a ring surface is one element.
  115223. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  115224. * * 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
  115225. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115226. * * 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
  115227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115228. * @param name defines the name of the mesh
  115229. * @param options defines the options used to create the mesh
  115230. * @param scene defines the hosting scene
  115231. * @returns the cylinder mesh
  115232. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  115233. */
  115234. static CreateCylinder(name: string, options: {
  115235. height?: number;
  115236. diameterTop?: number;
  115237. diameterBottom?: number;
  115238. diameter?: number;
  115239. tessellation?: number;
  115240. subdivisions?: number;
  115241. arc?: number;
  115242. faceColors?: Color4[];
  115243. faceUV?: Vector4[];
  115244. updatable?: boolean;
  115245. hasRings?: boolean;
  115246. enclose?: boolean;
  115247. cap?: number;
  115248. sideOrientation?: number;
  115249. frontUVs?: Vector4;
  115250. backUVs?: Vector4;
  115251. }, scene: any): Mesh;
  115252. }
  115253. }
  115254. declare module BABYLON {
  115255. /**
  115256. * States of the webXR experience
  115257. */
  115258. export enum WebXRState {
  115259. /**
  115260. * Transitioning to being in XR mode
  115261. */
  115262. ENTERING_XR = 0,
  115263. /**
  115264. * Transitioning to non XR mode
  115265. */
  115266. EXITING_XR = 1,
  115267. /**
  115268. * In XR mode and presenting
  115269. */
  115270. IN_XR = 2,
  115271. /**
  115272. * Not entered XR mode
  115273. */
  115274. NOT_IN_XR = 3
  115275. }
  115276. /**
  115277. * Abstraction of the XR render target
  115278. */
  115279. export interface WebXRRenderTarget extends IDisposable {
  115280. /**
  115281. * xrpresent context of the canvas which can be used to display/mirror xr content
  115282. */
  115283. canvasContext: WebGLRenderingContext;
  115284. /**
  115285. * xr layer for the canvas
  115286. */
  115287. xrLayer: Nullable<XRWebGLLayer>;
  115288. /**
  115289. * Initializes the xr layer for the session
  115290. * @param xrSession xr session
  115291. * @returns a promise that will resolve once the XR Layer has been created
  115292. */
  115293. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  115294. }
  115295. }
  115296. declare module BABYLON {
  115297. /**
  115298. * COnfiguration object for WebXR output canvas
  115299. */
  115300. export class WebXRManagedOutputCanvasOptions {
  115301. /**
  115302. * Options for this XR Layer output
  115303. */
  115304. canvasOptions?: XRWebGLLayerOptions;
  115305. /**
  115306. * CSS styling for a newly created canvas (if not provided)
  115307. */
  115308. newCanvasCssStyle?: string;
  115309. /**
  115310. * An optional canvas in case you wish to create it yourself and provide it here.
  115311. * If not provided, a new canvas will be created
  115312. */
  115313. canvasElement?: HTMLCanvasElement;
  115314. /**
  115315. * Get the default values of the configuration object
  115316. * @returns default values of this configuration object
  115317. */
  115318. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  115319. }
  115320. /**
  115321. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  115322. */
  115323. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  115324. private _options;
  115325. private _engine;
  115326. private _canvas;
  115327. /**
  115328. * Rendering context of the canvas which can be used to display/mirror xr content
  115329. */
  115330. canvasContext: WebGLRenderingContext;
  115331. /**
  115332. * xr layer for the canvas
  115333. */
  115334. xrLayer: Nullable<XRWebGLLayer>;
  115335. /**
  115336. * Initializes the xr layer for the session
  115337. * @param xrSession xr session
  115338. * @returns a promise that will resolve once the XR Layer has been created
  115339. */
  115340. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  115341. /**
  115342. * Initializes the canvas to be added/removed upon entering/exiting xr
  115343. * @param _xrSessionManager The XR Session manager
  115344. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  115345. */
  115346. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  115347. /**
  115348. * Disposes of the object
  115349. */
  115350. dispose(): void;
  115351. private _setManagedOutputCanvas;
  115352. private _addCanvas;
  115353. private _removeCanvas;
  115354. }
  115355. }
  115356. declare module BABYLON {
  115357. /**
  115358. * Manages an XRSession to work with Babylon's engine
  115359. * @see https://doc.babylonjs.com/how_to/webxr
  115360. */
  115361. export class WebXRSessionManager implements IDisposable {
  115362. /** The scene which the session should be created for */
  115363. scene: Scene;
  115364. /**
  115365. * Fires every time a new xrFrame arrives which can be used to update the camera
  115366. */
  115367. onXRFrameObservable: Observable<XRFrame>;
  115368. /**
  115369. * Fires when the xr session is ended either by the device or manually done
  115370. */
  115371. onXRSessionEnded: Observable<any>;
  115372. /**
  115373. * Fires when the xr session is ended either by the device or manually done
  115374. */
  115375. onXRSessionInit: Observable<XRSession>;
  115376. /**
  115377. * Fires when the reference space changed
  115378. */
  115379. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  115380. /**
  115381. * Underlying xr session
  115382. */
  115383. session: XRSession;
  115384. /**
  115385. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  115386. * or get the offset the player is currently at.
  115387. */
  115388. viewerReferenceSpace: XRReferenceSpace;
  115389. private _referenceSpace;
  115390. /**
  115391. * The current reference space used in this session. This reference space can constantly change!
  115392. * It is mainly used to offset the camera's position.
  115393. */
  115394. get referenceSpace(): XRReferenceSpace;
  115395. /**
  115396. * Set a new reference space and triggers the observable
  115397. */
  115398. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  115399. /**
  115400. * The base reference space from which the session started. good if you want to reset your
  115401. * reference space
  115402. */
  115403. baseReferenceSpace: XRReferenceSpace;
  115404. /**
  115405. * Used just in case of a failure to initialize an immersive session.
  115406. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  115407. */
  115408. defaultHeightCompensation: number;
  115409. /**
  115410. * Current XR frame
  115411. */
  115412. currentFrame: Nullable<XRFrame>;
  115413. /** WebXR timestamp updated every frame */
  115414. currentTimestamp: number;
  115415. private _xrNavigator;
  115416. private baseLayer;
  115417. private _rttProvider;
  115418. private _sessionEnded;
  115419. /**
  115420. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  115421. * @param scene The scene which the session should be created for
  115422. */
  115423. constructor(
  115424. /** The scene which the session should be created for */
  115425. scene: Scene);
  115426. /**
  115427. * Initializes the manager
  115428. * After initialization enterXR can be called to start an XR session
  115429. * @returns Promise which resolves after it is initialized
  115430. */
  115431. initializeAsync(): Promise<void>;
  115432. /**
  115433. * Initializes an xr session
  115434. * @param xrSessionMode mode to initialize
  115435. * @param xrSessionInit defines optional and required values to pass to the session builder
  115436. * @returns a promise which will resolve once the session has been initialized
  115437. */
  115438. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  115439. /**
  115440. * Sets the reference space on the xr session
  115441. * @param referenceSpaceType space to set
  115442. * @returns a promise that will resolve once the reference space has been set
  115443. */
  115444. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  115445. /**
  115446. * Resets the reference space to the one started the session
  115447. */
  115448. resetReferenceSpace(): void;
  115449. /**
  115450. * Updates the render state of the session
  115451. * @param state state to set
  115452. * @returns a promise that resolves once the render state has been updated
  115453. */
  115454. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  115455. /**
  115456. * Starts rendering to the xr layer
  115457. */
  115458. runXRRenderLoop(): void;
  115459. /**
  115460. * Gets the correct render target texture to be rendered this frame for this eye
  115461. * @param eye the eye for which to get the render target
  115462. * @returns the render target for the specified eye
  115463. */
  115464. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  115465. /**
  115466. * Stops the xrSession and restores the renderloop
  115467. * @returns Promise which resolves after it exits XR
  115468. */
  115469. exitXRAsync(): Promise<void>;
  115470. /**
  115471. * Checks if a session would be supported for the creation options specified
  115472. * @param sessionMode session mode to check if supported eg. immersive-vr
  115473. * @returns A Promise that resolves to true if supported and false if not
  115474. */
  115475. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  115476. /**
  115477. * Creates a WebXRRenderTarget object for the XR session
  115478. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  115479. * @param options optional options to provide when creating a new render target
  115480. * @returns a WebXR render target to which the session can render
  115481. */
  115482. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  115483. /**
  115484. * @hidden
  115485. * Converts the render layer of xrSession to a render target
  115486. * @param session session to create render target for
  115487. * @param scene scene the new render target should be created for
  115488. * @param baseLayer the webgl layer to create the render target for
  115489. */
  115490. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  115491. /**
  115492. * Disposes of the session manager
  115493. */
  115494. dispose(): void;
  115495. /**
  115496. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  115497. * @param sessionMode defines the session to test
  115498. * @returns a promise with boolean as final value
  115499. */
  115500. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  115501. }
  115502. }
  115503. declare module BABYLON {
  115504. /**
  115505. * WebXR Camera which holds the views for the xrSession
  115506. * @see https://doc.babylonjs.com/how_to/webxr_camera
  115507. */
  115508. export class WebXRCamera extends FreeCamera {
  115509. private _xrSessionManager;
  115510. private _firstFrame;
  115511. private _referenceQuaternion;
  115512. private _referencedPosition;
  115513. private _xrInvPositionCache;
  115514. private _xrInvQuaternionCache;
  115515. /**
  115516. * Should position compensation execute on first frame.
  115517. * This is used when copying the position from a native (non XR) camera
  115518. */
  115519. compensateOnFirstFrame: boolean;
  115520. /**
  115521. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  115522. * @param name the name of the camera
  115523. * @param scene the scene to add the camera to
  115524. * @param _xrSessionManager a constructed xr session manager
  115525. */
  115526. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  115527. /**
  115528. * Return the user's height, unrelated to the current ground.
  115529. * This will be the y position of this camera, when ground level is 0.
  115530. */
  115531. get realWorldHeight(): number;
  115532. /** @hidden */
  115533. _updateForDualEyeDebugging(): void;
  115534. /**
  115535. * Sets this camera's transformation based on a non-vr camera
  115536. * @param otherCamera the non-vr camera to copy the transformation from
  115537. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  115538. */
  115539. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  115540. private _updateFromXRSession;
  115541. private _updateNumberOfRigCameras;
  115542. private _updateReferenceSpace;
  115543. private _updateReferenceSpaceOffset;
  115544. }
  115545. }
  115546. declare module BABYLON {
  115547. /**
  115548. * Defining the interface required for a (webxr) feature
  115549. */
  115550. export interface IWebXRFeature extends IDisposable {
  115551. /**
  115552. * Is this feature attached
  115553. */
  115554. attached: boolean;
  115555. /**
  115556. * Should auto-attach be disabled?
  115557. */
  115558. disableAutoAttach: boolean;
  115559. /**
  115560. * Attach the feature to the session
  115561. * Will usually be called by the features manager
  115562. *
  115563. * @param force should attachment be forced (even when already attached)
  115564. * @returns true if successful.
  115565. */
  115566. attach(force?: boolean): boolean;
  115567. /**
  115568. * Detach the feature from the session
  115569. * Will usually be called by the features manager
  115570. *
  115571. * @returns true if successful.
  115572. */
  115573. detach(): boolean;
  115574. }
  115575. /**
  115576. * A list of the currently available features without referencing them
  115577. */
  115578. export class WebXRFeatureName {
  115579. /**
  115580. * The name of the hit test feature
  115581. */
  115582. static HIT_TEST: string;
  115583. /**
  115584. * The name of the anchor system feature
  115585. */
  115586. static ANCHOR_SYSTEM: string;
  115587. /**
  115588. * The name of the background remover feature
  115589. */
  115590. static BACKGROUND_REMOVER: string;
  115591. /**
  115592. * The name of the pointer selection feature
  115593. */
  115594. static POINTER_SELECTION: string;
  115595. /**
  115596. * The name of the teleportation feature
  115597. */
  115598. static TELEPORTATION: string;
  115599. /**
  115600. * The name of the plane detection feature
  115601. */
  115602. static PLANE_DETECTION: string;
  115603. /**
  115604. * physics impostors for xr controllers feature
  115605. */
  115606. static PHYSICS_CONTROLLERS: string;
  115607. }
  115608. /**
  115609. * Defining the constructor of a feature. Used to register the modules.
  115610. */
  115611. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  115612. /**
  115613. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  115614. * It is mainly used in AR sessions.
  115615. *
  115616. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  115617. */
  115618. export class WebXRFeaturesManager implements IDisposable {
  115619. private _xrSessionManager;
  115620. private static readonly _AvailableFeatures;
  115621. /**
  115622. * Used to register a module. After calling this function a developer can use this feature in the scene.
  115623. * Mainly used internally.
  115624. *
  115625. * @param featureName the name of the feature to register
  115626. * @param constructorFunction the function used to construct the module
  115627. * @param version the (babylon) version of the module
  115628. * @param stable is that a stable version of this module
  115629. */
  115630. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  115631. /**
  115632. * Returns a constructor of a specific feature.
  115633. *
  115634. * @param featureName the name of the feature to construct
  115635. * @param version the version of the feature to load
  115636. * @param xrSessionManager the xrSessionManager. Used to construct the module
  115637. * @param options optional options provided to the module.
  115638. * @returns a function that, when called, will return a new instance of this feature
  115639. */
  115640. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  115641. /**
  115642. * Return the latest unstable version of this feature
  115643. * @param featureName the name of the feature to search
  115644. * @returns the version number. if not found will return -1
  115645. */
  115646. static GetLatestVersionOfFeature(featureName: string): number;
  115647. /**
  115648. * Return the latest stable version of this feature
  115649. * @param featureName the name of the feature to search
  115650. * @returns the version number. if not found will return -1
  115651. */
  115652. static GetStableVersionOfFeature(featureName: string): number;
  115653. /**
  115654. * Can be used to return the list of features currently registered
  115655. *
  115656. * @returns an Array of available features
  115657. */
  115658. static GetAvailableFeatures(): string[];
  115659. /**
  115660. * Gets the versions available for a specific feature
  115661. * @param featureName the name of the feature
  115662. * @returns an array with the available versions
  115663. */
  115664. static GetAvailableVersions(featureName: string): string[];
  115665. private _features;
  115666. /**
  115667. * constructs a new features manages.
  115668. *
  115669. * @param _xrSessionManager an instance of WebXRSessionManager
  115670. */
  115671. constructor(_xrSessionManager: WebXRSessionManager);
  115672. /**
  115673. * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.
  115674. * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.
  115675. *
  115676. * @param featureName the name of the feature to load or the class of the feature
  115677. * @param version optional version to load. if not provided the latest version will be enabled
  115678. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  115679. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  115680. * @returns a new constructed feature or throws an error if feature not found.
  115681. */
  115682. enableFeature(featureName: string | {
  115683. Name: string;
  115684. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  115685. /**
  115686. * Used to disable an already-enabled feature
  115687. * The feature will be disposed and will be recreated once enabled.
  115688. * @param featureName the feature to disable
  115689. * @returns true if disable was successful
  115690. */
  115691. disableFeature(featureName: string | {
  115692. Name: string;
  115693. }): boolean;
  115694. /**
  115695. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  115696. * Can be used during a session to start a feature
  115697. * @param featureName the name of feature to attach
  115698. */
  115699. attachFeature(featureName: string): void;
  115700. /**
  115701. * Can be used inside a session or when the session ends to detach a specific feature
  115702. * @param featureName the name of the feature to detach
  115703. */
  115704. detachFeature(featureName: string): void;
  115705. /**
  115706. * Get the list of enabled features
  115707. * @returns an array of enabled features
  115708. */
  115709. getEnabledFeatures(): string[];
  115710. /**
  115711. * get the implementation of an enabled feature.
  115712. * @param featureName the name of the feature to load
  115713. * @returns the feature class, if found
  115714. */
  115715. getEnabledFeature(featureName: string): IWebXRFeature;
  115716. /**
  115717. * dispose this features manager
  115718. */
  115719. dispose(): void;
  115720. }
  115721. }
  115722. declare module BABYLON {
  115723. /**
  115724. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  115725. * @see https://doc.babylonjs.com/how_to/webxr
  115726. */
  115727. export class WebXRExperienceHelper implements IDisposable {
  115728. private scene;
  115729. /**
  115730. * Camera used to render xr content
  115731. */
  115732. camera: WebXRCamera;
  115733. /**
  115734. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  115735. */
  115736. state: WebXRState;
  115737. private _setState;
  115738. /**
  115739. * Fires when the state of the experience helper has changed
  115740. */
  115741. onStateChangedObservable: Observable<WebXRState>;
  115742. /**
  115743. * Observers registered here will be triggered after the camera's initial transformation is set
  115744. * This can be used to set a different ground level or an extra rotation.
  115745. *
  115746. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  115747. * to the position set after this observable is done executing.
  115748. */
  115749. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  115750. /** Session manager used to keep track of xr session */
  115751. sessionManager: WebXRSessionManager;
  115752. /** A features manager for this xr session */
  115753. featuresManager: WebXRFeaturesManager;
  115754. private _nonVRCamera;
  115755. private _originalSceneAutoClear;
  115756. private _supported;
  115757. /**
  115758. * Creates the experience helper
  115759. * @param scene the scene to attach the experience helper to
  115760. * @returns a promise for the experience helper
  115761. */
  115762. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  115763. /**
  115764. * Creates a WebXRExperienceHelper
  115765. * @param scene The scene the helper should be created in
  115766. */
  115767. private constructor();
  115768. /**
  115769. * Exits XR mode and returns the scene to its original state
  115770. * @returns promise that resolves after xr mode has exited
  115771. */
  115772. exitXRAsync(): Promise<void>;
  115773. /**
  115774. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  115775. * @param sessionMode options for the XR session
  115776. * @param referenceSpaceType frame of reference of the XR session
  115777. * @param renderTarget the output canvas that will be used to enter XR mode
  115778. * @returns promise that resolves after xr mode has entered
  115779. */
  115780. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  115781. /**
  115782. * Disposes of the experience helper
  115783. */
  115784. dispose(): void;
  115785. private _nonXRToXRCamera;
  115786. }
  115787. }
  115788. declare module BABYLON {
  115789. /**
  115790. * X-Y values for axes in WebXR
  115791. */
  115792. export interface IWebXRMotionControllerAxesValue {
  115793. /**
  115794. * The value of the x axis
  115795. */
  115796. x: number;
  115797. /**
  115798. * The value of the y-axis
  115799. */
  115800. y: number;
  115801. }
  115802. /**
  115803. * changed / previous values for the values of this component
  115804. */
  115805. export interface IWebXRMotionControllerComponentChangesValues<T> {
  115806. /**
  115807. * current (this frame) value
  115808. */
  115809. current: T;
  115810. /**
  115811. * previous (last change) value
  115812. */
  115813. previous: T;
  115814. }
  115815. /**
  115816. * Represents changes in the component between current frame and last values recorded
  115817. */
  115818. export interface IWebXRMotionControllerComponentChanges {
  115819. /**
  115820. * will be populated with previous and current values if touched changed
  115821. */
  115822. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  115823. /**
  115824. * will be populated with previous and current values if pressed changed
  115825. */
  115826. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  115827. /**
  115828. * will be populated with previous and current values if value changed
  115829. */
  115830. value?: IWebXRMotionControllerComponentChangesValues<number>;
  115831. /**
  115832. * will be populated with previous and current values if axes changed
  115833. */
  115834. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  115835. }
  115836. /**
  115837. * This class represents a single component (for example button or thumbstick) of a motion controller
  115838. */
  115839. export class WebXRControllerComponent implements IDisposable {
  115840. /**
  115841. * the id of this component
  115842. */
  115843. id: string;
  115844. /**
  115845. * the type of the component
  115846. */
  115847. type: MotionControllerComponentType;
  115848. private _buttonIndex;
  115849. private _axesIndices;
  115850. /**
  115851. * Thumbstick component type
  115852. */
  115853. static THUMBSTICK: MotionControllerComponentType;
  115854. /**
  115855. * Touchpad component type
  115856. */
  115857. static TOUCHPAD: MotionControllerComponentType;
  115858. /**
  115859. * trigger component type
  115860. */
  115861. static TRIGGER: MotionControllerComponentType;
  115862. /**
  115863. * squeeze component type
  115864. */
  115865. static SQUEEZE: MotionControllerComponentType;
  115866. /**
  115867. * button component type
  115868. */
  115869. static BUTTON: MotionControllerComponentType;
  115870. /**
  115871. * Observers registered here will be triggered when the state of a button changes
  115872. * State change is either pressed / touched / value
  115873. */
  115874. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  115875. /**
  115876. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  115877. * the axes data changes
  115878. */
  115879. onAxisValueChangedObservable: Observable<{
  115880. x: number;
  115881. y: number;
  115882. }>;
  115883. private _currentValue;
  115884. private _touched;
  115885. private _pressed;
  115886. private _axes;
  115887. private _changes;
  115888. private _hasChanges;
  115889. /**
  115890. * Return whether or not the component changed the last frame
  115891. */
  115892. get hasChanges(): boolean;
  115893. /**
  115894. * Creates a new component for a motion controller.
  115895. * It is created by the motion controller itself
  115896. *
  115897. * @param id the id of this component
  115898. * @param type the type of the component
  115899. * @param _buttonIndex index in the buttons array of the gamepad
  115900. * @param _axesIndices indices of the values in the axes array of the gamepad
  115901. */
  115902. constructor(
  115903. /**
  115904. * the id of this component
  115905. */
  115906. id: string,
  115907. /**
  115908. * the type of the component
  115909. */
  115910. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  115911. /**
  115912. * Get the current value of this component
  115913. */
  115914. get value(): number;
  115915. /**
  115916. * is the button currently pressed
  115917. */
  115918. get pressed(): boolean;
  115919. /**
  115920. * is the button currently touched
  115921. */
  115922. get touched(): boolean;
  115923. /**
  115924. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  115925. */
  115926. get axes(): IWebXRMotionControllerAxesValue;
  115927. /**
  115928. * Get the changes. Elements will be populated only if they changed with their previous and current value
  115929. */
  115930. get changes(): IWebXRMotionControllerComponentChanges;
  115931. /**
  115932. * Is this component a button (hence - pressable)
  115933. * @returns true if can be pressed
  115934. */
  115935. isButton(): boolean;
  115936. /**
  115937. * Are there axes correlating to this component
  115938. * @return true is axes data is available
  115939. */
  115940. isAxes(): boolean;
  115941. /**
  115942. * update this component using the gamepad object it is in. Called on every frame
  115943. * @param nativeController the native gamepad controller object
  115944. */
  115945. update(nativeController: IMinimalMotionControllerObject): void;
  115946. /**
  115947. * Dispose this component
  115948. */
  115949. dispose(): void;
  115950. }
  115951. }
  115952. declare module BABYLON {
  115953. /**
  115954. * Class used to represent data loading progression
  115955. */
  115956. export class SceneLoaderProgressEvent {
  115957. /** defines if data length to load can be evaluated */
  115958. readonly lengthComputable: boolean;
  115959. /** defines the loaded data length */
  115960. readonly loaded: number;
  115961. /** defines the data length to load */
  115962. readonly total: number;
  115963. /**
  115964. * Create a new progress event
  115965. * @param lengthComputable defines if data length to load can be evaluated
  115966. * @param loaded defines the loaded data length
  115967. * @param total defines the data length to load
  115968. */
  115969. constructor(
  115970. /** defines if data length to load can be evaluated */
  115971. lengthComputable: boolean,
  115972. /** defines the loaded data length */
  115973. loaded: number,
  115974. /** defines the data length to load */
  115975. total: number);
  115976. /**
  115977. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  115978. * @param event defines the source event
  115979. * @returns a new SceneLoaderProgressEvent
  115980. */
  115981. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  115982. }
  115983. /**
  115984. * Interface used by SceneLoader plugins to define supported file extensions
  115985. */
  115986. export interface ISceneLoaderPluginExtensions {
  115987. /**
  115988. * Defines the list of supported extensions
  115989. */
  115990. [extension: string]: {
  115991. isBinary: boolean;
  115992. };
  115993. }
  115994. /**
  115995. * Interface used by SceneLoader plugin factory
  115996. */
  115997. export interface ISceneLoaderPluginFactory {
  115998. /**
  115999. * Defines the name of the factory
  116000. */
  116001. name: string;
  116002. /**
  116003. * Function called to create a new plugin
  116004. * @return the new plugin
  116005. */
  116006. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  116007. /**
  116008. * The callback that returns true if the data can be directly loaded.
  116009. * @param data string containing the file data
  116010. * @returns if the data can be loaded directly
  116011. */
  116012. canDirectLoad?(data: string): boolean;
  116013. }
  116014. /**
  116015. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  116016. */
  116017. export interface ISceneLoaderPluginBase {
  116018. /**
  116019. * The friendly name of this plugin.
  116020. */
  116021. name: string;
  116022. /**
  116023. * The file extensions supported by this plugin.
  116024. */
  116025. extensions: string | ISceneLoaderPluginExtensions;
  116026. /**
  116027. * The callback called when loading from a url.
  116028. * @param scene scene loading this url
  116029. * @param url url to load
  116030. * @param onSuccess callback called when the file successfully loads
  116031. * @param onProgress callback called while file is loading (if the server supports this mode)
  116032. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116033. * @param onError callback called when the file fails to load
  116034. * @returns a file request object
  116035. */
  116036. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116037. /**
  116038. * The callback called when loading from a file object.
  116039. * @param scene scene loading this file
  116040. * @param file defines the file to load
  116041. * @param onSuccess defines the callback to call when data is loaded
  116042. * @param onProgress defines the callback to call during loading process
  116043. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  116044. * @param onError defines the callback to call when an error occurs
  116045. * @returns a file request object
  116046. */
  116047. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116048. /**
  116049. * The callback that returns true if the data can be directly loaded.
  116050. * @param data string containing the file data
  116051. * @returns if the data can be loaded directly
  116052. */
  116053. canDirectLoad?(data: string): boolean;
  116054. /**
  116055. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  116056. * @param scene scene loading this data
  116057. * @param data string containing the data
  116058. * @returns data to pass to the plugin
  116059. */
  116060. directLoad?(scene: Scene, data: string): any;
  116061. /**
  116062. * The callback that allows custom handling of the root url based on the response url.
  116063. * @param rootUrl the original root url
  116064. * @param responseURL the response url if available
  116065. * @returns the new root url
  116066. */
  116067. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  116068. }
  116069. /**
  116070. * Interface used to define a SceneLoader plugin
  116071. */
  116072. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  116073. /**
  116074. * Import meshes into a scene.
  116075. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116076. * @param scene The scene to import into
  116077. * @param data The data to import
  116078. * @param rootUrl The root url for scene and resources
  116079. * @param meshes The meshes array to import into
  116080. * @param particleSystems The particle systems array to import into
  116081. * @param skeletons The skeletons array to import into
  116082. * @param onError The callback when import fails
  116083. * @returns True if successful or false otherwise
  116084. */
  116085. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  116086. /**
  116087. * Load into a scene.
  116088. * @param scene The scene to load into
  116089. * @param data The data to import
  116090. * @param rootUrl The root url for scene and resources
  116091. * @param onError The callback when import fails
  116092. * @returns True if successful or false otherwise
  116093. */
  116094. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  116095. /**
  116096. * Load into an asset container.
  116097. * @param scene The scene to load into
  116098. * @param data The data to import
  116099. * @param rootUrl The root url for scene and resources
  116100. * @param onError The callback when import fails
  116101. * @returns The loaded asset container
  116102. */
  116103. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  116104. }
  116105. /**
  116106. * Interface used to define an async SceneLoader plugin
  116107. */
  116108. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  116109. /**
  116110. * Import meshes into a scene.
  116111. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116112. * @param scene The scene to import into
  116113. * @param data The data to import
  116114. * @param rootUrl The root url for scene and resources
  116115. * @param onProgress The callback when the load progresses
  116116. * @param fileName Defines the name of the file to load
  116117. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  116118. */
  116119. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  116120. meshes: AbstractMesh[];
  116121. particleSystems: IParticleSystem[];
  116122. skeletons: Skeleton[];
  116123. animationGroups: AnimationGroup[];
  116124. }>;
  116125. /**
  116126. * Load into a scene.
  116127. * @param scene The scene to load into
  116128. * @param data The data to import
  116129. * @param rootUrl The root url for scene and resources
  116130. * @param onProgress The callback when the load progresses
  116131. * @param fileName Defines the name of the file to load
  116132. * @returns Nothing
  116133. */
  116134. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  116135. /**
  116136. * Load into an asset container.
  116137. * @param scene The scene to load into
  116138. * @param data The data to import
  116139. * @param rootUrl The root url for scene and resources
  116140. * @param onProgress The callback when the load progresses
  116141. * @param fileName Defines the name of the file to load
  116142. * @returns The loaded asset container
  116143. */
  116144. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  116145. }
  116146. /**
  116147. * Mode that determines how to handle old animation groups before loading new ones.
  116148. */
  116149. export enum SceneLoaderAnimationGroupLoadingMode {
  116150. /**
  116151. * Reset all old animations to initial state then dispose them.
  116152. */
  116153. Clean = 0,
  116154. /**
  116155. * Stop all old animations.
  116156. */
  116157. Stop = 1,
  116158. /**
  116159. * Restart old animations from first frame.
  116160. */
  116161. Sync = 2,
  116162. /**
  116163. * Old animations remains untouched.
  116164. */
  116165. NoSync = 3
  116166. }
  116167. /**
  116168. * Class used to load scene from various file formats using registered plugins
  116169. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  116170. */
  116171. export class SceneLoader {
  116172. /**
  116173. * No logging while loading
  116174. */
  116175. static readonly NO_LOGGING: number;
  116176. /**
  116177. * Minimal logging while loading
  116178. */
  116179. static readonly MINIMAL_LOGGING: number;
  116180. /**
  116181. * Summary logging while loading
  116182. */
  116183. static readonly SUMMARY_LOGGING: number;
  116184. /**
  116185. * Detailled logging while loading
  116186. */
  116187. static readonly DETAILED_LOGGING: number;
  116188. /**
  116189. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  116190. */
  116191. static get ForceFullSceneLoadingForIncremental(): boolean;
  116192. static set ForceFullSceneLoadingForIncremental(value: boolean);
  116193. /**
  116194. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  116195. */
  116196. static get ShowLoadingScreen(): boolean;
  116197. static set ShowLoadingScreen(value: boolean);
  116198. /**
  116199. * Defines the current logging level (while loading the scene)
  116200. * @ignorenaming
  116201. */
  116202. static get loggingLevel(): number;
  116203. static set loggingLevel(value: number);
  116204. /**
  116205. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  116206. */
  116207. static get CleanBoneMatrixWeights(): boolean;
  116208. static set CleanBoneMatrixWeights(value: boolean);
  116209. /**
  116210. * Event raised when a plugin is used to load a scene
  116211. */
  116212. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  116213. private static _registeredPlugins;
  116214. private static _getDefaultPlugin;
  116215. private static _getPluginForExtension;
  116216. private static _getPluginForDirectLoad;
  116217. private static _getPluginForFilename;
  116218. private static _getDirectLoad;
  116219. private static _loadData;
  116220. private static _getFileInfo;
  116221. /**
  116222. * Gets a plugin that can load the given extension
  116223. * @param extension defines the extension to load
  116224. * @returns a plugin or null if none works
  116225. */
  116226. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  116227. /**
  116228. * Gets a boolean indicating that the given extension can be loaded
  116229. * @param extension defines the extension to load
  116230. * @returns true if the extension is supported
  116231. */
  116232. static IsPluginForExtensionAvailable(extension: string): boolean;
  116233. /**
  116234. * Adds a new plugin to the list of registered plugins
  116235. * @param plugin defines the plugin to add
  116236. */
  116237. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  116238. /**
  116239. * Import meshes into a scene
  116240. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116241. * @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)
  116242. * @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)
  116243. * @param scene the instance of BABYLON.Scene to append to
  116244. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  116245. * @param onProgress a callback with a progress event for each file being loaded
  116246. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116247. * @param pluginExtension the extension used to determine the plugin
  116248. * @returns The loaded plugin
  116249. */
  116250. 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>;
  116251. /**
  116252. * Import meshes into a scene
  116253. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116254. * @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)
  116255. * @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)
  116256. * @param scene the instance of BABYLON.Scene to append to
  116257. * @param onProgress a callback with a progress event for each file being loaded
  116258. * @param pluginExtension the extension used to determine the plugin
  116259. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  116260. */
  116261. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  116262. meshes: AbstractMesh[];
  116263. particleSystems: IParticleSystem[];
  116264. skeletons: Skeleton[];
  116265. animationGroups: AnimationGroup[];
  116266. }>;
  116267. /**
  116268. * Load a scene
  116269. * @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)
  116270. * @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)
  116271. * @param engine is the instance of BABYLON.Engine to use to create the scene
  116272. * @param onSuccess a callback with the scene when import succeeds
  116273. * @param onProgress a callback with a progress event for each file being loaded
  116274. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116275. * @param pluginExtension the extension used to determine the plugin
  116276. * @returns The loaded plugin
  116277. */
  116278. 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>;
  116279. /**
  116280. * Load a scene
  116281. * @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)
  116282. * @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)
  116283. * @param engine is the instance of BABYLON.Engine to use to create the scene
  116284. * @param onProgress a callback with a progress event for each file being loaded
  116285. * @param pluginExtension the extension used to determine the plugin
  116286. * @returns The loaded scene
  116287. */
  116288. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116289. /**
  116290. * Append a scene
  116291. * @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)
  116292. * @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)
  116293. * @param scene is the instance of BABYLON.Scene to append to
  116294. * @param onSuccess a callback with the scene when import succeeds
  116295. * @param onProgress a callback with a progress event for each file being loaded
  116296. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116297. * @param pluginExtension the extension used to determine the plugin
  116298. * @returns The loaded plugin
  116299. */
  116300. 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>;
  116301. /**
  116302. * Append a scene
  116303. * @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)
  116304. * @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)
  116305. * @param scene is the instance of BABYLON.Scene to append to
  116306. * @param onProgress a callback with a progress event for each file being loaded
  116307. * @param pluginExtension the extension used to determine the plugin
  116308. * @returns The given scene
  116309. */
  116310. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116311. /**
  116312. * Load a scene into an asset container
  116313. * @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)
  116314. * @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)
  116315. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116316. * @param onSuccess a callback with the scene when import succeeds
  116317. * @param onProgress a callback with a progress event for each file being loaded
  116318. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116319. * @param pluginExtension the extension used to determine the plugin
  116320. * @returns The loaded plugin
  116321. */
  116322. 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>;
  116323. /**
  116324. * Load a scene into an asset container
  116325. * @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)
  116326. * @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)
  116327. * @param scene is the instance of Scene to append to
  116328. * @param onProgress a callback with a progress event for each file being loaded
  116329. * @param pluginExtension the extension used to determine the plugin
  116330. * @returns The loaded asset container
  116331. */
  116332. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  116333. /**
  116334. * Import animations from a file into a scene
  116335. * @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)
  116336. * @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)
  116337. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116338. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  116339. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  116340. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  116341. * @param onSuccess a callback with the scene when import succeeds
  116342. * @param onProgress a callback with a progress event for each file being loaded
  116343. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116344. */
  116345. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  116346. /**
  116347. * Import animations from a file into a scene
  116348. * @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)
  116349. * @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)
  116350. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116351. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  116352. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  116353. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  116354. * @param onSuccess a callback with the scene when import succeeds
  116355. * @param onProgress a callback with a progress event for each file being loaded
  116356. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116357. * @returns the updated scene with imported animations
  116358. */
  116359. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  116360. }
  116361. }
  116362. declare module BABYLON {
  116363. /**
  116364. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  116365. */
  116366. export type MotionControllerHandness = "none" | "left" | "right";
  116367. /**
  116368. * The type of components available in motion controllers.
  116369. * This is not the name of the component.
  116370. */
  116371. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  116372. /**
  116373. * The state of a controller component
  116374. */
  116375. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  116376. /**
  116377. * The schema of motion controller layout.
  116378. * No object will be initialized using this interface
  116379. * This is used just to define the profile.
  116380. */
  116381. export interface IMotionControllerLayout {
  116382. /**
  116383. * Defines the main button component id
  116384. */
  116385. selectComponentId: string;
  116386. /**
  116387. * Available components (unsorted)
  116388. */
  116389. components: {
  116390. /**
  116391. * A map of component Ids
  116392. */
  116393. [componentId: string]: {
  116394. /**
  116395. * The type of input the component outputs
  116396. */
  116397. type: MotionControllerComponentType;
  116398. /**
  116399. * The indices of this component in the gamepad object
  116400. */
  116401. gamepadIndices: {
  116402. /**
  116403. * Index of button
  116404. */
  116405. button?: number;
  116406. /**
  116407. * If available, index of x-axis
  116408. */
  116409. xAxis?: number;
  116410. /**
  116411. * If available, index of y-axis
  116412. */
  116413. yAxis?: number;
  116414. };
  116415. /**
  116416. * The mesh's root node name
  116417. */
  116418. rootNodeName: string;
  116419. /**
  116420. * Animation definitions for this model
  116421. */
  116422. visualResponses: {
  116423. [stateKey: string]: {
  116424. /**
  116425. * What property will be animated
  116426. */
  116427. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  116428. /**
  116429. * What states influence this visual reponse
  116430. */
  116431. states: MotionControllerComponentStateType[];
  116432. /**
  116433. * Type of animation - movement or visibility
  116434. */
  116435. valueNodeProperty: "transform" | "visibility";
  116436. /**
  116437. * Base node name to move. Its position will be calculated according to the min and max nodes
  116438. */
  116439. valueNodeName?: string;
  116440. /**
  116441. * Minimum movement node
  116442. */
  116443. minNodeName?: string;
  116444. /**
  116445. * Max movement node
  116446. */
  116447. maxNodeName?: string;
  116448. };
  116449. };
  116450. /**
  116451. * If touch enabled, what is the name of node to display user feedback
  116452. */
  116453. touchPointNodeName?: string;
  116454. };
  116455. };
  116456. /**
  116457. * Is it xr standard mapping or not
  116458. */
  116459. gamepadMapping: "" | "xr-standard";
  116460. /**
  116461. * Base root node of this entire model
  116462. */
  116463. rootNodeName: string;
  116464. /**
  116465. * Path to load the assets. Usually relative to the base path
  116466. */
  116467. assetPath: string;
  116468. }
  116469. /**
  116470. * A definition for the layout map in the input profile
  116471. */
  116472. export interface IMotionControllerLayoutMap {
  116473. /**
  116474. * Layouts with handness type as a key
  116475. */
  116476. [handness: string]: IMotionControllerLayout;
  116477. }
  116478. /**
  116479. * The XR Input profile schema
  116480. * Profiles can be found here:
  116481. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  116482. */
  116483. export interface IMotionControllerProfile {
  116484. /**
  116485. * The id of this profile
  116486. * correlates to the profile(s) in the xrInput.profiles array
  116487. */
  116488. profileId: string;
  116489. /**
  116490. * fallback profiles for this profileId
  116491. */
  116492. fallbackProfileIds: string[];
  116493. /**
  116494. * The layout map, with handness as key
  116495. */
  116496. layouts: IMotionControllerLayoutMap;
  116497. }
  116498. /**
  116499. * A helper-interface for the 3 meshes needed for controller button animation
  116500. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  116501. */
  116502. export interface IMotionControllerButtonMeshMap {
  116503. /**
  116504. * The mesh that will be changed when value changes
  116505. */
  116506. valueMesh: AbstractMesh;
  116507. /**
  116508. * the mesh that defines the pressed value mesh position.
  116509. * This is used to find the max-position of this button
  116510. */
  116511. pressedMesh: AbstractMesh;
  116512. /**
  116513. * the mesh that defines the unpressed value mesh position.
  116514. * This is used to find the min (or initial) position of this button
  116515. */
  116516. unpressedMesh: AbstractMesh;
  116517. }
  116518. /**
  116519. * A helper-interface for the 3 meshes needed for controller axis animation.
  116520. * This will be expanded when touchpad animations are fully supported
  116521. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  116522. */
  116523. export interface IMotionControllerMeshMap {
  116524. /**
  116525. * The mesh that will be changed when axis value changes
  116526. */
  116527. valueMesh: AbstractMesh;
  116528. /**
  116529. * the mesh that defines the minimum value mesh position.
  116530. */
  116531. minMesh?: AbstractMesh;
  116532. /**
  116533. * the mesh that defines the maximum value mesh position.
  116534. */
  116535. maxMesh?: AbstractMesh;
  116536. }
  116537. /**
  116538. * The elements needed for change-detection of the gamepad objects in motion controllers
  116539. */
  116540. export interface IMinimalMotionControllerObject {
  116541. /**
  116542. * An array of available buttons
  116543. */
  116544. buttons: Array<{
  116545. /**
  116546. * Value of the button/trigger
  116547. */
  116548. value: number;
  116549. /**
  116550. * If the button/trigger is currently touched
  116551. */
  116552. touched: boolean;
  116553. /**
  116554. * If the button/trigger is currently pressed
  116555. */
  116556. pressed: boolean;
  116557. }>;
  116558. /**
  116559. * Available axes of this controller
  116560. */
  116561. axes: number[];
  116562. }
  116563. /**
  116564. * An Abstract Motion controller
  116565. * This class receives an xrInput and a profile layout and uses those to initialize the components
  116566. * Each component has an observable to check for changes in value and state
  116567. */
  116568. export abstract class WebXRAbstractMotionController implements IDisposable {
  116569. protected scene: Scene;
  116570. protected layout: IMotionControllerLayout;
  116571. /**
  116572. * The gamepad object correlating to this controller
  116573. */
  116574. gamepadObject: IMinimalMotionControllerObject;
  116575. /**
  116576. * handness (left/right/none) of this controller
  116577. */
  116578. handness: MotionControllerHandness;
  116579. /**
  116580. * The profile id of this motion controller
  116581. */
  116582. abstract profileId: string;
  116583. /**
  116584. * A map of components (WebXRControllerComponent) in this motion controller
  116585. * Components have a ComponentType and can also have both button and axis definitions
  116586. */
  116587. readonly components: {
  116588. [id: string]: WebXRControllerComponent;
  116589. };
  116590. /**
  116591. * Observers registered here will be triggered when the model of this controller is done loading
  116592. */
  116593. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  116594. /**
  116595. * The root mesh of the model. It is null if the model was not yet initialized
  116596. */
  116597. rootMesh: Nullable<AbstractMesh>;
  116598. /**
  116599. * Disable the model's animation. Can be set at any time.
  116600. */
  116601. disableAnimation: boolean;
  116602. private _modelReady;
  116603. /**
  116604. * constructs a new abstract motion controller
  116605. * @param scene the scene to which the model of the controller will be added
  116606. * @param layout The profile layout to load
  116607. * @param gamepadObject The gamepad object correlating to this controller
  116608. * @param handness handness (left/right/none) of this controller
  116609. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  116610. */
  116611. constructor(scene: Scene, layout: IMotionControllerLayout,
  116612. /**
  116613. * The gamepad object correlating to this controller
  116614. */
  116615. gamepadObject: IMinimalMotionControllerObject,
  116616. /**
  116617. * handness (left/right/none) of this controller
  116618. */
  116619. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  116620. private _initComponent;
  116621. /**
  116622. * Update this model using the current XRFrame
  116623. * @param xrFrame the current xr frame to use and update the model
  116624. */
  116625. updateFromXRFrame(xrFrame: XRFrame): void;
  116626. /**
  116627. * Get the list of components available in this motion controller
  116628. * @returns an array of strings correlating to available components
  116629. */
  116630. getComponentIds(): string[];
  116631. /**
  116632. * Get the main (Select) component of this controller as defined in the layout
  116633. * @returns the main component of this controller
  116634. */
  116635. getMainComponent(): WebXRControllerComponent;
  116636. /**
  116637. * get a component based an its component id as defined in layout.components
  116638. * @param id the id of the component
  116639. * @returns the component correlates to the id or undefined if not found
  116640. */
  116641. getComponent(id: string): WebXRControllerComponent;
  116642. /**
  116643. * Get the first component of specific type
  116644. * @param type type of component to find
  116645. * @return a controller component or null if not found
  116646. */
  116647. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  116648. /**
  116649. * Returns all components of specific type
  116650. * @param type the type to search for
  116651. * @return an array of components with this type
  116652. */
  116653. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  116654. /**
  116655. * Loads the model correlating to this controller
  116656. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  116657. * @returns A promise fulfilled with the result of the model loading
  116658. */
  116659. loadModel(): Promise<boolean>;
  116660. /**
  116661. * Update the model itself with the current frame data
  116662. * @param xrFrame the frame to use for updating the model mesh
  116663. */
  116664. protected updateModel(xrFrame: XRFrame): void;
  116665. /**
  116666. * Moves the axis on the controller mesh based on its current state
  116667. * @param axis the index of the axis
  116668. * @param axisValue the value of the axis which determines the meshes new position
  116669. * @hidden
  116670. */
  116671. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  116672. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  116673. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  116674. private _getGenericFilenameAndPath;
  116675. private _getGenericParentMesh;
  116676. /**
  116677. * Get the filename and path for this controller's model
  116678. * @returns a map of filename and path
  116679. */
  116680. protected abstract _getFilenameAndPath(): {
  116681. filename: string;
  116682. path: string;
  116683. };
  116684. /**
  116685. * This function will be called after the model was successfully loaded and can be used
  116686. * for mesh transformations before it is available for the user
  116687. * @param meshes the loaded meshes
  116688. */
  116689. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  116690. /**
  116691. * Set the root mesh for this controller. Important for the WebXR controller class
  116692. * @param meshes the loaded meshes
  116693. */
  116694. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  116695. /**
  116696. * A function executed each frame that updates the mesh (if needed)
  116697. * @param xrFrame the current xrFrame
  116698. */
  116699. protected abstract _updateModel(xrFrame: XRFrame): void;
  116700. /**
  116701. * This function is called before the mesh is loaded. It checks for loading constraints.
  116702. * For example, this function can check if the GLB loader is available
  116703. * If this function returns false, the generic controller will be loaded instead
  116704. * @returns Is the client ready to load the mesh
  116705. */
  116706. protected abstract _getModelLoadingConstraints(): boolean;
  116707. /**
  116708. * Dispose this controller, the model mesh and all its components
  116709. */
  116710. dispose(): void;
  116711. }
  116712. }
  116713. declare module BABYLON {
  116714. /**
  116715. * A generic trigger-only motion controller for WebXR
  116716. */
  116717. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  116718. /**
  116719. * Static version of the profile id of this controller
  116720. */
  116721. static ProfileId: string;
  116722. profileId: string;
  116723. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  116724. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  116725. protected _updateModel(): void;
  116726. protected _getFilenameAndPath(): {
  116727. filename: string;
  116728. path: string;
  116729. };
  116730. protected _setRootMesh(meshes: AbstractMesh[]): void;
  116731. protected _getModelLoadingConstraints(): boolean;
  116732. }
  116733. }
  116734. declare module BABYLON {
  116735. /**
  116736. * Class containing static functions to help procedurally build meshes
  116737. */
  116738. export class SphereBuilder {
  116739. /**
  116740. * Creates a sphere mesh
  116741. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  116742. * * 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`)
  116743. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  116744. * * 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
  116745. * * 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)
  116746. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116747. * * 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
  116748. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116749. * @param name defines the name of the mesh
  116750. * @param options defines the options used to create the mesh
  116751. * @param scene defines the hosting scene
  116752. * @returns the sphere mesh
  116753. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  116754. */
  116755. static CreateSphere(name: string, options: {
  116756. segments?: number;
  116757. diameter?: number;
  116758. diameterX?: number;
  116759. diameterY?: number;
  116760. diameterZ?: number;
  116761. arc?: number;
  116762. slice?: number;
  116763. sideOrientation?: number;
  116764. frontUVs?: Vector4;
  116765. backUVs?: Vector4;
  116766. updatable?: boolean;
  116767. }, scene?: Nullable<Scene>): Mesh;
  116768. }
  116769. }
  116770. declare module BABYLON {
  116771. /**
  116772. * A profiled motion controller has its profile loaded from an online repository.
  116773. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  116774. */
  116775. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  116776. private _repositoryUrl;
  116777. /**
  116778. * The profile ID of this controller. Will be populated when the controller initializes.
  116779. */
  116780. profileId: string;
  116781. private _buttonMeshMapping;
  116782. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  116783. protected _getFilenameAndPath(): {
  116784. filename: string;
  116785. path: string;
  116786. };
  116787. private _touchDots;
  116788. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  116789. protected _setRootMesh(meshes: AbstractMesh[]): void;
  116790. protected _updateModel(_xrFrame: XRFrame): void;
  116791. protected _getModelLoadingConstraints(): boolean;
  116792. dispose(): void;
  116793. }
  116794. }
  116795. declare module BABYLON {
  116796. /**
  116797. * A construction function type to create a new controller based on an xrInput object
  116798. */
  116799. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  116800. /**
  116801. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  116802. *
  116803. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  116804. * it should be replaced with auto-loaded controllers.
  116805. *
  116806. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  116807. */
  116808. export class WebXRMotionControllerManager {
  116809. /**
  116810. * The base URL of the online controller repository. Can be changed at any time.
  116811. */
  116812. static BaseRepositoryUrl: string;
  116813. /**
  116814. * Use the online repository, or use only locally-defined controllers
  116815. */
  116816. static UseOnlineRepository: boolean;
  116817. /**
  116818. * Which repository gets priority - local or online
  116819. */
  116820. static PrioritizeOnlineRepository: boolean;
  116821. private static _AvailableControllers;
  116822. private static _Fallbacks;
  116823. /**
  116824. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  116825. *
  116826. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  116827. *
  116828. * @param type the profile type to register
  116829. * @param constructFunction the function to be called when loading this profile
  116830. */
  116831. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  116832. /**
  116833. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  116834. * The order of search:
  116835. *
  116836. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  116837. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  116838. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  116839. * 4) return the generic trigger controller if none were found
  116840. *
  116841. * @param xrInput the xrInput to which a new controller is initialized
  116842. * @param scene the scene to which the model will be added
  116843. * @param forceProfile force a certain profile for this controller
  116844. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  116845. */
  116846. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  116847. private static _LoadProfilesFromAvailableControllers;
  116848. private static _ProfilesList;
  116849. private static _ProfileLoadingPromises;
  116850. private static _LoadProfileFromRepository;
  116851. /**
  116852. * Clear the cache used for profile loading and reload when requested again
  116853. */
  116854. static ClearProfilesCache(): void;
  116855. /**
  116856. * Will update the list of profiles available in the repository
  116857. * @return a promise that resolves to a map of profiles available online
  116858. */
  116859. static UpdateProfilesList(): Promise<{
  116860. [profile: string]: string;
  116861. }>;
  116862. /**
  116863. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  116864. * @param profileId the profile to which a fallback needs to be found
  116865. * @return an array with corresponding fallback profiles
  116866. */
  116867. static FindFallbackWithProfileId(profileId: string): string[];
  116868. /**
  116869. * Register a fallback to a specific profile.
  116870. * @param profileId the profileId that will receive the fallbacks
  116871. * @param fallbacks A list of fallback profiles
  116872. */
  116873. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  116874. /**
  116875. * Register the default fallbacks.
  116876. * This function is called automatically when this file is imported.
  116877. */
  116878. static DefaultFallbacks(): void;
  116879. }
  116880. }
  116881. declare module BABYLON {
  116882. /**
  116883. * Configuration options for the WebXR controller creation
  116884. */
  116885. export interface IWebXRControllerOptions {
  116886. /**
  116887. * Force a specific controller type for this controller.
  116888. * This can be used when creating your own profile or when testing different controllers
  116889. */
  116890. forceControllerProfile?: string;
  116891. /**
  116892. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  116893. */
  116894. doNotLoadControllerMesh?: boolean;
  116895. /**
  116896. * Should the controller mesh be animated when a user interacts with it
  116897. * The pressed buttons / thumbstick and touchpad animations will be disabled
  116898. */
  116899. disableMotionControllerAnimation?: boolean;
  116900. }
  116901. /**
  116902. * Represents an XR controller
  116903. */
  116904. export class WebXRInputSource {
  116905. private _scene;
  116906. /** The underlying input source for the controller */
  116907. inputSource: XRInputSource;
  116908. private _options;
  116909. /**
  116910. * 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
  116911. */
  116912. grip?: AbstractMesh;
  116913. /**
  116914. * Pointer which can be used to select objects or attach a visible laser to
  116915. */
  116916. pointer: AbstractMesh;
  116917. /**
  116918. * If available, this is the gamepad object related to this controller.
  116919. * Using this object it is possible to get click events and trackpad changes of the
  116920. * webxr controller that is currently being used.
  116921. */
  116922. motionController?: WebXRAbstractMotionController;
  116923. /**
  116924. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  116925. */
  116926. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  116927. /**
  116928. * Will be triggered when the mesh associated with the motion controller is done loading.
  116929. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  116930. * A shortened version of controller -> motion controller -> on mesh loaded.
  116931. */
  116932. onMeshLoadedObservable: Observable<AbstractMesh>;
  116933. /**
  116934. * Event that fires when the controller is removed/disposed.
  116935. * The object provided as event data is this controller, after associated assets were disposed.
  116936. * uniqueId is still available.
  116937. */
  116938. onDisposeObservable: Observable<WebXRInputSource>;
  116939. private _tmpQuaternion;
  116940. private _tmpVector;
  116941. private _uniqueId;
  116942. /**
  116943. * Creates the controller
  116944. * @see https://doc.babylonjs.com/how_to/webxr
  116945. * @param _scene the scene which the controller should be associated to
  116946. * @param inputSource the underlying input source for the controller
  116947. * @param _options options for this controller creation
  116948. */
  116949. constructor(_scene: Scene,
  116950. /** The underlying input source for the controller */
  116951. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  116952. /**
  116953. * Get this controllers unique id
  116954. */
  116955. get uniqueId(): string;
  116956. /**
  116957. * Updates the controller pose based on the given XRFrame
  116958. * @param xrFrame xr frame to update the pose with
  116959. * @param referenceSpace reference space to use
  116960. */
  116961. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  116962. /**
  116963. * Gets a world space ray coming from the pointer or grip
  116964. * @param result the resulting ray
  116965. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  116966. */
  116967. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  116968. /**
  116969. * Disposes of the object
  116970. */
  116971. dispose(): void;
  116972. }
  116973. }
  116974. declare module BABYLON {
  116975. /**
  116976. * The schema for initialization options of the XR Input class
  116977. */
  116978. export interface IWebXRInputOptions {
  116979. /**
  116980. * If set to true no model will be automatically loaded
  116981. */
  116982. doNotLoadControllerMeshes?: boolean;
  116983. /**
  116984. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  116985. * If not found, the xr input profile data will be used.
  116986. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  116987. */
  116988. forceInputProfile?: string;
  116989. /**
  116990. * Do not send a request to the controlle repository to load the profile.
  116991. *
  116992. * Instead, use the controllers available in babylon itself.
  116993. */
  116994. disableOnlineControllerRepository?: boolean;
  116995. /**
  116996. * A custom URL for the controllers repository
  116997. */
  116998. customControllersRepositoryURL?: string;
  116999. /**
  117000. * Should the controller model's components not move according to the user input
  117001. */
  117002. disableControllerAnimation?: boolean;
  117003. }
  117004. /**
  117005. * XR input used to track XR inputs such as controllers/rays
  117006. */
  117007. export class WebXRInput implements IDisposable {
  117008. /**
  117009. * the xr session manager for this session
  117010. */
  117011. xrSessionManager: WebXRSessionManager;
  117012. /**
  117013. * the WebXR camera for this session. Mainly used for teleportation
  117014. */
  117015. xrCamera: WebXRCamera;
  117016. private readonly options;
  117017. /**
  117018. * XR controllers being tracked
  117019. */
  117020. controllers: Array<WebXRInputSource>;
  117021. private _frameObserver;
  117022. private _sessionEndedObserver;
  117023. private _sessionInitObserver;
  117024. /**
  117025. * Event when a controller has been connected/added
  117026. */
  117027. onControllerAddedObservable: Observable<WebXRInputSource>;
  117028. /**
  117029. * Event when a controller has been removed/disconnected
  117030. */
  117031. onControllerRemovedObservable: Observable<WebXRInputSource>;
  117032. /**
  117033. * Initializes the WebXRInput
  117034. * @param xrSessionManager the xr session manager for this session
  117035. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  117036. * @param options = initialization options for this xr input
  117037. */
  117038. constructor(
  117039. /**
  117040. * the xr session manager for this session
  117041. */
  117042. xrSessionManager: WebXRSessionManager,
  117043. /**
  117044. * the WebXR camera for this session. Mainly used for teleportation
  117045. */
  117046. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  117047. private _onInputSourcesChange;
  117048. private _addAndRemoveControllers;
  117049. /**
  117050. * Disposes of the object
  117051. */
  117052. dispose(): void;
  117053. }
  117054. }
  117055. declare module BABYLON {
  117056. /**
  117057. * This is the base class for all WebXR features.
  117058. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  117059. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  117060. */
  117061. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  117062. protected _xrSessionManager: WebXRSessionManager;
  117063. /**
  117064. * Construct a new (abstract) webxr feature
  117065. * @param _xrSessionManager the xr session manager for this feature
  117066. */
  117067. constructor(_xrSessionManager: WebXRSessionManager);
  117068. private _attached;
  117069. private _removeOnDetach;
  117070. /**
  117071. * Is this feature attached
  117072. */
  117073. get attached(): boolean;
  117074. /**
  117075. * Should auto-attach be disabled?
  117076. */
  117077. disableAutoAttach: boolean;
  117078. /**
  117079. * attach this feature
  117080. *
  117081. * @param force should attachment be forced (even when already attached)
  117082. * @returns true if successful, false is failed or already attached
  117083. */
  117084. attach(force?: boolean): boolean;
  117085. /**
  117086. * detach this feature.
  117087. *
  117088. * @returns true if successful, false if failed or already detached
  117089. */
  117090. detach(): boolean;
  117091. /**
  117092. * Dispose this feature and all of the resources attached
  117093. */
  117094. dispose(): void;
  117095. /**
  117096. * Code in this function will be executed on each xrFrame received from the browser.
  117097. * This function will not execute after the feature is detached.
  117098. * @param _xrFrame the current frame
  117099. */
  117100. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  117101. /**
  117102. * This is used to register callbacks that will automatically be removed when detach is called.
  117103. * @param observable the observable to which the observer will be attached
  117104. * @param callback the callback to register
  117105. */
  117106. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  117107. }
  117108. }
  117109. declare module BABYLON {
  117110. /**
  117111. * Options interface for the pointer selection module
  117112. */
  117113. export interface IWebXRControllerPointerSelectionOptions {
  117114. /**
  117115. * the xr input to use with this pointer selection
  117116. */
  117117. xrInput: WebXRInput;
  117118. /**
  117119. * Different button type to use instead of the main component
  117120. */
  117121. overrideButtonId?: string;
  117122. /**
  117123. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  117124. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  117125. * 3000 means 3 seconds between pointing at something and selecting it
  117126. */
  117127. timeToSelect?: number;
  117128. /**
  117129. * Disable the pointer up event when the xr controller in screen and gaze mode is disposed (meaning - when the user removed the finger from the screen)
  117130. * If not disabled, the last picked point will be used to execute a pointer up event
  117131. * If disabled, pointer up event will be triggered right after the pointer down event.
  117132. * Used in screen and gaze target ray mode only
  117133. */
  117134. disablePointerUpOnTouchOut: boolean;
  117135. /**
  117136. * For gaze mode (time to select instead of press)
  117137. */
  117138. forceGazeMode: boolean;
  117139. /**
  117140. * Factor to be applied to the pointer-moved function in the gaze mode. How sensitive should the gaze mode be when checking if the pointer moved
  117141. * to start a new countdown to the pointer down event.
  117142. * Defaults to 1.
  117143. */
  117144. gazeModePointerMovedFactor?: number;
  117145. }
  117146. /**
  117147. * A module that will enable pointer selection for motion controllers of XR Input Sources
  117148. */
  117149. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  117150. private readonly _options;
  117151. /**
  117152. * The module's name
  117153. */
  117154. static readonly Name: string;
  117155. /**
  117156. * The (Babylon) version of this module.
  117157. * This is an integer representing the implementation version.
  117158. * This number does not correspond to the webxr specs version
  117159. */
  117160. static readonly Version: number;
  117161. /**
  117162. * This color will be set to the laser pointer when selection is triggered
  117163. */
  117164. laserPointerPickedColor: Color3;
  117165. /**
  117166. * This color will be applied to the selection ring when selection is triggered
  117167. */
  117168. selectionMeshPickedColor: Color3;
  117169. /**
  117170. * default color of the selection ring
  117171. */
  117172. selectionMeshDefaultColor: Color3;
  117173. /**
  117174. * Default color of the laser pointer
  117175. */
  117176. lasterPointerDefaultColor: Color3;
  117177. /**
  117178. * Should the laser pointer be displayed
  117179. */
  117180. displayLaserPointer: boolean;
  117181. /**
  117182. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  117183. */
  117184. displaySelectionMesh: boolean;
  117185. /**
  117186. * Disable lighting on the laser pointer (so it will always be visible)
  117187. */
  117188. disablePointerLighting: boolean;
  117189. /**
  117190. * Disable lighting on the selection mesh (so it will always be visible)
  117191. */
  117192. disableSelectionMeshLighting: boolean;
  117193. private static _idCounter;
  117194. private _tmpRay;
  117195. private _controllers;
  117196. private _scene;
  117197. /**
  117198. * constructs a new background remover module
  117199. * @param _xrSessionManager the session manager for this module
  117200. * @param _options read-only options to be used in this module
  117201. */
  117202. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  117203. /**
  117204. * attach this feature
  117205. * Will usually be called by the features manager
  117206. *
  117207. * @returns true if successful.
  117208. */
  117209. attach(): boolean;
  117210. /**
  117211. * detach this feature.
  117212. * Will usually be called by the features manager
  117213. *
  117214. * @returns true if successful.
  117215. */
  117216. detach(): boolean;
  117217. /**
  117218. * Get the xr controller that correlates to the pointer id in the pointer event
  117219. *
  117220. * @param id the pointer id to search for
  117221. * @returns the controller that correlates to this id or null if not found
  117222. */
  117223. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  117224. protected _onXRFrame(_xrFrame: XRFrame): void;
  117225. private _attachController;
  117226. private _attachScreenRayMode;
  117227. private _attachGazeMode;
  117228. private _tmpVectorForPickCompare;
  117229. private _pickingMoved;
  117230. private _attachTrackedPointerRayMode;
  117231. private _detachController;
  117232. private _generateNewMeshPair;
  117233. private _convertNormalToDirectionOfRay;
  117234. private _updatePointerDistance;
  117235. }
  117236. }
  117237. declare module BABYLON {
  117238. /**
  117239. * Button which can be used to enter a different mode of XR
  117240. */
  117241. export class WebXREnterExitUIButton {
  117242. /** button element */
  117243. element: HTMLElement;
  117244. /** XR initialization options for the button */
  117245. sessionMode: XRSessionMode;
  117246. /** Reference space type */
  117247. referenceSpaceType: XRReferenceSpaceType;
  117248. /**
  117249. * Creates a WebXREnterExitUIButton
  117250. * @param element button element
  117251. * @param sessionMode XR initialization session mode
  117252. * @param referenceSpaceType the type of reference space to be used
  117253. */
  117254. constructor(
  117255. /** button element */
  117256. element: HTMLElement,
  117257. /** XR initialization options for the button */
  117258. sessionMode: XRSessionMode,
  117259. /** Reference space type */
  117260. referenceSpaceType: XRReferenceSpaceType);
  117261. /**
  117262. * Overwritable function which can be used to update the button's visuals when the state changes
  117263. * @param activeButton the current active button in the UI
  117264. */
  117265. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  117266. }
  117267. /**
  117268. * Options to create the webXR UI
  117269. */
  117270. export class WebXREnterExitUIOptions {
  117271. /**
  117272. * Context to enter xr with
  117273. */
  117274. renderTarget?: Nullable<WebXRRenderTarget>;
  117275. /**
  117276. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  117277. */
  117278. customButtons?: Array<WebXREnterExitUIButton>;
  117279. /**
  117280. * A session mode to use when creating the default button.
  117281. * Default is immersive-vr
  117282. */
  117283. sessionMode?: XRSessionMode;
  117284. /**
  117285. * A reference space type to use when creating the default button.
  117286. * Default is local-floor
  117287. */
  117288. referenceSpaceType?: XRReferenceSpaceType;
  117289. }
  117290. /**
  117291. * UI to allow the user to enter/exit XR mode
  117292. */
  117293. export class WebXREnterExitUI implements IDisposable {
  117294. private scene;
  117295. /** version of the options passed to this UI */
  117296. options: WebXREnterExitUIOptions;
  117297. private _overlay;
  117298. private _buttons;
  117299. private _activeButton;
  117300. /**
  117301. * Fired every time the active button is changed.
  117302. *
  117303. * When xr is entered via a button that launches xr that button will be the callback parameter
  117304. *
  117305. * When exiting xr the callback parameter will be null)
  117306. */
  117307. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  117308. /**
  117309. * Creates UI to allow the user to enter/exit XR mode
  117310. * @param scene the scene to add the ui to
  117311. * @param helper the xr experience helper to enter/exit xr with
  117312. * @param options options to configure the UI
  117313. * @returns the created ui
  117314. */
  117315. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  117316. /**
  117317. *
  117318. * @param scene babylon scene object to use
  117319. * @param options (read-only) version of the options passed to this UI
  117320. */
  117321. private constructor();
  117322. private _updateButtons;
  117323. /**
  117324. * Disposes of the object
  117325. */
  117326. dispose(): void;
  117327. }
  117328. }
  117329. declare module BABYLON {
  117330. /**
  117331. * Class containing static functions to help procedurally build meshes
  117332. */
  117333. export class LinesBuilder {
  117334. /**
  117335. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  117336. * * 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
  117337. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  117338. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  117339. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  117340. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  117341. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  117342. * * 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
  117343. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  117344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117345. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  117346. * @param name defines the name of the new line system
  117347. * @param options defines the options used to create the line system
  117348. * @param scene defines the hosting scene
  117349. * @returns a new line system mesh
  117350. */
  117351. static CreateLineSystem(name: string, options: {
  117352. lines: Vector3[][];
  117353. updatable?: boolean;
  117354. instance?: Nullable<LinesMesh>;
  117355. colors?: Nullable<Color4[][]>;
  117356. useVertexAlpha?: boolean;
  117357. }, scene: Nullable<Scene>): LinesMesh;
  117358. /**
  117359. * Creates a line mesh
  117360. * 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
  117361. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117362. * * The parameter `points` is an array successive Vector3
  117363. * * 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
  117364. * * The optional parameter `colors` is an array of successive Color4, one per line point
  117365. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  117366. * * When updating an instance, remember that only point positions can change, not the number of points
  117367. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117368. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  117369. * @param name defines the name of the new line system
  117370. * @param options defines the options used to create the line system
  117371. * @param scene defines the hosting scene
  117372. * @returns a new line mesh
  117373. */
  117374. static CreateLines(name: string, options: {
  117375. points: Vector3[];
  117376. updatable?: boolean;
  117377. instance?: Nullable<LinesMesh>;
  117378. colors?: Color4[];
  117379. useVertexAlpha?: boolean;
  117380. }, scene?: Nullable<Scene>): LinesMesh;
  117381. /**
  117382. * Creates a dashed line mesh
  117383. * * 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
  117384. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117385. * * The parameter `points` is an array successive Vector3
  117386. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  117387. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  117388. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  117389. * * 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
  117390. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  117391. * * When updating an instance, remember that only point positions can change, not the number of points
  117392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117393. * @param name defines the name of the mesh
  117394. * @param options defines the options used to create the mesh
  117395. * @param scene defines the hosting scene
  117396. * @returns the dashed line mesh
  117397. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  117398. */
  117399. static CreateDashedLines(name: string, options: {
  117400. points: Vector3[];
  117401. dashSize?: number;
  117402. gapSize?: number;
  117403. dashNb?: number;
  117404. updatable?: boolean;
  117405. instance?: LinesMesh;
  117406. useVertexAlpha?: boolean;
  117407. }, scene?: Nullable<Scene>): LinesMesh;
  117408. }
  117409. }
  117410. declare module BABYLON {
  117411. /**
  117412. * The options container for the teleportation module
  117413. */
  117414. export interface IWebXRTeleportationOptions {
  117415. /**
  117416. * Babylon XR Input class for controller
  117417. */
  117418. xrInput: WebXRInput;
  117419. /**
  117420. * A list of meshes to use as floor meshes.
  117421. * Meshes can be added and removed after initializing the feature using the
  117422. * addFloorMesh and removeFloorMesh functions
  117423. * If empty, rotation will still work
  117424. */
  117425. floorMeshes?: AbstractMesh[];
  117426. /**
  117427. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  117428. * If you want to support rotation, make sure your mesh has a direction indicator.
  117429. *
  117430. * When left untouched, the default mesh will be initialized.
  117431. */
  117432. teleportationTargetMesh?: AbstractMesh;
  117433. /**
  117434. * Values to configure the default target mesh
  117435. */
  117436. defaultTargetMeshOptions?: {
  117437. /**
  117438. * Fill color of the teleportation area
  117439. */
  117440. teleportationFillColor?: string;
  117441. /**
  117442. * Border color for the teleportation area
  117443. */
  117444. teleportationBorderColor?: string;
  117445. /**
  117446. * Disable the mesh's animation sequence
  117447. */
  117448. disableAnimation?: boolean;
  117449. /**
  117450. * Disable lighting on the material or the ring and arrow
  117451. */
  117452. disableLighting?: boolean;
  117453. /**
  117454. * Override the default material of the torus and arrow
  117455. */
  117456. torusArrowMaterial?: Material;
  117457. };
  117458. /**
  117459. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  117460. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  117461. */
  117462. useMainComponentOnly?: boolean;
  117463. /**
  117464. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  117465. */
  117466. timeToTeleport?: number;
  117467. }
  117468. /**
  117469. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  117470. * When enabled and attached, the feature will allow a user to move aroundand rotate in the scene using
  117471. * the input of the attached controllers.
  117472. */
  117473. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  117474. private _options;
  117475. /**
  117476. * The module's name
  117477. */
  117478. static readonly Name: string;
  117479. /**
  117480. * The (Babylon) version of this module.
  117481. * This is an integer representing the implementation version.
  117482. * This number does not correspond to the webxr specs version
  117483. */
  117484. static readonly Version: number;
  117485. /**
  117486. * Is rotation enabled when moving forward?
  117487. * Disabling this feature will prevent the user from deciding the direction when teleporting
  117488. */
  117489. rotationEnabled: boolean;
  117490. /**
  117491. * Should the module support parabolic ray on top of direct ray
  117492. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  117493. * Very helpful when moving between floors / different heights
  117494. */
  117495. parabolicRayEnabled: boolean;
  117496. /**
  117497. * The distance from the user to the inspection point in the direction of the controller
  117498. * A higher number will allow the user to move further
  117499. * defaults to 5 (meters, in xr units)
  117500. */
  117501. parabolicCheckRadius: number;
  117502. /**
  117503. * How much rotation should be applied when rotating right and left
  117504. */
  117505. rotationAngle: number;
  117506. /**
  117507. * Is movement backwards enabled
  117508. */
  117509. backwardsMovementEnabled: boolean;
  117510. /**
  117511. * Distance to travel when moving backwards
  117512. */
  117513. backwardsTeleportationDistance: number;
  117514. /**
  117515. * Add a new mesh to the floor meshes array
  117516. * @param mesh the mesh to use as floor mesh
  117517. */
  117518. addFloorMesh(mesh: AbstractMesh): void;
  117519. /**
  117520. * Remove a mesh from the floor meshes array
  117521. * @param mesh the mesh to remove
  117522. */
  117523. removeFloorMesh(mesh: AbstractMesh): void;
  117524. /**
  117525. * Remove a mesh from the floor meshes array using its name
  117526. * @param name the mesh name to remove
  117527. */
  117528. removeFloorMeshByName(name: string): void;
  117529. private _tmpRay;
  117530. private _tmpVector;
  117531. private _floorMeshes;
  117532. private _controllers;
  117533. /**
  117534. * constructs a new anchor system
  117535. * @param _xrSessionManager an instance of WebXRSessionManager
  117536. * @param _options configuration object for this feature
  117537. */
  117538. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  117539. private _selectionFeature;
  117540. /**
  117541. * This function sets a selection feature that will be disabled when
  117542. * the forward ray is shown and will be reattached when hidden.
  117543. * This is used to remove the selection rays when moving.
  117544. * @param selectionFeature the feature to disable when forward movement is enabled
  117545. */
  117546. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  117547. attach(): boolean;
  117548. detach(): boolean;
  117549. dispose(): void;
  117550. protected _onXRFrame(_xrFrame: XRFrame): void;
  117551. private _currentTeleportationControllerId;
  117552. private _attachController;
  117553. private _teleportForward;
  117554. private _detachController;
  117555. private createDefaultTargetMesh;
  117556. private setTargetMeshVisibility;
  117557. private setTargetMeshPosition;
  117558. private _quadraticBezierCurve;
  117559. private _showParabolicPath;
  117560. }
  117561. }
  117562. declare module BABYLON {
  117563. /**
  117564. * Options for the default xr helper
  117565. */
  117566. export class WebXRDefaultExperienceOptions {
  117567. /**
  117568. * Floor meshes that will be used for teleporting
  117569. */
  117570. floorMeshes?: Array<AbstractMesh>;
  117571. /**
  117572. * Enable or disable default UI to enter XR
  117573. */
  117574. disableDefaultUI?: boolean;
  117575. /**
  117576. * optional configuration for the output canvas
  117577. */
  117578. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  117579. /**
  117580. * optional UI options. This can be used among other to change session mode and reference space type
  117581. */
  117582. uiOptions?: WebXREnterExitUIOptions;
  117583. /**
  117584. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  117585. */
  117586. inputOptions?: IWebXRInputOptions;
  117587. /**
  117588. * Should teleportation not initialize. defaults to false.
  117589. */
  117590. disableTeleportation?: boolean;
  117591. /**
  117592. * If set to true, the first frame will not be used to reset position
  117593. * The first frame is mainly used when copying transformation from the old camera
  117594. * Mainly used in AR
  117595. */
  117596. ignoreNativeCameraTransformation?: boolean;
  117597. /**
  117598. * When loading teleportation and pointer select, use stable versions instead of latest.
  117599. */
  117600. useStablePlugins?: boolean;
  117601. }
  117602. /**
  117603. * Default experience which provides a similar setup to the previous webVRExperience
  117604. */
  117605. export class WebXRDefaultExperience {
  117606. /**
  117607. * Base experience
  117608. */
  117609. baseExperience: WebXRExperienceHelper;
  117610. /**
  117611. * Input experience extension
  117612. */
  117613. input: WebXRInput;
  117614. /**
  117615. * Enables laser pointer and selection
  117616. */
  117617. pointerSelection: WebXRControllerPointerSelection;
  117618. /**
  117619. * Enables teleportation
  117620. */
  117621. teleportation: WebXRMotionControllerTeleportation;
  117622. /**
  117623. * Enables ui for entering/exiting xr
  117624. */
  117625. enterExitUI: WebXREnterExitUI;
  117626. /**
  117627. * Default target xr should render to
  117628. */
  117629. renderTarget: WebXRRenderTarget;
  117630. /**
  117631. * Creates the default xr experience
  117632. * @param scene scene
  117633. * @param options options for basic configuration
  117634. * @returns resulting WebXRDefaultExperience
  117635. */
  117636. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  117637. private constructor();
  117638. /**
  117639. * DIsposes of the experience helper
  117640. */
  117641. dispose(): void;
  117642. }
  117643. }
  117644. declare module BABYLON {
  117645. /**
  117646. * Options to modify the vr teleportation behavior.
  117647. */
  117648. export interface VRTeleportationOptions {
  117649. /**
  117650. * The name of the mesh which should be used as the teleportation floor. (default: null)
  117651. */
  117652. floorMeshName?: string;
  117653. /**
  117654. * A list of meshes to be used as the teleportation floor. (default: empty)
  117655. */
  117656. floorMeshes?: Mesh[];
  117657. /**
  117658. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  117659. */
  117660. teleportationMode?: number;
  117661. /**
  117662. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  117663. */
  117664. teleportationTime?: number;
  117665. /**
  117666. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  117667. */
  117668. teleportationSpeed?: number;
  117669. /**
  117670. * The easing function used in the animation or null for Linear. (default CircleEase)
  117671. */
  117672. easingFunction?: EasingFunction;
  117673. }
  117674. /**
  117675. * Options to modify the vr experience helper's behavior.
  117676. */
  117677. export interface VRExperienceHelperOptions extends WebVROptions {
  117678. /**
  117679. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  117680. */
  117681. createDeviceOrientationCamera?: boolean;
  117682. /**
  117683. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  117684. */
  117685. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  117686. /**
  117687. * Uses the main button on the controller to toggle the laser casted. (default: true)
  117688. */
  117689. laserToggle?: boolean;
  117690. /**
  117691. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  117692. */
  117693. floorMeshes?: Mesh[];
  117694. /**
  117695. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  117696. */
  117697. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  117698. /**
  117699. * Defines if WebXR should be used instead of WebVR (if available)
  117700. */
  117701. useXR?: boolean;
  117702. }
  117703. /**
  117704. * Event containing information after VR has been entered
  117705. */
  117706. export class OnAfterEnteringVRObservableEvent {
  117707. /**
  117708. * If entering vr was successful
  117709. */
  117710. success: boolean;
  117711. }
  117712. /**
  117713. * Helps to quickly add VR support to an existing scene.
  117714. * See http://doc.babylonjs.com/how_to/webvr_helper
  117715. */
  117716. export class VRExperienceHelper {
  117717. /** Options to modify the vr experience helper's behavior. */
  117718. webVROptions: VRExperienceHelperOptions;
  117719. private _scene;
  117720. private _position;
  117721. private _btnVR;
  117722. private _btnVRDisplayed;
  117723. private _webVRsupported;
  117724. private _webVRready;
  117725. private _webVRrequesting;
  117726. private _webVRpresenting;
  117727. private _hasEnteredVR;
  117728. private _fullscreenVRpresenting;
  117729. private _inputElement;
  117730. private _webVRCamera;
  117731. private _vrDeviceOrientationCamera;
  117732. private _deviceOrientationCamera;
  117733. private _existingCamera;
  117734. private _onKeyDown;
  117735. private _onVrDisplayPresentChange;
  117736. private _onVRDisplayChanged;
  117737. private _onVRRequestPresentStart;
  117738. private _onVRRequestPresentComplete;
  117739. /**
  117740. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  117741. */
  117742. enableGazeEvenWhenNoPointerLock: boolean;
  117743. /**
  117744. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  117745. */
  117746. exitVROnDoubleTap: boolean;
  117747. /**
  117748. * Observable raised right before entering VR.
  117749. */
  117750. onEnteringVRObservable: Observable<VRExperienceHelper>;
  117751. /**
  117752. * Observable raised when entering VR has completed.
  117753. */
  117754. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  117755. /**
  117756. * Observable raised when exiting VR.
  117757. */
  117758. onExitingVRObservable: Observable<VRExperienceHelper>;
  117759. /**
  117760. * Observable raised when controller mesh is loaded.
  117761. */
  117762. onControllerMeshLoadedObservable: Observable<WebVRController>;
  117763. /** Return this.onEnteringVRObservable
  117764. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  117765. */
  117766. get onEnteringVR(): Observable<VRExperienceHelper>;
  117767. /** Return this.onExitingVRObservable
  117768. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  117769. */
  117770. get onExitingVR(): Observable<VRExperienceHelper>;
  117771. /** Return this.onControllerMeshLoadedObservable
  117772. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  117773. */
  117774. get onControllerMeshLoaded(): Observable<WebVRController>;
  117775. private _rayLength;
  117776. private _useCustomVRButton;
  117777. private _teleportationRequested;
  117778. private _teleportActive;
  117779. private _floorMeshName;
  117780. private _floorMeshesCollection;
  117781. private _teleportationMode;
  117782. private _teleportationTime;
  117783. private _teleportationSpeed;
  117784. private _teleportationEasing;
  117785. private _rotationAllowed;
  117786. private _teleportBackwardsVector;
  117787. private _teleportationTarget;
  117788. private _isDefaultTeleportationTarget;
  117789. private _postProcessMove;
  117790. private _teleportationFillColor;
  117791. private _teleportationBorderColor;
  117792. private _rotationAngle;
  117793. private _haloCenter;
  117794. private _cameraGazer;
  117795. private _padSensibilityUp;
  117796. private _padSensibilityDown;
  117797. private _leftController;
  117798. private _rightController;
  117799. private _gazeColor;
  117800. private _laserColor;
  117801. private _pickedLaserColor;
  117802. private _pickedGazeColor;
  117803. /**
  117804. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  117805. */
  117806. onNewMeshSelected: Observable<AbstractMesh>;
  117807. /**
  117808. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  117809. * This observable will provide the mesh and the controller used to select the mesh
  117810. */
  117811. onMeshSelectedWithController: Observable<{
  117812. mesh: AbstractMesh;
  117813. controller: WebVRController;
  117814. }>;
  117815. /**
  117816. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  117817. */
  117818. onNewMeshPicked: Observable<PickingInfo>;
  117819. private _circleEase;
  117820. /**
  117821. * Observable raised before camera teleportation
  117822. */
  117823. onBeforeCameraTeleport: Observable<Vector3>;
  117824. /**
  117825. * Observable raised after camera teleportation
  117826. */
  117827. onAfterCameraTeleport: Observable<Vector3>;
  117828. /**
  117829. * Observable raised when current selected mesh gets unselected
  117830. */
  117831. onSelectedMeshUnselected: Observable<AbstractMesh>;
  117832. private _raySelectionPredicate;
  117833. /**
  117834. * To be optionaly changed by user to define custom ray selection
  117835. */
  117836. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  117837. /**
  117838. * To be optionaly changed by user to define custom selection logic (after ray selection)
  117839. */
  117840. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  117841. /**
  117842. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  117843. */
  117844. teleportationEnabled: boolean;
  117845. private _defaultHeight;
  117846. private _teleportationInitialized;
  117847. private _interactionsEnabled;
  117848. private _interactionsRequested;
  117849. private _displayGaze;
  117850. private _displayLaserPointer;
  117851. /**
  117852. * The mesh used to display where the user is going to teleport.
  117853. */
  117854. get teleportationTarget(): Mesh;
  117855. /**
  117856. * Sets the mesh to be used to display where the user is going to teleport.
  117857. */
  117858. set teleportationTarget(value: Mesh);
  117859. /**
  117860. * 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
  117861. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  117862. * See http://doc.babylonjs.com/resources/baking_transformations
  117863. */
  117864. get gazeTrackerMesh(): Mesh;
  117865. set gazeTrackerMesh(value: Mesh);
  117866. /**
  117867. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  117868. */
  117869. updateGazeTrackerScale: boolean;
  117870. /**
  117871. * If the gaze trackers color should be updated when selecting meshes
  117872. */
  117873. updateGazeTrackerColor: boolean;
  117874. /**
  117875. * If the controller laser color should be updated when selecting meshes
  117876. */
  117877. updateControllerLaserColor: boolean;
  117878. /**
  117879. * The gaze tracking mesh corresponding to the left controller
  117880. */
  117881. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  117882. /**
  117883. * The gaze tracking mesh corresponding to the right controller
  117884. */
  117885. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  117886. /**
  117887. * If the ray of the gaze should be displayed.
  117888. */
  117889. get displayGaze(): boolean;
  117890. /**
  117891. * Sets if the ray of the gaze should be displayed.
  117892. */
  117893. set displayGaze(value: boolean);
  117894. /**
  117895. * If the ray of the LaserPointer should be displayed.
  117896. */
  117897. get displayLaserPointer(): boolean;
  117898. /**
  117899. * Sets if the ray of the LaserPointer should be displayed.
  117900. */
  117901. set displayLaserPointer(value: boolean);
  117902. /**
  117903. * The deviceOrientationCamera used as the camera when not in VR.
  117904. */
  117905. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  117906. /**
  117907. * Based on the current WebVR support, returns the current VR camera used.
  117908. */
  117909. get currentVRCamera(): Nullable<Camera>;
  117910. /**
  117911. * The webVRCamera which is used when in VR.
  117912. */
  117913. get webVRCamera(): WebVRFreeCamera;
  117914. /**
  117915. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  117916. */
  117917. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  117918. /**
  117919. * The html button that is used to trigger entering into VR.
  117920. */
  117921. get vrButton(): Nullable<HTMLButtonElement>;
  117922. private get _teleportationRequestInitiated();
  117923. /**
  117924. * Defines whether or not Pointer lock should be requested when switching to
  117925. * full screen.
  117926. */
  117927. requestPointerLockOnFullScreen: boolean;
  117928. /**
  117929. * If asking to force XR, this will be populated with the default xr experience
  117930. */
  117931. xr: WebXRDefaultExperience;
  117932. /**
  117933. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  117934. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  117935. */
  117936. xrTestDone: boolean;
  117937. /**
  117938. * Instantiates a VRExperienceHelper.
  117939. * Helps to quickly add VR support to an existing scene.
  117940. * @param scene The scene the VRExperienceHelper belongs to.
  117941. * @param webVROptions Options to modify the vr experience helper's behavior.
  117942. */
  117943. constructor(scene: Scene,
  117944. /** Options to modify the vr experience helper's behavior. */
  117945. webVROptions?: VRExperienceHelperOptions);
  117946. private completeVRInit;
  117947. private _onDefaultMeshLoaded;
  117948. private _onResize;
  117949. private _onFullscreenChange;
  117950. /**
  117951. * Gets a value indicating if we are currently in VR mode.
  117952. */
  117953. get isInVRMode(): boolean;
  117954. private onVrDisplayPresentChange;
  117955. private onVRDisplayChanged;
  117956. private moveButtonToBottomRight;
  117957. private displayVRButton;
  117958. private updateButtonVisibility;
  117959. private _cachedAngularSensibility;
  117960. /**
  117961. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  117962. * Otherwise, will use the fullscreen API.
  117963. */
  117964. enterVR(): void;
  117965. /**
  117966. * Attempt to exit VR, or fullscreen.
  117967. */
  117968. exitVR(): void;
  117969. /**
  117970. * The position of the vr experience helper.
  117971. */
  117972. get position(): Vector3;
  117973. /**
  117974. * Sets the position of the vr experience helper.
  117975. */
  117976. set position(value: Vector3);
  117977. /**
  117978. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  117979. */
  117980. enableInteractions(): void;
  117981. private get _noControllerIsActive();
  117982. private beforeRender;
  117983. private _isTeleportationFloor;
  117984. /**
  117985. * Adds a floor mesh to be used for teleportation.
  117986. * @param floorMesh the mesh to be used for teleportation.
  117987. */
  117988. addFloorMesh(floorMesh: Mesh): void;
  117989. /**
  117990. * Removes a floor mesh from being used for teleportation.
  117991. * @param floorMesh the mesh to be removed.
  117992. */
  117993. removeFloorMesh(floorMesh: Mesh): void;
  117994. /**
  117995. * Enables interactions and teleportation using the VR controllers and gaze.
  117996. * @param vrTeleportationOptions options to modify teleportation behavior.
  117997. */
  117998. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  117999. private _onNewGamepadConnected;
  118000. private _tryEnableInteractionOnController;
  118001. private _onNewGamepadDisconnected;
  118002. private _enableInteractionOnController;
  118003. private _checkTeleportWithRay;
  118004. private _checkRotate;
  118005. private _checkTeleportBackwards;
  118006. private _enableTeleportationOnController;
  118007. private _createTeleportationCircles;
  118008. private _displayTeleportationTarget;
  118009. private _hideTeleportationTarget;
  118010. private _rotateCamera;
  118011. private _moveTeleportationSelectorTo;
  118012. private _workingVector;
  118013. private _workingQuaternion;
  118014. private _workingMatrix;
  118015. /**
  118016. * Time Constant Teleportation Mode
  118017. */
  118018. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  118019. /**
  118020. * Speed Constant Teleportation Mode
  118021. */
  118022. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  118023. /**
  118024. * Teleports the users feet to the desired location
  118025. * @param location The location where the user's feet should be placed
  118026. */
  118027. teleportCamera(location: Vector3): void;
  118028. private _convertNormalToDirectionOfRay;
  118029. private _castRayAndSelectObject;
  118030. private _notifySelectedMeshUnselected;
  118031. /**
  118032. * Permanently set new colors for the laser pointer
  118033. * @param color the new laser color
  118034. * @param pickedColor the new laser color when picked mesh detected
  118035. */
  118036. setLaserColor(color: Color3, pickedColor?: Color3): void;
  118037. /**
  118038. * Set lighting enabled / disabled on the laser pointer of both controllers
  118039. * @param enabled should the lighting be enabled on the laser pointer
  118040. */
  118041. setLaserLightingState(enabled?: boolean): void;
  118042. /**
  118043. * Permanently set new colors for the gaze pointer
  118044. * @param color the new gaze color
  118045. * @param pickedColor the new gaze color when picked mesh detected
  118046. */
  118047. setGazeColor(color: Color3, pickedColor?: Color3): void;
  118048. /**
  118049. * Sets the color of the laser ray from the vr controllers.
  118050. * @param color new color for the ray.
  118051. */
  118052. changeLaserColor(color: Color3): void;
  118053. /**
  118054. * Sets the color of the ray from the vr headsets gaze.
  118055. * @param color new color for the ray.
  118056. */
  118057. changeGazeColor(color: Color3): void;
  118058. /**
  118059. * Exits VR and disposes of the vr experience helper
  118060. */
  118061. dispose(): void;
  118062. /**
  118063. * Gets the name of the VRExperienceHelper class
  118064. * @returns "VRExperienceHelper"
  118065. */
  118066. getClassName(): string;
  118067. }
  118068. }
  118069. declare module BABYLON {
  118070. /**
  118071. * Contains an array of blocks representing the octree
  118072. */
  118073. export interface IOctreeContainer<T> {
  118074. /**
  118075. * Blocks within the octree
  118076. */
  118077. blocks: Array<OctreeBlock<T>>;
  118078. }
  118079. /**
  118080. * Class used to store a cell in an octree
  118081. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118082. */
  118083. export class OctreeBlock<T> {
  118084. /**
  118085. * Gets the content of the current block
  118086. */
  118087. entries: T[];
  118088. /**
  118089. * Gets the list of block children
  118090. */
  118091. blocks: Array<OctreeBlock<T>>;
  118092. private _depth;
  118093. private _maxDepth;
  118094. private _capacity;
  118095. private _minPoint;
  118096. private _maxPoint;
  118097. private _boundingVectors;
  118098. private _creationFunc;
  118099. /**
  118100. * Creates a new block
  118101. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  118102. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  118103. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118104. * @param depth defines the current depth of this block in the octree
  118105. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  118106. * @param creationFunc defines a callback to call when an element is added to the block
  118107. */
  118108. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  118109. /**
  118110. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118111. */
  118112. get capacity(): number;
  118113. /**
  118114. * Gets the minimum vector (in world space) of the block's bounding box
  118115. */
  118116. get minPoint(): Vector3;
  118117. /**
  118118. * Gets the maximum vector (in world space) of the block's bounding box
  118119. */
  118120. get maxPoint(): Vector3;
  118121. /**
  118122. * Add a new element to this block
  118123. * @param entry defines the element to add
  118124. */
  118125. addEntry(entry: T): void;
  118126. /**
  118127. * Remove an element from this block
  118128. * @param entry defines the element to remove
  118129. */
  118130. removeEntry(entry: T): void;
  118131. /**
  118132. * Add an array of elements to this block
  118133. * @param entries defines the array of elements to add
  118134. */
  118135. addEntries(entries: T[]): void;
  118136. /**
  118137. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  118138. * @param frustumPlanes defines the frustum planes to test
  118139. * @param selection defines the array to store current content if selection is positive
  118140. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118141. */
  118142. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118143. /**
  118144. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  118145. * @param sphereCenter defines the bounding sphere center
  118146. * @param sphereRadius defines the bounding sphere radius
  118147. * @param selection defines the array to store current content if selection is positive
  118148. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118149. */
  118150. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118151. /**
  118152. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  118153. * @param ray defines the ray to test with
  118154. * @param selection defines the array to store current content if selection is positive
  118155. */
  118156. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  118157. /**
  118158. * Subdivide the content into child blocks (this block will then be empty)
  118159. */
  118160. createInnerBlocks(): void;
  118161. /**
  118162. * @hidden
  118163. */
  118164. 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;
  118165. }
  118166. }
  118167. declare module BABYLON {
  118168. /**
  118169. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  118170. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118171. */
  118172. export class Octree<T> {
  118173. /** 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.) */
  118174. maxDepth: number;
  118175. /**
  118176. * Blocks within the octree containing objects
  118177. */
  118178. blocks: Array<OctreeBlock<T>>;
  118179. /**
  118180. * Content stored in the octree
  118181. */
  118182. dynamicContent: T[];
  118183. private _maxBlockCapacity;
  118184. private _selectionContent;
  118185. private _creationFunc;
  118186. /**
  118187. * Creates a octree
  118188. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118189. * @param creationFunc function to be used to instatiate the octree
  118190. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  118191. * @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.)
  118192. */
  118193. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  118194. /** 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.) */
  118195. maxDepth?: number);
  118196. /**
  118197. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  118198. * @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);
  118199. * @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);
  118200. * @param entries meshes to be added to the octree blocks
  118201. */
  118202. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  118203. /**
  118204. * Adds a mesh to the octree
  118205. * @param entry Mesh to add to the octree
  118206. */
  118207. addMesh(entry: T): void;
  118208. /**
  118209. * Remove an element from the octree
  118210. * @param entry defines the element to remove
  118211. */
  118212. removeMesh(entry: T): void;
  118213. /**
  118214. * Selects an array of meshes within the frustum
  118215. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  118216. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  118217. * @returns array of meshes within the frustum
  118218. */
  118219. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  118220. /**
  118221. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  118222. * @param sphereCenter defines the bounding sphere center
  118223. * @param sphereRadius defines the bounding sphere radius
  118224. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118225. * @returns an array of objects that intersect the sphere
  118226. */
  118227. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  118228. /**
  118229. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  118230. * @param ray defines the ray to test with
  118231. * @returns array of intersected objects
  118232. */
  118233. intersectsRay(ray: Ray): SmartArray<T>;
  118234. /**
  118235. * Adds a mesh into the octree block if it intersects the block
  118236. */
  118237. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  118238. /**
  118239. * Adds a submesh into the octree block if it intersects the block
  118240. */
  118241. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  118242. }
  118243. }
  118244. declare module BABYLON {
  118245. interface Scene {
  118246. /**
  118247. * @hidden
  118248. * Backing Filed
  118249. */
  118250. _selectionOctree: Octree<AbstractMesh>;
  118251. /**
  118252. * Gets the octree used to boost mesh selection (picking)
  118253. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118254. */
  118255. selectionOctree: Octree<AbstractMesh>;
  118256. /**
  118257. * Creates or updates the octree used to boost selection (picking)
  118258. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118259. * @param maxCapacity defines the maximum capacity per leaf
  118260. * @param maxDepth defines the maximum depth of the octree
  118261. * @returns an octree of AbstractMesh
  118262. */
  118263. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  118264. }
  118265. interface AbstractMesh {
  118266. /**
  118267. * @hidden
  118268. * Backing Field
  118269. */
  118270. _submeshesOctree: Octree<SubMesh>;
  118271. /**
  118272. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  118273. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  118274. * @param maxCapacity defines the maximum size of each block (64 by default)
  118275. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  118276. * @returns the new octree
  118277. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  118278. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118279. */
  118280. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  118281. }
  118282. /**
  118283. * Defines the octree scene component responsible to manage any octrees
  118284. * in a given scene.
  118285. */
  118286. export class OctreeSceneComponent {
  118287. /**
  118288. * The component name help to identify the component in the list of scene components.
  118289. */
  118290. readonly name: string;
  118291. /**
  118292. * The scene the component belongs to.
  118293. */
  118294. scene: Scene;
  118295. /**
  118296. * Indicates if the meshes have been checked to make sure they are isEnabled()
  118297. */
  118298. readonly checksIsEnabled: boolean;
  118299. /**
  118300. * Creates a new instance of the component for the given scene
  118301. * @param scene Defines the scene to register the component in
  118302. */
  118303. constructor(scene: Scene);
  118304. /**
  118305. * Registers the component in a given scene
  118306. */
  118307. register(): void;
  118308. /**
  118309. * Return the list of active meshes
  118310. * @returns the list of active meshes
  118311. */
  118312. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  118313. /**
  118314. * Return the list of active sub meshes
  118315. * @param mesh The mesh to get the candidates sub meshes from
  118316. * @returns the list of active sub meshes
  118317. */
  118318. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  118319. private _tempRay;
  118320. /**
  118321. * Return the list of sub meshes intersecting with a given local ray
  118322. * @param mesh defines the mesh to find the submesh for
  118323. * @param localRay defines the ray in local space
  118324. * @returns the list of intersecting sub meshes
  118325. */
  118326. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  118327. /**
  118328. * Return the list of sub meshes colliding with a collider
  118329. * @param mesh defines the mesh to find the submesh for
  118330. * @param collider defines the collider to evaluate the collision against
  118331. * @returns the list of colliding sub meshes
  118332. */
  118333. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  118334. /**
  118335. * Rebuilds the elements related to this component in case of
  118336. * context lost for instance.
  118337. */
  118338. rebuild(): void;
  118339. /**
  118340. * Disposes the component and the associated ressources.
  118341. */
  118342. dispose(): void;
  118343. }
  118344. }
  118345. declare module BABYLON {
  118346. /**
  118347. * Renders a layer on top of an existing scene
  118348. */
  118349. export class UtilityLayerRenderer implements IDisposable {
  118350. /** the original scene that will be rendered on top of */
  118351. originalScene: Scene;
  118352. private _pointerCaptures;
  118353. private _lastPointerEvents;
  118354. private static _DefaultUtilityLayer;
  118355. private static _DefaultKeepDepthUtilityLayer;
  118356. private _sharedGizmoLight;
  118357. private _renderCamera;
  118358. /**
  118359. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  118360. * @returns the camera that is used when rendering the utility layer
  118361. */
  118362. getRenderCamera(): Camera;
  118363. /**
  118364. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  118365. * @param cam the camera that should be used when rendering the utility layer
  118366. */
  118367. setRenderCamera(cam: Nullable<Camera>): void;
  118368. /**
  118369. * @hidden
  118370. * Light which used by gizmos to get light shading
  118371. */
  118372. _getSharedGizmoLight(): HemisphericLight;
  118373. /**
  118374. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  118375. */
  118376. pickUtilitySceneFirst: boolean;
  118377. /**
  118378. * 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)
  118379. */
  118380. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  118381. /**
  118382. * 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)
  118383. */
  118384. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  118385. /**
  118386. * The scene that is rendered on top of the original scene
  118387. */
  118388. utilityLayerScene: Scene;
  118389. /**
  118390. * If the utility layer should automatically be rendered on top of existing scene
  118391. */
  118392. shouldRender: boolean;
  118393. /**
  118394. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  118395. */
  118396. onlyCheckPointerDownEvents: boolean;
  118397. /**
  118398. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  118399. */
  118400. processAllEvents: boolean;
  118401. /**
  118402. * Observable raised when the pointer move from the utility layer scene to the main scene
  118403. */
  118404. onPointerOutObservable: Observable<number>;
  118405. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  118406. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  118407. private _afterRenderObserver;
  118408. private _sceneDisposeObserver;
  118409. private _originalPointerObserver;
  118410. /**
  118411. * Instantiates a UtilityLayerRenderer
  118412. * @param originalScene the original scene that will be rendered on top of
  118413. * @param handleEvents boolean indicating if the utility layer should handle events
  118414. */
  118415. constructor(
  118416. /** the original scene that will be rendered on top of */
  118417. originalScene: Scene, handleEvents?: boolean);
  118418. private _notifyObservers;
  118419. /**
  118420. * Renders the utility layers scene on top of the original scene
  118421. */
  118422. render(): void;
  118423. /**
  118424. * Disposes of the renderer
  118425. */
  118426. dispose(): void;
  118427. private _updateCamera;
  118428. }
  118429. }
  118430. declare module BABYLON {
  118431. /**
  118432. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  118433. */
  118434. export class Gizmo implements IDisposable {
  118435. /** The utility layer the gizmo will be added to */
  118436. gizmoLayer: UtilityLayerRenderer;
  118437. /**
  118438. * The root mesh of the gizmo
  118439. */
  118440. _rootMesh: Mesh;
  118441. private _attachedMesh;
  118442. /**
  118443. * Ratio for the scale of the gizmo (Default: 1)
  118444. */
  118445. scaleRatio: number;
  118446. /**
  118447. * If a custom mesh has been set (Default: false)
  118448. */
  118449. protected _customMeshSet: boolean;
  118450. /**
  118451. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  118452. * * When set, interactions will be enabled
  118453. */
  118454. get attachedMesh(): Nullable<AbstractMesh>;
  118455. set attachedMesh(value: Nullable<AbstractMesh>);
  118456. /**
  118457. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  118458. * @param mesh The mesh to replace the default mesh of the gizmo
  118459. */
  118460. setCustomMesh(mesh: Mesh): void;
  118461. /**
  118462. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  118463. */
  118464. updateGizmoRotationToMatchAttachedMesh: boolean;
  118465. /**
  118466. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  118467. */
  118468. updateGizmoPositionToMatchAttachedMesh: boolean;
  118469. /**
  118470. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  118471. */
  118472. updateScale: boolean;
  118473. protected _interactionsEnabled: boolean;
  118474. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118475. private _beforeRenderObserver;
  118476. private _tempVector;
  118477. /**
  118478. * Creates a gizmo
  118479. * @param gizmoLayer The utility layer the gizmo will be added to
  118480. */
  118481. constructor(
  118482. /** The utility layer the gizmo will be added to */
  118483. gizmoLayer?: UtilityLayerRenderer);
  118484. /**
  118485. * Updates the gizmo to match the attached mesh's position/rotation
  118486. */
  118487. protected _update(): void;
  118488. /**
  118489. * Disposes of the gizmo
  118490. */
  118491. dispose(): void;
  118492. }
  118493. }
  118494. declare module BABYLON {
  118495. /**
  118496. * Single plane drag gizmo
  118497. */
  118498. export class PlaneDragGizmo extends Gizmo {
  118499. /**
  118500. * Drag behavior responsible for the gizmos dragging interactions
  118501. */
  118502. dragBehavior: PointerDragBehavior;
  118503. private _pointerObserver;
  118504. /**
  118505. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118506. */
  118507. snapDistance: number;
  118508. /**
  118509. * Event that fires each time the gizmo snaps to a new location.
  118510. * * snapDistance is the the change in distance
  118511. */
  118512. onSnapObservable: Observable<{
  118513. snapDistance: number;
  118514. }>;
  118515. private _plane;
  118516. private _coloredMaterial;
  118517. private _hoverMaterial;
  118518. private _isEnabled;
  118519. private _parent;
  118520. /** @hidden */
  118521. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  118522. /** @hidden */
  118523. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  118524. /**
  118525. * Creates a PlaneDragGizmo
  118526. * @param gizmoLayer The utility layer the gizmo will be added to
  118527. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  118528. * @param color The color of the gizmo
  118529. */
  118530. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  118531. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118532. /**
  118533. * If the gizmo is enabled
  118534. */
  118535. set isEnabled(value: boolean);
  118536. get isEnabled(): boolean;
  118537. /**
  118538. * Disposes of the gizmo
  118539. */
  118540. dispose(): void;
  118541. }
  118542. }
  118543. declare module BABYLON {
  118544. /**
  118545. * Gizmo that enables dragging a mesh along 3 axis
  118546. */
  118547. export class PositionGizmo extends Gizmo {
  118548. /**
  118549. * Internal gizmo used for interactions on the x axis
  118550. */
  118551. xGizmo: AxisDragGizmo;
  118552. /**
  118553. * Internal gizmo used for interactions on the y axis
  118554. */
  118555. yGizmo: AxisDragGizmo;
  118556. /**
  118557. * Internal gizmo used for interactions on the z axis
  118558. */
  118559. zGizmo: AxisDragGizmo;
  118560. /**
  118561. * Internal gizmo used for interactions on the yz plane
  118562. */
  118563. xPlaneGizmo: PlaneDragGizmo;
  118564. /**
  118565. * Internal gizmo used for interactions on the xz plane
  118566. */
  118567. yPlaneGizmo: PlaneDragGizmo;
  118568. /**
  118569. * Internal gizmo used for interactions on the xy plane
  118570. */
  118571. zPlaneGizmo: PlaneDragGizmo;
  118572. /**
  118573. * private variables
  118574. */
  118575. private _meshAttached;
  118576. private _updateGizmoRotationToMatchAttachedMesh;
  118577. private _snapDistance;
  118578. private _scaleRatio;
  118579. /** Fires an event when any of it's sub gizmos are dragged */
  118580. onDragStartObservable: Observable<unknown>;
  118581. /** Fires an event when any of it's sub gizmos are released from dragging */
  118582. onDragEndObservable: Observable<unknown>;
  118583. /**
  118584. * If set to true, planar drag is enabled
  118585. */
  118586. private _planarGizmoEnabled;
  118587. get attachedMesh(): Nullable<AbstractMesh>;
  118588. set attachedMesh(mesh: Nullable<AbstractMesh>);
  118589. /**
  118590. * Creates a PositionGizmo
  118591. * @param gizmoLayer The utility layer the gizmo will be added to
  118592. */
  118593. constructor(gizmoLayer?: UtilityLayerRenderer);
  118594. /**
  118595. * If the planar drag gizmo is enabled
  118596. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  118597. */
  118598. set planarGizmoEnabled(value: boolean);
  118599. get planarGizmoEnabled(): boolean;
  118600. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  118601. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  118602. /**
  118603. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118604. */
  118605. set snapDistance(value: number);
  118606. get snapDistance(): number;
  118607. /**
  118608. * Ratio for the scale of the gizmo (Default: 1)
  118609. */
  118610. set scaleRatio(value: number);
  118611. get scaleRatio(): number;
  118612. /**
  118613. * Disposes of the gizmo
  118614. */
  118615. dispose(): void;
  118616. /**
  118617. * CustomMeshes are not supported by this gizmo
  118618. * @param mesh The mesh to replace the default mesh of the gizmo
  118619. */
  118620. setCustomMesh(mesh: Mesh): void;
  118621. }
  118622. }
  118623. declare module BABYLON {
  118624. /**
  118625. * Single axis drag gizmo
  118626. */
  118627. export class AxisDragGizmo extends Gizmo {
  118628. /**
  118629. * Drag behavior responsible for the gizmos dragging interactions
  118630. */
  118631. dragBehavior: PointerDragBehavior;
  118632. private _pointerObserver;
  118633. /**
  118634. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118635. */
  118636. snapDistance: number;
  118637. /**
  118638. * Event that fires each time the gizmo snaps to a new location.
  118639. * * snapDistance is the the change in distance
  118640. */
  118641. onSnapObservable: Observable<{
  118642. snapDistance: number;
  118643. }>;
  118644. private _isEnabled;
  118645. private _parent;
  118646. private _arrow;
  118647. private _coloredMaterial;
  118648. private _hoverMaterial;
  118649. /** @hidden */
  118650. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  118651. /** @hidden */
  118652. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  118653. /**
  118654. * Creates an AxisDragGizmo
  118655. * @param gizmoLayer The utility layer the gizmo will be added to
  118656. * @param dragAxis The axis which the gizmo will be able to drag on
  118657. * @param color The color of the gizmo
  118658. */
  118659. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  118660. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118661. /**
  118662. * If the gizmo is enabled
  118663. */
  118664. set isEnabled(value: boolean);
  118665. get isEnabled(): boolean;
  118666. /**
  118667. * Disposes of the gizmo
  118668. */
  118669. dispose(): void;
  118670. }
  118671. }
  118672. declare module BABYLON.Debug {
  118673. /**
  118674. * The Axes viewer will show 3 axes in a specific point in space
  118675. */
  118676. export class AxesViewer {
  118677. private _xAxis;
  118678. private _yAxis;
  118679. private _zAxis;
  118680. private _scaleLinesFactor;
  118681. private _instanced;
  118682. /**
  118683. * Gets the hosting scene
  118684. */
  118685. scene: Scene;
  118686. /**
  118687. * Gets or sets a number used to scale line length
  118688. */
  118689. scaleLines: number;
  118690. /** Gets the node hierarchy used to render x-axis */
  118691. get xAxis(): TransformNode;
  118692. /** Gets the node hierarchy used to render y-axis */
  118693. get yAxis(): TransformNode;
  118694. /** Gets the node hierarchy used to render z-axis */
  118695. get zAxis(): TransformNode;
  118696. /**
  118697. * Creates a new AxesViewer
  118698. * @param scene defines the hosting scene
  118699. * @param scaleLines defines a number used to scale line length (1 by default)
  118700. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  118701. * @param xAxis defines the node hierarchy used to render the x-axis
  118702. * @param yAxis defines the node hierarchy used to render the y-axis
  118703. * @param zAxis defines the node hierarchy used to render the z-axis
  118704. */
  118705. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  118706. /**
  118707. * Force the viewer to update
  118708. * @param position defines the position of the viewer
  118709. * @param xaxis defines the x axis of the viewer
  118710. * @param yaxis defines the y axis of the viewer
  118711. * @param zaxis defines the z axis of the viewer
  118712. */
  118713. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  118714. /**
  118715. * Creates an instance of this axes viewer.
  118716. * @returns a new axes viewer with instanced meshes
  118717. */
  118718. createInstance(): AxesViewer;
  118719. /** Releases resources */
  118720. dispose(): void;
  118721. private static _SetRenderingGroupId;
  118722. }
  118723. }
  118724. declare module BABYLON.Debug {
  118725. /**
  118726. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  118727. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  118728. */
  118729. export class BoneAxesViewer extends AxesViewer {
  118730. /**
  118731. * Gets or sets the target mesh where to display the axes viewer
  118732. */
  118733. mesh: Nullable<Mesh>;
  118734. /**
  118735. * Gets or sets the target bone where to display the axes viewer
  118736. */
  118737. bone: Nullable<Bone>;
  118738. /** Gets current position */
  118739. pos: Vector3;
  118740. /** Gets direction of X axis */
  118741. xaxis: Vector3;
  118742. /** Gets direction of Y axis */
  118743. yaxis: Vector3;
  118744. /** Gets direction of Z axis */
  118745. zaxis: Vector3;
  118746. /**
  118747. * Creates a new BoneAxesViewer
  118748. * @param scene defines the hosting scene
  118749. * @param bone defines the target bone
  118750. * @param mesh defines the target mesh
  118751. * @param scaleLines defines a scaling factor for line length (1 by default)
  118752. */
  118753. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  118754. /**
  118755. * Force the viewer to update
  118756. */
  118757. update(): void;
  118758. /** Releases resources */
  118759. dispose(): void;
  118760. }
  118761. }
  118762. declare module BABYLON {
  118763. /**
  118764. * Interface used to define scene explorer extensibility option
  118765. */
  118766. export interface IExplorerExtensibilityOption {
  118767. /**
  118768. * Define the option label
  118769. */
  118770. label: string;
  118771. /**
  118772. * Defines the action to execute on click
  118773. */
  118774. action: (entity: any) => void;
  118775. }
  118776. /**
  118777. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  118778. */
  118779. export interface IExplorerExtensibilityGroup {
  118780. /**
  118781. * Defines a predicate to test if a given type mut be extended
  118782. */
  118783. predicate: (entity: any) => boolean;
  118784. /**
  118785. * Gets the list of options added to a type
  118786. */
  118787. entries: IExplorerExtensibilityOption[];
  118788. }
  118789. /**
  118790. * Interface used to define the options to use to create the Inspector
  118791. */
  118792. export interface IInspectorOptions {
  118793. /**
  118794. * Display in overlay mode (default: false)
  118795. */
  118796. overlay?: boolean;
  118797. /**
  118798. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  118799. */
  118800. globalRoot?: HTMLElement;
  118801. /**
  118802. * Display the Scene explorer
  118803. */
  118804. showExplorer?: boolean;
  118805. /**
  118806. * Display the property inspector
  118807. */
  118808. showInspector?: boolean;
  118809. /**
  118810. * Display in embed mode (both panes on the right)
  118811. */
  118812. embedMode?: boolean;
  118813. /**
  118814. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  118815. */
  118816. handleResize?: boolean;
  118817. /**
  118818. * Allow the panes to popup (default: true)
  118819. */
  118820. enablePopup?: boolean;
  118821. /**
  118822. * Allow the panes to be closed by users (default: true)
  118823. */
  118824. enableClose?: boolean;
  118825. /**
  118826. * Optional list of extensibility entries
  118827. */
  118828. explorerExtensibility?: IExplorerExtensibilityGroup[];
  118829. /**
  118830. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  118831. */
  118832. inspectorURL?: string;
  118833. /**
  118834. * Optional initial tab (default to DebugLayerTab.Properties)
  118835. */
  118836. initialTab?: DebugLayerTab;
  118837. }
  118838. interface Scene {
  118839. /**
  118840. * @hidden
  118841. * Backing field
  118842. */
  118843. _debugLayer: DebugLayer;
  118844. /**
  118845. * Gets the debug layer (aka Inspector) associated with the scene
  118846. * @see http://doc.babylonjs.com/features/playground_debuglayer
  118847. */
  118848. debugLayer: DebugLayer;
  118849. }
  118850. /**
  118851. * Enum of inspector action tab
  118852. */
  118853. export enum DebugLayerTab {
  118854. /**
  118855. * Properties tag (default)
  118856. */
  118857. Properties = 0,
  118858. /**
  118859. * Debug tab
  118860. */
  118861. Debug = 1,
  118862. /**
  118863. * Statistics tab
  118864. */
  118865. Statistics = 2,
  118866. /**
  118867. * Tools tab
  118868. */
  118869. Tools = 3,
  118870. /**
  118871. * Settings tab
  118872. */
  118873. Settings = 4
  118874. }
  118875. /**
  118876. * The debug layer (aka Inspector) is the go to tool in order to better understand
  118877. * what is happening in your scene
  118878. * @see http://doc.babylonjs.com/features/playground_debuglayer
  118879. */
  118880. export class DebugLayer {
  118881. /**
  118882. * Define the url to get the inspector script from.
  118883. * By default it uses the babylonjs CDN.
  118884. * @ignoreNaming
  118885. */
  118886. static InspectorURL: string;
  118887. private _scene;
  118888. private BJSINSPECTOR;
  118889. private _onPropertyChangedObservable?;
  118890. /**
  118891. * Observable triggered when a property is changed through the inspector.
  118892. */
  118893. get onPropertyChangedObservable(): any;
  118894. /**
  118895. * Instantiates a new debug layer.
  118896. * The debug layer (aka Inspector) is the go to tool in order to better understand
  118897. * what is happening in your scene
  118898. * @see http://doc.babylonjs.com/features/playground_debuglayer
  118899. * @param scene Defines the scene to inspect
  118900. */
  118901. constructor(scene: Scene);
  118902. /** Creates the inspector window. */
  118903. private _createInspector;
  118904. /**
  118905. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  118906. * @param entity defines the entity to select
  118907. * @param lineContainerTitle defines the specific block to highlight
  118908. */
  118909. select(entity: any, lineContainerTitle?: string): void;
  118910. /** Get the inspector from bundle or global */
  118911. private _getGlobalInspector;
  118912. /**
  118913. * Get if the inspector is visible or not.
  118914. * @returns true if visible otherwise, false
  118915. */
  118916. isVisible(): boolean;
  118917. /**
  118918. * Hide the inspector and close its window.
  118919. */
  118920. hide(): void;
  118921. /**
  118922. * Launch the debugLayer.
  118923. * @param config Define the configuration of the inspector
  118924. * @return a promise fulfilled when the debug layer is visible
  118925. */
  118926. show(config?: IInspectorOptions): Promise<DebugLayer>;
  118927. }
  118928. }
  118929. declare module BABYLON {
  118930. /**
  118931. * Class containing static functions to help procedurally build meshes
  118932. */
  118933. export class BoxBuilder {
  118934. /**
  118935. * Creates a box mesh
  118936. * * The parameter `size` sets the size (float) of each box side (default 1)
  118937. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  118938. * * 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)
  118939. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  118940. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118941. * * 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
  118942. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118943. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  118944. * @param name defines the name of the mesh
  118945. * @param options defines the options used to create the mesh
  118946. * @param scene defines the hosting scene
  118947. * @returns the box mesh
  118948. */
  118949. static CreateBox(name: string, options: {
  118950. size?: number;
  118951. width?: number;
  118952. height?: number;
  118953. depth?: number;
  118954. faceUV?: Vector4[];
  118955. faceColors?: Color4[];
  118956. sideOrientation?: number;
  118957. frontUVs?: Vector4;
  118958. backUVs?: Vector4;
  118959. wrap?: boolean;
  118960. topBaseAt?: number;
  118961. bottomBaseAt?: number;
  118962. updatable?: boolean;
  118963. }, scene?: Nullable<Scene>): Mesh;
  118964. }
  118965. }
  118966. declare module BABYLON.Debug {
  118967. /**
  118968. * Used to show the physics impostor around the specific mesh
  118969. */
  118970. export class PhysicsViewer {
  118971. /** @hidden */
  118972. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  118973. /** @hidden */
  118974. protected _meshes: Array<Nullable<AbstractMesh>>;
  118975. /** @hidden */
  118976. protected _scene: Nullable<Scene>;
  118977. /** @hidden */
  118978. protected _numMeshes: number;
  118979. /** @hidden */
  118980. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  118981. private _renderFunction;
  118982. private _utilityLayer;
  118983. private _debugBoxMesh;
  118984. private _debugSphereMesh;
  118985. private _debugCylinderMesh;
  118986. private _debugMaterial;
  118987. private _debugMeshMeshes;
  118988. /**
  118989. * Creates a new PhysicsViewer
  118990. * @param scene defines the hosting scene
  118991. */
  118992. constructor(scene: Scene);
  118993. /** @hidden */
  118994. protected _updateDebugMeshes(): void;
  118995. /**
  118996. * Renders a specified physic impostor
  118997. * @param impostor defines the impostor to render
  118998. * @param targetMesh defines the mesh represented by the impostor
  118999. * @returns the new debug mesh used to render the impostor
  119000. */
  119001. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  119002. /**
  119003. * Hides a specified physic impostor
  119004. * @param impostor defines the impostor to hide
  119005. */
  119006. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  119007. private _getDebugMaterial;
  119008. private _getDebugBoxMesh;
  119009. private _getDebugSphereMesh;
  119010. private _getDebugCylinderMesh;
  119011. private _getDebugMeshMesh;
  119012. private _getDebugMesh;
  119013. /** Releases all resources */
  119014. dispose(): void;
  119015. }
  119016. }
  119017. declare module BABYLON {
  119018. /**
  119019. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119020. * in order to better appreciate the issue one might have.
  119021. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119022. */
  119023. export class RayHelper {
  119024. /**
  119025. * Defines the ray we are currently tryin to visualize.
  119026. */
  119027. ray: Nullable<Ray>;
  119028. private _renderPoints;
  119029. private _renderLine;
  119030. private _renderFunction;
  119031. private _scene;
  119032. private _updateToMeshFunction;
  119033. private _attachedToMesh;
  119034. private _meshSpaceDirection;
  119035. private _meshSpaceOrigin;
  119036. /**
  119037. * Helper function to create a colored helper in a scene in one line.
  119038. * @param ray Defines the ray we are currently tryin to visualize
  119039. * @param scene Defines the scene the ray is used in
  119040. * @param color Defines the color we want to see the ray in
  119041. * @returns The newly created ray helper.
  119042. */
  119043. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  119044. /**
  119045. * Instantiate a new ray helper.
  119046. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119047. * in order to better appreciate the issue one might have.
  119048. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119049. * @param ray Defines the ray we are currently tryin to visualize
  119050. */
  119051. constructor(ray: Ray);
  119052. /**
  119053. * Shows the ray we are willing to debug.
  119054. * @param scene Defines the scene the ray needs to be rendered in
  119055. * @param color Defines the color the ray needs to be rendered in
  119056. */
  119057. show(scene: Scene, color?: Color3): void;
  119058. /**
  119059. * Hides the ray we are debugging.
  119060. */
  119061. hide(): void;
  119062. private _render;
  119063. /**
  119064. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  119065. * @param mesh Defines the mesh we want the helper attached to
  119066. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  119067. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  119068. * @param length Defines the length of the ray
  119069. */
  119070. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  119071. /**
  119072. * Detach the ray helper from the mesh it has previously been attached to.
  119073. */
  119074. detachFromMesh(): void;
  119075. private _updateToMesh;
  119076. /**
  119077. * Dispose the helper and release its associated resources.
  119078. */
  119079. dispose(): void;
  119080. }
  119081. }
  119082. declare module BABYLON.Debug {
  119083. /**
  119084. * Class used to render a debug view of a given skeleton
  119085. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  119086. */
  119087. export class SkeletonViewer {
  119088. /** defines the skeleton to render */
  119089. skeleton: Skeleton;
  119090. /** defines the mesh attached to the skeleton */
  119091. mesh: AbstractMesh;
  119092. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119093. autoUpdateBonesMatrices: boolean;
  119094. /** defines the rendering group id to use with the viewer */
  119095. renderingGroupId: number;
  119096. /** Gets or sets the color used to render the skeleton */
  119097. color: Color3;
  119098. private _scene;
  119099. private _debugLines;
  119100. private _debugMesh;
  119101. private _isEnabled;
  119102. private _renderFunction;
  119103. private _utilityLayer;
  119104. /**
  119105. * Returns the mesh used to render the bones
  119106. */
  119107. get debugMesh(): Nullable<LinesMesh>;
  119108. /**
  119109. * Creates a new SkeletonViewer
  119110. * @param skeleton defines the skeleton to render
  119111. * @param mesh defines the mesh attached to the skeleton
  119112. * @param scene defines the hosting scene
  119113. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  119114. * @param renderingGroupId defines the rendering group id to use with the viewer
  119115. */
  119116. constructor(
  119117. /** defines the skeleton to render */
  119118. skeleton: Skeleton,
  119119. /** defines the mesh attached to the skeleton */
  119120. mesh: AbstractMesh, scene: Scene,
  119121. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119122. autoUpdateBonesMatrices?: boolean,
  119123. /** defines the rendering group id to use with the viewer */
  119124. renderingGroupId?: number);
  119125. /** Gets or sets a boolean indicating if the viewer is enabled */
  119126. set isEnabled(value: boolean);
  119127. get isEnabled(): boolean;
  119128. private _getBonePosition;
  119129. private _getLinesForBonesWithLength;
  119130. private _getLinesForBonesNoLength;
  119131. /** Update the viewer to sync with current skeleton state */
  119132. update(): void;
  119133. /** Release associated resources */
  119134. dispose(): void;
  119135. }
  119136. }
  119137. declare module BABYLON {
  119138. /**
  119139. * Options to create the null engine
  119140. */
  119141. export class NullEngineOptions {
  119142. /**
  119143. * Render width (Default: 512)
  119144. */
  119145. renderWidth: number;
  119146. /**
  119147. * Render height (Default: 256)
  119148. */
  119149. renderHeight: number;
  119150. /**
  119151. * Texture size (Default: 512)
  119152. */
  119153. textureSize: number;
  119154. /**
  119155. * If delta time between frames should be constant
  119156. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119157. */
  119158. deterministicLockstep: boolean;
  119159. /**
  119160. * Maximum about of steps between frames (Default: 4)
  119161. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119162. */
  119163. lockstepMaxSteps: number;
  119164. }
  119165. /**
  119166. * The null engine class provides support for headless version of babylon.js.
  119167. * This can be used in server side scenario or for testing purposes
  119168. */
  119169. export class NullEngine extends Engine {
  119170. private _options;
  119171. /**
  119172. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  119173. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119174. * @returns true if engine is in deterministic lock step mode
  119175. */
  119176. isDeterministicLockStep(): boolean;
  119177. /**
  119178. * Gets the max steps when engine is running in deterministic lock step
  119179. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119180. * @returns the max steps
  119181. */
  119182. getLockstepMaxSteps(): number;
  119183. /**
  119184. * Gets the current hardware scaling level.
  119185. * By default the hardware scaling level is computed from the window device ratio.
  119186. * 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.
  119187. * @returns a number indicating the current hardware scaling level
  119188. */
  119189. getHardwareScalingLevel(): number;
  119190. constructor(options?: NullEngineOptions);
  119191. /**
  119192. * Creates a vertex buffer
  119193. * @param vertices the data for the vertex buffer
  119194. * @returns the new WebGL static buffer
  119195. */
  119196. createVertexBuffer(vertices: FloatArray): DataBuffer;
  119197. /**
  119198. * Creates a new index buffer
  119199. * @param indices defines the content of the index buffer
  119200. * @param updatable defines if the index buffer must be updatable
  119201. * @returns a new webGL buffer
  119202. */
  119203. createIndexBuffer(indices: IndicesArray): DataBuffer;
  119204. /**
  119205. * Clear the current render buffer or the current render target (if any is set up)
  119206. * @param color defines the color to use
  119207. * @param backBuffer defines if the back buffer must be cleared
  119208. * @param depth defines if the depth buffer must be cleared
  119209. * @param stencil defines if the stencil buffer must be cleared
  119210. */
  119211. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  119212. /**
  119213. * Gets the current render width
  119214. * @param useScreen defines if screen size must be used (or the current render target if any)
  119215. * @returns a number defining the current render width
  119216. */
  119217. getRenderWidth(useScreen?: boolean): number;
  119218. /**
  119219. * Gets the current render height
  119220. * @param useScreen defines if screen size must be used (or the current render target if any)
  119221. * @returns a number defining the current render height
  119222. */
  119223. getRenderHeight(useScreen?: boolean): number;
  119224. /**
  119225. * Set the WebGL's viewport
  119226. * @param viewport defines the viewport element to be used
  119227. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  119228. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  119229. */
  119230. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  119231. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  119232. /**
  119233. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  119234. * @param pipelineContext defines the pipeline context to use
  119235. * @param uniformsNames defines the list of uniform names
  119236. * @returns an array of webGL uniform locations
  119237. */
  119238. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  119239. /**
  119240. * Gets the lsit of active attributes for a given webGL program
  119241. * @param pipelineContext defines the pipeline context to use
  119242. * @param attributesNames defines the list of attribute names to get
  119243. * @returns an array of indices indicating the offset of each attribute
  119244. */
  119245. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  119246. /**
  119247. * Binds an effect to the webGL context
  119248. * @param effect defines the effect to bind
  119249. */
  119250. bindSamplers(effect: Effect): void;
  119251. /**
  119252. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  119253. * @param effect defines the effect to activate
  119254. */
  119255. enableEffect(effect: Effect): void;
  119256. /**
  119257. * Set various states to the webGL context
  119258. * @param culling defines backface culling state
  119259. * @param zOffset defines the value to apply to zOffset (0 by default)
  119260. * @param force defines if states must be applied even if cache is up to date
  119261. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  119262. */
  119263. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  119264. /**
  119265. * Set the value of an uniform to an array of int32
  119266. * @param uniform defines the webGL uniform location where to store the value
  119267. * @param array defines the array of int32 to store
  119268. */
  119269. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  119270. /**
  119271. * Set the value of an uniform to an array of int32 (stored as vec2)
  119272. * @param uniform defines the webGL uniform location where to store the value
  119273. * @param array defines the array of int32 to store
  119274. */
  119275. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  119276. /**
  119277. * Set the value of an uniform to an array of int32 (stored as vec3)
  119278. * @param uniform defines the webGL uniform location where to store the value
  119279. * @param array defines the array of int32 to store
  119280. */
  119281. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  119282. /**
  119283. * Set the value of an uniform to an array of int32 (stored as vec4)
  119284. * @param uniform defines the webGL uniform location where to store the value
  119285. * @param array defines the array of int32 to store
  119286. */
  119287. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  119288. /**
  119289. * Set the value of an uniform to an array of float32
  119290. * @param uniform defines the webGL uniform location where to store the value
  119291. * @param array defines the array of float32 to store
  119292. */
  119293. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  119294. /**
  119295. * Set the value of an uniform to an array of float32 (stored as vec2)
  119296. * @param uniform defines the webGL uniform location where to store the value
  119297. * @param array defines the array of float32 to store
  119298. */
  119299. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  119300. /**
  119301. * Set the value of an uniform to an array of float32 (stored as vec3)
  119302. * @param uniform defines the webGL uniform location where to store the value
  119303. * @param array defines the array of float32 to store
  119304. */
  119305. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  119306. /**
  119307. * Set the value of an uniform to an array of float32 (stored as vec4)
  119308. * @param uniform defines the webGL uniform location where to store the value
  119309. * @param array defines the array of float32 to store
  119310. */
  119311. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  119312. /**
  119313. * Set the value of an uniform to an array of number
  119314. * @param uniform defines the webGL uniform location where to store the value
  119315. * @param array defines the array of number to store
  119316. */
  119317. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  119318. /**
  119319. * Set the value of an uniform to an array of number (stored as vec2)
  119320. * @param uniform defines the webGL uniform location where to store the value
  119321. * @param array defines the array of number to store
  119322. */
  119323. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  119324. /**
  119325. * Set the value of an uniform to an array of number (stored as vec3)
  119326. * @param uniform defines the webGL uniform location where to store the value
  119327. * @param array defines the array of number to store
  119328. */
  119329. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  119330. /**
  119331. * Set the value of an uniform to an array of number (stored as vec4)
  119332. * @param uniform defines the webGL uniform location where to store the value
  119333. * @param array defines the array of number to store
  119334. */
  119335. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  119336. /**
  119337. * Set the value of an uniform to an array of float32 (stored as matrices)
  119338. * @param uniform defines the webGL uniform location where to store the value
  119339. * @param matrices defines the array of float32 to store
  119340. */
  119341. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  119342. /**
  119343. * Set the value of an uniform to a matrix (3x3)
  119344. * @param uniform defines the webGL uniform location where to store the value
  119345. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  119346. */
  119347. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119348. /**
  119349. * Set the value of an uniform to a matrix (2x2)
  119350. * @param uniform defines the webGL uniform location where to store the value
  119351. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  119352. */
  119353. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119354. /**
  119355. * Set the value of an uniform to a number (float)
  119356. * @param uniform defines the webGL uniform location where to store the value
  119357. * @param value defines the float number to store
  119358. */
  119359. setFloat(uniform: WebGLUniformLocation, value: number): void;
  119360. /**
  119361. * Set the value of an uniform to a vec2
  119362. * @param uniform defines the webGL uniform location where to store the value
  119363. * @param x defines the 1st component of the value
  119364. * @param y defines the 2nd component of the value
  119365. */
  119366. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  119367. /**
  119368. * Set the value of an uniform to a vec3
  119369. * @param uniform defines the webGL uniform location where to store the value
  119370. * @param x defines the 1st component of the value
  119371. * @param y defines the 2nd component of the value
  119372. * @param z defines the 3rd component of the value
  119373. */
  119374. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  119375. /**
  119376. * Set the value of an uniform to a boolean
  119377. * @param uniform defines the webGL uniform location where to store the value
  119378. * @param bool defines the boolean to store
  119379. */
  119380. setBool(uniform: WebGLUniformLocation, bool: number): void;
  119381. /**
  119382. * Set the value of an uniform to a vec4
  119383. * @param uniform defines the webGL uniform location where to store the value
  119384. * @param x defines the 1st component of the value
  119385. * @param y defines the 2nd component of the value
  119386. * @param z defines the 3rd component of the value
  119387. * @param w defines the 4th component of the value
  119388. */
  119389. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  119390. /**
  119391. * Sets the current alpha mode
  119392. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  119393. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  119394. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  119395. */
  119396. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  119397. /**
  119398. * Bind webGl buffers directly to the webGL context
  119399. * @param vertexBuffers defines the vertex buffer to bind
  119400. * @param indexBuffer defines the index buffer to bind
  119401. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  119402. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  119403. * @param effect defines the effect associated with the vertex buffer
  119404. */
  119405. bindBuffers(vertexBuffers: {
  119406. [key: string]: VertexBuffer;
  119407. }, indexBuffer: DataBuffer, effect: Effect): void;
  119408. /**
  119409. * Force the entire cache to be cleared
  119410. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  119411. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  119412. */
  119413. wipeCaches(bruteForce?: boolean): void;
  119414. /**
  119415. * Send a draw order
  119416. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  119417. * @param indexStart defines the starting index
  119418. * @param indexCount defines the number of index to draw
  119419. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119420. */
  119421. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  119422. /**
  119423. * Draw a list of indexed primitives
  119424. * @param fillMode defines the primitive to use
  119425. * @param indexStart defines the starting index
  119426. * @param indexCount defines the number of index to draw
  119427. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119428. */
  119429. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  119430. /**
  119431. * Draw a list of unindexed primitives
  119432. * @param fillMode defines the primitive to use
  119433. * @param verticesStart defines the index of first vertex to draw
  119434. * @param verticesCount defines the count of vertices to draw
  119435. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119436. */
  119437. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119438. /** @hidden */
  119439. _createTexture(): WebGLTexture;
  119440. /** @hidden */
  119441. _releaseTexture(texture: InternalTexture): void;
  119442. /**
  119443. * Usually called from Texture.ts.
  119444. * Passed information to create a WebGLTexture
  119445. * @param urlArg defines a value which contains one of the following:
  119446. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  119447. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  119448. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  119449. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  119450. * @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)
  119451. * @param scene needed for loading to the correct scene
  119452. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  119453. * @param onLoad optional callback to be called upon successful completion
  119454. * @param onError optional callback to be called upon failure
  119455. * @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
  119456. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  119457. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  119458. * @param forcedExtension defines the extension to use to pick the right loader
  119459. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  119460. * @returns a InternalTexture for assignment back into BABYLON.Texture
  119461. */
  119462. 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;
  119463. /**
  119464. * Creates a new render target texture
  119465. * @param size defines the size of the texture
  119466. * @param options defines the options used to create the texture
  119467. * @returns a new render target texture stored in an InternalTexture
  119468. */
  119469. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  119470. /**
  119471. * Update the sampling mode of a given texture
  119472. * @param samplingMode defines the required sampling mode
  119473. * @param texture defines the texture to update
  119474. */
  119475. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  119476. /**
  119477. * Binds the frame buffer to the specified texture.
  119478. * @param texture The texture to render to or null for the default canvas
  119479. * @param faceIndex The face of the texture to render to in case of cube texture
  119480. * @param requiredWidth The width of the target to render to
  119481. * @param requiredHeight The height of the target to render to
  119482. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  119483. * @param lodLevel defines le lod level to bind to the frame buffer
  119484. */
  119485. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  119486. /**
  119487. * Unbind the current render target texture from the webGL context
  119488. * @param texture defines the render target texture to unbind
  119489. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  119490. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  119491. */
  119492. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  119493. /**
  119494. * Creates a dynamic vertex buffer
  119495. * @param vertices the data for the dynamic vertex buffer
  119496. * @returns the new WebGL dynamic buffer
  119497. */
  119498. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  119499. /**
  119500. * Update the content of a dynamic texture
  119501. * @param texture defines the texture to update
  119502. * @param canvas defines the canvas containing the source
  119503. * @param invertY defines if data must be stored with Y axis inverted
  119504. * @param premulAlpha defines if alpha is stored as premultiplied
  119505. * @param format defines the format of the data
  119506. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  119507. */
  119508. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  119509. /**
  119510. * Gets a boolean indicating if all created effects are ready
  119511. * @returns true if all effects are ready
  119512. */
  119513. areAllEffectsReady(): boolean;
  119514. /**
  119515. * @hidden
  119516. * Get the current error code of the webGL context
  119517. * @returns the error code
  119518. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  119519. */
  119520. getError(): number;
  119521. /** @hidden */
  119522. _getUnpackAlignement(): number;
  119523. /** @hidden */
  119524. _unpackFlipY(value: boolean): void;
  119525. /**
  119526. * Update a dynamic index buffer
  119527. * @param indexBuffer defines the target index buffer
  119528. * @param indices defines the data to update
  119529. * @param offset defines the offset in the target index buffer where update should start
  119530. */
  119531. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  119532. /**
  119533. * Updates a dynamic vertex buffer.
  119534. * @param vertexBuffer the vertex buffer to update
  119535. * @param vertices the data used to update the vertex buffer
  119536. * @param byteOffset the byte offset of the data (optional)
  119537. * @param byteLength the byte length of the data (optional)
  119538. */
  119539. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  119540. /** @hidden */
  119541. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  119542. /** @hidden */
  119543. _bindTexture(channel: number, texture: InternalTexture): void;
  119544. protected _deleteBuffer(buffer: WebGLBuffer): void;
  119545. /**
  119546. * 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
  119547. */
  119548. releaseEffects(): void;
  119549. displayLoadingUI(): void;
  119550. hideLoadingUI(): void;
  119551. /** @hidden */
  119552. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  119553. /** @hidden */
  119554. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  119555. /** @hidden */
  119556. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  119557. /** @hidden */
  119558. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  119559. }
  119560. }
  119561. declare module BABYLON {
  119562. /** @hidden */
  119563. export class _OcclusionDataStorage {
  119564. /** @hidden */
  119565. occlusionInternalRetryCounter: number;
  119566. /** @hidden */
  119567. isOcclusionQueryInProgress: boolean;
  119568. /** @hidden */
  119569. isOccluded: boolean;
  119570. /** @hidden */
  119571. occlusionRetryCount: number;
  119572. /** @hidden */
  119573. occlusionType: number;
  119574. /** @hidden */
  119575. occlusionQueryAlgorithmType: number;
  119576. }
  119577. interface Engine {
  119578. /**
  119579. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  119580. * @return the new query
  119581. */
  119582. createQuery(): WebGLQuery;
  119583. /**
  119584. * Delete and release a webGL query
  119585. * @param query defines the query to delete
  119586. * @return the current engine
  119587. */
  119588. deleteQuery(query: WebGLQuery): Engine;
  119589. /**
  119590. * Check if a given query has resolved and got its value
  119591. * @param query defines the query to check
  119592. * @returns true if the query got its value
  119593. */
  119594. isQueryResultAvailable(query: WebGLQuery): boolean;
  119595. /**
  119596. * Gets the value of a given query
  119597. * @param query defines the query to check
  119598. * @returns the value of the query
  119599. */
  119600. getQueryResult(query: WebGLQuery): number;
  119601. /**
  119602. * Initiates an occlusion query
  119603. * @param algorithmType defines the algorithm to use
  119604. * @param query defines the query to use
  119605. * @returns the current engine
  119606. * @see http://doc.babylonjs.com/features/occlusionquery
  119607. */
  119608. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  119609. /**
  119610. * Ends an occlusion query
  119611. * @see http://doc.babylonjs.com/features/occlusionquery
  119612. * @param algorithmType defines the algorithm to use
  119613. * @returns the current engine
  119614. */
  119615. endOcclusionQuery(algorithmType: number): Engine;
  119616. /**
  119617. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  119618. * Please note that only one query can be issued at a time
  119619. * @returns a time token used to track the time span
  119620. */
  119621. startTimeQuery(): Nullable<_TimeToken>;
  119622. /**
  119623. * Ends a time query
  119624. * @param token defines the token used to measure the time span
  119625. * @returns the time spent (in ns)
  119626. */
  119627. endTimeQuery(token: _TimeToken): int;
  119628. /** @hidden */
  119629. _currentNonTimestampToken: Nullable<_TimeToken>;
  119630. /** @hidden */
  119631. _createTimeQuery(): WebGLQuery;
  119632. /** @hidden */
  119633. _deleteTimeQuery(query: WebGLQuery): void;
  119634. /** @hidden */
  119635. _getGlAlgorithmType(algorithmType: number): number;
  119636. /** @hidden */
  119637. _getTimeQueryResult(query: WebGLQuery): any;
  119638. /** @hidden */
  119639. _getTimeQueryAvailability(query: WebGLQuery): any;
  119640. }
  119641. interface AbstractMesh {
  119642. /**
  119643. * Backing filed
  119644. * @hidden
  119645. */
  119646. __occlusionDataStorage: _OcclusionDataStorage;
  119647. /**
  119648. * Access property
  119649. * @hidden
  119650. */
  119651. _occlusionDataStorage: _OcclusionDataStorage;
  119652. /**
  119653. * 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.
  119654. * The default value is -1 which means don't break the query and wait till the result
  119655. * @see http://doc.babylonjs.com/features/occlusionquery
  119656. */
  119657. occlusionRetryCount: number;
  119658. /**
  119659. * 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:
  119660. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  119661. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  119662. * * 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.
  119663. * @see http://doc.babylonjs.com/features/occlusionquery
  119664. */
  119665. occlusionType: number;
  119666. /**
  119667. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  119668. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  119669. * * 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.
  119670. * @see http://doc.babylonjs.com/features/occlusionquery
  119671. */
  119672. occlusionQueryAlgorithmType: number;
  119673. /**
  119674. * 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
  119675. * @see http://doc.babylonjs.com/features/occlusionquery
  119676. */
  119677. isOccluded: boolean;
  119678. /**
  119679. * Flag to check the progress status of the query
  119680. * @see http://doc.babylonjs.com/features/occlusionquery
  119681. */
  119682. isOcclusionQueryInProgress: boolean;
  119683. }
  119684. }
  119685. declare module BABYLON {
  119686. /** @hidden */
  119687. export var _forceTransformFeedbackToBundle: boolean;
  119688. interface Engine {
  119689. /**
  119690. * Creates a webGL transform feedback object
  119691. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  119692. * @returns the webGL transform feedback object
  119693. */
  119694. createTransformFeedback(): WebGLTransformFeedback;
  119695. /**
  119696. * Delete a webGL transform feedback object
  119697. * @param value defines the webGL transform feedback object to delete
  119698. */
  119699. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  119700. /**
  119701. * Bind a webGL transform feedback object to the webgl context
  119702. * @param value defines the webGL transform feedback object to bind
  119703. */
  119704. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  119705. /**
  119706. * Begins a transform feedback operation
  119707. * @param usePoints defines if points or triangles must be used
  119708. */
  119709. beginTransformFeedback(usePoints: boolean): void;
  119710. /**
  119711. * Ends a transform feedback operation
  119712. */
  119713. endTransformFeedback(): void;
  119714. /**
  119715. * Specify the varyings to use with transform feedback
  119716. * @param program defines the associated webGL program
  119717. * @param value defines the list of strings representing the varying names
  119718. */
  119719. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  119720. /**
  119721. * Bind a webGL buffer for a transform feedback operation
  119722. * @param value defines the webGL buffer to bind
  119723. */
  119724. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  119725. }
  119726. }
  119727. declare module BABYLON {
  119728. /**
  119729. * Creation options of the multi render target texture.
  119730. */
  119731. export interface IMultiRenderTargetOptions {
  119732. /**
  119733. * Define if the texture needs to create mip maps after render.
  119734. */
  119735. generateMipMaps?: boolean;
  119736. /**
  119737. * Define the types of all the draw buffers we want to create
  119738. */
  119739. types?: number[];
  119740. /**
  119741. * Define the sampling modes of all the draw buffers we want to create
  119742. */
  119743. samplingModes?: number[];
  119744. /**
  119745. * Define if a depth buffer is required
  119746. */
  119747. generateDepthBuffer?: boolean;
  119748. /**
  119749. * Define if a stencil buffer is required
  119750. */
  119751. generateStencilBuffer?: boolean;
  119752. /**
  119753. * Define if a depth texture is required instead of a depth buffer
  119754. */
  119755. generateDepthTexture?: boolean;
  119756. /**
  119757. * Define the number of desired draw buffers
  119758. */
  119759. textureCount?: number;
  119760. /**
  119761. * Define if aspect ratio should be adapted to the texture or stay the scene one
  119762. */
  119763. doNotChangeAspectRatio?: boolean;
  119764. /**
  119765. * Define the default type of the buffers we are creating
  119766. */
  119767. defaultType?: number;
  119768. }
  119769. /**
  119770. * A multi render target, like a render target provides the ability to render to a texture.
  119771. * Unlike the render target, it can render to several draw buffers in one draw.
  119772. * This is specially interesting in deferred rendering or for any effects requiring more than
  119773. * just one color from a single pass.
  119774. */
  119775. export class MultiRenderTarget extends RenderTargetTexture {
  119776. private _internalTextures;
  119777. private _textures;
  119778. private _multiRenderTargetOptions;
  119779. /**
  119780. * Get if draw buffers are currently supported by the used hardware and browser.
  119781. */
  119782. get isSupported(): boolean;
  119783. /**
  119784. * Get the list of textures generated by the multi render target.
  119785. */
  119786. get textures(): Texture[];
  119787. /**
  119788. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  119789. */
  119790. get depthTexture(): Texture;
  119791. /**
  119792. * Set the wrapping mode on U of all the textures we are rendering to.
  119793. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  119794. */
  119795. set wrapU(wrap: number);
  119796. /**
  119797. * Set the wrapping mode on V of all the textures we are rendering to.
  119798. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  119799. */
  119800. set wrapV(wrap: number);
  119801. /**
  119802. * Instantiate a new multi render target texture.
  119803. * A multi render target, like a render target provides the ability to render to a texture.
  119804. * Unlike the render target, it can render to several draw buffers in one draw.
  119805. * This is specially interesting in deferred rendering or for any effects requiring more than
  119806. * just one color from a single pass.
  119807. * @param name Define the name of the texture
  119808. * @param size Define the size of the buffers to render to
  119809. * @param count Define the number of target we are rendering into
  119810. * @param scene Define the scene the texture belongs to
  119811. * @param options Define the options used to create the multi render target
  119812. */
  119813. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  119814. /** @hidden */
  119815. _rebuild(): void;
  119816. private _createInternalTextures;
  119817. private _createTextures;
  119818. /**
  119819. * Define the number of samples used if MSAA is enabled.
  119820. */
  119821. get samples(): number;
  119822. set samples(value: number);
  119823. /**
  119824. * Resize all the textures in the multi render target.
  119825. * Be carrefull as it will recreate all the data in the new texture.
  119826. * @param size Define the new size
  119827. */
  119828. resize(size: any): void;
  119829. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  119830. /**
  119831. * Dispose the render targets and their associated resources
  119832. */
  119833. dispose(): void;
  119834. /**
  119835. * Release all the underlying texture used as draw buffers.
  119836. */
  119837. releaseInternalTextures(): void;
  119838. }
  119839. }
  119840. declare module BABYLON {
  119841. interface ThinEngine {
  119842. /**
  119843. * Unbind a list of render target textures from the webGL context
  119844. * This is used only when drawBuffer extension or webGL2 are active
  119845. * @param textures defines the render target textures to unbind
  119846. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  119847. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  119848. */
  119849. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  119850. /**
  119851. * Create a multi render target texture
  119852. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  119853. * @param size defines the size of the texture
  119854. * @param options defines the creation options
  119855. * @returns the cube texture as an InternalTexture
  119856. */
  119857. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  119858. /**
  119859. * Update the sample count for a given multiple render target texture
  119860. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  119861. * @param textures defines the textures to update
  119862. * @param samples defines the sample count to set
  119863. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  119864. */
  119865. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  119866. }
  119867. }
  119868. declare module BABYLON {
  119869. /**
  119870. * Class used to define an additional view for the engine
  119871. * @see https://doc.babylonjs.com/how_to/multi_canvases
  119872. */
  119873. export class EngineView {
  119874. /** Defines the canvas where to render the view */
  119875. target: HTMLCanvasElement;
  119876. /** Defines an optional camera used to render the view (will use active camera else) */
  119877. camera?: Camera;
  119878. }
  119879. interface Engine {
  119880. /**
  119881. * Gets or sets the HTML element to use for attaching events
  119882. */
  119883. inputElement: Nullable<HTMLElement>;
  119884. /**
  119885. * Gets the current engine view
  119886. * @see https://doc.babylonjs.com/how_to/multi_canvases
  119887. */
  119888. activeView: Nullable<EngineView>;
  119889. /** Gets or sets the list of views */
  119890. views: EngineView[];
  119891. /**
  119892. * Register a new child canvas
  119893. * @param canvas defines the canvas to register
  119894. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  119895. * @returns the associated view
  119896. */
  119897. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  119898. /**
  119899. * Remove a registered child canvas
  119900. * @param canvas defines the canvas to remove
  119901. * @returns the current engine
  119902. */
  119903. unRegisterView(canvas: HTMLCanvasElement): Engine;
  119904. }
  119905. }
  119906. declare module BABYLON {
  119907. /**
  119908. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  119909. */
  119910. export interface CubeMapInfo {
  119911. /**
  119912. * The pixel array for the front face.
  119913. * This is stored in format, left to right, up to down format.
  119914. */
  119915. front: Nullable<ArrayBufferView>;
  119916. /**
  119917. * The pixel array for the back face.
  119918. * This is stored in format, left to right, up to down format.
  119919. */
  119920. back: Nullable<ArrayBufferView>;
  119921. /**
  119922. * The pixel array for the left face.
  119923. * This is stored in format, left to right, up to down format.
  119924. */
  119925. left: Nullable<ArrayBufferView>;
  119926. /**
  119927. * The pixel array for the right face.
  119928. * This is stored in format, left to right, up to down format.
  119929. */
  119930. right: Nullable<ArrayBufferView>;
  119931. /**
  119932. * The pixel array for the up face.
  119933. * This is stored in format, left to right, up to down format.
  119934. */
  119935. up: Nullable<ArrayBufferView>;
  119936. /**
  119937. * The pixel array for the down face.
  119938. * This is stored in format, left to right, up to down format.
  119939. */
  119940. down: Nullable<ArrayBufferView>;
  119941. /**
  119942. * The size of the cubemap stored.
  119943. *
  119944. * Each faces will be size * size pixels.
  119945. */
  119946. size: number;
  119947. /**
  119948. * The format of the texture.
  119949. *
  119950. * RGBA, RGB.
  119951. */
  119952. format: number;
  119953. /**
  119954. * The type of the texture data.
  119955. *
  119956. * UNSIGNED_INT, FLOAT.
  119957. */
  119958. type: number;
  119959. /**
  119960. * Specifies whether the texture is in gamma space.
  119961. */
  119962. gammaSpace: boolean;
  119963. }
  119964. /**
  119965. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  119966. */
  119967. export class PanoramaToCubeMapTools {
  119968. private static FACE_FRONT;
  119969. private static FACE_BACK;
  119970. private static FACE_RIGHT;
  119971. private static FACE_LEFT;
  119972. private static FACE_DOWN;
  119973. private static FACE_UP;
  119974. /**
  119975. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  119976. *
  119977. * @param float32Array The source data.
  119978. * @param inputWidth The width of the input panorama.
  119979. * @param inputHeight The height of the input panorama.
  119980. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  119981. * @return The cubemap data
  119982. */
  119983. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  119984. private static CreateCubemapTexture;
  119985. private static CalcProjectionSpherical;
  119986. }
  119987. }
  119988. declare module BABYLON {
  119989. /**
  119990. * Helper class dealing with the extraction of spherical polynomial dataArray
  119991. * from a cube map.
  119992. */
  119993. export class CubeMapToSphericalPolynomialTools {
  119994. private static FileFaces;
  119995. /**
  119996. * Converts a texture to the according Spherical Polynomial data.
  119997. * This extracts the first 3 orders only as they are the only one used in the lighting.
  119998. *
  119999. * @param texture The texture to extract the information from.
  120000. * @return The Spherical Polynomial data.
  120001. */
  120002. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  120003. /**
  120004. * Converts a cubemap to the according Spherical Polynomial data.
  120005. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120006. *
  120007. * @param cubeInfo The Cube map to extract the information from.
  120008. * @return The Spherical Polynomial data.
  120009. */
  120010. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  120011. }
  120012. }
  120013. declare module BABYLON {
  120014. interface BaseTexture {
  120015. /**
  120016. * Get the polynomial representation of the texture data.
  120017. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  120018. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  120019. */
  120020. sphericalPolynomial: Nullable<SphericalPolynomial>;
  120021. }
  120022. }
  120023. declare module BABYLON {
  120024. /** @hidden */
  120025. export var rgbdEncodePixelShader: {
  120026. name: string;
  120027. shader: string;
  120028. };
  120029. }
  120030. declare module BABYLON {
  120031. /** @hidden */
  120032. export var rgbdDecodePixelShader: {
  120033. name: string;
  120034. shader: string;
  120035. };
  120036. }
  120037. declare module BABYLON {
  120038. /**
  120039. * Raw texture data and descriptor sufficient for WebGL texture upload
  120040. */
  120041. export interface EnvironmentTextureInfo {
  120042. /**
  120043. * Version of the environment map
  120044. */
  120045. version: number;
  120046. /**
  120047. * Width of image
  120048. */
  120049. width: number;
  120050. /**
  120051. * Irradiance information stored in the file.
  120052. */
  120053. irradiance: any;
  120054. /**
  120055. * Specular information stored in the file.
  120056. */
  120057. specular: any;
  120058. }
  120059. /**
  120060. * Defines One Image in the file. It requires only the position in the file
  120061. * as well as the length.
  120062. */
  120063. interface BufferImageData {
  120064. /**
  120065. * Length of the image data.
  120066. */
  120067. length: number;
  120068. /**
  120069. * Position of the data from the null terminator delimiting the end of the JSON.
  120070. */
  120071. position: number;
  120072. }
  120073. /**
  120074. * Defines the specular data enclosed in the file.
  120075. * This corresponds to the version 1 of the data.
  120076. */
  120077. export interface EnvironmentTextureSpecularInfoV1 {
  120078. /**
  120079. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  120080. */
  120081. specularDataPosition?: number;
  120082. /**
  120083. * This contains all the images data needed to reconstruct the cubemap.
  120084. */
  120085. mipmaps: Array<BufferImageData>;
  120086. /**
  120087. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  120088. */
  120089. lodGenerationScale: number;
  120090. }
  120091. /**
  120092. * Sets of helpers addressing the serialization and deserialization of environment texture
  120093. * stored in a BabylonJS env file.
  120094. * Those files are usually stored as .env files.
  120095. */
  120096. export class EnvironmentTextureTools {
  120097. /**
  120098. * Magic number identifying the env file.
  120099. */
  120100. private static _MagicBytes;
  120101. /**
  120102. * Gets the environment info from an env file.
  120103. * @param data The array buffer containing the .env bytes.
  120104. * @returns the environment file info (the json header) if successfully parsed.
  120105. */
  120106. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  120107. /**
  120108. * Creates an environment texture from a loaded cube texture.
  120109. * @param texture defines the cube texture to convert in env file
  120110. * @return a promise containing the environment data if succesfull.
  120111. */
  120112. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  120113. /**
  120114. * Creates a JSON representation of the spherical data.
  120115. * @param texture defines the texture containing the polynomials
  120116. * @return the JSON representation of the spherical info
  120117. */
  120118. private static _CreateEnvTextureIrradiance;
  120119. /**
  120120. * Creates the ArrayBufferViews used for initializing environment texture image data.
  120121. * @param data the image data
  120122. * @param info parameters that determine what views will be created for accessing the underlying buffer
  120123. * @return the views described by info providing access to the underlying buffer
  120124. */
  120125. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  120126. /**
  120127. * Uploads the texture info contained in the env file to the GPU.
  120128. * @param texture defines the internal texture to upload to
  120129. * @param data defines the data to load
  120130. * @param info defines the texture info retrieved through the GetEnvInfo method
  120131. * @returns a promise
  120132. */
  120133. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  120134. private static _OnImageReadyAsync;
  120135. /**
  120136. * Uploads the levels of image data to the GPU.
  120137. * @param texture defines the internal texture to upload to
  120138. * @param imageData defines the array buffer views of image data [mipmap][face]
  120139. * @returns a promise
  120140. */
  120141. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  120142. /**
  120143. * Uploads spherical polynomials information to the texture.
  120144. * @param texture defines the texture we are trying to upload the information to
  120145. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  120146. */
  120147. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  120148. /** @hidden */
  120149. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  120150. }
  120151. }
  120152. declare module BABYLON {
  120153. /**
  120154. * Contains position and normal vectors for a vertex
  120155. */
  120156. export class PositionNormalVertex {
  120157. /** the position of the vertex (defaut: 0,0,0) */
  120158. position: Vector3;
  120159. /** the normal of the vertex (defaut: 0,1,0) */
  120160. normal: Vector3;
  120161. /**
  120162. * Creates a PositionNormalVertex
  120163. * @param position the position of the vertex (defaut: 0,0,0)
  120164. * @param normal the normal of the vertex (defaut: 0,1,0)
  120165. */
  120166. constructor(
  120167. /** the position of the vertex (defaut: 0,0,0) */
  120168. position?: Vector3,
  120169. /** the normal of the vertex (defaut: 0,1,0) */
  120170. normal?: Vector3);
  120171. /**
  120172. * Clones the PositionNormalVertex
  120173. * @returns the cloned PositionNormalVertex
  120174. */
  120175. clone(): PositionNormalVertex;
  120176. }
  120177. /**
  120178. * Contains position, normal and uv vectors for a vertex
  120179. */
  120180. export class PositionNormalTextureVertex {
  120181. /** the position of the vertex (defaut: 0,0,0) */
  120182. position: Vector3;
  120183. /** the normal of the vertex (defaut: 0,1,0) */
  120184. normal: Vector3;
  120185. /** the uv of the vertex (default: 0,0) */
  120186. uv: Vector2;
  120187. /**
  120188. * Creates a PositionNormalTextureVertex
  120189. * @param position the position of the vertex (defaut: 0,0,0)
  120190. * @param normal the normal of the vertex (defaut: 0,1,0)
  120191. * @param uv the uv of the vertex (default: 0,0)
  120192. */
  120193. constructor(
  120194. /** the position of the vertex (defaut: 0,0,0) */
  120195. position?: Vector3,
  120196. /** the normal of the vertex (defaut: 0,1,0) */
  120197. normal?: Vector3,
  120198. /** the uv of the vertex (default: 0,0) */
  120199. uv?: Vector2);
  120200. /**
  120201. * Clones the PositionNormalTextureVertex
  120202. * @returns the cloned PositionNormalTextureVertex
  120203. */
  120204. clone(): PositionNormalTextureVertex;
  120205. }
  120206. }
  120207. declare module BABYLON {
  120208. /** @hidden */
  120209. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  120210. private _genericAttributeLocation;
  120211. private _varyingLocationCount;
  120212. private _varyingLocationMap;
  120213. private _replacements;
  120214. private _textureCount;
  120215. private _uniforms;
  120216. lineProcessor(line: string): string;
  120217. attributeProcessor(attribute: string): string;
  120218. varyingProcessor(varying: string, isFragment: boolean): string;
  120219. uniformProcessor(uniform: string): string;
  120220. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  120221. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  120222. }
  120223. }
  120224. declare module BABYLON {
  120225. /**
  120226. * Container for accessors for natively-stored mesh data buffers.
  120227. */
  120228. class NativeDataBuffer extends DataBuffer {
  120229. /**
  120230. * Accessor value used to identify/retrieve a natively-stored index buffer.
  120231. */
  120232. nativeIndexBuffer?: any;
  120233. /**
  120234. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  120235. */
  120236. nativeVertexBuffer?: any;
  120237. }
  120238. /** @hidden */
  120239. class NativeTexture extends InternalTexture {
  120240. getInternalTexture(): InternalTexture;
  120241. getViewCount(): number;
  120242. }
  120243. /** @hidden */
  120244. export class NativeEngine extends Engine {
  120245. private readonly _native;
  120246. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  120247. private readonly INVALID_HANDLE;
  120248. getHardwareScalingLevel(): number;
  120249. constructor();
  120250. /**
  120251. * Can be used to override the current requestAnimationFrame requester.
  120252. * @hidden
  120253. */
  120254. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  120255. /**
  120256. * Override default engine behavior.
  120257. * @param color
  120258. * @param backBuffer
  120259. * @param depth
  120260. * @param stencil
  120261. */
  120262. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  120263. /**
  120264. * Gets host document
  120265. * @returns the host document object
  120266. */
  120267. getHostDocument(): Nullable<Document>;
  120268. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  120269. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  120270. createVertexBuffer(data: DataArray): NativeDataBuffer;
  120271. recordVertexArrayObject(vertexBuffers: {
  120272. [key: string]: VertexBuffer;
  120273. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  120274. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120275. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120276. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  120277. /**
  120278. * Draw a list of indexed primitives
  120279. * @param fillMode defines the primitive to use
  120280. * @param indexStart defines the starting index
  120281. * @param indexCount defines the number of index to draw
  120282. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120283. */
  120284. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120285. /**
  120286. * Draw a list of unindexed primitives
  120287. * @param fillMode defines the primitive to use
  120288. * @param verticesStart defines the index of first vertex to draw
  120289. * @param verticesCount defines the count of vertices to draw
  120290. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120291. */
  120292. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120293. createPipelineContext(): IPipelineContext;
  120294. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  120295. /** @hidden */
  120296. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  120297. /** @hidden */
  120298. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  120299. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120300. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120301. protected _setProgram(program: WebGLProgram): void;
  120302. _releaseEffect(effect: Effect): void;
  120303. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  120304. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  120305. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  120306. bindSamplers(effect: Effect): void;
  120307. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  120308. getRenderWidth(useScreen?: boolean): number;
  120309. getRenderHeight(useScreen?: boolean): number;
  120310. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  120311. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  120312. /**
  120313. * Set the z offset to apply to current rendering
  120314. * @param value defines the offset to apply
  120315. */
  120316. setZOffset(value: number): void;
  120317. /**
  120318. * Gets the current value of the zOffset
  120319. * @returns the current zOffset state
  120320. */
  120321. getZOffset(): number;
  120322. /**
  120323. * Enable or disable depth buffering
  120324. * @param enable defines the state to set
  120325. */
  120326. setDepthBuffer(enable: boolean): void;
  120327. /**
  120328. * Gets a boolean indicating if depth writing is enabled
  120329. * @returns the current depth writing state
  120330. */
  120331. getDepthWrite(): boolean;
  120332. /**
  120333. * Enable or disable depth writing
  120334. * @param enable defines the state to set
  120335. */
  120336. setDepthWrite(enable: boolean): void;
  120337. /**
  120338. * Enable or disable color writing
  120339. * @param enable defines the state to set
  120340. */
  120341. setColorWrite(enable: boolean): void;
  120342. /**
  120343. * Gets a boolean indicating if color writing is enabled
  120344. * @returns the current color writing state
  120345. */
  120346. getColorWrite(): boolean;
  120347. /**
  120348. * Sets alpha constants used by some alpha blending modes
  120349. * @param r defines the red component
  120350. * @param g defines the green component
  120351. * @param b defines the blue component
  120352. * @param a defines the alpha component
  120353. */
  120354. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  120355. /**
  120356. * Sets the current alpha mode
  120357. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  120358. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  120359. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120360. */
  120361. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  120362. /**
  120363. * Gets the current alpha mode
  120364. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120365. * @returns the current alpha mode
  120366. */
  120367. getAlphaMode(): number;
  120368. setInt(uniform: WebGLUniformLocation, int: number): void;
  120369. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  120370. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  120371. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  120372. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  120373. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  120374. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  120375. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  120376. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  120377. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  120378. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  120379. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  120380. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  120381. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  120382. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120383. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120384. setFloat(uniform: WebGLUniformLocation, value: number): void;
  120385. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  120386. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  120387. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  120388. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  120389. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  120390. wipeCaches(bruteForce?: boolean): void;
  120391. _createTexture(): WebGLTexture;
  120392. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  120393. /**
  120394. * Usually called from BABYLON.Texture.ts.
  120395. * Passed information to create a WebGLTexture
  120396. * @param urlArg defines a value which contains one of the following:
  120397. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120398. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120399. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120400. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120401. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  120402. * @param scene needed for loading to the correct scene
  120403. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  120404. * @param onLoad optional callback to be called upon successful completion
  120405. * @param onError optional callback to be called upon failure
  120406. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  120407. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120408. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120409. * @param forcedExtension defines the extension to use to pick the right loader
  120410. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120411. */
  120412. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  120413. /**
  120414. * Creates a cube texture
  120415. * @param rootUrl defines the url where the files to load is located
  120416. * @param scene defines the current scene
  120417. * @param files defines the list of files to load (1 per face)
  120418. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  120419. * @param onLoad defines an optional callback raised when the texture is loaded
  120420. * @param onError defines an optional callback raised if there is an issue to load the texture
  120421. * @param format defines the format of the data
  120422. * @param forcedExtension defines the extension to use to pick the right loader
  120423. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  120424. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  120425. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  120426. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  120427. * @returns the cube texture as an InternalTexture
  120428. */
  120429. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  120430. private _getSamplingFilter;
  120431. private static _GetNativeTextureFormat;
  120432. createRenderTargetTexture(size: number | {
  120433. width: number;
  120434. height: number;
  120435. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  120436. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  120437. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  120438. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  120439. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  120440. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  120441. /**
  120442. * Updates a dynamic vertex buffer.
  120443. * @param vertexBuffer the vertex buffer to update
  120444. * @param data the data used to update the vertex buffer
  120445. * @param byteOffset the byte offset of the data (optional)
  120446. * @param byteLength the byte length of the data (optional)
  120447. */
  120448. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  120449. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  120450. private _updateAnisotropicLevel;
  120451. private _getAddressMode;
  120452. /** @hidden */
  120453. _bindTexture(channel: number, texture: InternalTexture): void;
  120454. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  120455. releaseEffects(): void;
  120456. /** @hidden */
  120457. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120458. /** @hidden */
  120459. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120460. /** @hidden */
  120461. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120462. /** @hidden */
  120463. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  120464. }
  120465. }
  120466. declare module BABYLON {
  120467. /**
  120468. * Gather the list of clipboard event types as constants.
  120469. */
  120470. export class ClipboardEventTypes {
  120471. /**
  120472. * The clipboard event is fired when a copy command is active (pressed).
  120473. */
  120474. static readonly COPY: number;
  120475. /**
  120476. * The clipboard event is fired when a cut command is active (pressed).
  120477. */
  120478. static readonly CUT: number;
  120479. /**
  120480. * The clipboard event is fired when a paste command is active (pressed).
  120481. */
  120482. static readonly PASTE: number;
  120483. }
  120484. /**
  120485. * This class is used to store clipboard related info for the onClipboardObservable event.
  120486. */
  120487. export class ClipboardInfo {
  120488. /**
  120489. * Defines the type of event (BABYLON.ClipboardEventTypes)
  120490. */
  120491. type: number;
  120492. /**
  120493. * Defines the related dom event
  120494. */
  120495. event: ClipboardEvent;
  120496. /**
  120497. *Creates an instance of ClipboardInfo.
  120498. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  120499. * @param event Defines the related dom event
  120500. */
  120501. constructor(
  120502. /**
  120503. * Defines the type of event (BABYLON.ClipboardEventTypes)
  120504. */
  120505. type: number,
  120506. /**
  120507. * Defines the related dom event
  120508. */
  120509. event: ClipboardEvent);
  120510. /**
  120511. * Get the clipboard event's type from the keycode.
  120512. * @param keyCode Defines the keyCode for the current keyboard event.
  120513. * @return {number}
  120514. */
  120515. static GetTypeFromCharacter(keyCode: number): number;
  120516. }
  120517. }
  120518. declare module BABYLON {
  120519. /**
  120520. * Google Daydream controller
  120521. */
  120522. export class DaydreamController extends WebVRController {
  120523. /**
  120524. * Base Url for the controller model.
  120525. */
  120526. static MODEL_BASE_URL: string;
  120527. /**
  120528. * File name for the controller model.
  120529. */
  120530. static MODEL_FILENAME: string;
  120531. /**
  120532. * Gamepad Id prefix used to identify Daydream Controller.
  120533. */
  120534. static readonly GAMEPAD_ID_PREFIX: string;
  120535. /**
  120536. * Creates a new DaydreamController from a gamepad
  120537. * @param vrGamepad the gamepad that the controller should be created from
  120538. */
  120539. constructor(vrGamepad: any);
  120540. /**
  120541. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  120542. * @param scene scene in which to add meshes
  120543. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  120544. */
  120545. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  120546. /**
  120547. * Called once for each button that changed state since the last frame
  120548. * @param buttonIdx Which button index changed
  120549. * @param state New state of the button
  120550. * @param changes Which properties on the state changed since last frame
  120551. */
  120552. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  120553. }
  120554. }
  120555. declare module BABYLON {
  120556. /**
  120557. * Gear VR Controller
  120558. */
  120559. export class GearVRController extends WebVRController {
  120560. /**
  120561. * Base Url for the controller model.
  120562. */
  120563. static MODEL_BASE_URL: string;
  120564. /**
  120565. * File name for the controller model.
  120566. */
  120567. static MODEL_FILENAME: string;
  120568. /**
  120569. * Gamepad Id prefix used to identify this controller.
  120570. */
  120571. static readonly GAMEPAD_ID_PREFIX: string;
  120572. private readonly _buttonIndexToObservableNameMap;
  120573. /**
  120574. * Creates a new GearVRController from a gamepad
  120575. * @param vrGamepad the gamepad that the controller should be created from
  120576. */
  120577. constructor(vrGamepad: any);
  120578. /**
  120579. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  120580. * @param scene scene in which to add meshes
  120581. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  120582. */
  120583. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  120584. /**
  120585. * Called once for each button that changed state since the last frame
  120586. * @param buttonIdx Which button index changed
  120587. * @param state New state of the button
  120588. * @param changes Which properties on the state changed since last frame
  120589. */
  120590. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  120591. }
  120592. }
  120593. declare module BABYLON {
  120594. /**
  120595. * Generic Controller
  120596. */
  120597. export class GenericController extends WebVRController {
  120598. /**
  120599. * Base Url for the controller model.
  120600. */
  120601. static readonly MODEL_BASE_URL: string;
  120602. /**
  120603. * File name for the controller model.
  120604. */
  120605. static readonly MODEL_FILENAME: string;
  120606. /**
  120607. * Creates a new GenericController from a gamepad
  120608. * @param vrGamepad the gamepad that the controller should be created from
  120609. */
  120610. constructor(vrGamepad: any);
  120611. /**
  120612. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  120613. * @param scene scene in which to add meshes
  120614. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  120615. */
  120616. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  120617. /**
  120618. * Called once for each button that changed state since the last frame
  120619. * @param buttonIdx Which button index changed
  120620. * @param state New state of the button
  120621. * @param changes Which properties on the state changed since last frame
  120622. */
  120623. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  120624. }
  120625. }
  120626. declare module BABYLON {
  120627. /**
  120628. * Oculus Touch Controller
  120629. */
  120630. export class OculusTouchController extends WebVRController {
  120631. /**
  120632. * Base Url for the controller model.
  120633. */
  120634. static MODEL_BASE_URL: string;
  120635. /**
  120636. * File name for the left controller model.
  120637. */
  120638. static MODEL_LEFT_FILENAME: string;
  120639. /**
  120640. * File name for the right controller model.
  120641. */
  120642. static MODEL_RIGHT_FILENAME: string;
  120643. /**
  120644. * Base Url for the Quest controller model.
  120645. */
  120646. static QUEST_MODEL_BASE_URL: string;
  120647. /**
  120648. * @hidden
  120649. * If the controllers are running on a device that needs the updated Quest controller models
  120650. */
  120651. static _IsQuest: boolean;
  120652. /**
  120653. * Fired when the secondary trigger on this controller is modified
  120654. */
  120655. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  120656. /**
  120657. * Fired when the thumb rest on this controller is modified
  120658. */
  120659. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  120660. /**
  120661. * Creates a new OculusTouchController from a gamepad
  120662. * @param vrGamepad the gamepad that the controller should be created from
  120663. */
  120664. constructor(vrGamepad: any);
  120665. /**
  120666. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  120667. * @param scene scene in which to add meshes
  120668. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  120669. */
  120670. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  120671. /**
  120672. * Fired when the A button on this controller is modified
  120673. */
  120674. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120675. /**
  120676. * Fired when the B button on this controller is modified
  120677. */
  120678. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120679. /**
  120680. * Fired when the X button on this controller is modified
  120681. */
  120682. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120683. /**
  120684. * Fired when the Y button on this controller is modified
  120685. */
  120686. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120687. /**
  120688. * Called once for each button that changed state since the last frame
  120689. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  120690. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  120691. * 2) secondary trigger (same)
  120692. * 3) A (right) X (left), touch, pressed = value
  120693. * 4) B / Y
  120694. * 5) thumb rest
  120695. * @param buttonIdx Which button index changed
  120696. * @param state New state of the button
  120697. * @param changes Which properties on the state changed since last frame
  120698. */
  120699. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  120700. }
  120701. }
  120702. declare module BABYLON {
  120703. /**
  120704. * Vive Controller
  120705. */
  120706. export class ViveController extends WebVRController {
  120707. /**
  120708. * Base Url for the controller model.
  120709. */
  120710. static MODEL_BASE_URL: string;
  120711. /**
  120712. * File name for the controller model.
  120713. */
  120714. static MODEL_FILENAME: string;
  120715. /**
  120716. * Creates a new ViveController from a gamepad
  120717. * @param vrGamepad the gamepad that the controller should be created from
  120718. */
  120719. constructor(vrGamepad: any);
  120720. /**
  120721. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  120722. * @param scene scene in which to add meshes
  120723. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  120724. */
  120725. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  120726. /**
  120727. * Fired when the left button on this controller is modified
  120728. */
  120729. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120730. /**
  120731. * Fired when the right button on this controller is modified
  120732. */
  120733. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120734. /**
  120735. * Fired when the menu button on this controller is modified
  120736. */
  120737. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120738. /**
  120739. * Called once for each button that changed state since the last frame
  120740. * Vive mapping:
  120741. * 0: touchpad
  120742. * 1: trigger
  120743. * 2: left AND right buttons
  120744. * 3: menu button
  120745. * @param buttonIdx Which button index changed
  120746. * @param state New state of the button
  120747. * @param changes Which properties on the state changed since last frame
  120748. */
  120749. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  120750. }
  120751. }
  120752. declare module BABYLON {
  120753. /**
  120754. * Defines the WindowsMotionController object that the state of the windows motion controller
  120755. */
  120756. export class WindowsMotionController extends WebVRController {
  120757. /**
  120758. * The base url used to load the left and right controller models
  120759. */
  120760. static MODEL_BASE_URL: string;
  120761. /**
  120762. * The name of the left controller model file
  120763. */
  120764. static MODEL_LEFT_FILENAME: string;
  120765. /**
  120766. * The name of the right controller model file
  120767. */
  120768. static MODEL_RIGHT_FILENAME: string;
  120769. /**
  120770. * The controller name prefix for this controller type
  120771. */
  120772. static readonly GAMEPAD_ID_PREFIX: string;
  120773. /**
  120774. * The controller id pattern for this controller type
  120775. */
  120776. private static readonly GAMEPAD_ID_PATTERN;
  120777. private _loadedMeshInfo;
  120778. protected readonly _mapping: {
  120779. buttons: string[];
  120780. buttonMeshNames: {
  120781. 'trigger': string;
  120782. 'menu': string;
  120783. 'grip': string;
  120784. 'thumbstick': string;
  120785. 'trackpad': string;
  120786. };
  120787. buttonObservableNames: {
  120788. 'trigger': string;
  120789. 'menu': string;
  120790. 'grip': string;
  120791. 'thumbstick': string;
  120792. 'trackpad': string;
  120793. };
  120794. axisMeshNames: string[];
  120795. pointingPoseMeshName: string;
  120796. };
  120797. /**
  120798. * Fired when the trackpad on this controller is clicked
  120799. */
  120800. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  120801. /**
  120802. * Fired when the trackpad on this controller is modified
  120803. */
  120804. onTrackpadValuesChangedObservable: Observable<StickValues>;
  120805. /**
  120806. * The current x and y values of this controller's trackpad
  120807. */
  120808. trackpad: StickValues;
  120809. /**
  120810. * Creates a new WindowsMotionController from a gamepad
  120811. * @param vrGamepad the gamepad that the controller should be created from
  120812. */
  120813. constructor(vrGamepad: any);
  120814. /**
  120815. * Fired when the trigger on this controller is modified
  120816. */
  120817. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120818. /**
  120819. * Fired when the menu button on this controller is modified
  120820. */
  120821. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120822. /**
  120823. * Fired when the grip button on this controller is modified
  120824. */
  120825. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120826. /**
  120827. * Fired when the thumbstick button on this controller is modified
  120828. */
  120829. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120830. /**
  120831. * Fired when the touchpad button on this controller is modified
  120832. */
  120833. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120834. /**
  120835. * Fired when the touchpad values on this controller are modified
  120836. */
  120837. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  120838. protected _updateTrackpad(): void;
  120839. /**
  120840. * Called once per frame by the engine.
  120841. */
  120842. update(): void;
  120843. /**
  120844. * Called once for each button that changed state since the last frame
  120845. * @param buttonIdx Which button index changed
  120846. * @param state New state of the button
  120847. * @param changes Which properties on the state changed since last frame
  120848. */
  120849. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  120850. /**
  120851. * Moves the buttons on the controller mesh based on their current state
  120852. * @param buttonName the name of the button to move
  120853. * @param buttonValue the value of the button which determines the buttons new position
  120854. */
  120855. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  120856. /**
  120857. * Moves the axis on the controller mesh based on its current state
  120858. * @param axis the index of the axis
  120859. * @param axisValue the value of the axis which determines the meshes new position
  120860. * @hidden
  120861. */
  120862. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  120863. /**
  120864. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  120865. * @param scene scene in which to add meshes
  120866. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  120867. */
  120868. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  120869. /**
  120870. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  120871. * can be transformed by button presses and axes values, based on this._mapping.
  120872. *
  120873. * @param scene scene in which the meshes exist
  120874. * @param meshes list of meshes that make up the controller model to process
  120875. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  120876. */
  120877. private processModel;
  120878. private createMeshInfo;
  120879. /**
  120880. * Gets the ray of the controller in the direction the controller is pointing
  120881. * @param length the length the resulting ray should be
  120882. * @returns a ray in the direction the controller is pointing
  120883. */
  120884. getForwardRay(length?: number): Ray;
  120885. /**
  120886. * Disposes of the controller
  120887. */
  120888. dispose(): void;
  120889. }
  120890. /**
  120891. * This class represents a new windows motion controller in XR.
  120892. */
  120893. export class XRWindowsMotionController extends WindowsMotionController {
  120894. /**
  120895. * Changing the original WIndowsMotionController mapping to fir the new mapping
  120896. */
  120897. protected readonly _mapping: {
  120898. buttons: string[];
  120899. buttonMeshNames: {
  120900. 'trigger': string;
  120901. 'menu': string;
  120902. 'grip': string;
  120903. 'thumbstick': string;
  120904. 'trackpad': string;
  120905. };
  120906. buttonObservableNames: {
  120907. 'trigger': string;
  120908. 'menu': string;
  120909. 'grip': string;
  120910. 'thumbstick': string;
  120911. 'trackpad': string;
  120912. };
  120913. axisMeshNames: string[];
  120914. pointingPoseMeshName: string;
  120915. };
  120916. /**
  120917. * Construct a new XR-Based windows motion controller
  120918. *
  120919. * @param gamepadInfo the gamepad object from the browser
  120920. */
  120921. constructor(gamepadInfo: any);
  120922. /**
  120923. * holds the thumbstick values (X,Y)
  120924. */
  120925. thumbstickValues: StickValues;
  120926. /**
  120927. * Fired when the thumbstick on this controller is clicked
  120928. */
  120929. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  120930. /**
  120931. * Fired when the thumbstick on this controller is modified
  120932. */
  120933. onThumbstickValuesChangedObservable: Observable<StickValues>;
  120934. /**
  120935. * Fired when the touchpad button on this controller is modified
  120936. */
  120937. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  120938. /**
  120939. * Fired when the touchpad values on this controller are modified
  120940. */
  120941. onTrackpadValuesChangedObservable: Observable<StickValues>;
  120942. /**
  120943. * Fired when the thumbstick button on this controller is modified
  120944. * here to prevent breaking changes
  120945. */
  120946. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  120947. /**
  120948. * updating the thumbstick(!) and not the trackpad.
  120949. * This is named this way due to the difference between WebVR and XR and to avoid
  120950. * changing the parent class.
  120951. */
  120952. protected _updateTrackpad(): void;
  120953. /**
  120954. * Disposes the class with joy
  120955. */
  120956. dispose(): void;
  120957. }
  120958. }
  120959. declare module BABYLON {
  120960. /**
  120961. * Class containing static functions to help procedurally build meshes
  120962. */
  120963. export class PolyhedronBuilder {
  120964. /**
  120965. * Creates a polyhedron mesh
  120966. * * 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
  120967. * * The parameter `size` (positive float, default 1) sets the polygon size
  120968. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  120969. * * 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`
  120970. * * 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
  120971. * * 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)`)
  120972. * * 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
  120973. * * 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
  120974. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120975. * * 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
  120976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120977. * @param name defines the name of the mesh
  120978. * @param options defines the options used to create the mesh
  120979. * @param scene defines the hosting scene
  120980. * @returns the polyhedron mesh
  120981. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  120982. */
  120983. static CreatePolyhedron(name: string, options: {
  120984. type?: number;
  120985. size?: number;
  120986. sizeX?: number;
  120987. sizeY?: number;
  120988. sizeZ?: number;
  120989. custom?: any;
  120990. faceUV?: Vector4[];
  120991. faceColors?: Color4[];
  120992. flat?: boolean;
  120993. updatable?: boolean;
  120994. sideOrientation?: number;
  120995. frontUVs?: Vector4;
  120996. backUVs?: Vector4;
  120997. }, scene?: Nullable<Scene>): Mesh;
  120998. }
  120999. }
  121000. declare module BABYLON {
  121001. /**
  121002. * Gizmo that enables scaling a mesh along 3 axis
  121003. */
  121004. export class ScaleGizmo extends Gizmo {
  121005. /**
  121006. * Internal gizmo used for interactions on the x axis
  121007. */
  121008. xGizmo: AxisScaleGizmo;
  121009. /**
  121010. * Internal gizmo used for interactions on the y axis
  121011. */
  121012. yGizmo: AxisScaleGizmo;
  121013. /**
  121014. * Internal gizmo used for interactions on the z axis
  121015. */
  121016. zGizmo: AxisScaleGizmo;
  121017. /**
  121018. * Internal gizmo used to scale all axis equally
  121019. */
  121020. uniformScaleGizmo: AxisScaleGizmo;
  121021. private _meshAttached;
  121022. private _updateGizmoRotationToMatchAttachedMesh;
  121023. private _snapDistance;
  121024. private _scaleRatio;
  121025. private _uniformScalingMesh;
  121026. private _octahedron;
  121027. private _sensitivity;
  121028. /** Fires an event when any of it's sub gizmos are dragged */
  121029. onDragStartObservable: Observable<unknown>;
  121030. /** Fires an event when any of it's sub gizmos are released from dragging */
  121031. onDragEndObservable: Observable<unknown>;
  121032. get attachedMesh(): Nullable<AbstractMesh>;
  121033. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121034. /**
  121035. * Creates a ScaleGizmo
  121036. * @param gizmoLayer The utility layer the gizmo will be added to
  121037. */
  121038. constructor(gizmoLayer?: UtilityLayerRenderer);
  121039. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121040. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121041. /**
  121042. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121043. */
  121044. set snapDistance(value: number);
  121045. get snapDistance(): number;
  121046. /**
  121047. * Ratio for the scale of the gizmo (Default: 1)
  121048. */
  121049. set scaleRatio(value: number);
  121050. get scaleRatio(): number;
  121051. /**
  121052. * Sensitivity factor for dragging (Default: 1)
  121053. */
  121054. set sensitivity(value: number);
  121055. get sensitivity(): number;
  121056. /**
  121057. * Disposes of the gizmo
  121058. */
  121059. dispose(): void;
  121060. }
  121061. }
  121062. declare module BABYLON {
  121063. /**
  121064. * Single axis scale gizmo
  121065. */
  121066. export class AxisScaleGizmo extends Gizmo {
  121067. /**
  121068. * Drag behavior responsible for the gizmos dragging interactions
  121069. */
  121070. dragBehavior: PointerDragBehavior;
  121071. private _pointerObserver;
  121072. /**
  121073. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121074. */
  121075. snapDistance: number;
  121076. /**
  121077. * Event that fires each time the gizmo snaps to a new location.
  121078. * * snapDistance is the the change in distance
  121079. */
  121080. onSnapObservable: Observable<{
  121081. snapDistance: number;
  121082. }>;
  121083. /**
  121084. * If the scaling operation should be done on all axis (default: false)
  121085. */
  121086. uniformScaling: boolean;
  121087. /**
  121088. * Custom sensitivity value for the drag strength
  121089. */
  121090. sensitivity: number;
  121091. private _isEnabled;
  121092. private _parent;
  121093. private _arrow;
  121094. private _coloredMaterial;
  121095. private _hoverMaterial;
  121096. /**
  121097. * Creates an AxisScaleGizmo
  121098. * @param gizmoLayer The utility layer the gizmo will be added to
  121099. * @param dragAxis The axis which the gizmo will be able to scale on
  121100. * @param color The color of the gizmo
  121101. */
  121102. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  121103. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121104. /**
  121105. * If the gizmo is enabled
  121106. */
  121107. set isEnabled(value: boolean);
  121108. get isEnabled(): boolean;
  121109. /**
  121110. * Disposes of the gizmo
  121111. */
  121112. dispose(): void;
  121113. /**
  121114. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  121115. * @param mesh The mesh to replace the default mesh of the gizmo
  121116. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  121117. */
  121118. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  121119. }
  121120. }
  121121. declare module BABYLON {
  121122. /**
  121123. * Bounding box gizmo
  121124. */
  121125. export class BoundingBoxGizmo extends Gizmo {
  121126. private _lineBoundingBox;
  121127. private _rotateSpheresParent;
  121128. private _scaleBoxesParent;
  121129. private _boundingDimensions;
  121130. private _renderObserver;
  121131. private _pointerObserver;
  121132. private _scaleDragSpeed;
  121133. private _tmpQuaternion;
  121134. private _tmpVector;
  121135. private _tmpRotationMatrix;
  121136. /**
  121137. * 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)
  121138. */
  121139. ignoreChildren: boolean;
  121140. /**
  121141. * 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)
  121142. */
  121143. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  121144. /**
  121145. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  121146. */
  121147. rotationSphereSize: number;
  121148. /**
  121149. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  121150. */
  121151. scaleBoxSize: number;
  121152. /**
  121153. * 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)
  121154. */
  121155. fixedDragMeshScreenSize: boolean;
  121156. /**
  121157. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  121158. */
  121159. fixedDragMeshScreenSizeDistanceFactor: number;
  121160. /**
  121161. * Fired when a rotation sphere or scale box is dragged
  121162. */
  121163. onDragStartObservable: Observable<{}>;
  121164. /**
  121165. * Fired when a scale box is dragged
  121166. */
  121167. onScaleBoxDragObservable: Observable<{}>;
  121168. /**
  121169. * Fired when a scale box drag is ended
  121170. */
  121171. onScaleBoxDragEndObservable: Observable<{}>;
  121172. /**
  121173. * Fired when a rotation sphere is dragged
  121174. */
  121175. onRotationSphereDragObservable: Observable<{}>;
  121176. /**
  121177. * Fired when a rotation sphere drag is ended
  121178. */
  121179. onRotationSphereDragEndObservable: Observable<{}>;
  121180. /**
  121181. * 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)
  121182. */
  121183. scalePivot: Nullable<Vector3>;
  121184. /**
  121185. * Mesh used as a pivot to rotate the attached mesh
  121186. */
  121187. private _anchorMesh;
  121188. private _existingMeshScale;
  121189. private _dragMesh;
  121190. private pointerDragBehavior;
  121191. private coloredMaterial;
  121192. private hoverColoredMaterial;
  121193. /**
  121194. * Sets the color of the bounding box gizmo
  121195. * @param color the color to set
  121196. */
  121197. setColor(color: Color3): void;
  121198. /**
  121199. * Creates an BoundingBoxGizmo
  121200. * @param gizmoLayer The utility layer the gizmo will be added to
  121201. * @param color The color of the gizmo
  121202. */
  121203. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  121204. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121205. private _selectNode;
  121206. /**
  121207. * Updates the bounding box information for the Gizmo
  121208. */
  121209. updateBoundingBox(): void;
  121210. private _updateRotationSpheres;
  121211. private _updateScaleBoxes;
  121212. /**
  121213. * Enables rotation on the specified axis and disables rotation on the others
  121214. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  121215. */
  121216. setEnabledRotationAxis(axis: string): void;
  121217. /**
  121218. * Enables/disables scaling
  121219. * @param enable if scaling should be enabled
  121220. */
  121221. setEnabledScaling(enable: boolean): void;
  121222. private _updateDummy;
  121223. /**
  121224. * Enables a pointer drag behavior on the bounding box of the gizmo
  121225. */
  121226. enableDragBehavior(): void;
  121227. /**
  121228. * Disposes of the gizmo
  121229. */
  121230. dispose(): void;
  121231. /**
  121232. * 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)
  121233. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  121234. * @returns the bounding box mesh with the passed in mesh as a child
  121235. */
  121236. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  121237. /**
  121238. * CustomMeshes are not supported by this gizmo
  121239. * @param mesh The mesh to replace the default mesh of the gizmo
  121240. */
  121241. setCustomMesh(mesh: Mesh): void;
  121242. }
  121243. }
  121244. declare module BABYLON {
  121245. /**
  121246. * Single plane rotation gizmo
  121247. */
  121248. export class PlaneRotationGizmo extends Gizmo {
  121249. /**
  121250. * Drag behavior responsible for the gizmos dragging interactions
  121251. */
  121252. dragBehavior: PointerDragBehavior;
  121253. private _pointerObserver;
  121254. /**
  121255. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  121256. */
  121257. snapDistance: number;
  121258. /**
  121259. * Event that fires each time the gizmo snaps to a new location.
  121260. * * snapDistance is the the change in distance
  121261. */
  121262. onSnapObservable: Observable<{
  121263. snapDistance: number;
  121264. }>;
  121265. private _isEnabled;
  121266. private _parent;
  121267. /**
  121268. * Creates a PlaneRotationGizmo
  121269. * @param gizmoLayer The utility layer the gizmo will be added to
  121270. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  121271. * @param color The color of the gizmo
  121272. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121273. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121274. */
  121275. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  121276. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121277. /**
  121278. * If the gizmo is enabled
  121279. */
  121280. set isEnabled(value: boolean);
  121281. get isEnabled(): boolean;
  121282. /**
  121283. * Disposes of the gizmo
  121284. */
  121285. dispose(): void;
  121286. }
  121287. }
  121288. declare module BABYLON {
  121289. /**
  121290. * Gizmo that enables rotating a mesh along 3 axis
  121291. */
  121292. export class RotationGizmo extends Gizmo {
  121293. /**
  121294. * Internal gizmo used for interactions on the x axis
  121295. */
  121296. xGizmo: PlaneRotationGizmo;
  121297. /**
  121298. * Internal gizmo used for interactions on the y axis
  121299. */
  121300. yGizmo: PlaneRotationGizmo;
  121301. /**
  121302. * Internal gizmo used for interactions on the z axis
  121303. */
  121304. zGizmo: PlaneRotationGizmo;
  121305. /** Fires an event when any of it's sub gizmos are dragged */
  121306. onDragStartObservable: Observable<unknown>;
  121307. /** Fires an event when any of it's sub gizmos are released from dragging */
  121308. onDragEndObservable: Observable<unknown>;
  121309. private _meshAttached;
  121310. get attachedMesh(): Nullable<AbstractMesh>;
  121311. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121312. /**
  121313. * Creates a RotationGizmo
  121314. * @param gizmoLayer The utility layer the gizmo will be added to
  121315. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121316. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121317. */
  121318. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  121319. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121320. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121321. /**
  121322. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121323. */
  121324. set snapDistance(value: number);
  121325. get snapDistance(): number;
  121326. /**
  121327. * Ratio for the scale of the gizmo (Default: 1)
  121328. */
  121329. set scaleRatio(value: number);
  121330. get scaleRatio(): number;
  121331. /**
  121332. * Disposes of the gizmo
  121333. */
  121334. dispose(): void;
  121335. /**
  121336. * CustomMeshes are not supported by this gizmo
  121337. * @param mesh The mesh to replace the default mesh of the gizmo
  121338. */
  121339. setCustomMesh(mesh: Mesh): void;
  121340. }
  121341. }
  121342. declare module BABYLON {
  121343. /**
  121344. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  121345. */
  121346. export class GizmoManager implements IDisposable {
  121347. private scene;
  121348. /**
  121349. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  121350. */
  121351. gizmos: {
  121352. positionGizmo: Nullable<PositionGizmo>;
  121353. rotationGizmo: Nullable<RotationGizmo>;
  121354. scaleGizmo: Nullable<ScaleGizmo>;
  121355. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  121356. };
  121357. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  121358. clearGizmoOnEmptyPointerEvent: boolean;
  121359. /** Fires an event when the manager is attached to a mesh */
  121360. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  121361. private _gizmosEnabled;
  121362. private _pointerObserver;
  121363. private _attachedMesh;
  121364. private _boundingBoxColor;
  121365. private _defaultUtilityLayer;
  121366. private _defaultKeepDepthUtilityLayer;
  121367. /**
  121368. * When bounding box gizmo is enabled, this can be used to track drag/end events
  121369. */
  121370. boundingBoxDragBehavior: SixDofDragBehavior;
  121371. /**
  121372. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  121373. */
  121374. attachableMeshes: Nullable<Array<AbstractMesh>>;
  121375. /**
  121376. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  121377. */
  121378. usePointerToAttachGizmos: boolean;
  121379. /**
  121380. * Utility layer that the bounding box gizmo belongs to
  121381. */
  121382. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  121383. /**
  121384. * Utility layer that all gizmos besides bounding box belong to
  121385. */
  121386. get utilityLayer(): UtilityLayerRenderer;
  121387. /**
  121388. * Instatiates a gizmo manager
  121389. * @param scene the scene to overlay the gizmos on top of
  121390. */
  121391. constructor(scene: Scene);
  121392. /**
  121393. * Attaches a set of gizmos to the specified mesh
  121394. * @param mesh The mesh the gizmo's should be attached to
  121395. */
  121396. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  121397. /**
  121398. * If the position gizmo is enabled
  121399. */
  121400. set positionGizmoEnabled(value: boolean);
  121401. get positionGizmoEnabled(): boolean;
  121402. /**
  121403. * If the rotation gizmo is enabled
  121404. */
  121405. set rotationGizmoEnabled(value: boolean);
  121406. get rotationGizmoEnabled(): boolean;
  121407. /**
  121408. * If the scale gizmo is enabled
  121409. */
  121410. set scaleGizmoEnabled(value: boolean);
  121411. get scaleGizmoEnabled(): boolean;
  121412. /**
  121413. * If the boundingBox gizmo is enabled
  121414. */
  121415. set boundingBoxGizmoEnabled(value: boolean);
  121416. get boundingBoxGizmoEnabled(): boolean;
  121417. /**
  121418. * Disposes of the gizmo manager
  121419. */
  121420. dispose(): void;
  121421. }
  121422. }
  121423. declare module BABYLON {
  121424. /**
  121425. * A directional light is defined by a direction (what a surprise!).
  121426. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  121427. * 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.
  121428. * Documentation: https://doc.babylonjs.com/babylon101/lights
  121429. */
  121430. export class DirectionalLight extends ShadowLight {
  121431. private _shadowFrustumSize;
  121432. /**
  121433. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  121434. */
  121435. get shadowFrustumSize(): number;
  121436. /**
  121437. * Specifies a fix frustum size for the shadow generation.
  121438. */
  121439. set shadowFrustumSize(value: number);
  121440. private _shadowOrthoScale;
  121441. /**
  121442. * Gets the shadow projection scale against the optimal computed one.
  121443. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  121444. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  121445. */
  121446. get shadowOrthoScale(): number;
  121447. /**
  121448. * Sets the shadow projection scale against the optimal computed one.
  121449. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  121450. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  121451. */
  121452. set shadowOrthoScale(value: number);
  121453. /**
  121454. * Automatically compute the projection matrix to best fit (including all the casters)
  121455. * on each frame.
  121456. */
  121457. autoUpdateExtends: boolean;
  121458. /**
  121459. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  121460. * on each frame. autoUpdateExtends must be set to true for this to work
  121461. */
  121462. autoCalcShadowZBounds: boolean;
  121463. private _orthoLeft;
  121464. private _orthoRight;
  121465. private _orthoTop;
  121466. private _orthoBottom;
  121467. /**
  121468. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  121469. * The directional light is emitted from everywhere in the given direction.
  121470. * It can cast shadows.
  121471. * Documentation : https://doc.babylonjs.com/babylon101/lights
  121472. * @param name The friendly name of the light
  121473. * @param direction The direction of the light
  121474. * @param scene The scene the light belongs to
  121475. */
  121476. constructor(name: string, direction: Vector3, scene: Scene);
  121477. /**
  121478. * Returns the string "DirectionalLight".
  121479. * @return The class name
  121480. */
  121481. getClassName(): string;
  121482. /**
  121483. * Returns the integer 1.
  121484. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  121485. */
  121486. getTypeID(): number;
  121487. /**
  121488. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  121489. * Returns the DirectionalLight Shadow projection matrix.
  121490. */
  121491. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  121492. /**
  121493. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  121494. * Returns the DirectionalLight Shadow projection matrix.
  121495. */
  121496. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  121497. /**
  121498. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  121499. * Returns the DirectionalLight Shadow projection matrix.
  121500. */
  121501. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  121502. protected _buildUniformLayout(): void;
  121503. /**
  121504. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  121505. * @param effect The effect to update
  121506. * @param lightIndex The index of the light in the effect to update
  121507. * @returns The directional light
  121508. */
  121509. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  121510. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  121511. /**
  121512. * Gets the minZ used for shadow according to both the scene and the light.
  121513. *
  121514. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  121515. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  121516. * @param activeCamera The camera we are returning the min for
  121517. * @returns the depth min z
  121518. */
  121519. getDepthMinZ(activeCamera: Camera): number;
  121520. /**
  121521. * Gets the maxZ used for shadow according to both the scene and the light.
  121522. *
  121523. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  121524. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  121525. * @param activeCamera The camera we are returning the max for
  121526. * @returns the depth max z
  121527. */
  121528. getDepthMaxZ(activeCamera: Camera): number;
  121529. /**
  121530. * Prepares the list of defines specific to the light type.
  121531. * @param defines the list of defines
  121532. * @param lightIndex defines the index of the light for the effect
  121533. */
  121534. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  121535. }
  121536. }
  121537. declare module BABYLON {
  121538. /**
  121539. * Class containing static functions to help procedurally build meshes
  121540. */
  121541. export class HemisphereBuilder {
  121542. /**
  121543. * Creates a hemisphere mesh
  121544. * @param name defines the name of the mesh
  121545. * @param options defines the options used to create the mesh
  121546. * @param scene defines the hosting scene
  121547. * @returns the hemisphere mesh
  121548. */
  121549. static CreateHemisphere(name: string, options: {
  121550. segments?: number;
  121551. diameter?: number;
  121552. sideOrientation?: number;
  121553. }, scene: any): Mesh;
  121554. }
  121555. }
  121556. declare module BABYLON {
  121557. /**
  121558. * A spot light is defined by a position, a direction, an angle, and an exponent.
  121559. * These values define a cone of light starting from the position, emitting toward the direction.
  121560. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  121561. * and the exponent defines the speed of the decay of the light with distance (reach).
  121562. * Documentation: https://doc.babylonjs.com/babylon101/lights
  121563. */
  121564. export class SpotLight extends ShadowLight {
  121565. private _angle;
  121566. private _innerAngle;
  121567. private _cosHalfAngle;
  121568. private _lightAngleScale;
  121569. private _lightAngleOffset;
  121570. /**
  121571. * Gets the cone angle of the spot light in Radians.
  121572. */
  121573. get angle(): number;
  121574. /**
  121575. * Sets the cone angle of the spot light in Radians.
  121576. */
  121577. set angle(value: number);
  121578. /**
  121579. * Only used in gltf falloff mode, this defines the angle where
  121580. * the directional falloff will start before cutting at angle which could be seen
  121581. * as outer angle.
  121582. */
  121583. get innerAngle(): number;
  121584. /**
  121585. * Only used in gltf falloff mode, this defines the angle where
  121586. * the directional falloff will start before cutting at angle which could be seen
  121587. * as outer angle.
  121588. */
  121589. set innerAngle(value: number);
  121590. private _shadowAngleScale;
  121591. /**
  121592. * Allows scaling the angle of the light for shadow generation only.
  121593. */
  121594. get shadowAngleScale(): number;
  121595. /**
  121596. * Allows scaling the angle of the light for shadow generation only.
  121597. */
  121598. set shadowAngleScale(value: number);
  121599. /**
  121600. * The light decay speed with the distance from the emission spot.
  121601. */
  121602. exponent: number;
  121603. private _projectionTextureMatrix;
  121604. /**
  121605. * Allows reading the projecton texture
  121606. */
  121607. get projectionTextureMatrix(): Matrix;
  121608. protected _projectionTextureLightNear: number;
  121609. /**
  121610. * Gets the near clip of the Spotlight for texture projection.
  121611. */
  121612. get projectionTextureLightNear(): number;
  121613. /**
  121614. * Sets the near clip of the Spotlight for texture projection.
  121615. */
  121616. set projectionTextureLightNear(value: number);
  121617. protected _projectionTextureLightFar: number;
  121618. /**
  121619. * Gets the far clip of the Spotlight for texture projection.
  121620. */
  121621. get projectionTextureLightFar(): number;
  121622. /**
  121623. * Sets the far clip of the Spotlight for texture projection.
  121624. */
  121625. set projectionTextureLightFar(value: number);
  121626. protected _projectionTextureUpDirection: Vector3;
  121627. /**
  121628. * Gets the Up vector of the Spotlight for texture projection.
  121629. */
  121630. get projectionTextureUpDirection(): Vector3;
  121631. /**
  121632. * Sets the Up vector of the Spotlight for texture projection.
  121633. */
  121634. set projectionTextureUpDirection(value: Vector3);
  121635. private _projectionTexture;
  121636. /**
  121637. * Gets the projection texture of the light.
  121638. */
  121639. get projectionTexture(): Nullable<BaseTexture>;
  121640. /**
  121641. * Sets the projection texture of the light.
  121642. */
  121643. set projectionTexture(value: Nullable<BaseTexture>);
  121644. private _projectionTextureViewLightDirty;
  121645. private _projectionTextureProjectionLightDirty;
  121646. private _projectionTextureDirty;
  121647. private _projectionTextureViewTargetVector;
  121648. private _projectionTextureViewLightMatrix;
  121649. private _projectionTextureProjectionLightMatrix;
  121650. private _projectionTextureScalingMatrix;
  121651. /**
  121652. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  121653. * It can cast shadows.
  121654. * Documentation : https://doc.babylonjs.com/babylon101/lights
  121655. * @param name The light friendly name
  121656. * @param position The position of the spot light in the scene
  121657. * @param direction The direction of the light in the scene
  121658. * @param angle The cone angle of the light in Radians
  121659. * @param exponent The light decay speed with the distance from the emission spot
  121660. * @param scene The scene the lights belongs to
  121661. */
  121662. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  121663. /**
  121664. * Returns the string "SpotLight".
  121665. * @returns the class name
  121666. */
  121667. getClassName(): string;
  121668. /**
  121669. * Returns the integer 2.
  121670. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  121671. */
  121672. getTypeID(): number;
  121673. /**
  121674. * Overrides the direction setter to recompute the projection texture view light Matrix.
  121675. */
  121676. protected _setDirection(value: Vector3): void;
  121677. /**
  121678. * Overrides the position setter to recompute the projection texture view light Matrix.
  121679. */
  121680. protected _setPosition(value: Vector3): void;
  121681. /**
  121682. * 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.
  121683. * Returns the SpotLight.
  121684. */
  121685. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  121686. protected _computeProjectionTextureViewLightMatrix(): void;
  121687. protected _computeProjectionTextureProjectionLightMatrix(): void;
  121688. /**
  121689. * Main function for light texture projection matrix computing.
  121690. */
  121691. protected _computeProjectionTextureMatrix(): void;
  121692. protected _buildUniformLayout(): void;
  121693. private _computeAngleValues;
  121694. /**
  121695. * Sets the passed Effect "effect" with the Light textures.
  121696. * @param effect The effect to update
  121697. * @param lightIndex The index of the light in the effect to update
  121698. * @returns The light
  121699. */
  121700. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  121701. /**
  121702. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  121703. * @param effect The effect to update
  121704. * @param lightIndex The index of the light in the effect to update
  121705. * @returns The spot light
  121706. */
  121707. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  121708. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  121709. /**
  121710. * Disposes the light and the associated resources.
  121711. */
  121712. dispose(): void;
  121713. /**
  121714. * Prepares the list of defines specific to the light type.
  121715. * @param defines the list of defines
  121716. * @param lightIndex defines the index of the light for the effect
  121717. */
  121718. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  121719. }
  121720. }
  121721. declare module BABYLON {
  121722. /**
  121723. * Gizmo that enables viewing a light
  121724. */
  121725. export class LightGizmo extends Gizmo {
  121726. private _lightMesh;
  121727. private _material;
  121728. private _cachedPosition;
  121729. private _cachedForward;
  121730. private _attachedMeshParent;
  121731. /**
  121732. * Creates a LightGizmo
  121733. * @param gizmoLayer The utility layer the gizmo will be added to
  121734. */
  121735. constructor(gizmoLayer?: UtilityLayerRenderer);
  121736. private _light;
  121737. /**
  121738. * The light that the gizmo is attached to
  121739. */
  121740. set light(light: Nullable<Light>);
  121741. get light(): Nullable<Light>;
  121742. /**
  121743. * Gets the material used to render the light gizmo
  121744. */
  121745. get material(): StandardMaterial;
  121746. /**
  121747. * @hidden
  121748. * Updates the gizmo to match the attached mesh's position/rotation
  121749. */
  121750. protected _update(): void;
  121751. private static _Scale;
  121752. /**
  121753. * Creates the lines for a light mesh
  121754. */
  121755. private static _CreateLightLines;
  121756. /**
  121757. * Disposes of the light gizmo
  121758. */
  121759. dispose(): void;
  121760. private static _CreateHemisphericLightMesh;
  121761. private static _CreatePointLightMesh;
  121762. private static _CreateSpotLightMesh;
  121763. private static _CreateDirectionalLightMesh;
  121764. }
  121765. }
  121766. declare module BABYLON {
  121767. /** @hidden */
  121768. export var backgroundFragmentDeclaration: {
  121769. name: string;
  121770. shader: string;
  121771. };
  121772. }
  121773. declare module BABYLON {
  121774. /** @hidden */
  121775. export var backgroundUboDeclaration: {
  121776. name: string;
  121777. shader: string;
  121778. };
  121779. }
  121780. declare module BABYLON {
  121781. /** @hidden */
  121782. export var backgroundPixelShader: {
  121783. name: string;
  121784. shader: string;
  121785. };
  121786. }
  121787. declare module BABYLON {
  121788. /** @hidden */
  121789. export var backgroundVertexDeclaration: {
  121790. name: string;
  121791. shader: string;
  121792. };
  121793. }
  121794. declare module BABYLON {
  121795. /** @hidden */
  121796. export var backgroundVertexShader: {
  121797. name: string;
  121798. shader: string;
  121799. };
  121800. }
  121801. declare module BABYLON {
  121802. /**
  121803. * Background material used to create an efficient environement around your scene.
  121804. */
  121805. export class BackgroundMaterial extends PushMaterial {
  121806. /**
  121807. * Standard reflectance value at parallel view angle.
  121808. */
  121809. static StandardReflectance0: number;
  121810. /**
  121811. * Standard reflectance value at grazing angle.
  121812. */
  121813. static StandardReflectance90: number;
  121814. protected _primaryColor: Color3;
  121815. /**
  121816. * Key light Color (multiply against the environement texture)
  121817. */
  121818. primaryColor: Color3;
  121819. protected __perceptualColor: Nullable<Color3>;
  121820. /**
  121821. * Experimental Internal Use Only.
  121822. *
  121823. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  121824. * This acts as a helper to set the primary color to a more "human friendly" value.
  121825. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  121826. * output color as close as possible from the chosen value.
  121827. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  121828. * part of lighting setup.)
  121829. */
  121830. get _perceptualColor(): Nullable<Color3>;
  121831. set _perceptualColor(value: Nullable<Color3>);
  121832. protected _primaryColorShadowLevel: float;
  121833. /**
  121834. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  121835. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  121836. */
  121837. get primaryColorShadowLevel(): float;
  121838. set primaryColorShadowLevel(value: float);
  121839. protected _primaryColorHighlightLevel: float;
  121840. /**
  121841. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  121842. * The primary color is used at the level chosen to define what the white area would look.
  121843. */
  121844. get primaryColorHighlightLevel(): float;
  121845. set primaryColorHighlightLevel(value: float);
  121846. protected _reflectionTexture: Nullable<BaseTexture>;
  121847. /**
  121848. * Reflection Texture used in the material.
  121849. * Should be author in a specific way for the best result (refer to the documentation).
  121850. */
  121851. reflectionTexture: Nullable<BaseTexture>;
  121852. protected _reflectionBlur: float;
  121853. /**
  121854. * Reflection Texture level of blur.
  121855. *
  121856. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  121857. * texture twice.
  121858. */
  121859. reflectionBlur: float;
  121860. protected _diffuseTexture: Nullable<BaseTexture>;
  121861. /**
  121862. * Diffuse Texture used in the material.
  121863. * Should be author in a specific way for the best result (refer to the documentation).
  121864. */
  121865. diffuseTexture: Nullable<BaseTexture>;
  121866. protected _shadowLights: Nullable<IShadowLight[]>;
  121867. /**
  121868. * Specify the list of lights casting shadow on the material.
  121869. * All scene shadow lights will be included if null.
  121870. */
  121871. shadowLights: Nullable<IShadowLight[]>;
  121872. protected _shadowLevel: float;
  121873. /**
  121874. * Helps adjusting the shadow to a softer level if required.
  121875. * 0 means black shadows and 1 means no shadows.
  121876. */
  121877. shadowLevel: float;
  121878. protected _sceneCenter: Vector3;
  121879. /**
  121880. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  121881. * It is usually zero but might be interesting to modify according to your setup.
  121882. */
  121883. sceneCenter: Vector3;
  121884. protected _opacityFresnel: boolean;
  121885. /**
  121886. * This helps specifying that the material is falling off to the sky box at grazing angle.
  121887. * This helps ensuring a nice transition when the camera goes under the ground.
  121888. */
  121889. opacityFresnel: boolean;
  121890. protected _reflectionFresnel: boolean;
  121891. /**
  121892. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  121893. * This helps adding a mirror texture on the ground.
  121894. */
  121895. reflectionFresnel: boolean;
  121896. protected _reflectionFalloffDistance: number;
  121897. /**
  121898. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  121899. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  121900. */
  121901. reflectionFalloffDistance: number;
  121902. protected _reflectionAmount: number;
  121903. /**
  121904. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  121905. */
  121906. reflectionAmount: number;
  121907. protected _reflectionReflectance0: number;
  121908. /**
  121909. * This specifies the weight of the reflection at grazing angle.
  121910. */
  121911. reflectionReflectance0: number;
  121912. protected _reflectionReflectance90: number;
  121913. /**
  121914. * This specifies the weight of the reflection at a perpendicular point of view.
  121915. */
  121916. reflectionReflectance90: number;
  121917. /**
  121918. * Sets the reflection reflectance fresnel values according to the default standard
  121919. * empirically know to work well :-)
  121920. */
  121921. set reflectionStandardFresnelWeight(value: number);
  121922. protected _useRGBColor: boolean;
  121923. /**
  121924. * Helps to directly use the maps channels instead of their level.
  121925. */
  121926. useRGBColor: boolean;
  121927. protected _enableNoise: boolean;
  121928. /**
  121929. * This helps reducing the banding effect that could occur on the background.
  121930. */
  121931. enableNoise: boolean;
  121932. /**
  121933. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  121934. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  121935. * Recommended to be keep at 1.0 except for special cases.
  121936. */
  121937. get fovMultiplier(): number;
  121938. set fovMultiplier(value: number);
  121939. private _fovMultiplier;
  121940. /**
  121941. * Enable the FOV adjustment feature controlled by fovMultiplier.
  121942. */
  121943. useEquirectangularFOV: boolean;
  121944. private _maxSimultaneousLights;
  121945. /**
  121946. * Number of Simultaneous lights allowed on the material.
  121947. */
  121948. maxSimultaneousLights: int;
  121949. /**
  121950. * Default configuration related to image processing available in the Background Material.
  121951. */
  121952. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  121953. /**
  121954. * Keep track of the image processing observer to allow dispose and replace.
  121955. */
  121956. private _imageProcessingObserver;
  121957. /**
  121958. * Attaches a new image processing configuration to the PBR Material.
  121959. * @param configuration (if null the scene configuration will be use)
  121960. */
  121961. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  121962. /**
  121963. * Gets the image processing configuration used either in this material.
  121964. */
  121965. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  121966. /**
  121967. * Sets the Default image processing configuration used either in the this material.
  121968. *
  121969. * If sets to null, the scene one is in use.
  121970. */
  121971. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  121972. /**
  121973. * Gets wether the color curves effect is enabled.
  121974. */
  121975. get cameraColorCurvesEnabled(): boolean;
  121976. /**
  121977. * Sets wether the color curves effect is enabled.
  121978. */
  121979. set cameraColorCurvesEnabled(value: boolean);
  121980. /**
  121981. * Gets wether the color grading effect is enabled.
  121982. */
  121983. get cameraColorGradingEnabled(): boolean;
  121984. /**
  121985. * Gets wether the color grading effect is enabled.
  121986. */
  121987. set cameraColorGradingEnabled(value: boolean);
  121988. /**
  121989. * Gets wether tonemapping is enabled or not.
  121990. */
  121991. get cameraToneMappingEnabled(): boolean;
  121992. /**
  121993. * Sets wether tonemapping is enabled or not
  121994. */
  121995. set cameraToneMappingEnabled(value: boolean);
  121996. /**
  121997. * The camera exposure used on this material.
  121998. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  121999. * This corresponds to a photographic exposure.
  122000. */
  122001. get cameraExposure(): float;
  122002. /**
  122003. * The camera exposure used on this material.
  122004. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122005. * This corresponds to a photographic exposure.
  122006. */
  122007. set cameraExposure(value: float);
  122008. /**
  122009. * Gets The camera contrast used on this material.
  122010. */
  122011. get cameraContrast(): float;
  122012. /**
  122013. * Sets The camera contrast used on this material.
  122014. */
  122015. set cameraContrast(value: float);
  122016. /**
  122017. * Gets the Color Grading 2D Lookup Texture.
  122018. */
  122019. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  122020. /**
  122021. * Sets the Color Grading 2D Lookup Texture.
  122022. */
  122023. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  122024. /**
  122025. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122026. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122027. * 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;
  122028. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122029. */
  122030. get cameraColorCurves(): Nullable<ColorCurves>;
  122031. /**
  122032. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122033. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122034. * 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;
  122035. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122036. */
  122037. set cameraColorCurves(value: Nullable<ColorCurves>);
  122038. /**
  122039. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  122040. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  122041. */
  122042. switchToBGR: boolean;
  122043. private _renderTargets;
  122044. private _reflectionControls;
  122045. private _white;
  122046. private _primaryShadowColor;
  122047. private _primaryHighlightColor;
  122048. /**
  122049. * Instantiates a Background Material in the given scene
  122050. * @param name The friendly name of the material
  122051. * @param scene The scene to add the material to
  122052. */
  122053. constructor(name: string, scene: Scene);
  122054. /**
  122055. * Gets a boolean indicating that current material needs to register RTT
  122056. */
  122057. get hasRenderTargetTextures(): boolean;
  122058. /**
  122059. * The entire material has been created in order to prevent overdraw.
  122060. * @returns false
  122061. */
  122062. needAlphaTesting(): boolean;
  122063. /**
  122064. * The entire material has been created in order to prevent overdraw.
  122065. * @returns true if blending is enable
  122066. */
  122067. needAlphaBlending(): boolean;
  122068. /**
  122069. * Checks wether the material is ready to be rendered for a given mesh.
  122070. * @param mesh The mesh to render
  122071. * @param subMesh The submesh to check against
  122072. * @param useInstances Specify wether or not the material is used with instances
  122073. * @returns true if all the dependencies are ready (Textures, Effects...)
  122074. */
  122075. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  122076. /**
  122077. * Compute the primary color according to the chosen perceptual color.
  122078. */
  122079. private _computePrimaryColorFromPerceptualColor;
  122080. /**
  122081. * Compute the highlights and shadow colors according to their chosen levels.
  122082. */
  122083. private _computePrimaryColors;
  122084. /**
  122085. * Build the uniform buffer used in the material.
  122086. */
  122087. buildUniformLayout(): void;
  122088. /**
  122089. * Unbind the material.
  122090. */
  122091. unbind(): void;
  122092. /**
  122093. * Bind only the world matrix to the material.
  122094. * @param world The world matrix to bind.
  122095. */
  122096. bindOnlyWorldMatrix(world: Matrix): void;
  122097. /**
  122098. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  122099. * @param world The world matrix to bind.
  122100. * @param subMesh The submesh to bind for.
  122101. */
  122102. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  122103. /**
  122104. * Checks to see if a texture is used in the material.
  122105. * @param texture - Base texture to use.
  122106. * @returns - Boolean specifying if a texture is used in the material.
  122107. */
  122108. hasTexture(texture: BaseTexture): boolean;
  122109. /**
  122110. * Dispose the material.
  122111. * @param forceDisposeEffect Force disposal of the associated effect.
  122112. * @param forceDisposeTextures Force disposal of the associated textures.
  122113. */
  122114. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  122115. /**
  122116. * Clones the material.
  122117. * @param name The cloned name.
  122118. * @returns The cloned material.
  122119. */
  122120. clone(name: string): BackgroundMaterial;
  122121. /**
  122122. * Serializes the current material to its JSON representation.
  122123. * @returns The JSON representation.
  122124. */
  122125. serialize(): any;
  122126. /**
  122127. * Gets the class name of the material
  122128. * @returns "BackgroundMaterial"
  122129. */
  122130. getClassName(): string;
  122131. /**
  122132. * Parse a JSON input to create back a background material.
  122133. * @param source The JSON data to parse
  122134. * @param scene The scene to create the parsed material in
  122135. * @param rootUrl The root url of the assets the material depends upon
  122136. * @returns the instantiated BackgroundMaterial.
  122137. */
  122138. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  122139. }
  122140. }
  122141. declare module BABYLON {
  122142. /**
  122143. * Represents the different options available during the creation of
  122144. * a Environment helper.
  122145. *
  122146. * This can control the default ground, skybox and image processing setup of your scene.
  122147. */
  122148. export interface IEnvironmentHelperOptions {
  122149. /**
  122150. * Specifies whether or not to create a ground.
  122151. * True by default.
  122152. */
  122153. createGround: boolean;
  122154. /**
  122155. * Specifies the ground size.
  122156. * 15 by default.
  122157. */
  122158. groundSize: number;
  122159. /**
  122160. * The texture used on the ground for the main color.
  122161. * Comes from the BabylonJS CDN by default.
  122162. *
  122163. * Remarks: Can be either a texture or a url.
  122164. */
  122165. groundTexture: string | BaseTexture;
  122166. /**
  122167. * The color mixed in the ground texture by default.
  122168. * BabylonJS clearColor by default.
  122169. */
  122170. groundColor: Color3;
  122171. /**
  122172. * Specifies the ground opacity.
  122173. * 1 by default.
  122174. */
  122175. groundOpacity: number;
  122176. /**
  122177. * Enables the ground to receive shadows.
  122178. * True by default.
  122179. */
  122180. enableGroundShadow: boolean;
  122181. /**
  122182. * Helps preventing the shadow to be fully black on the ground.
  122183. * 0.5 by default.
  122184. */
  122185. groundShadowLevel: number;
  122186. /**
  122187. * Creates a mirror texture attach to the ground.
  122188. * false by default.
  122189. */
  122190. enableGroundMirror: boolean;
  122191. /**
  122192. * Specifies the ground mirror size ratio.
  122193. * 0.3 by default as the default kernel is 64.
  122194. */
  122195. groundMirrorSizeRatio: number;
  122196. /**
  122197. * Specifies the ground mirror blur kernel size.
  122198. * 64 by default.
  122199. */
  122200. groundMirrorBlurKernel: number;
  122201. /**
  122202. * Specifies the ground mirror visibility amount.
  122203. * 1 by default
  122204. */
  122205. groundMirrorAmount: number;
  122206. /**
  122207. * Specifies the ground mirror reflectance weight.
  122208. * This uses the standard weight of the background material to setup the fresnel effect
  122209. * of the mirror.
  122210. * 1 by default.
  122211. */
  122212. groundMirrorFresnelWeight: number;
  122213. /**
  122214. * Specifies the ground mirror Falloff distance.
  122215. * This can helps reducing the size of the reflection.
  122216. * 0 by Default.
  122217. */
  122218. groundMirrorFallOffDistance: number;
  122219. /**
  122220. * Specifies the ground mirror texture type.
  122221. * Unsigned Int by Default.
  122222. */
  122223. groundMirrorTextureType: number;
  122224. /**
  122225. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  122226. * the shown objects.
  122227. */
  122228. groundYBias: number;
  122229. /**
  122230. * Specifies whether or not to create a skybox.
  122231. * True by default.
  122232. */
  122233. createSkybox: boolean;
  122234. /**
  122235. * Specifies the skybox size.
  122236. * 20 by default.
  122237. */
  122238. skyboxSize: number;
  122239. /**
  122240. * The texture used on the skybox for the main color.
  122241. * Comes from the BabylonJS CDN by default.
  122242. *
  122243. * Remarks: Can be either a texture or a url.
  122244. */
  122245. skyboxTexture: string | BaseTexture;
  122246. /**
  122247. * The color mixed in the skybox texture by default.
  122248. * BabylonJS clearColor by default.
  122249. */
  122250. skyboxColor: Color3;
  122251. /**
  122252. * The background rotation around the Y axis of the scene.
  122253. * This helps aligning the key lights of your scene with the background.
  122254. * 0 by default.
  122255. */
  122256. backgroundYRotation: number;
  122257. /**
  122258. * Compute automatically the size of the elements to best fit with the scene.
  122259. */
  122260. sizeAuto: boolean;
  122261. /**
  122262. * Default position of the rootMesh if autoSize is not true.
  122263. */
  122264. rootPosition: Vector3;
  122265. /**
  122266. * Sets up the image processing in the scene.
  122267. * true by default.
  122268. */
  122269. setupImageProcessing: boolean;
  122270. /**
  122271. * The texture used as your environment texture in the scene.
  122272. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  122273. *
  122274. * Remarks: Can be either a texture or a url.
  122275. */
  122276. environmentTexture: string | BaseTexture;
  122277. /**
  122278. * The value of the exposure to apply to the scene.
  122279. * 0.6 by default if setupImageProcessing is true.
  122280. */
  122281. cameraExposure: number;
  122282. /**
  122283. * The value of the contrast to apply to the scene.
  122284. * 1.6 by default if setupImageProcessing is true.
  122285. */
  122286. cameraContrast: number;
  122287. /**
  122288. * Specifies whether or not tonemapping should be enabled in the scene.
  122289. * true by default if setupImageProcessing is true.
  122290. */
  122291. toneMappingEnabled: boolean;
  122292. }
  122293. /**
  122294. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  122295. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  122296. * It also helps with the default setup of your imageProcessing configuration.
  122297. */
  122298. export class EnvironmentHelper {
  122299. /**
  122300. * Default ground texture URL.
  122301. */
  122302. private static _groundTextureCDNUrl;
  122303. /**
  122304. * Default skybox texture URL.
  122305. */
  122306. private static _skyboxTextureCDNUrl;
  122307. /**
  122308. * Default environment texture URL.
  122309. */
  122310. private static _environmentTextureCDNUrl;
  122311. /**
  122312. * Creates the default options for the helper.
  122313. */
  122314. private static _getDefaultOptions;
  122315. private _rootMesh;
  122316. /**
  122317. * Gets the root mesh created by the helper.
  122318. */
  122319. get rootMesh(): Mesh;
  122320. private _skybox;
  122321. /**
  122322. * Gets the skybox created by the helper.
  122323. */
  122324. get skybox(): Nullable<Mesh>;
  122325. private _skyboxTexture;
  122326. /**
  122327. * Gets the skybox texture created by the helper.
  122328. */
  122329. get skyboxTexture(): Nullable<BaseTexture>;
  122330. private _skyboxMaterial;
  122331. /**
  122332. * Gets the skybox material created by the helper.
  122333. */
  122334. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  122335. private _ground;
  122336. /**
  122337. * Gets the ground mesh created by the helper.
  122338. */
  122339. get ground(): Nullable<Mesh>;
  122340. private _groundTexture;
  122341. /**
  122342. * Gets the ground texture created by the helper.
  122343. */
  122344. get groundTexture(): Nullable<BaseTexture>;
  122345. private _groundMirror;
  122346. /**
  122347. * Gets the ground mirror created by the helper.
  122348. */
  122349. get groundMirror(): Nullable<MirrorTexture>;
  122350. /**
  122351. * Gets the ground mirror render list to helps pushing the meshes
  122352. * you wish in the ground reflection.
  122353. */
  122354. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  122355. private _groundMaterial;
  122356. /**
  122357. * Gets the ground material created by the helper.
  122358. */
  122359. get groundMaterial(): Nullable<BackgroundMaterial>;
  122360. /**
  122361. * Stores the creation options.
  122362. */
  122363. private readonly _scene;
  122364. private _options;
  122365. /**
  122366. * This observable will be notified with any error during the creation of the environment,
  122367. * mainly texture creation errors.
  122368. */
  122369. onErrorObservable: Observable<{
  122370. message?: string;
  122371. exception?: any;
  122372. }>;
  122373. /**
  122374. * constructor
  122375. * @param options Defines the options we want to customize the helper
  122376. * @param scene The scene to add the material to
  122377. */
  122378. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  122379. /**
  122380. * Updates the background according to the new options
  122381. * @param options
  122382. */
  122383. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  122384. /**
  122385. * Sets the primary color of all the available elements.
  122386. * @param color the main color to affect to the ground and the background
  122387. */
  122388. setMainColor(color: Color3): void;
  122389. /**
  122390. * Setup the image processing according to the specified options.
  122391. */
  122392. private _setupImageProcessing;
  122393. /**
  122394. * Setup the environment texture according to the specified options.
  122395. */
  122396. private _setupEnvironmentTexture;
  122397. /**
  122398. * Setup the background according to the specified options.
  122399. */
  122400. private _setupBackground;
  122401. /**
  122402. * Get the scene sizes according to the setup.
  122403. */
  122404. private _getSceneSize;
  122405. /**
  122406. * Setup the ground according to the specified options.
  122407. */
  122408. private _setupGround;
  122409. /**
  122410. * Setup the ground material according to the specified options.
  122411. */
  122412. private _setupGroundMaterial;
  122413. /**
  122414. * Setup the ground diffuse texture according to the specified options.
  122415. */
  122416. private _setupGroundDiffuseTexture;
  122417. /**
  122418. * Setup the ground mirror texture according to the specified options.
  122419. */
  122420. private _setupGroundMirrorTexture;
  122421. /**
  122422. * Setup the ground to receive the mirror texture.
  122423. */
  122424. private _setupMirrorInGroundMaterial;
  122425. /**
  122426. * Setup the skybox according to the specified options.
  122427. */
  122428. private _setupSkybox;
  122429. /**
  122430. * Setup the skybox material according to the specified options.
  122431. */
  122432. private _setupSkyboxMaterial;
  122433. /**
  122434. * Setup the skybox reflection texture according to the specified options.
  122435. */
  122436. private _setupSkyboxReflectionTexture;
  122437. private _errorHandler;
  122438. /**
  122439. * Dispose all the elements created by the Helper.
  122440. */
  122441. dispose(): void;
  122442. }
  122443. }
  122444. declare module BABYLON {
  122445. /**
  122446. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  122447. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  122448. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  122449. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  122450. */
  122451. export class PhotoDome extends TransformNode {
  122452. /**
  122453. * Define the image as a Monoscopic panoramic 360 image.
  122454. */
  122455. static readonly MODE_MONOSCOPIC: number;
  122456. /**
  122457. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  122458. */
  122459. static readonly MODE_TOPBOTTOM: number;
  122460. /**
  122461. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  122462. */
  122463. static readonly MODE_SIDEBYSIDE: number;
  122464. private _useDirectMapping;
  122465. /**
  122466. * The texture being displayed on the sphere
  122467. */
  122468. protected _photoTexture: Texture;
  122469. /**
  122470. * Gets or sets the texture being displayed on the sphere
  122471. */
  122472. get photoTexture(): Texture;
  122473. set photoTexture(value: Texture);
  122474. /**
  122475. * Observable raised when an error occured while loading the 360 image
  122476. */
  122477. onLoadErrorObservable: Observable<string>;
  122478. /**
  122479. * The skybox material
  122480. */
  122481. protected _material: BackgroundMaterial;
  122482. /**
  122483. * The surface used for the skybox
  122484. */
  122485. protected _mesh: Mesh;
  122486. /**
  122487. * Gets the mesh used for the skybox.
  122488. */
  122489. get mesh(): Mesh;
  122490. /**
  122491. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  122492. * Also see the options.resolution property.
  122493. */
  122494. get fovMultiplier(): number;
  122495. set fovMultiplier(value: number);
  122496. private _imageMode;
  122497. /**
  122498. * Gets or set the current video mode for the video. It can be:
  122499. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  122500. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  122501. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  122502. */
  122503. get imageMode(): number;
  122504. set imageMode(value: number);
  122505. /**
  122506. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  122507. * @param name Element's name, child elements will append suffixes for their own names.
  122508. * @param urlsOfPhoto defines the url of the photo to display
  122509. * @param options defines an object containing optional or exposed sub element properties
  122510. * @param onError defines a callback called when an error occured while loading the texture
  122511. */
  122512. constructor(name: string, urlOfPhoto: string, options: {
  122513. resolution?: number;
  122514. size?: number;
  122515. useDirectMapping?: boolean;
  122516. faceForward?: boolean;
  122517. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  122518. private _onBeforeCameraRenderObserver;
  122519. private _changeImageMode;
  122520. /**
  122521. * Releases resources associated with this node.
  122522. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  122523. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  122524. */
  122525. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  122526. }
  122527. }
  122528. declare module BABYLON {
  122529. /**
  122530. * Class used to host RGBD texture specific utilities
  122531. */
  122532. export class RGBDTextureTools {
  122533. /**
  122534. * Expand the RGBD Texture from RGBD to Half Float if possible.
  122535. * @param texture the texture to expand.
  122536. */
  122537. static ExpandRGBDTexture(texture: Texture): void;
  122538. }
  122539. }
  122540. declare module BABYLON {
  122541. /**
  122542. * Class used to host texture specific utilities
  122543. */
  122544. export class BRDFTextureTools {
  122545. /**
  122546. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  122547. * @param scene defines the hosting scene
  122548. * @returns the environment BRDF texture
  122549. */
  122550. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  122551. private static _environmentBRDFBase64Texture;
  122552. }
  122553. }
  122554. declare module BABYLON {
  122555. /**
  122556. * @hidden
  122557. */
  122558. export interface IMaterialClearCoatDefines {
  122559. CLEARCOAT: boolean;
  122560. CLEARCOAT_DEFAULTIOR: boolean;
  122561. CLEARCOAT_TEXTURE: boolean;
  122562. CLEARCOAT_TEXTUREDIRECTUV: number;
  122563. CLEARCOAT_BUMP: boolean;
  122564. CLEARCOAT_BUMPDIRECTUV: number;
  122565. CLEARCOAT_TINT: boolean;
  122566. CLEARCOAT_TINT_TEXTURE: boolean;
  122567. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  122568. /** @hidden */
  122569. _areTexturesDirty: boolean;
  122570. }
  122571. /**
  122572. * Define the code related to the clear coat parameters of the pbr material.
  122573. */
  122574. export class PBRClearCoatConfiguration {
  122575. /**
  122576. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  122577. * The default fits with a polyurethane material.
  122578. */
  122579. private static readonly _DefaultIndexOfRefraction;
  122580. private _isEnabled;
  122581. /**
  122582. * Defines if the clear coat is enabled in the material.
  122583. */
  122584. isEnabled: boolean;
  122585. /**
  122586. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  122587. */
  122588. intensity: number;
  122589. /**
  122590. * Defines the clear coat layer roughness.
  122591. */
  122592. roughness: number;
  122593. private _indexOfRefraction;
  122594. /**
  122595. * Defines the index of refraction of the clear coat.
  122596. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  122597. * The default fits with a polyurethane material.
  122598. * Changing the default value is more performance intensive.
  122599. */
  122600. indexOfRefraction: number;
  122601. private _texture;
  122602. /**
  122603. * Stores the clear coat values in a texture.
  122604. */
  122605. texture: Nullable<BaseTexture>;
  122606. private _bumpTexture;
  122607. /**
  122608. * Define the clear coat specific bump texture.
  122609. */
  122610. bumpTexture: Nullable<BaseTexture>;
  122611. private _isTintEnabled;
  122612. /**
  122613. * Defines if the clear coat tint is enabled in the material.
  122614. */
  122615. isTintEnabled: boolean;
  122616. /**
  122617. * Defines the clear coat tint of the material.
  122618. * This is only use if tint is enabled
  122619. */
  122620. tintColor: Color3;
  122621. /**
  122622. * Defines the distance at which the tint color should be found in the
  122623. * clear coat media.
  122624. * This is only use if tint is enabled
  122625. */
  122626. tintColorAtDistance: number;
  122627. /**
  122628. * Defines the clear coat layer thickness.
  122629. * This is only use if tint is enabled
  122630. */
  122631. tintThickness: number;
  122632. private _tintTexture;
  122633. /**
  122634. * Stores the clear tint values in a texture.
  122635. * rgb is tint
  122636. * a is a thickness factor
  122637. */
  122638. tintTexture: Nullable<BaseTexture>;
  122639. /** @hidden */
  122640. private _internalMarkAllSubMeshesAsTexturesDirty;
  122641. /** @hidden */
  122642. _markAllSubMeshesAsTexturesDirty(): void;
  122643. /**
  122644. * Instantiate a new istance of clear coat configuration.
  122645. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  122646. */
  122647. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  122648. /**
  122649. * Gets wehter the submesh is ready to be used or not.
  122650. * @param defines the list of "defines" to update.
  122651. * @param scene defines the scene the material belongs to.
  122652. * @param engine defines the engine the material belongs to.
  122653. * @param disableBumpMap defines wether the material disables bump or not.
  122654. * @returns - boolean indicating that the submesh is ready or not.
  122655. */
  122656. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  122657. /**
  122658. * Checks to see if a texture is used in the material.
  122659. * @param defines the list of "defines" to update.
  122660. * @param scene defines the scene to the material belongs to.
  122661. */
  122662. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  122663. /**
  122664. * Binds the material data.
  122665. * @param uniformBuffer defines the Uniform buffer to fill in.
  122666. * @param scene defines the scene the material belongs to.
  122667. * @param engine defines the engine the material belongs to.
  122668. * @param disableBumpMap defines wether the material disables bump or not.
  122669. * @param isFrozen defines wether the material is frozen or not.
  122670. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  122671. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  122672. */
  122673. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  122674. /**
  122675. * Checks to see if a texture is used in the material.
  122676. * @param texture - Base texture to use.
  122677. * @returns - Boolean specifying if a texture is used in the material.
  122678. */
  122679. hasTexture(texture: BaseTexture): boolean;
  122680. /**
  122681. * Returns an array of the actively used textures.
  122682. * @param activeTextures Array of BaseTextures
  122683. */
  122684. getActiveTextures(activeTextures: BaseTexture[]): void;
  122685. /**
  122686. * Returns the animatable textures.
  122687. * @param animatables Array of animatable textures.
  122688. */
  122689. getAnimatables(animatables: IAnimatable[]): void;
  122690. /**
  122691. * Disposes the resources of the material.
  122692. * @param forceDisposeTextures - Forces the disposal of all textures.
  122693. */
  122694. dispose(forceDisposeTextures?: boolean): void;
  122695. /**
  122696. * Get the current class name of the texture useful for serialization or dynamic coding.
  122697. * @returns "PBRClearCoatConfiguration"
  122698. */
  122699. getClassName(): string;
  122700. /**
  122701. * Add fallbacks to the effect fallbacks list.
  122702. * @param defines defines the Base texture to use.
  122703. * @param fallbacks defines the current fallback list.
  122704. * @param currentRank defines the current fallback rank.
  122705. * @returns the new fallback rank.
  122706. */
  122707. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  122708. /**
  122709. * Add the required uniforms to the current list.
  122710. * @param uniforms defines the current uniform list.
  122711. */
  122712. static AddUniforms(uniforms: string[]): void;
  122713. /**
  122714. * Add the required samplers to the current list.
  122715. * @param samplers defines the current sampler list.
  122716. */
  122717. static AddSamplers(samplers: string[]): void;
  122718. /**
  122719. * Add the required uniforms to the current buffer.
  122720. * @param uniformBuffer defines the current uniform buffer.
  122721. */
  122722. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  122723. /**
  122724. * Makes a duplicate of the current configuration into another one.
  122725. * @param clearCoatConfiguration define the config where to copy the info
  122726. */
  122727. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  122728. /**
  122729. * Serializes this clear coat configuration.
  122730. * @returns - An object with the serialized config.
  122731. */
  122732. serialize(): any;
  122733. /**
  122734. * Parses a anisotropy Configuration from a serialized object.
  122735. * @param source - Serialized object.
  122736. * @param scene Defines the scene we are parsing for
  122737. * @param rootUrl Defines the rootUrl to load from
  122738. */
  122739. parse(source: any, scene: Scene, rootUrl: string): void;
  122740. }
  122741. }
  122742. declare module BABYLON {
  122743. /**
  122744. * @hidden
  122745. */
  122746. export interface IMaterialAnisotropicDefines {
  122747. ANISOTROPIC: boolean;
  122748. ANISOTROPIC_TEXTURE: boolean;
  122749. ANISOTROPIC_TEXTUREDIRECTUV: number;
  122750. MAINUV1: boolean;
  122751. _areTexturesDirty: boolean;
  122752. _needUVs: boolean;
  122753. }
  122754. /**
  122755. * Define the code related to the anisotropic parameters of the pbr material.
  122756. */
  122757. export class PBRAnisotropicConfiguration {
  122758. private _isEnabled;
  122759. /**
  122760. * Defines if the anisotropy is enabled in the material.
  122761. */
  122762. isEnabled: boolean;
  122763. /**
  122764. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  122765. */
  122766. intensity: number;
  122767. /**
  122768. * Defines if the effect is along the tangents, bitangents or in between.
  122769. * By default, the effect is "strectching" the highlights along the tangents.
  122770. */
  122771. direction: Vector2;
  122772. private _texture;
  122773. /**
  122774. * Stores the anisotropy values in a texture.
  122775. * rg is direction (like normal from -1 to 1)
  122776. * b is a intensity
  122777. */
  122778. texture: Nullable<BaseTexture>;
  122779. /** @hidden */
  122780. private _internalMarkAllSubMeshesAsTexturesDirty;
  122781. /** @hidden */
  122782. _markAllSubMeshesAsTexturesDirty(): void;
  122783. /**
  122784. * Instantiate a new istance of anisotropy configuration.
  122785. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  122786. */
  122787. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  122788. /**
  122789. * Specifies that the submesh is ready to be used.
  122790. * @param defines the list of "defines" to update.
  122791. * @param scene defines the scene the material belongs to.
  122792. * @returns - boolean indicating that the submesh is ready or not.
  122793. */
  122794. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  122795. /**
  122796. * Checks to see if a texture is used in the material.
  122797. * @param defines the list of "defines" to update.
  122798. * @param mesh the mesh we are preparing the defines for.
  122799. * @param scene defines the scene the material belongs to.
  122800. */
  122801. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  122802. /**
  122803. * Binds the material data.
  122804. * @param uniformBuffer defines the Uniform buffer to fill in.
  122805. * @param scene defines the scene the material belongs to.
  122806. * @param isFrozen defines wether the material is frozen or not.
  122807. */
  122808. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  122809. /**
  122810. * Checks to see if a texture is used in the material.
  122811. * @param texture - Base texture to use.
  122812. * @returns - Boolean specifying if a texture is used in the material.
  122813. */
  122814. hasTexture(texture: BaseTexture): boolean;
  122815. /**
  122816. * Returns an array of the actively used textures.
  122817. * @param activeTextures Array of BaseTextures
  122818. */
  122819. getActiveTextures(activeTextures: BaseTexture[]): void;
  122820. /**
  122821. * Returns the animatable textures.
  122822. * @param animatables Array of animatable textures.
  122823. */
  122824. getAnimatables(animatables: IAnimatable[]): void;
  122825. /**
  122826. * Disposes the resources of the material.
  122827. * @param forceDisposeTextures - Forces the disposal of all textures.
  122828. */
  122829. dispose(forceDisposeTextures?: boolean): void;
  122830. /**
  122831. * Get the current class name of the texture useful for serialization or dynamic coding.
  122832. * @returns "PBRAnisotropicConfiguration"
  122833. */
  122834. getClassName(): string;
  122835. /**
  122836. * Add fallbacks to the effect fallbacks list.
  122837. * @param defines defines the Base texture to use.
  122838. * @param fallbacks defines the current fallback list.
  122839. * @param currentRank defines the current fallback rank.
  122840. * @returns the new fallback rank.
  122841. */
  122842. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  122843. /**
  122844. * Add the required uniforms to the current list.
  122845. * @param uniforms defines the current uniform list.
  122846. */
  122847. static AddUniforms(uniforms: string[]): void;
  122848. /**
  122849. * Add the required uniforms to the current buffer.
  122850. * @param uniformBuffer defines the current uniform buffer.
  122851. */
  122852. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  122853. /**
  122854. * Add the required samplers to the current list.
  122855. * @param samplers defines the current sampler list.
  122856. */
  122857. static AddSamplers(samplers: string[]): void;
  122858. /**
  122859. * Makes a duplicate of the current configuration into another one.
  122860. * @param anisotropicConfiguration define the config where to copy the info
  122861. */
  122862. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  122863. /**
  122864. * Serializes this anisotropy configuration.
  122865. * @returns - An object with the serialized config.
  122866. */
  122867. serialize(): any;
  122868. /**
  122869. * Parses a anisotropy Configuration from a serialized object.
  122870. * @param source - Serialized object.
  122871. * @param scene Defines the scene we are parsing for
  122872. * @param rootUrl Defines the rootUrl to load from
  122873. */
  122874. parse(source: any, scene: Scene, rootUrl: string): void;
  122875. }
  122876. }
  122877. declare module BABYLON {
  122878. /**
  122879. * @hidden
  122880. */
  122881. export interface IMaterialBRDFDefines {
  122882. BRDF_V_HEIGHT_CORRELATED: boolean;
  122883. MS_BRDF_ENERGY_CONSERVATION: boolean;
  122884. SPHERICAL_HARMONICS: boolean;
  122885. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  122886. /** @hidden */
  122887. _areMiscDirty: boolean;
  122888. }
  122889. /**
  122890. * Define the code related to the BRDF parameters of the pbr material.
  122891. */
  122892. export class PBRBRDFConfiguration {
  122893. /**
  122894. * Default value used for the energy conservation.
  122895. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  122896. */
  122897. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  122898. /**
  122899. * Default value used for the Smith Visibility Height Correlated mode.
  122900. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  122901. */
  122902. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  122903. /**
  122904. * Default value used for the IBL diffuse part.
  122905. * This can help switching back to the polynomials mode globally which is a tiny bit
  122906. * less GPU intensive at the drawback of a lower quality.
  122907. */
  122908. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  122909. /**
  122910. * Default value used for activating energy conservation for the specular workflow.
  122911. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  122912. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  122913. */
  122914. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  122915. private _useEnergyConservation;
  122916. /**
  122917. * Defines if the material uses energy conservation.
  122918. */
  122919. useEnergyConservation: boolean;
  122920. private _useSmithVisibilityHeightCorrelated;
  122921. /**
  122922. * LEGACY Mode set to false
  122923. * Defines if the material uses height smith correlated visibility term.
  122924. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  122925. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  122926. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  122927. * Not relying on height correlated will also disable energy conservation.
  122928. */
  122929. useSmithVisibilityHeightCorrelated: boolean;
  122930. private _useSphericalHarmonics;
  122931. /**
  122932. * LEGACY Mode set to false
  122933. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  122934. * diffuse part of the IBL.
  122935. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  122936. * to the ground truth.
  122937. */
  122938. useSphericalHarmonics: boolean;
  122939. private _useSpecularGlossinessInputEnergyConservation;
  122940. /**
  122941. * Defines if the material uses energy conservation, when the specular workflow is active.
  122942. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  122943. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  122944. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  122945. */
  122946. useSpecularGlossinessInputEnergyConservation: boolean;
  122947. /** @hidden */
  122948. private _internalMarkAllSubMeshesAsMiscDirty;
  122949. /** @hidden */
  122950. _markAllSubMeshesAsMiscDirty(): void;
  122951. /**
  122952. * Instantiate a new istance of clear coat configuration.
  122953. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  122954. */
  122955. constructor(markAllSubMeshesAsMiscDirty: () => void);
  122956. /**
  122957. * Checks to see if a texture is used in the material.
  122958. * @param defines the list of "defines" to update.
  122959. */
  122960. prepareDefines(defines: IMaterialBRDFDefines): void;
  122961. /**
  122962. * Get the current class name of the texture useful for serialization or dynamic coding.
  122963. * @returns "PBRClearCoatConfiguration"
  122964. */
  122965. getClassName(): string;
  122966. /**
  122967. * Makes a duplicate of the current configuration into another one.
  122968. * @param brdfConfiguration define the config where to copy the info
  122969. */
  122970. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  122971. /**
  122972. * Serializes this BRDF configuration.
  122973. * @returns - An object with the serialized config.
  122974. */
  122975. serialize(): any;
  122976. /**
  122977. * Parses a anisotropy Configuration from a serialized object.
  122978. * @param source - Serialized object.
  122979. * @param scene Defines the scene we are parsing for
  122980. * @param rootUrl Defines the rootUrl to load from
  122981. */
  122982. parse(source: any, scene: Scene, rootUrl: string): void;
  122983. }
  122984. }
  122985. declare module BABYLON {
  122986. /**
  122987. * @hidden
  122988. */
  122989. export interface IMaterialSheenDefines {
  122990. SHEEN: boolean;
  122991. SHEEN_TEXTURE: boolean;
  122992. SHEEN_TEXTUREDIRECTUV: number;
  122993. SHEEN_LINKWITHALBEDO: boolean;
  122994. /** @hidden */
  122995. _areTexturesDirty: boolean;
  122996. }
  122997. /**
  122998. * Define the code related to the Sheen parameters of the pbr material.
  122999. */
  123000. export class PBRSheenConfiguration {
  123001. private _isEnabled;
  123002. /**
  123003. * Defines if the material uses sheen.
  123004. */
  123005. isEnabled: boolean;
  123006. private _linkSheenWithAlbedo;
  123007. /**
  123008. * Defines if the sheen is linked to the sheen color.
  123009. */
  123010. linkSheenWithAlbedo: boolean;
  123011. /**
  123012. * Defines the sheen intensity.
  123013. */
  123014. intensity: number;
  123015. /**
  123016. * Defines the sheen color.
  123017. */
  123018. color: Color3;
  123019. private _texture;
  123020. /**
  123021. * Stores the sheen tint values in a texture.
  123022. * rgb is tint
  123023. * a is a intensity
  123024. */
  123025. texture: Nullable<BaseTexture>;
  123026. /** @hidden */
  123027. private _internalMarkAllSubMeshesAsTexturesDirty;
  123028. /** @hidden */
  123029. _markAllSubMeshesAsTexturesDirty(): void;
  123030. /**
  123031. * Instantiate a new istance of clear coat configuration.
  123032. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123033. */
  123034. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123035. /**
  123036. * Specifies that the submesh is ready to be used.
  123037. * @param defines the list of "defines" to update.
  123038. * @param scene defines the scene the material belongs to.
  123039. * @returns - boolean indicating that the submesh is ready or not.
  123040. */
  123041. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  123042. /**
  123043. * Checks to see if a texture is used in the material.
  123044. * @param defines the list of "defines" to update.
  123045. * @param scene defines the scene the material belongs to.
  123046. */
  123047. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  123048. /**
  123049. * Binds the material data.
  123050. * @param uniformBuffer defines the Uniform buffer to fill in.
  123051. * @param scene defines the scene the material belongs to.
  123052. * @param isFrozen defines wether the material is frozen or not.
  123053. */
  123054. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123055. /**
  123056. * Checks to see if a texture is used in the material.
  123057. * @param texture - Base texture to use.
  123058. * @returns - Boolean specifying if a texture is used in the material.
  123059. */
  123060. hasTexture(texture: BaseTexture): boolean;
  123061. /**
  123062. * Returns an array of the actively used textures.
  123063. * @param activeTextures Array of BaseTextures
  123064. */
  123065. getActiveTextures(activeTextures: BaseTexture[]): void;
  123066. /**
  123067. * Returns the animatable textures.
  123068. * @param animatables Array of animatable textures.
  123069. */
  123070. getAnimatables(animatables: IAnimatable[]): void;
  123071. /**
  123072. * Disposes the resources of the material.
  123073. * @param forceDisposeTextures - Forces the disposal of all textures.
  123074. */
  123075. dispose(forceDisposeTextures?: boolean): void;
  123076. /**
  123077. * Get the current class name of the texture useful for serialization or dynamic coding.
  123078. * @returns "PBRSheenConfiguration"
  123079. */
  123080. getClassName(): string;
  123081. /**
  123082. * Add fallbacks to the effect fallbacks list.
  123083. * @param defines defines the Base texture to use.
  123084. * @param fallbacks defines the current fallback list.
  123085. * @param currentRank defines the current fallback rank.
  123086. * @returns the new fallback rank.
  123087. */
  123088. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123089. /**
  123090. * Add the required uniforms to the current list.
  123091. * @param uniforms defines the current uniform list.
  123092. */
  123093. static AddUniforms(uniforms: string[]): void;
  123094. /**
  123095. * Add the required uniforms to the current buffer.
  123096. * @param uniformBuffer defines the current uniform buffer.
  123097. */
  123098. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123099. /**
  123100. * Add the required samplers to the current list.
  123101. * @param samplers defines the current sampler list.
  123102. */
  123103. static AddSamplers(samplers: string[]): void;
  123104. /**
  123105. * Makes a duplicate of the current configuration into another one.
  123106. * @param sheenConfiguration define the config where to copy the info
  123107. */
  123108. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  123109. /**
  123110. * Serializes this BRDF configuration.
  123111. * @returns - An object with the serialized config.
  123112. */
  123113. serialize(): any;
  123114. /**
  123115. * Parses a anisotropy Configuration from a serialized object.
  123116. * @param source - Serialized object.
  123117. * @param scene Defines the scene we are parsing for
  123118. * @param rootUrl Defines the rootUrl to load from
  123119. */
  123120. parse(source: any, scene: Scene, rootUrl: string): void;
  123121. }
  123122. }
  123123. declare module BABYLON {
  123124. /**
  123125. * @hidden
  123126. */
  123127. export interface IMaterialSubSurfaceDefines {
  123128. SUBSURFACE: boolean;
  123129. SS_REFRACTION: boolean;
  123130. SS_TRANSLUCENCY: boolean;
  123131. SS_SCATERRING: boolean;
  123132. SS_THICKNESSANDMASK_TEXTURE: boolean;
  123133. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  123134. SS_REFRACTIONMAP_3D: boolean;
  123135. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  123136. SS_LODINREFRACTIONALPHA: boolean;
  123137. SS_GAMMAREFRACTION: boolean;
  123138. SS_RGBDREFRACTION: boolean;
  123139. SS_LINEARSPECULARREFRACTION: boolean;
  123140. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  123141. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  123142. /** @hidden */
  123143. _areTexturesDirty: boolean;
  123144. }
  123145. /**
  123146. * Define the code related to the sub surface parameters of the pbr material.
  123147. */
  123148. export class PBRSubSurfaceConfiguration {
  123149. private _isRefractionEnabled;
  123150. /**
  123151. * Defines if the refraction is enabled in the material.
  123152. */
  123153. isRefractionEnabled: boolean;
  123154. private _isTranslucencyEnabled;
  123155. /**
  123156. * Defines if the translucency is enabled in the material.
  123157. */
  123158. isTranslucencyEnabled: boolean;
  123159. private _isScatteringEnabled;
  123160. /**
  123161. * Defines the refraction intensity of the material.
  123162. * The refraction when enabled replaces the Diffuse part of the material.
  123163. * The intensity helps transitionning between diffuse and refraction.
  123164. */
  123165. refractionIntensity: number;
  123166. /**
  123167. * Defines the translucency intensity of the material.
  123168. * When translucency has been enabled, this defines how much of the "translucency"
  123169. * is addded to the diffuse part of the material.
  123170. */
  123171. translucencyIntensity: number;
  123172. /**
  123173. * Defines the scattering intensity of the material.
  123174. * When scattering has been enabled, this defines how much of the "scattered light"
  123175. * is addded to the diffuse part of the material.
  123176. */
  123177. scatteringIntensity: number;
  123178. private _thicknessTexture;
  123179. /**
  123180. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  123181. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  123182. * 0 would mean minimumThickness
  123183. * 1 would mean maximumThickness
  123184. * The other channels might be use as a mask to vary the different effects intensity.
  123185. */
  123186. thicknessTexture: Nullable<BaseTexture>;
  123187. private _refractionTexture;
  123188. /**
  123189. * Defines the texture to use for refraction.
  123190. */
  123191. refractionTexture: Nullable<BaseTexture>;
  123192. private _indexOfRefraction;
  123193. /**
  123194. * Defines the index of refraction used in the material.
  123195. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  123196. */
  123197. indexOfRefraction: number;
  123198. private _invertRefractionY;
  123199. /**
  123200. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  123201. */
  123202. invertRefractionY: boolean;
  123203. private _linkRefractionWithTransparency;
  123204. /**
  123205. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  123206. * Materials half opaque for instance using refraction could benefit from this control.
  123207. */
  123208. linkRefractionWithTransparency: boolean;
  123209. /**
  123210. * Defines the minimum thickness stored in the thickness map.
  123211. * If no thickness map is defined, this value will be used to simulate thickness.
  123212. */
  123213. minimumThickness: number;
  123214. /**
  123215. * Defines the maximum thickness stored in the thickness map.
  123216. */
  123217. maximumThickness: number;
  123218. /**
  123219. * Defines the volume tint of the material.
  123220. * This is used for both translucency and scattering.
  123221. */
  123222. tintColor: Color3;
  123223. /**
  123224. * Defines the distance at which the tint color should be found in the media.
  123225. * This is used for refraction only.
  123226. */
  123227. tintColorAtDistance: number;
  123228. /**
  123229. * Defines how far each channel transmit through the media.
  123230. * It is defined as a color to simplify it selection.
  123231. */
  123232. diffusionDistance: Color3;
  123233. private _useMaskFromThicknessTexture;
  123234. /**
  123235. * Stores the intensity of the different subsurface effects in the thickness texture.
  123236. * * the green channel is the translucency intensity.
  123237. * * the blue channel is the scattering intensity.
  123238. * * the alpha channel is the refraction intensity.
  123239. */
  123240. useMaskFromThicknessTexture: boolean;
  123241. /** @hidden */
  123242. private _internalMarkAllSubMeshesAsTexturesDirty;
  123243. /** @hidden */
  123244. _markAllSubMeshesAsTexturesDirty(): void;
  123245. /**
  123246. * Instantiate a new istance of sub surface configuration.
  123247. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123248. */
  123249. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123250. /**
  123251. * Gets wehter the submesh is ready to be used or not.
  123252. * @param defines the list of "defines" to update.
  123253. * @param scene defines the scene the material belongs to.
  123254. * @returns - boolean indicating that the submesh is ready or not.
  123255. */
  123256. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  123257. /**
  123258. * Checks to see if a texture is used in the material.
  123259. * @param defines the list of "defines" to update.
  123260. * @param scene defines the scene to the material belongs to.
  123261. */
  123262. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  123263. /**
  123264. * Binds the material data.
  123265. * @param uniformBuffer defines the Uniform buffer to fill in.
  123266. * @param scene defines the scene the material belongs to.
  123267. * @param engine defines the engine the material belongs to.
  123268. * @param isFrozen defines wether the material is frozen or not.
  123269. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  123270. */
  123271. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  123272. /**
  123273. * Unbinds the material from the mesh.
  123274. * @param activeEffect defines the effect that should be unbound from.
  123275. * @returns true if unbound, otherwise false
  123276. */
  123277. unbind(activeEffect: Effect): boolean;
  123278. /**
  123279. * Returns the texture used for refraction or null if none is used.
  123280. * @param scene defines the scene the material belongs to.
  123281. * @returns - Refraction texture if present. If no refraction texture and refraction
  123282. * is linked with transparency, returns environment texture. Otherwise, returns null.
  123283. */
  123284. private _getRefractionTexture;
  123285. /**
  123286. * Returns true if alpha blending should be disabled.
  123287. */
  123288. get disableAlphaBlending(): boolean;
  123289. /**
  123290. * Fills the list of render target textures.
  123291. * @param renderTargets the list of render targets to update
  123292. */
  123293. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  123294. /**
  123295. * Checks to see if a texture is used in the material.
  123296. * @param texture - Base texture to use.
  123297. * @returns - Boolean specifying if a texture is used in the material.
  123298. */
  123299. hasTexture(texture: BaseTexture): boolean;
  123300. /**
  123301. * Gets a boolean indicating that current material needs to register RTT
  123302. * @returns true if this uses a render target otherwise false.
  123303. */
  123304. hasRenderTargetTextures(): boolean;
  123305. /**
  123306. * Returns an array of the actively used textures.
  123307. * @param activeTextures Array of BaseTextures
  123308. */
  123309. getActiveTextures(activeTextures: BaseTexture[]): void;
  123310. /**
  123311. * Returns the animatable textures.
  123312. * @param animatables Array of animatable textures.
  123313. */
  123314. getAnimatables(animatables: IAnimatable[]): void;
  123315. /**
  123316. * Disposes the resources of the material.
  123317. * @param forceDisposeTextures - Forces the disposal of all textures.
  123318. */
  123319. dispose(forceDisposeTextures?: boolean): void;
  123320. /**
  123321. * Get the current class name of the texture useful for serialization or dynamic coding.
  123322. * @returns "PBRSubSurfaceConfiguration"
  123323. */
  123324. getClassName(): string;
  123325. /**
  123326. * Add fallbacks to the effect fallbacks list.
  123327. * @param defines defines the Base texture to use.
  123328. * @param fallbacks defines the current fallback list.
  123329. * @param currentRank defines the current fallback rank.
  123330. * @returns the new fallback rank.
  123331. */
  123332. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123333. /**
  123334. * Add the required uniforms to the current list.
  123335. * @param uniforms defines the current uniform list.
  123336. */
  123337. static AddUniforms(uniforms: string[]): void;
  123338. /**
  123339. * Add the required samplers to the current list.
  123340. * @param samplers defines the current sampler list.
  123341. */
  123342. static AddSamplers(samplers: string[]): void;
  123343. /**
  123344. * Add the required uniforms to the current buffer.
  123345. * @param uniformBuffer defines the current uniform buffer.
  123346. */
  123347. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123348. /**
  123349. * Makes a duplicate of the current configuration into another one.
  123350. * @param configuration define the config where to copy the info
  123351. */
  123352. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  123353. /**
  123354. * Serializes this Sub Surface configuration.
  123355. * @returns - An object with the serialized config.
  123356. */
  123357. serialize(): any;
  123358. /**
  123359. * Parses a anisotropy Configuration from a serialized object.
  123360. * @param source - Serialized object.
  123361. * @param scene Defines the scene we are parsing for
  123362. * @param rootUrl Defines the rootUrl to load from
  123363. */
  123364. parse(source: any, scene: Scene, rootUrl: string): void;
  123365. }
  123366. }
  123367. declare module BABYLON {
  123368. /** @hidden */
  123369. export var pbrFragmentDeclaration: {
  123370. name: string;
  123371. shader: string;
  123372. };
  123373. }
  123374. declare module BABYLON {
  123375. /** @hidden */
  123376. export var pbrUboDeclaration: {
  123377. name: string;
  123378. shader: string;
  123379. };
  123380. }
  123381. declare module BABYLON {
  123382. /** @hidden */
  123383. export var pbrFragmentExtraDeclaration: {
  123384. name: string;
  123385. shader: string;
  123386. };
  123387. }
  123388. declare module BABYLON {
  123389. /** @hidden */
  123390. export var pbrFragmentSamplersDeclaration: {
  123391. name: string;
  123392. shader: string;
  123393. };
  123394. }
  123395. declare module BABYLON {
  123396. /** @hidden */
  123397. export var pbrHelperFunctions: {
  123398. name: string;
  123399. shader: string;
  123400. };
  123401. }
  123402. declare module BABYLON {
  123403. /** @hidden */
  123404. export var harmonicsFunctions: {
  123405. name: string;
  123406. shader: string;
  123407. };
  123408. }
  123409. declare module BABYLON {
  123410. /** @hidden */
  123411. export var pbrDirectLightingSetupFunctions: {
  123412. name: string;
  123413. shader: string;
  123414. };
  123415. }
  123416. declare module BABYLON {
  123417. /** @hidden */
  123418. export var pbrDirectLightingFalloffFunctions: {
  123419. name: string;
  123420. shader: string;
  123421. };
  123422. }
  123423. declare module BABYLON {
  123424. /** @hidden */
  123425. export var pbrBRDFFunctions: {
  123426. name: string;
  123427. shader: string;
  123428. };
  123429. }
  123430. declare module BABYLON {
  123431. /** @hidden */
  123432. export var pbrDirectLightingFunctions: {
  123433. name: string;
  123434. shader: string;
  123435. };
  123436. }
  123437. declare module BABYLON {
  123438. /** @hidden */
  123439. export var pbrIBLFunctions: {
  123440. name: string;
  123441. shader: string;
  123442. };
  123443. }
  123444. declare module BABYLON {
  123445. /** @hidden */
  123446. export var pbrDebug: {
  123447. name: string;
  123448. shader: string;
  123449. };
  123450. }
  123451. declare module BABYLON {
  123452. /** @hidden */
  123453. export var pbrPixelShader: {
  123454. name: string;
  123455. shader: string;
  123456. };
  123457. }
  123458. declare module BABYLON {
  123459. /** @hidden */
  123460. export var pbrVertexDeclaration: {
  123461. name: string;
  123462. shader: string;
  123463. };
  123464. }
  123465. declare module BABYLON {
  123466. /** @hidden */
  123467. export var pbrVertexShader: {
  123468. name: string;
  123469. shader: string;
  123470. };
  123471. }
  123472. declare module BABYLON {
  123473. /**
  123474. * Manages the defines for the PBR Material.
  123475. * @hidden
  123476. */
  123477. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  123478. PBR: boolean;
  123479. MAINUV1: boolean;
  123480. MAINUV2: boolean;
  123481. UV1: boolean;
  123482. UV2: boolean;
  123483. ALBEDO: boolean;
  123484. ALBEDODIRECTUV: number;
  123485. VERTEXCOLOR: boolean;
  123486. AMBIENT: boolean;
  123487. AMBIENTDIRECTUV: number;
  123488. AMBIENTINGRAYSCALE: boolean;
  123489. OPACITY: boolean;
  123490. VERTEXALPHA: boolean;
  123491. OPACITYDIRECTUV: number;
  123492. OPACITYRGB: boolean;
  123493. ALPHATEST: boolean;
  123494. DEPTHPREPASS: boolean;
  123495. ALPHABLEND: boolean;
  123496. ALPHAFROMALBEDO: boolean;
  123497. ALPHATESTVALUE: string;
  123498. SPECULAROVERALPHA: boolean;
  123499. RADIANCEOVERALPHA: boolean;
  123500. ALPHAFRESNEL: boolean;
  123501. LINEARALPHAFRESNEL: boolean;
  123502. PREMULTIPLYALPHA: boolean;
  123503. EMISSIVE: boolean;
  123504. EMISSIVEDIRECTUV: number;
  123505. REFLECTIVITY: boolean;
  123506. REFLECTIVITYDIRECTUV: number;
  123507. SPECULARTERM: boolean;
  123508. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  123509. MICROSURFACEAUTOMATIC: boolean;
  123510. LODBASEDMICROSFURACE: boolean;
  123511. MICROSURFACEMAP: boolean;
  123512. MICROSURFACEMAPDIRECTUV: number;
  123513. METALLICWORKFLOW: boolean;
  123514. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  123515. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  123516. METALLNESSSTOREINMETALMAPBLUE: boolean;
  123517. AOSTOREINMETALMAPRED: boolean;
  123518. METALLICF0FACTORFROMMETALLICMAP: boolean;
  123519. ENVIRONMENTBRDF: boolean;
  123520. ENVIRONMENTBRDF_RGBD: boolean;
  123521. NORMAL: boolean;
  123522. TANGENT: boolean;
  123523. BUMP: boolean;
  123524. BUMPDIRECTUV: number;
  123525. OBJECTSPACE_NORMALMAP: boolean;
  123526. PARALLAX: boolean;
  123527. PARALLAXOCCLUSION: boolean;
  123528. NORMALXYSCALE: boolean;
  123529. LIGHTMAP: boolean;
  123530. LIGHTMAPDIRECTUV: number;
  123531. USELIGHTMAPASSHADOWMAP: boolean;
  123532. GAMMALIGHTMAP: boolean;
  123533. RGBDLIGHTMAP: boolean;
  123534. REFLECTION: boolean;
  123535. REFLECTIONMAP_3D: boolean;
  123536. REFLECTIONMAP_SPHERICAL: boolean;
  123537. REFLECTIONMAP_PLANAR: boolean;
  123538. REFLECTIONMAP_CUBIC: boolean;
  123539. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  123540. REFLECTIONMAP_PROJECTION: boolean;
  123541. REFLECTIONMAP_SKYBOX: boolean;
  123542. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  123543. REFLECTIONMAP_EXPLICIT: boolean;
  123544. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  123545. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  123546. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  123547. INVERTCUBICMAP: boolean;
  123548. USESPHERICALFROMREFLECTIONMAP: boolean;
  123549. USEIRRADIANCEMAP: boolean;
  123550. SPHERICAL_HARMONICS: boolean;
  123551. USESPHERICALINVERTEX: boolean;
  123552. REFLECTIONMAP_OPPOSITEZ: boolean;
  123553. LODINREFLECTIONALPHA: boolean;
  123554. GAMMAREFLECTION: boolean;
  123555. RGBDREFLECTION: boolean;
  123556. LINEARSPECULARREFLECTION: boolean;
  123557. RADIANCEOCCLUSION: boolean;
  123558. HORIZONOCCLUSION: boolean;
  123559. INSTANCES: boolean;
  123560. NUM_BONE_INFLUENCERS: number;
  123561. BonesPerMesh: number;
  123562. BONETEXTURE: boolean;
  123563. NONUNIFORMSCALING: boolean;
  123564. MORPHTARGETS: boolean;
  123565. MORPHTARGETS_NORMAL: boolean;
  123566. MORPHTARGETS_TANGENT: boolean;
  123567. MORPHTARGETS_UV: boolean;
  123568. NUM_MORPH_INFLUENCERS: number;
  123569. IMAGEPROCESSING: boolean;
  123570. VIGNETTE: boolean;
  123571. VIGNETTEBLENDMODEMULTIPLY: boolean;
  123572. VIGNETTEBLENDMODEOPAQUE: boolean;
  123573. TONEMAPPING: boolean;
  123574. TONEMAPPING_ACES: boolean;
  123575. CONTRAST: boolean;
  123576. COLORCURVES: boolean;
  123577. COLORGRADING: boolean;
  123578. COLORGRADING3D: boolean;
  123579. SAMPLER3DGREENDEPTH: boolean;
  123580. SAMPLER3DBGRMAP: boolean;
  123581. IMAGEPROCESSINGPOSTPROCESS: boolean;
  123582. EXPOSURE: boolean;
  123583. MULTIVIEW: boolean;
  123584. USEPHYSICALLIGHTFALLOFF: boolean;
  123585. USEGLTFLIGHTFALLOFF: boolean;
  123586. TWOSIDEDLIGHTING: boolean;
  123587. SHADOWFLOAT: boolean;
  123588. CLIPPLANE: boolean;
  123589. CLIPPLANE2: boolean;
  123590. CLIPPLANE3: boolean;
  123591. CLIPPLANE4: boolean;
  123592. CLIPPLANE5: boolean;
  123593. CLIPPLANE6: boolean;
  123594. POINTSIZE: boolean;
  123595. FOG: boolean;
  123596. LOGARITHMICDEPTH: boolean;
  123597. FORCENORMALFORWARD: boolean;
  123598. SPECULARAA: boolean;
  123599. CLEARCOAT: boolean;
  123600. CLEARCOAT_DEFAULTIOR: boolean;
  123601. CLEARCOAT_TEXTURE: boolean;
  123602. CLEARCOAT_TEXTUREDIRECTUV: number;
  123603. CLEARCOAT_BUMP: boolean;
  123604. CLEARCOAT_BUMPDIRECTUV: number;
  123605. CLEARCOAT_TINT: boolean;
  123606. CLEARCOAT_TINT_TEXTURE: boolean;
  123607. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  123608. ANISOTROPIC: boolean;
  123609. ANISOTROPIC_TEXTURE: boolean;
  123610. ANISOTROPIC_TEXTUREDIRECTUV: number;
  123611. BRDF_V_HEIGHT_CORRELATED: boolean;
  123612. MS_BRDF_ENERGY_CONSERVATION: boolean;
  123613. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  123614. SHEEN: boolean;
  123615. SHEEN_TEXTURE: boolean;
  123616. SHEEN_TEXTUREDIRECTUV: number;
  123617. SHEEN_LINKWITHALBEDO: boolean;
  123618. SUBSURFACE: boolean;
  123619. SS_REFRACTION: boolean;
  123620. SS_TRANSLUCENCY: boolean;
  123621. SS_SCATERRING: boolean;
  123622. SS_THICKNESSANDMASK_TEXTURE: boolean;
  123623. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  123624. SS_REFRACTIONMAP_3D: boolean;
  123625. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  123626. SS_LODINREFRACTIONALPHA: boolean;
  123627. SS_GAMMAREFRACTION: boolean;
  123628. SS_RGBDREFRACTION: boolean;
  123629. SS_LINEARSPECULARREFRACTION: boolean;
  123630. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  123631. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  123632. UNLIT: boolean;
  123633. DEBUGMODE: number;
  123634. /**
  123635. * Initializes the PBR Material defines.
  123636. */
  123637. constructor();
  123638. /**
  123639. * Resets the PBR Material defines.
  123640. */
  123641. reset(): void;
  123642. }
  123643. /**
  123644. * The Physically based material base class of BJS.
  123645. *
  123646. * This offers the main features of a standard PBR material.
  123647. * For more information, please refer to the documentation :
  123648. * https://doc.babylonjs.com/how_to/physically_based_rendering
  123649. */
  123650. export abstract class PBRBaseMaterial extends PushMaterial {
  123651. /**
  123652. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  123653. */
  123654. static readonly PBRMATERIAL_OPAQUE: number;
  123655. /**
  123656. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  123657. */
  123658. static readonly PBRMATERIAL_ALPHATEST: number;
  123659. /**
  123660. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  123661. */
  123662. static readonly PBRMATERIAL_ALPHABLEND: number;
  123663. /**
  123664. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  123665. * They are also discarded below the alpha cutoff threshold to improve performances.
  123666. */
  123667. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  123668. /**
  123669. * Defines the default value of how much AO map is occluding the analytical lights
  123670. * (point spot...).
  123671. */
  123672. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  123673. /**
  123674. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  123675. */
  123676. static readonly LIGHTFALLOFF_PHYSICAL: number;
  123677. /**
  123678. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  123679. * to enhance interoperability with other engines.
  123680. */
  123681. static readonly LIGHTFALLOFF_GLTF: number;
  123682. /**
  123683. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  123684. * to enhance interoperability with other materials.
  123685. */
  123686. static readonly LIGHTFALLOFF_STANDARD: number;
  123687. /**
  123688. * Intensity of the direct lights e.g. the four lights available in your scene.
  123689. * This impacts both the direct diffuse and specular highlights.
  123690. */
  123691. protected _directIntensity: number;
  123692. /**
  123693. * Intensity of the emissive part of the material.
  123694. * This helps controlling the emissive effect without modifying the emissive color.
  123695. */
  123696. protected _emissiveIntensity: number;
  123697. /**
  123698. * Intensity of the environment e.g. how much the environment will light the object
  123699. * either through harmonics for rough material or through the refelction for shiny ones.
  123700. */
  123701. protected _environmentIntensity: number;
  123702. /**
  123703. * This is a special control allowing the reduction of the specular highlights coming from the
  123704. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  123705. */
  123706. protected _specularIntensity: number;
  123707. /**
  123708. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  123709. */
  123710. private _lightingInfos;
  123711. /**
  123712. * Debug Control allowing disabling the bump map on this material.
  123713. */
  123714. protected _disableBumpMap: boolean;
  123715. /**
  123716. * AKA Diffuse Texture in standard nomenclature.
  123717. */
  123718. protected _albedoTexture: Nullable<BaseTexture>;
  123719. /**
  123720. * AKA Occlusion Texture in other nomenclature.
  123721. */
  123722. protected _ambientTexture: Nullable<BaseTexture>;
  123723. /**
  123724. * AKA Occlusion Texture Intensity in other nomenclature.
  123725. */
  123726. protected _ambientTextureStrength: number;
  123727. /**
  123728. * Defines how much the AO map is occluding the analytical lights (point spot...).
  123729. * 1 means it completely occludes it
  123730. * 0 mean it has no impact
  123731. */
  123732. protected _ambientTextureImpactOnAnalyticalLights: number;
  123733. /**
  123734. * Stores the alpha values in a texture.
  123735. */
  123736. protected _opacityTexture: Nullable<BaseTexture>;
  123737. /**
  123738. * Stores the reflection values in a texture.
  123739. */
  123740. protected _reflectionTexture: Nullable<BaseTexture>;
  123741. /**
  123742. * Stores the emissive values in a texture.
  123743. */
  123744. protected _emissiveTexture: Nullable<BaseTexture>;
  123745. /**
  123746. * AKA Specular texture in other nomenclature.
  123747. */
  123748. protected _reflectivityTexture: Nullable<BaseTexture>;
  123749. /**
  123750. * Used to switch from specular/glossiness to metallic/roughness workflow.
  123751. */
  123752. protected _metallicTexture: Nullable<BaseTexture>;
  123753. /**
  123754. * Specifies the metallic scalar of the metallic/roughness workflow.
  123755. * Can also be used to scale the metalness values of the metallic texture.
  123756. */
  123757. protected _metallic: Nullable<number>;
  123758. /**
  123759. * Specifies the roughness scalar of the metallic/roughness workflow.
  123760. * Can also be used to scale the roughness values of the metallic texture.
  123761. */
  123762. protected _roughness: Nullable<number>;
  123763. /**
  123764. * Specifies the an F0 factor to help configuring the material F0.
  123765. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  123766. * to 0.5 the previously hard coded value stays the same.
  123767. * Can also be used to scale the F0 values of the metallic texture.
  123768. */
  123769. protected _metallicF0Factor: number;
  123770. /**
  123771. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  123772. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  123773. * your expectation as it multiplies with the texture data.
  123774. */
  123775. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  123776. /**
  123777. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  123778. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  123779. */
  123780. protected _microSurfaceTexture: Nullable<BaseTexture>;
  123781. /**
  123782. * Stores surface normal data used to displace a mesh in a texture.
  123783. */
  123784. protected _bumpTexture: Nullable<BaseTexture>;
  123785. /**
  123786. * Stores the pre-calculated light information of a mesh in a texture.
  123787. */
  123788. protected _lightmapTexture: Nullable<BaseTexture>;
  123789. /**
  123790. * The color of a material in ambient lighting.
  123791. */
  123792. protected _ambientColor: Color3;
  123793. /**
  123794. * AKA Diffuse Color in other nomenclature.
  123795. */
  123796. protected _albedoColor: Color3;
  123797. /**
  123798. * AKA Specular Color in other nomenclature.
  123799. */
  123800. protected _reflectivityColor: Color3;
  123801. /**
  123802. * The color applied when light is reflected from a material.
  123803. */
  123804. protected _reflectionColor: Color3;
  123805. /**
  123806. * The color applied when light is emitted from a material.
  123807. */
  123808. protected _emissiveColor: Color3;
  123809. /**
  123810. * AKA Glossiness in other nomenclature.
  123811. */
  123812. protected _microSurface: number;
  123813. /**
  123814. * Specifies that the material will use the light map as a show map.
  123815. */
  123816. protected _useLightmapAsShadowmap: boolean;
  123817. /**
  123818. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  123819. * makes the reflect vector face the model (under horizon).
  123820. */
  123821. protected _useHorizonOcclusion: boolean;
  123822. /**
  123823. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  123824. * too much the area relying on ambient texture to define their ambient occlusion.
  123825. */
  123826. protected _useRadianceOcclusion: boolean;
  123827. /**
  123828. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  123829. */
  123830. protected _useAlphaFromAlbedoTexture: boolean;
  123831. /**
  123832. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  123833. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  123834. */
  123835. protected _useSpecularOverAlpha: boolean;
  123836. /**
  123837. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  123838. */
  123839. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  123840. /**
  123841. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  123842. */
  123843. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  123844. /**
  123845. * Specifies if the metallic texture contains the roughness information in its green channel.
  123846. */
  123847. protected _useRoughnessFromMetallicTextureGreen: boolean;
  123848. /**
  123849. * Specifies if the metallic texture contains the metallness information in its blue channel.
  123850. */
  123851. protected _useMetallnessFromMetallicTextureBlue: boolean;
  123852. /**
  123853. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  123854. */
  123855. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  123856. /**
  123857. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  123858. */
  123859. protected _useAmbientInGrayScale: boolean;
  123860. /**
  123861. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  123862. * The material will try to infer what glossiness each pixel should be.
  123863. */
  123864. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  123865. /**
  123866. * Defines the falloff type used in this material.
  123867. * It by default is Physical.
  123868. */
  123869. protected _lightFalloff: number;
  123870. /**
  123871. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  123872. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  123873. */
  123874. protected _useRadianceOverAlpha: boolean;
  123875. /**
  123876. * Allows using an object space normal map (instead of tangent space).
  123877. */
  123878. protected _useObjectSpaceNormalMap: boolean;
  123879. /**
  123880. * Allows using the bump map in parallax mode.
  123881. */
  123882. protected _useParallax: boolean;
  123883. /**
  123884. * Allows using the bump map in parallax occlusion mode.
  123885. */
  123886. protected _useParallaxOcclusion: boolean;
  123887. /**
  123888. * Controls the scale bias of the parallax mode.
  123889. */
  123890. protected _parallaxScaleBias: number;
  123891. /**
  123892. * If sets to true, disables all the lights affecting the material.
  123893. */
  123894. protected _disableLighting: boolean;
  123895. /**
  123896. * Number of Simultaneous lights allowed on the material.
  123897. */
  123898. protected _maxSimultaneousLights: number;
  123899. /**
  123900. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  123901. */
  123902. protected _invertNormalMapX: boolean;
  123903. /**
  123904. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  123905. */
  123906. protected _invertNormalMapY: boolean;
  123907. /**
  123908. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  123909. */
  123910. protected _twoSidedLighting: boolean;
  123911. /**
  123912. * Defines the alpha limits in alpha test mode.
  123913. */
  123914. protected _alphaCutOff: number;
  123915. /**
  123916. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  123917. */
  123918. protected _forceAlphaTest: boolean;
  123919. /**
  123920. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  123921. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  123922. */
  123923. protected _useAlphaFresnel: boolean;
  123924. /**
  123925. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  123926. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  123927. */
  123928. protected _useLinearAlphaFresnel: boolean;
  123929. /**
  123930. * The transparency mode of the material.
  123931. */
  123932. protected _transparencyMode: Nullable<number>;
  123933. /**
  123934. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  123935. * from cos thetav and roughness:
  123936. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  123937. */
  123938. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  123939. /**
  123940. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  123941. */
  123942. protected _forceIrradianceInFragment: boolean;
  123943. /**
  123944. * Force normal to face away from face.
  123945. */
  123946. protected _forceNormalForward: boolean;
  123947. /**
  123948. * Enables specular anti aliasing in the PBR shader.
  123949. * It will both interacts on the Geometry for analytical and IBL lighting.
  123950. * It also prefilter the roughness map based on the bump values.
  123951. */
  123952. protected _enableSpecularAntiAliasing: boolean;
  123953. /**
  123954. * Default configuration related to image processing available in the PBR Material.
  123955. */
  123956. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123957. /**
  123958. * Keep track of the image processing observer to allow dispose and replace.
  123959. */
  123960. private _imageProcessingObserver;
  123961. /**
  123962. * Attaches a new image processing configuration to the PBR Material.
  123963. * @param configuration
  123964. */
  123965. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  123966. /**
  123967. * Stores the available render targets.
  123968. */
  123969. private _renderTargets;
  123970. /**
  123971. * Sets the global ambient color for the material used in lighting calculations.
  123972. */
  123973. private _globalAmbientColor;
  123974. /**
  123975. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  123976. */
  123977. private _useLogarithmicDepth;
  123978. /**
  123979. * If set to true, no lighting calculations will be applied.
  123980. */
  123981. private _unlit;
  123982. private _debugMode;
  123983. /**
  123984. * @hidden
  123985. * This is reserved for the inspector.
  123986. * Defines the material debug mode.
  123987. * It helps seeing only some components of the material while troubleshooting.
  123988. */
  123989. debugMode: number;
  123990. /**
  123991. * @hidden
  123992. * This is reserved for the inspector.
  123993. * Specify from where on screen the debug mode should start.
  123994. * The value goes from -1 (full screen) to 1 (not visible)
  123995. * It helps with side by side comparison against the final render
  123996. * This defaults to -1
  123997. */
  123998. private debugLimit;
  123999. /**
  124000. * @hidden
  124001. * This is reserved for the inspector.
  124002. * As the default viewing range might not be enough (if the ambient is really small for instance)
  124003. * You can use the factor to better multiply the final value.
  124004. */
  124005. private debugFactor;
  124006. /**
  124007. * Defines the clear coat layer parameters for the material.
  124008. */
  124009. readonly clearCoat: PBRClearCoatConfiguration;
  124010. /**
  124011. * Defines the anisotropic parameters for the material.
  124012. */
  124013. readonly anisotropy: PBRAnisotropicConfiguration;
  124014. /**
  124015. * Defines the BRDF parameters for the material.
  124016. */
  124017. readonly brdf: PBRBRDFConfiguration;
  124018. /**
  124019. * Defines the Sheen parameters for the material.
  124020. */
  124021. readonly sheen: PBRSheenConfiguration;
  124022. /**
  124023. * Defines the SubSurface parameters for the material.
  124024. */
  124025. readonly subSurface: PBRSubSurfaceConfiguration;
  124026. /**
  124027. * Custom callback helping to override the default shader used in the material.
  124028. */
  124029. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  124030. protected _rebuildInParallel: boolean;
  124031. /**
  124032. * Instantiates a new PBRMaterial instance.
  124033. *
  124034. * @param name The material name
  124035. * @param scene The scene the material will be use in.
  124036. */
  124037. constructor(name: string, scene: Scene);
  124038. /**
  124039. * Gets a boolean indicating that current material needs to register RTT
  124040. */
  124041. get hasRenderTargetTextures(): boolean;
  124042. /**
  124043. * Gets the name of the material class.
  124044. */
  124045. getClassName(): string;
  124046. /**
  124047. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124048. */
  124049. get useLogarithmicDepth(): boolean;
  124050. /**
  124051. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124052. */
  124053. set useLogarithmicDepth(value: boolean);
  124054. /**
  124055. * Gets the current transparency mode.
  124056. */
  124057. get transparencyMode(): Nullable<number>;
  124058. /**
  124059. * Sets the transparency mode of the material.
  124060. *
  124061. * | Value | Type | Description |
  124062. * | ----- | ----------------------------------- | ----------- |
  124063. * | 0 | OPAQUE | |
  124064. * | 1 | ALPHATEST | |
  124065. * | 2 | ALPHABLEND | |
  124066. * | 3 | ALPHATESTANDBLEND | |
  124067. *
  124068. */
  124069. set transparencyMode(value: Nullable<number>);
  124070. /**
  124071. * Returns true if alpha blending should be disabled.
  124072. */
  124073. private get _disableAlphaBlending();
  124074. /**
  124075. * Specifies whether or not this material should be rendered in alpha blend mode.
  124076. */
  124077. needAlphaBlending(): boolean;
  124078. /**
  124079. * Specifies if the mesh will require alpha blending.
  124080. * @param mesh - BJS mesh.
  124081. */
  124082. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  124083. /**
  124084. * Specifies whether or not this material should be rendered in alpha test mode.
  124085. */
  124086. needAlphaTesting(): boolean;
  124087. /**
  124088. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  124089. */
  124090. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  124091. /**
  124092. * Gets the texture used for the alpha test.
  124093. */
  124094. getAlphaTestTexture(): Nullable<BaseTexture>;
  124095. /**
  124096. * Specifies that the submesh is ready to be used.
  124097. * @param mesh - BJS mesh.
  124098. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  124099. * @param useInstances - Specifies that instances should be used.
  124100. * @returns - boolean indicating that the submesh is ready or not.
  124101. */
  124102. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  124103. /**
  124104. * Specifies if the material uses metallic roughness workflow.
  124105. * @returns boolean specifiying if the material uses metallic roughness workflow.
  124106. */
  124107. isMetallicWorkflow(): boolean;
  124108. private _prepareEffect;
  124109. private _prepareDefines;
  124110. /**
  124111. * Force shader compilation
  124112. */
  124113. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  124114. /**
  124115. * Initializes the uniform buffer layout for the shader.
  124116. */
  124117. buildUniformLayout(): void;
  124118. /**
  124119. * Unbinds the material from the mesh
  124120. */
  124121. unbind(): void;
  124122. /**
  124123. * Binds the submesh data.
  124124. * @param world - The world matrix.
  124125. * @param mesh - The BJS mesh.
  124126. * @param subMesh - A submesh of the BJS mesh.
  124127. */
  124128. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  124129. /**
  124130. * Returns the animatable textures.
  124131. * @returns - Array of animatable textures.
  124132. */
  124133. getAnimatables(): IAnimatable[];
  124134. /**
  124135. * Returns the texture used for reflections.
  124136. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  124137. */
  124138. private _getReflectionTexture;
  124139. /**
  124140. * Returns an array of the actively used textures.
  124141. * @returns - Array of BaseTextures
  124142. */
  124143. getActiveTextures(): BaseTexture[];
  124144. /**
  124145. * Checks to see if a texture is used in the material.
  124146. * @param texture - Base texture to use.
  124147. * @returns - Boolean specifying if a texture is used in the material.
  124148. */
  124149. hasTexture(texture: BaseTexture): boolean;
  124150. /**
  124151. * Disposes the resources of the material.
  124152. * @param forceDisposeEffect - Forces the disposal of effects.
  124153. * @param forceDisposeTextures - Forces the disposal of all textures.
  124154. */
  124155. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  124156. }
  124157. }
  124158. declare module BABYLON {
  124159. /**
  124160. * The Physically based material of BJS.
  124161. *
  124162. * This offers the main features of a standard PBR material.
  124163. * For more information, please refer to the documentation :
  124164. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124165. */
  124166. export class PBRMaterial extends PBRBaseMaterial {
  124167. /**
  124168. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124169. */
  124170. static readonly PBRMATERIAL_OPAQUE: number;
  124171. /**
  124172. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124173. */
  124174. static readonly PBRMATERIAL_ALPHATEST: number;
  124175. /**
  124176. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124177. */
  124178. static readonly PBRMATERIAL_ALPHABLEND: number;
  124179. /**
  124180. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124181. * They are also discarded below the alpha cutoff threshold to improve performances.
  124182. */
  124183. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124184. /**
  124185. * Defines the default value of how much AO map is occluding the analytical lights
  124186. * (point spot...).
  124187. */
  124188. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124189. /**
  124190. * Intensity of the direct lights e.g. the four lights available in your scene.
  124191. * This impacts both the direct diffuse and specular highlights.
  124192. */
  124193. directIntensity: number;
  124194. /**
  124195. * Intensity of the emissive part of the material.
  124196. * This helps controlling the emissive effect without modifying the emissive color.
  124197. */
  124198. emissiveIntensity: number;
  124199. /**
  124200. * Intensity of the environment e.g. how much the environment will light the object
  124201. * either through harmonics for rough material or through the refelction for shiny ones.
  124202. */
  124203. environmentIntensity: number;
  124204. /**
  124205. * This is a special control allowing the reduction of the specular highlights coming from the
  124206. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124207. */
  124208. specularIntensity: number;
  124209. /**
  124210. * Debug Control allowing disabling the bump map on this material.
  124211. */
  124212. disableBumpMap: boolean;
  124213. /**
  124214. * AKA Diffuse Texture in standard nomenclature.
  124215. */
  124216. albedoTexture: BaseTexture;
  124217. /**
  124218. * AKA Occlusion Texture in other nomenclature.
  124219. */
  124220. ambientTexture: BaseTexture;
  124221. /**
  124222. * AKA Occlusion Texture Intensity in other nomenclature.
  124223. */
  124224. ambientTextureStrength: number;
  124225. /**
  124226. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124227. * 1 means it completely occludes it
  124228. * 0 mean it has no impact
  124229. */
  124230. ambientTextureImpactOnAnalyticalLights: number;
  124231. /**
  124232. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  124233. */
  124234. opacityTexture: BaseTexture;
  124235. /**
  124236. * Stores the reflection values in a texture.
  124237. */
  124238. reflectionTexture: Nullable<BaseTexture>;
  124239. /**
  124240. * Stores the emissive values in a texture.
  124241. */
  124242. emissiveTexture: BaseTexture;
  124243. /**
  124244. * AKA Specular texture in other nomenclature.
  124245. */
  124246. reflectivityTexture: BaseTexture;
  124247. /**
  124248. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124249. */
  124250. metallicTexture: BaseTexture;
  124251. /**
  124252. * Specifies the metallic scalar of the metallic/roughness workflow.
  124253. * Can also be used to scale the metalness values of the metallic texture.
  124254. */
  124255. metallic: Nullable<number>;
  124256. /**
  124257. * Specifies the roughness scalar of the metallic/roughness workflow.
  124258. * Can also be used to scale the roughness values of the metallic texture.
  124259. */
  124260. roughness: Nullable<number>;
  124261. /**
  124262. * Specifies the an F0 factor to help configuring the material F0.
  124263. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124264. * to 0.5 the previously hard coded value stays the same.
  124265. * Can also be used to scale the F0 values of the metallic texture.
  124266. */
  124267. metallicF0Factor: number;
  124268. /**
  124269. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124270. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124271. * your expectation as it multiplies with the texture data.
  124272. */
  124273. useMetallicF0FactorFromMetallicTexture: boolean;
  124274. /**
  124275. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124276. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124277. */
  124278. microSurfaceTexture: BaseTexture;
  124279. /**
  124280. * Stores surface normal data used to displace a mesh in a texture.
  124281. */
  124282. bumpTexture: BaseTexture;
  124283. /**
  124284. * Stores the pre-calculated light information of a mesh in a texture.
  124285. */
  124286. lightmapTexture: BaseTexture;
  124287. /**
  124288. * Stores the refracted light information in a texture.
  124289. */
  124290. get refractionTexture(): Nullable<BaseTexture>;
  124291. set refractionTexture(value: Nullable<BaseTexture>);
  124292. /**
  124293. * The color of a material in ambient lighting.
  124294. */
  124295. ambientColor: Color3;
  124296. /**
  124297. * AKA Diffuse Color in other nomenclature.
  124298. */
  124299. albedoColor: Color3;
  124300. /**
  124301. * AKA Specular Color in other nomenclature.
  124302. */
  124303. reflectivityColor: Color3;
  124304. /**
  124305. * The color reflected from the material.
  124306. */
  124307. reflectionColor: Color3;
  124308. /**
  124309. * The color emitted from the material.
  124310. */
  124311. emissiveColor: Color3;
  124312. /**
  124313. * AKA Glossiness in other nomenclature.
  124314. */
  124315. microSurface: number;
  124316. /**
  124317. * source material index of refraction (IOR)' / 'destination material IOR.
  124318. */
  124319. get indexOfRefraction(): number;
  124320. set indexOfRefraction(value: number);
  124321. /**
  124322. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  124323. */
  124324. get invertRefractionY(): boolean;
  124325. set invertRefractionY(value: boolean);
  124326. /**
  124327. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  124328. * Materials half opaque for instance using refraction could benefit from this control.
  124329. */
  124330. get linkRefractionWithTransparency(): boolean;
  124331. set linkRefractionWithTransparency(value: boolean);
  124332. /**
  124333. * If true, the light map contains occlusion information instead of lighting info.
  124334. */
  124335. useLightmapAsShadowmap: boolean;
  124336. /**
  124337. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124338. */
  124339. useAlphaFromAlbedoTexture: boolean;
  124340. /**
  124341. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124342. */
  124343. forceAlphaTest: boolean;
  124344. /**
  124345. * Defines the alpha limits in alpha test mode.
  124346. */
  124347. alphaCutOff: number;
  124348. /**
  124349. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  124350. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124351. */
  124352. useSpecularOverAlpha: boolean;
  124353. /**
  124354. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124355. */
  124356. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124357. /**
  124358. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124359. */
  124360. useRoughnessFromMetallicTextureAlpha: boolean;
  124361. /**
  124362. * Specifies if the metallic texture contains the roughness information in its green channel.
  124363. */
  124364. useRoughnessFromMetallicTextureGreen: boolean;
  124365. /**
  124366. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124367. */
  124368. useMetallnessFromMetallicTextureBlue: boolean;
  124369. /**
  124370. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124371. */
  124372. useAmbientOcclusionFromMetallicTextureRed: boolean;
  124373. /**
  124374. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124375. */
  124376. useAmbientInGrayScale: boolean;
  124377. /**
  124378. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124379. * The material will try to infer what glossiness each pixel should be.
  124380. */
  124381. useAutoMicroSurfaceFromReflectivityMap: boolean;
  124382. /**
  124383. * BJS is using an harcoded light falloff based on a manually sets up range.
  124384. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  124385. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  124386. */
  124387. get usePhysicalLightFalloff(): boolean;
  124388. /**
  124389. * BJS is using an harcoded light falloff based on a manually sets up range.
  124390. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  124391. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  124392. */
  124393. set usePhysicalLightFalloff(value: boolean);
  124394. /**
  124395. * In order to support the falloff compatibility with gltf, a special mode has been added
  124396. * to reproduce the gltf light falloff.
  124397. */
  124398. get useGLTFLightFalloff(): boolean;
  124399. /**
  124400. * In order to support the falloff compatibility with gltf, a special mode has been added
  124401. * to reproduce the gltf light falloff.
  124402. */
  124403. set useGLTFLightFalloff(value: boolean);
  124404. /**
  124405. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  124406. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  124407. */
  124408. useRadianceOverAlpha: boolean;
  124409. /**
  124410. * Allows using an object space normal map (instead of tangent space).
  124411. */
  124412. useObjectSpaceNormalMap: boolean;
  124413. /**
  124414. * Allows using the bump map in parallax mode.
  124415. */
  124416. useParallax: boolean;
  124417. /**
  124418. * Allows using the bump map in parallax occlusion mode.
  124419. */
  124420. useParallaxOcclusion: boolean;
  124421. /**
  124422. * Controls the scale bias of the parallax mode.
  124423. */
  124424. parallaxScaleBias: number;
  124425. /**
  124426. * If sets to true, disables all the lights affecting the material.
  124427. */
  124428. disableLighting: boolean;
  124429. /**
  124430. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  124431. */
  124432. forceIrradianceInFragment: boolean;
  124433. /**
  124434. * Number of Simultaneous lights allowed on the material.
  124435. */
  124436. maxSimultaneousLights: number;
  124437. /**
  124438. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  124439. */
  124440. invertNormalMapX: boolean;
  124441. /**
  124442. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  124443. */
  124444. invertNormalMapY: boolean;
  124445. /**
  124446. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124447. */
  124448. twoSidedLighting: boolean;
  124449. /**
  124450. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124451. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  124452. */
  124453. useAlphaFresnel: boolean;
  124454. /**
  124455. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124456. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  124457. */
  124458. useLinearAlphaFresnel: boolean;
  124459. /**
  124460. * Let user defines the brdf lookup texture used for IBL.
  124461. * A default 8bit version is embedded but you could point at :
  124462. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  124463. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  124464. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  124465. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  124466. */
  124467. environmentBRDFTexture: Nullable<BaseTexture>;
  124468. /**
  124469. * Force normal to face away from face.
  124470. */
  124471. forceNormalForward: boolean;
  124472. /**
  124473. * Enables specular anti aliasing in the PBR shader.
  124474. * It will both interacts on the Geometry for analytical and IBL lighting.
  124475. * It also prefilter the roughness map based on the bump values.
  124476. */
  124477. enableSpecularAntiAliasing: boolean;
  124478. /**
  124479. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  124480. * makes the reflect vector face the model (under horizon).
  124481. */
  124482. useHorizonOcclusion: boolean;
  124483. /**
  124484. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  124485. * too much the area relying on ambient texture to define their ambient occlusion.
  124486. */
  124487. useRadianceOcclusion: boolean;
  124488. /**
  124489. * If set to true, no lighting calculations will be applied.
  124490. */
  124491. unlit: boolean;
  124492. /**
  124493. * Gets the image processing configuration used either in this material.
  124494. */
  124495. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  124496. /**
  124497. * Sets the Default image processing configuration used either in the this material.
  124498. *
  124499. * If sets to null, the scene one is in use.
  124500. */
  124501. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  124502. /**
  124503. * Gets wether the color curves effect is enabled.
  124504. */
  124505. get cameraColorCurvesEnabled(): boolean;
  124506. /**
  124507. * Sets wether the color curves effect is enabled.
  124508. */
  124509. set cameraColorCurvesEnabled(value: boolean);
  124510. /**
  124511. * Gets wether the color grading effect is enabled.
  124512. */
  124513. get cameraColorGradingEnabled(): boolean;
  124514. /**
  124515. * Gets wether the color grading effect is enabled.
  124516. */
  124517. set cameraColorGradingEnabled(value: boolean);
  124518. /**
  124519. * Gets wether tonemapping is enabled or not.
  124520. */
  124521. get cameraToneMappingEnabled(): boolean;
  124522. /**
  124523. * Sets wether tonemapping is enabled or not
  124524. */
  124525. set cameraToneMappingEnabled(value: boolean);
  124526. /**
  124527. * The camera exposure used on this material.
  124528. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  124529. * This corresponds to a photographic exposure.
  124530. */
  124531. get cameraExposure(): number;
  124532. /**
  124533. * The camera exposure used on this material.
  124534. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  124535. * This corresponds to a photographic exposure.
  124536. */
  124537. set cameraExposure(value: number);
  124538. /**
  124539. * Gets The camera contrast used on this material.
  124540. */
  124541. get cameraContrast(): number;
  124542. /**
  124543. * Sets The camera contrast used on this material.
  124544. */
  124545. set cameraContrast(value: number);
  124546. /**
  124547. * Gets the Color Grading 2D Lookup Texture.
  124548. */
  124549. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  124550. /**
  124551. * Sets the Color Grading 2D Lookup Texture.
  124552. */
  124553. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  124554. /**
  124555. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  124556. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  124557. * 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;
  124558. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  124559. */
  124560. get cameraColorCurves(): Nullable<ColorCurves>;
  124561. /**
  124562. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  124563. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  124564. * 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;
  124565. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  124566. */
  124567. set cameraColorCurves(value: Nullable<ColorCurves>);
  124568. /**
  124569. * Instantiates a new PBRMaterial instance.
  124570. *
  124571. * @param name The material name
  124572. * @param scene The scene the material will be use in.
  124573. */
  124574. constructor(name: string, scene: Scene);
  124575. /**
  124576. * Returns the name of this material class.
  124577. */
  124578. getClassName(): string;
  124579. /**
  124580. * Makes a duplicate of the current material.
  124581. * @param name - name to use for the new material.
  124582. */
  124583. clone(name: string): PBRMaterial;
  124584. /**
  124585. * Serializes this PBR Material.
  124586. * @returns - An object with the serialized material.
  124587. */
  124588. serialize(): any;
  124589. /**
  124590. * Parses a PBR Material from a serialized object.
  124591. * @param source - Serialized object.
  124592. * @param scene - BJS scene instance.
  124593. * @param rootUrl - url for the scene object
  124594. * @returns - PBRMaterial
  124595. */
  124596. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  124597. }
  124598. }
  124599. declare module BABYLON {
  124600. /**
  124601. * Direct draw surface info
  124602. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  124603. */
  124604. export interface DDSInfo {
  124605. /**
  124606. * Width of the texture
  124607. */
  124608. width: number;
  124609. /**
  124610. * Width of the texture
  124611. */
  124612. height: number;
  124613. /**
  124614. * Number of Mipmaps for the texture
  124615. * @see https://en.wikipedia.org/wiki/Mipmap
  124616. */
  124617. mipmapCount: number;
  124618. /**
  124619. * If the textures format is a known fourCC format
  124620. * @see https://www.fourcc.org/
  124621. */
  124622. isFourCC: boolean;
  124623. /**
  124624. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  124625. */
  124626. isRGB: boolean;
  124627. /**
  124628. * If the texture is a lumincance format
  124629. */
  124630. isLuminance: boolean;
  124631. /**
  124632. * If this is a cube texture
  124633. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  124634. */
  124635. isCube: boolean;
  124636. /**
  124637. * If the texture is a compressed format eg. FOURCC_DXT1
  124638. */
  124639. isCompressed: boolean;
  124640. /**
  124641. * The dxgiFormat of the texture
  124642. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  124643. */
  124644. dxgiFormat: number;
  124645. /**
  124646. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  124647. */
  124648. textureType: number;
  124649. /**
  124650. * Sphericle polynomial created for the dds texture
  124651. */
  124652. sphericalPolynomial?: SphericalPolynomial;
  124653. }
  124654. /**
  124655. * Class used to provide DDS decompression tools
  124656. */
  124657. export class DDSTools {
  124658. /**
  124659. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  124660. */
  124661. static StoreLODInAlphaChannel: boolean;
  124662. /**
  124663. * Gets DDS information from an array buffer
  124664. * @param data defines the array buffer view to read data from
  124665. * @returns the DDS information
  124666. */
  124667. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  124668. private static _FloatView;
  124669. private static _Int32View;
  124670. private static _ToHalfFloat;
  124671. private static _FromHalfFloat;
  124672. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  124673. private static _GetHalfFloatRGBAArrayBuffer;
  124674. private static _GetFloatRGBAArrayBuffer;
  124675. private static _GetFloatAsUIntRGBAArrayBuffer;
  124676. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  124677. private static _GetRGBAArrayBuffer;
  124678. private static _ExtractLongWordOrder;
  124679. private static _GetRGBArrayBuffer;
  124680. private static _GetLuminanceArrayBuffer;
  124681. /**
  124682. * Uploads DDS Levels to a Babylon Texture
  124683. * @hidden
  124684. */
  124685. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  124686. }
  124687. interface ThinEngine {
  124688. /**
  124689. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  124690. * @param rootUrl defines the url where the file to load is located
  124691. * @param scene defines the current scene
  124692. * @param lodScale defines scale to apply to the mip map selection
  124693. * @param lodOffset defines offset to apply to the mip map selection
  124694. * @param onLoad defines an optional callback raised when the texture is loaded
  124695. * @param onError defines an optional callback raised if there is an issue to load the texture
  124696. * @param format defines the format of the data
  124697. * @param forcedExtension defines the extension to use to pick the right loader
  124698. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  124699. * @returns the cube texture as an InternalTexture
  124700. */
  124701. 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;
  124702. }
  124703. }
  124704. declare module BABYLON {
  124705. /**
  124706. * Implementation of the DDS Texture Loader.
  124707. * @hidden
  124708. */
  124709. export class _DDSTextureLoader implements IInternalTextureLoader {
  124710. /**
  124711. * Defines wether the loader supports cascade loading the different faces.
  124712. */
  124713. readonly supportCascades: boolean;
  124714. /**
  124715. * This returns if the loader support the current file information.
  124716. * @param extension defines the file extension of the file being loaded
  124717. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124718. * @param fallback defines the fallback internal texture if any
  124719. * @param isBase64 defines whether the texture is encoded as a base64
  124720. * @param isBuffer defines whether the texture data are stored as a buffer
  124721. * @returns true if the loader can load the specified file
  124722. */
  124723. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  124724. /**
  124725. * Transform the url before loading if required.
  124726. * @param rootUrl the url of the texture
  124727. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124728. * @returns the transformed texture
  124729. */
  124730. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  124731. /**
  124732. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  124733. * @param rootUrl the url of the texture
  124734. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124735. * @returns the fallback texture
  124736. */
  124737. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  124738. /**
  124739. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  124740. * @param data contains the texture data
  124741. * @param texture defines the BabylonJS internal texture
  124742. * @param createPolynomials will be true if polynomials have been requested
  124743. * @param onLoad defines the callback to trigger once the texture is ready
  124744. * @param onError defines the callback to trigger in case of error
  124745. */
  124746. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  124747. /**
  124748. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  124749. * @param data contains the texture data
  124750. * @param texture defines the BabylonJS internal texture
  124751. * @param callback defines the method to call once ready to upload
  124752. */
  124753. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  124754. }
  124755. }
  124756. declare module BABYLON {
  124757. /**
  124758. * Implementation of the ENV Texture Loader.
  124759. * @hidden
  124760. */
  124761. export class _ENVTextureLoader implements IInternalTextureLoader {
  124762. /**
  124763. * Defines wether the loader supports cascade loading the different faces.
  124764. */
  124765. readonly supportCascades: boolean;
  124766. /**
  124767. * This returns if the loader support the current file information.
  124768. * @param extension defines the file extension of the file being loaded
  124769. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124770. * @param fallback defines the fallback internal texture if any
  124771. * @param isBase64 defines whether the texture is encoded as a base64
  124772. * @param isBuffer defines whether the texture data are stored as a buffer
  124773. * @returns true if the loader can load the specified file
  124774. */
  124775. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  124776. /**
  124777. * Transform the url before loading if required.
  124778. * @param rootUrl the url of the texture
  124779. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124780. * @returns the transformed texture
  124781. */
  124782. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  124783. /**
  124784. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  124785. * @param rootUrl the url of the texture
  124786. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124787. * @returns the fallback texture
  124788. */
  124789. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  124790. /**
  124791. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  124792. * @param data contains the texture data
  124793. * @param texture defines the BabylonJS internal texture
  124794. * @param createPolynomials will be true if polynomials have been requested
  124795. * @param onLoad defines the callback to trigger once the texture is ready
  124796. * @param onError defines the callback to trigger in case of error
  124797. */
  124798. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  124799. /**
  124800. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  124801. * @param data contains the texture data
  124802. * @param texture defines the BabylonJS internal texture
  124803. * @param callback defines the method to call once ready to upload
  124804. */
  124805. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  124806. }
  124807. }
  124808. declare module BABYLON {
  124809. /**
  124810. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  124811. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  124812. */
  124813. export class KhronosTextureContainer {
  124814. /** contents of the KTX container file */
  124815. data: ArrayBufferView;
  124816. private static HEADER_LEN;
  124817. private static COMPRESSED_2D;
  124818. private static COMPRESSED_3D;
  124819. private static TEX_2D;
  124820. private static TEX_3D;
  124821. /**
  124822. * Gets the openGL type
  124823. */
  124824. glType: number;
  124825. /**
  124826. * Gets the openGL type size
  124827. */
  124828. glTypeSize: number;
  124829. /**
  124830. * Gets the openGL format
  124831. */
  124832. glFormat: number;
  124833. /**
  124834. * Gets the openGL internal format
  124835. */
  124836. glInternalFormat: number;
  124837. /**
  124838. * Gets the base internal format
  124839. */
  124840. glBaseInternalFormat: number;
  124841. /**
  124842. * Gets image width in pixel
  124843. */
  124844. pixelWidth: number;
  124845. /**
  124846. * Gets image height in pixel
  124847. */
  124848. pixelHeight: number;
  124849. /**
  124850. * Gets image depth in pixels
  124851. */
  124852. pixelDepth: number;
  124853. /**
  124854. * Gets the number of array elements
  124855. */
  124856. numberOfArrayElements: number;
  124857. /**
  124858. * Gets the number of faces
  124859. */
  124860. numberOfFaces: number;
  124861. /**
  124862. * Gets the number of mipmap levels
  124863. */
  124864. numberOfMipmapLevels: number;
  124865. /**
  124866. * Gets the bytes of key value data
  124867. */
  124868. bytesOfKeyValueData: number;
  124869. /**
  124870. * Gets the load type
  124871. */
  124872. loadType: number;
  124873. /**
  124874. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  124875. */
  124876. isInvalid: boolean;
  124877. /**
  124878. * Creates a new KhronosTextureContainer
  124879. * @param data contents of the KTX container file
  124880. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  124881. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  124882. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  124883. */
  124884. constructor(
  124885. /** contents of the KTX container file */
  124886. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  124887. /**
  124888. * Uploads KTX content to a Babylon Texture.
  124889. * It is assumed that the texture has already been created & is currently bound
  124890. * @hidden
  124891. */
  124892. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  124893. private _upload2DCompressedLevels;
  124894. }
  124895. }
  124896. declare module BABYLON {
  124897. /**
  124898. * Implementation of the KTX Texture Loader.
  124899. * @hidden
  124900. */
  124901. export class _KTXTextureLoader implements IInternalTextureLoader {
  124902. /**
  124903. * Defines wether the loader supports cascade loading the different faces.
  124904. */
  124905. readonly supportCascades: boolean;
  124906. /**
  124907. * This returns if the loader support the current file information.
  124908. * @param extension defines the file extension of the file being loaded
  124909. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124910. * @param fallback defines the fallback internal texture if any
  124911. * @param isBase64 defines whether the texture is encoded as a base64
  124912. * @param isBuffer defines whether the texture data are stored as a buffer
  124913. * @returns true if the loader can load the specified file
  124914. */
  124915. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  124916. /**
  124917. * Transform the url before loading if required.
  124918. * @param rootUrl the url of the texture
  124919. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124920. * @returns the transformed texture
  124921. */
  124922. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  124923. /**
  124924. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  124925. * @param rootUrl the url of the texture
  124926. * @param textureFormatInUse defines the current compressed format in use iun the engine
  124927. * @returns the fallback texture
  124928. */
  124929. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  124930. /**
  124931. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  124932. * @param data contains the texture data
  124933. * @param texture defines the BabylonJS internal texture
  124934. * @param createPolynomials will be true if polynomials have been requested
  124935. * @param onLoad defines the callback to trigger once the texture is ready
  124936. * @param onError defines the callback to trigger in case of error
  124937. */
  124938. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  124939. /**
  124940. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  124941. * @param data contains the texture data
  124942. * @param texture defines the BabylonJS internal texture
  124943. * @param callback defines the method to call once ready to upload
  124944. */
  124945. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  124946. }
  124947. }
  124948. declare module BABYLON {
  124949. /** @hidden */
  124950. export var _forceSceneHelpersToBundle: boolean;
  124951. interface Scene {
  124952. /**
  124953. * Creates a default light for the scene.
  124954. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  124955. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  124956. */
  124957. createDefaultLight(replace?: boolean): void;
  124958. /**
  124959. * Creates a default camera for the scene.
  124960. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  124961. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  124962. * @param replace has default false, when true replaces the active camera in the scene
  124963. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  124964. */
  124965. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  124966. /**
  124967. * Creates a default camera and a default light.
  124968. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  124969. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  124970. * @param replace has the default false, when true replaces the active camera/light in the scene
  124971. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  124972. */
  124973. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  124974. /**
  124975. * Creates a new sky box
  124976. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  124977. * @param environmentTexture defines the texture to use as environment texture
  124978. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  124979. * @param scale defines the overall scale of the skybox
  124980. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  124981. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  124982. * @returns a new mesh holding the sky box
  124983. */
  124984. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  124985. /**
  124986. * Creates a new environment
  124987. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  124988. * @param options defines the options you can use to configure the environment
  124989. * @returns the new EnvironmentHelper
  124990. */
  124991. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  124992. /**
  124993. * Creates a new VREXperienceHelper
  124994. * @see http://doc.babylonjs.com/how_to/webvr_helper
  124995. * @param webVROptions defines the options used to create the new VREXperienceHelper
  124996. * @returns a new VREXperienceHelper
  124997. */
  124998. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  124999. /**
  125000. * Creates a new WebXRDefaultExperience
  125001. * @see http://doc.babylonjs.com/how_to/webxr
  125002. * @param options experience options
  125003. * @returns a promise for a new WebXRDefaultExperience
  125004. */
  125005. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  125006. }
  125007. }
  125008. declare module BABYLON {
  125009. /**
  125010. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  125011. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  125012. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  125013. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  125014. */
  125015. export class VideoDome extends TransformNode {
  125016. /**
  125017. * Define the video source as a Monoscopic panoramic 360 video.
  125018. */
  125019. static readonly MODE_MONOSCOPIC: number;
  125020. /**
  125021. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125022. */
  125023. static readonly MODE_TOPBOTTOM: number;
  125024. /**
  125025. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125026. */
  125027. static readonly MODE_SIDEBYSIDE: number;
  125028. private _halfDome;
  125029. private _useDirectMapping;
  125030. /**
  125031. * The video texture being displayed on the sphere
  125032. */
  125033. protected _videoTexture: VideoTexture;
  125034. /**
  125035. * Gets the video texture being displayed on the sphere
  125036. */
  125037. get videoTexture(): VideoTexture;
  125038. /**
  125039. * The skybox material
  125040. */
  125041. protected _material: BackgroundMaterial;
  125042. /**
  125043. * The surface used for the skybox
  125044. */
  125045. protected _mesh: Mesh;
  125046. /**
  125047. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  125048. */
  125049. private _halfDomeMask;
  125050. /**
  125051. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  125052. * Also see the options.resolution property.
  125053. */
  125054. get fovMultiplier(): number;
  125055. set fovMultiplier(value: number);
  125056. private _videoMode;
  125057. /**
  125058. * Gets or set the current video mode for the video. It can be:
  125059. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  125060. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125061. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125062. */
  125063. get videoMode(): number;
  125064. set videoMode(value: number);
  125065. /**
  125066. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  125067. *
  125068. */
  125069. get halfDome(): boolean;
  125070. /**
  125071. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  125072. */
  125073. set halfDome(enabled: boolean);
  125074. /**
  125075. * Oberserver used in Stereoscopic VR Mode.
  125076. */
  125077. private _onBeforeCameraRenderObserver;
  125078. /**
  125079. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  125080. * @param name Element's name, child elements will append suffixes for their own names.
  125081. * @param urlsOrVideo defines the url(s) or the video element to use
  125082. * @param options An object containing optional or exposed sub element properties
  125083. */
  125084. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  125085. resolution?: number;
  125086. clickToPlay?: boolean;
  125087. autoPlay?: boolean;
  125088. loop?: boolean;
  125089. size?: number;
  125090. poster?: string;
  125091. faceForward?: boolean;
  125092. useDirectMapping?: boolean;
  125093. halfDomeMode?: boolean;
  125094. }, scene: Scene);
  125095. private _changeVideoMode;
  125096. /**
  125097. * Releases resources associated with this node.
  125098. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  125099. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  125100. */
  125101. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  125102. }
  125103. }
  125104. declare module BABYLON {
  125105. /**
  125106. * This class can be used to get instrumentation data from a Babylon engine
  125107. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125108. */
  125109. export class EngineInstrumentation implements IDisposable {
  125110. /**
  125111. * Define the instrumented engine.
  125112. */
  125113. engine: Engine;
  125114. private _captureGPUFrameTime;
  125115. private _gpuFrameTimeToken;
  125116. private _gpuFrameTime;
  125117. private _captureShaderCompilationTime;
  125118. private _shaderCompilationTime;
  125119. private _onBeginFrameObserver;
  125120. private _onEndFrameObserver;
  125121. private _onBeforeShaderCompilationObserver;
  125122. private _onAfterShaderCompilationObserver;
  125123. /**
  125124. * Gets the perf counter used for GPU frame time
  125125. */
  125126. get gpuFrameTimeCounter(): PerfCounter;
  125127. /**
  125128. * Gets the GPU frame time capture status
  125129. */
  125130. get captureGPUFrameTime(): boolean;
  125131. /**
  125132. * Enable or disable the GPU frame time capture
  125133. */
  125134. set captureGPUFrameTime(value: boolean);
  125135. /**
  125136. * Gets the perf counter used for shader compilation time
  125137. */
  125138. get shaderCompilationTimeCounter(): PerfCounter;
  125139. /**
  125140. * Gets the shader compilation time capture status
  125141. */
  125142. get captureShaderCompilationTime(): boolean;
  125143. /**
  125144. * Enable or disable the shader compilation time capture
  125145. */
  125146. set captureShaderCompilationTime(value: boolean);
  125147. /**
  125148. * Instantiates a new engine instrumentation.
  125149. * This class can be used to get instrumentation data from a Babylon engine
  125150. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125151. * @param engine Defines the engine to instrument
  125152. */
  125153. constructor(
  125154. /**
  125155. * Define the instrumented engine.
  125156. */
  125157. engine: Engine);
  125158. /**
  125159. * Dispose and release associated resources.
  125160. */
  125161. dispose(): void;
  125162. }
  125163. }
  125164. declare module BABYLON {
  125165. /**
  125166. * This class can be used to get instrumentation data from a Babylon engine
  125167. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125168. */
  125169. export class SceneInstrumentation implements IDisposable {
  125170. /**
  125171. * Defines the scene to instrument
  125172. */
  125173. scene: Scene;
  125174. private _captureActiveMeshesEvaluationTime;
  125175. private _activeMeshesEvaluationTime;
  125176. private _captureRenderTargetsRenderTime;
  125177. private _renderTargetsRenderTime;
  125178. private _captureFrameTime;
  125179. private _frameTime;
  125180. private _captureRenderTime;
  125181. private _renderTime;
  125182. private _captureInterFrameTime;
  125183. private _interFrameTime;
  125184. private _captureParticlesRenderTime;
  125185. private _particlesRenderTime;
  125186. private _captureSpritesRenderTime;
  125187. private _spritesRenderTime;
  125188. private _capturePhysicsTime;
  125189. private _physicsTime;
  125190. private _captureAnimationsTime;
  125191. private _animationsTime;
  125192. private _captureCameraRenderTime;
  125193. private _cameraRenderTime;
  125194. private _onBeforeActiveMeshesEvaluationObserver;
  125195. private _onAfterActiveMeshesEvaluationObserver;
  125196. private _onBeforeRenderTargetsRenderObserver;
  125197. private _onAfterRenderTargetsRenderObserver;
  125198. private _onAfterRenderObserver;
  125199. private _onBeforeDrawPhaseObserver;
  125200. private _onAfterDrawPhaseObserver;
  125201. private _onBeforeAnimationsObserver;
  125202. private _onBeforeParticlesRenderingObserver;
  125203. private _onAfterParticlesRenderingObserver;
  125204. private _onBeforeSpritesRenderingObserver;
  125205. private _onAfterSpritesRenderingObserver;
  125206. private _onBeforePhysicsObserver;
  125207. private _onAfterPhysicsObserver;
  125208. private _onAfterAnimationsObserver;
  125209. private _onBeforeCameraRenderObserver;
  125210. private _onAfterCameraRenderObserver;
  125211. /**
  125212. * Gets the perf counter used for active meshes evaluation time
  125213. */
  125214. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  125215. /**
  125216. * Gets the active meshes evaluation time capture status
  125217. */
  125218. get captureActiveMeshesEvaluationTime(): boolean;
  125219. /**
  125220. * Enable or disable the active meshes evaluation time capture
  125221. */
  125222. set captureActiveMeshesEvaluationTime(value: boolean);
  125223. /**
  125224. * Gets the perf counter used for render targets render time
  125225. */
  125226. get renderTargetsRenderTimeCounter(): PerfCounter;
  125227. /**
  125228. * Gets the render targets render time capture status
  125229. */
  125230. get captureRenderTargetsRenderTime(): boolean;
  125231. /**
  125232. * Enable or disable the render targets render time capture
  125233. */
  125234. set captureRenderTargetsRenderTime(value: boolean);
  125235. /**
  125236. * Gets the perf counter used for particles render time
  125237. */
  125238. get particlesRenderTimeCounter(): PerfCounter;
  125239. /**
  125240. * Gets the particles render time capture status
  125241. */
  125242. get captureParticlesRenderTime(): boolean;
  125243. /**
  125244. * Enable or disable the particles render time capture
  125245. */
  125246. set captureParticlesRenderTime(value: boolean);
  125247. /**
  125248. * Gets the perf counter used for sprites render time
  125249. */
  125250. get spritesRenderTimeCounter(): PerfCounter;
  125251. /**
  125252. * Gets the sprites render time capture status
  125253. */
  125254. get captureSpritesRenderTime(): boolean;
  125255. /**
  125256. * Enable or disable the sprites render time capture
  125257. */
  125258. set captureSpritesRenderTime(value: boolean);
  125259. /**
  125260. * Gets the perf counter used for physics time
  125261. */
  125262. get physicsTimeCounter(): PerfCounter;
  125263. /**
  125264. * Gets the physics time capture status
  125265. */
  125266. get capturePhysicsTime(): boolean;
  125267. /**
  125268. * Enable or disable the physics time capture
  125269. */
  125270. set capturePhysicsTime(value: boolean);
  125271. /**
  125272. * Gets the perf counter used for animations time
  125273. */
  125274. get animationsTimeCounter(): PerfCounter;
  125275. /**
  125276. * Gets the animations time capture status
  125277. */
  125278. get captureAnimationsTime(): boolean;
  125279. /**
  125280. * Enable or disable the animations time capture
  125281. */
  125282. set captureAnimationsTime(value: boolean);
  125283. /**
  125284. * Gets the perf counter used for frame time capture
  125285. */
  125286. get frameTimeCounter(): PerfCounter;
  125287. /**
  125288. * Gets the frame time capture status
  125289. */
  125290. get captureFrameTime(): boolean;
  125291. /**
  125292. * Enable or disable the frame time capture
  125293. */
  125294. set captureFrameTime(value: boolean);
  125295. /**
  125296. * Gets the perf counter used for inter-frames time capture
  125297. */
  125298. get interFrameTimeCounter(): PerfCounter;
  125299. /**
  125300. * Gets the inter-frames time capture status
  125301. */
  125302. get captureInterFrameTime(): boolean;
  125303. /**
  125304. * Enable or disable the inter-frames time capture
  125305. */
  125306. set captureInterFrameTime(value: boolean);
  125307. /**
  125308. * Gets the perf counter used for render time capture
  125309. */
  125310. get renderTimeCounter(): PerfCounter;
  125311. /**
  125312. * Gets the render time capture status
  125313. */
  125314. get captureRenderTime(): boolean;
  125315. /**
  125316. * Enable or disable the render time capture
  125317. */
  125318. set captureRenderTime(value: boolean);
  125319. /**
  125320. * Gets the perf counter used for camera render time capture
  125321. */
  125322. get cameraRenderTimeCounter(): PerfCounter;
  125323. /**
  125324. * Gets the camera render time capture status
  125325. */
  125326. get captureCameraRenderTime(): boolean;
  125327. /**
  125328. * Enable or disable the camera render time capture
  125329. */
  125330. set captureCameraRenderTime(value: boolean);
  125331. /**
  125332. * Gets the perf counter used for draw calls
  125333. */
  125334. get drawCallsCounter(): PerfCounter;
  125335. /**
  125336. * Instantiates a new scene instrumentation.
  125337. * This class can be used to get instrumentation data from a Babylon engine
  125338. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125339. * @param scene Defines the scene to instrument
  125340. */
  125341. constructor(
  125342. /**
  125343. * Defines the scene to instrument
  125344. */
  125345. scene: Scene);
  125346. /**
  125347. * Dispose and release associated resources.
  125348. */
  125349. dispose(): void;
  125350. }
  125351. }
  125352. declare module BABYLON {
  125353. /** @hidden */
  125354. export var glowMapGenerationPixelShader: {
  125355. name: string;
  125356. shader: string;
  125357. };
  125358. }
  125359. declare module BABYLON {
  125360. /** @hidden */
  125361. export var glowMapGenerationVertexShader: {
  125362. name: string;
  125363. shader: string;
  125364. };
  125365. }
  125366. declare module BABYLON {
  125367. /**
  125368. * Effect layer options. This helps customizing the behaviour
  125369. * of the effect layer.
  125370. */
  125371. export interface IEffectLayerOptions {
  125372. /**
  125373. * Multiplication factor apply to the canvas size to compute the render target size
  125374. * used to generated the objects (the smaller the faster).
  125375. */
  125376. mainTextureRatio: number;
  125377. /**
  125378. * Enforces a fixed size texture to ensure effect stability across devices.
  125379. */
  125380. mainTextureFixedSize?: number;
  125381. /**
  125382. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  125383. */
  125384. alphaBlendingMode: number;
  125385. /**
  125386. * The camera attached to the layer.
  125387. */
  125388. camera: Nullable<Camera>;
  125389. /**
  125390. * The rendering group to draw the layer in.
  125391. */
  125392. renderingGroupId: number;
  125393. }
  125394. /**
  125395. * The effect layer Helps adding post process effect blended with the main pass.
  125396. *
  125397. * This can be for instance use to generate glow or higlight effects on the scene.
  125398. *
  125399. * The effect layer class can not be used directly and is intented to inherited from to be
  125400. * customized per effects.
  125401. */
  125402. export abstract class EffectLayer {
  125403. private _vertexBuffers;
  125404. private _indexBuffer;
  125405. private _cachedDefines;
  125406. private _effectLayerMapGenerationEffect;
  125407. private _effectLayerOptions;
  125408. private _mergeEffect;
  125409. protected _scene: Scene;
  125410. protected _engine: Engine;
  125411. protected _maxSize: number;
  125412. protected _mainTextureDesiredSize: ISize;
  125413. protected _mainTexture: RenderTargetTexture;
  125414. protected _shouldRender: boolean;
  125415. protected _postProcesses: PostProcess[];
  125416. protected _textures: BaseTexture[];
  125417. protected _emissiveTextureAndColor: {
  125418. texture: Nullable<BaseTexture>;
  125419. color: Color4;
  125420. };
  125421. /**
  125422. * The name of the layer
  125423. */
  125424. name: string;
  125425. /**
  125426. * The clear color of the texture used to generate the glow map.
  125427. */
  125428. neutralColor: Color4;
  125429. /**
  125430. * Specifies whether the highlight layer is enabled or not.
  125431. */
  125432. isEnabled: boolean;
  125433. /**
  125434. * Gets the camera attached to the layer.
  125435. */
  125436. get camera(): Nullable<Camera>;
  125437. /**
  125438. * Gets the rendering group id the layer should render in.
  125439. */
  125440. get renderingGroupId(): number;
  125441. set renderingGroupId(renderingGroupId: number);
  125442. /**
  125443. * An event triggered when the effect layer has been disposed.
  125444. */
  125445. onDisposeObservable: Observable<EffectLayer>;
  125446. /**
  125447. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  125448. */
  125449. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  125450. /**
  125451. * An event triggered when the generated texture is being merged in the scene.
  125452. */
  125453. onBeforeComposeObservable: Observable<EffectLayer>;
  125454. /**
  125455. * An event triggered when the mesh is rendered into the effect render target.
  125456. */
  125457. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  125458. /**
  125459. * An event triggered after the mesh has been rendered into the effect render target.
  125460. */
  125461. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  125462. /**
  125463. * An event triggered when the generated texture has been merged in the scene.
  125464. */
  125465. onAfterComposeObservable: Observable<EffectLayer>;
  125466. /**
  125467. * An event triggered when the efffect layer changes its size.
  125468. */
  125469. onSizeChangedObservable: Observable<EffectLayer>;
  125470. /** @hidden */
  125471. static _SceneComponentInitialization: (scene: Scene) => void;
  125472. /**
  125473. * Instantiates a new effect Layer and references it in the scene.
  125474. * @param name The name of the layer
  125475. * @param scene The scene to use the layer in
  125476. */
  125477. constructor(
  125478. /** The Friendly of the effect in the scene */
  125479. name: string, scene: Scene);
  125480. /**
  125481. * Get the effect name of the layer.
  125482. * @return The effect name
  125483. */
  125484. abstract getEffectName(): string;
  125485. /**
  125486. * Checks for the readiness of the element composing the layer.
  125487. * @param subMesh the mesh to check for
  125488. * @param useInstances specify whether or not to use instances to render the mesh
  125489. * @return true if ready otherwise, false
  125490. */
  125491. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  125492. /**
  125493. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  125494. * @returns true if the effect requires stencil during the main canvas render pass.
  125495. */
  125496. abstract needStencil(): boolean;
  125497. /**
  125498. * Create the merge effect. This is the shader use to blit the information back
  125499. * to the main canvas at the end of the scene rendering.
  125500. * @returns The effect containing the shader used to merge the effect on the main canvas
  125501. */
  125502. protected abstract _createMergeEffect(): Effect;
  125503. /**
  125504. * Creates the render target textures and post processes used in the effect layer.
  125505. */
  125506. protected abstract _createTextureAndPostProcesses(): void;
  125507. /**
  125508. * Implementation specific of rendering the generating effect on the main canvas.
  125509. * @param effect The effect used to render through
  125510. */
  125511. protected abstract _internalRender(effect: Effect): void;
  125512. /**
  125513. * Sets the required values for both the emissive texture and and the main color.
  125514. */
  125515. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  125516. /**
  125517. * Free any resources and references associated to a mesh.
  125518. * Internal use
  125519. * @param mesh The mesh to free.
  125520. */
  125521. abstract _disposeMesh(mesh: Mesh): void;
  125522. /**
  125523. * Serializes this layer (Glow or Highlight for example)
  125524. * @returns a serialized layer object
  125525. */
  125526. abstract serialize?(): any;
  125527. /**
  125528. * Initializes the effect layer with the required options.
  125529. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  125530. */
  125531. protected _init(options: Partial<IEffectLayerOptions>): void;
  125532. /**
  125533. * Generates the index buffer of the full screen quad blending to the main canvas.
  125534. */
  125535. private _generateIndexBuffer;
  125536. /**
  125537. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  125538. */
  125539. private _generateVertexBuffer;
  125540. /**
  125541. * Sets the main texture desired size which is the closest power of two
  125542. * of the engine canvas size.
  125543. */
  125544. private _setMainTextureSize;
  125545. /**
  125546. * Creates the main texture for the effect layer.
  125547. */
  125548. protected _createMainTexture(): void;
  125549. /**
  125550. * Adds specific effects defines.
  125551. * @param defines The defines to add specifics to.
  125552. */
  125553. protected _addCustomEffectDefines(defines: string[]): void;
  125554. /**
  125555. * Checks for the readiness of the element composing the layer.
  125556. * @param subMesh the mesh to check for
  125557. * @param useInstances specify whether or not to use instances to render the mesh
  125558. * @param emissiveTexture the associated emissive texture used to generate the glow
  125559. * @return true if ready otherwise, false
  125560. */
  125561. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  125562. /**
  125563. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  125564. */
  125565. render(): void;
  125566. /**
  125567. * Determine if a given mesh will be used in the current effect.
  125568. * @param mesh mesh to test
  125569. * @returns true if the mesh will be used
  125570. */
  125571. hasMesh(mesh: AbstractMesh): boolean;
  125572. /**
  125573. * Returns true if the layer contains information to display, otherwise false.
  125574. * @returns true if the glow layer should be rendered
  125575. */
  125576. shouldRender(): boolean;
  125577. /**
  125578. * Returns true if the mesh should render, otherwise false.
  125579. * @param mesh The mesh to render
  125580. * @returns true if it should render otherwise false
  125581. */
  125582. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  125583. /**
  125584. * Returns true if the mesh can be rendered, otherwise false.
  125585. * @param mesh The mesh to render
  125586. * @param material The material used on the mesh
  125587. * @returns true if it can be rendered otherwise false
  125588. */
  125589. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  125590. /**
  125591. * Returns true if the mesh should render, otherwise false.
  125592. * @param mesh The mesh to render
  125593. * @returns true if it should render otherwise false
  125594. */
  125595. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  125596. /**
  125597. * Renders the submesh passed in parameter to the generation map.
  125598. */
  125599. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  125600. /**
  125601. * Defines whether the current material of the mesh should be use to render the effect.
  125602. * @param mesh defines the current mesh to render
  125603. */
  125604. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  125605. /**
  125606. * Rebuild the required buffers.
  125607. * @hidden Internal use only.
  125608. */
  125609. _rebuild(): void;
  125610. /**
  125611. * Dispose only the render target textures and post process.
  125612. */
  125613. private _disposeTextureAndPostProcesses;
  125614. /**
  125615. * Dispose the highlight layer and free resources.
  125616. */
  125617. dispose(): void;
  125618. /**
  125619. * Gets the class name of the effect layer
  125620. * @returns the string with the class name of the effect layer
  125621. */
  125622. getClassName(): string;
  125623. /**
  125624. * Creates an effect layer from parsed effect layer data
  125625. * @param parsedEffectLayer defines effect layer data
  125626. * @param scene defines the current scene
  125627. * @param rootUrl defines the root URL containing the effect layer information
  125628. * @returns a parsed effect Layer
  125629. */
  125630. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  125631. }
  125632. }
  125633. declare module BABYLON {
  125634. interface AbstractScene {
  125635. /**
  125636. * The list of effect layers (highlights/glow) added to the scene
  125637. * @see http://doc.babylonjs.com/how_to/highlight_layer
  125638. * @see http://doc.babylonjs.com/how_to/glow_layer
  125639. */
  125640. effectLayers: Array<EffectLayer>;
  125641. /**
  125642. * Removes the given effect layer from this scene.
  125643. * @param toRemove defines the effect layer to remove
  125644. * @returns the index of the removed effect layer
  125645. */
  125646. removeEffectLayer(toRemove: EffectLayer): number;
  125647. /**
  125648. * Adds the given effect layer to this scene
  125649. * @param newEffectLayer defines the effect layer to add
  125650. */
  125651. addEffectLayer(newEffectLayer: EffectLayer): void;
  125652. }
  125653. /**
  125654. * Defines the layer scene component responsible to manage any effect layers
  125655. * in a given scene.
  125656. */
  125657. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  125658. /**
  125659. * The component name helpfull to identify the component in the list of scene components.
  125660. */
  125661. readonly name: string;
  125662. /**
  125663. * The scene the component belongs to.
  125664. */
  125665. scene: Scene;
  125666. private _engine;
  125667. private _renderEffects;
  125668. private _needStencil;
  125669. private _previousStencilState;
  125670. /**
  125671. * Creates a new instance of the component for the given scene
  125672. * @param scene Defines the scene to register the component in
  125673. */
  125674. constructor(scene: Scene);
  125675. /**
  125676. * Registers the component in a given scene
  125677. */
  125678. register(): void;
  125679. /**
  125680. * Rebuilds the elements related to this component in case of
  125681. * context lost for instance.
  125682. */
  125683. rebuild(): void;
  125684. /**
  125685. * Serializes the component data to the specified json object
  125686. * @param serializationObject The object to serialize to
  125687. */
  125688. serialize(serializationObject: any): void;
  125689. /**
  125690. * Adds all the elements from the container to the scene
  125691. * @param container the container holding the elements
  125692. */
  125693. addFromContainer(container: AbstractScene): void;
  125694. /**
  125695. * Removes all the elements in the container from the scene
  125696. * @param container contains the elements to remove
  125697. * @param dispose if the removed element should be disposed (default: false)
  125698. */
  125699. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  125700. /**
  125701. * Disposes the component and the associated ressources.
  125702. */
  125703. dispose(): void;
  125704. private _isReadyForMesh;
  125705. private _renderMainTexture;
  125706. private _setStencil;
  125707. private _setStencilBack;
  125708. private _draw;
  125709. private _drawCamera;
  125710. private _drawRenderingGroup;
  125711. }
  125712. }
  125713. declare module BABYLON {
  125714. /** @hidden */
  125715. export var glowMapMergePixelShader: {
  125716. name: string;
  125717. shader: string;
  125718. };
  125719. }
  125720. declare module BABYLON {
  125721. /** @hidden */
  125722. export var glowMapMergeVertexShader: {
  125723. name: string;
  125724. shader: string;
  125725. };
  125726. }
  125727. declare module BABYLON {
  125728. interface AbstractScene {
  125729. /**
  125730. * Return a the first highlight layer of the scene with a given name.
  125731. * @param name The name of the highlight layer to look for.
  125732. * @return The highlight layer if found otherwise null.
  125733. */
  125734. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  125735. }
  125736. /**
  125737. * Glow layer options. This helps customizing the behaviour
  125738. * of the glow layer.
  125739. */
  125740. export interface IGlowLayerOptions {
  125741. /**
  125742. * Multiplication factor apply to the canvas size to compute the render target size
  125743. * used to generated the glowing objects (the smaller the faster).
  125744. */
  125745. mainTextureRatio: number;
  125746. /**
  125747. * Enforces a fixed size texture to ensure resize independant blur.
  125748. */
  125749. mainTextureFixedSize?: number;
  125750. /**
  125751. * How big is the kernel of the blur texture.
  125752. */
  125753. blurKernelSize: number;
  125754. /**
  125755. * The camera attached to the layer.
  125756. */
  125757. camera: Nullable<Camera>;
  125758. /**
  125759. * Enable MSAA by chosing the number of samples.
  125760. */
  125761. mainTextureSamples?: number;
  125762. /**
  125763. * The rendering group to draw the layer in.
  125764. */
  125765. renderingGroupId: number;
  125766. }
  125767. /**
  125768. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  125769. *
  125770. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  125771. *
  125772. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  125773. */
  125774. export class GlowLayer extends EffectLayer {
  125775. /**
  125776. * Effect Name of the layer.
  125777. */
  125778. static readonly EffectName: string;
  125779. /**
  125780. * The default blur kernel size used for the glow.
  125781. */
  125782. static DefaultBlurKernelSize: number;
  125783. /**
  125784. * The default texture size ratio used for the glow.
  125785. */
  125786. static DefaultTextureRatio: number;
  125787. /**
  125788. * Sets the kernel size of the blur.
  125789. */
  125790. set blurKernelSize(value: number);
  125791. /**
  125792. * Gets the kernel size of the blur.
  125793. */
  125794. get blurKernelSize(): number;
  125795. /**
  125796. * Sets the glow intensity.
  125797. */
  125798. set intensity(value: number);
  125799. /**
  125800. * Gets the glow intensity.
  125801. */
  125802. get intensity(): number;
  125803. private _options;
  125804. private _intensity;
  125805. private _horizontalBlurPostprocess1;
  125806. private _verticalBlurPostprocess1;
  125807. private _horizontalBlurPostprocess2;
  125808. private _verticalBlurPostprocess2;
  125809. private _blurTexture1;
  125810. private _blurTexture2;
  125811. private _postProcesses1;
  125812. private _postProcesses2;
  125813. private _includedOnlyMeshes;
  125814. private _excludedMeshes;
  125815. private _meshesUsingTheirOwnMaterials;
  125816. /**
  125817. * Callback used to let the user override the color selection on a per mesh basis
  125818. */
  125819. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  125820. /**
  125821. * Callback used to let the user override the texture selection on a per mesh basis
  125822. */
  125823. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  125824. /**
  125825. * Instantiates a new glow Layer and references it to the scene.
  125826. * @param name The name of the layer
  125827. * @param scene The scene to use the layer in
  125828. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  125829. */
  125830. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  125831. /**
  125832. * Get the effect name of the layer.
  125833. * @return The effect name
  125834. */
  125835. getEffectName(): string;
  125836. /**
  125837. * Create the merge effect. This is the shader use to blit the information back
  125838. * to the main canvas at the end of the scene rendering.
  125839. */
  125840. protected _createMergeEffect(): Effect;
  125841. /**
  125842. * Creates the render target textures and post processes used in the glow layer.
  125843. */
  125844. protected _createTextureAndPostProcesses(): void;
  125845. /**
  125846. * Checks for the readiness of the element composing the layer.
  125847. * @param subMesh the mesh to check for
  125848. * @param useInstances specify wether or not to use instances to render the mesh
  125849. * @param emissiveTexture the associated emissive texture used to generate the glow
  125850. * @return true if ready otherwise, false
  125851. */
  125852. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  125853. /**
  125854. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  125855. */
  125856. needStencil(): boolean;
  125857. /**
  125858. * Returns true if the mesh can be rendered, otherwise false.
  125859. * @param mesh The mesh to render
  125860. * @param material The material used on the mesh
  125861. * @returns true if it can be rendered otherwise false
  125862. */
  125863. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  125864. /**
  125865. * Implementation specific of rendering the generating effect on the main canvas.
  125866. * @param effect The effect used to render through
  125867. */
  125868. protected _internalRender(effect: Effect): void;
  125869. /**
  125870. * Sets the required values for both the emissive texture and and the main color.
  125871. */
  125872. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  125873. /**
  125874. * Returns true if the mesh should render, otherwise false.
  125875. * @param mesh The mesh to render
  125876. * @returns true if it should render otherwise false
  125877. */
  125878. protected _shouldRenderMesh(mesh: Mesh): boolean;
  125879. /**
  125880. * Adds specific effects defines.
  125881. * @param defines The defines to add specifics to.
  125882. */
  125883. protected _addCustomEffectDefines(defines: string[]): void;
  125884. /**
  125885. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  125886. * @param mesh The mesh to exclude from the glow layer
  125887. */
  125888. addExcludedMesh(mesh: Mesh): void;
  125889. /**
  125890. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  125891. * @param mesh The mesh to remove
  125892. */
  125893. removeExcludedMesh(mesh: Mesh): void;
  125894. /**
  125895. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  125896. * @param mesh The mesh to include in the glow layer
  125897. */
  125898. addIncludedOnlyMesh(mesh: Mesh): void;
  125899. /**
  125900. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  125901. * @param mesh The mesh to remove
  125902. */
  125903. removeIncludedOnlyMesh(mesh: Mesh): void;
  125904. /**
  125905. * Determine if a given mesh will be used in the glow layer
  125906. * @param mesh The mesh to test
  125907. * @returns true if the mesh will be highlighted by the current glow layer
  125908. */
  125909. hasMesh(mesh: AbstractMesh): boolean;
  125910. /**
  125911. * Defines whether the current material of the mesh should be use to render the effect.
  125912. * @param mesh defines the current mesh to render
  125913. */
  125914. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  125915. /**
  125916. * Add a mesh to be rendered through its own material and not with emissive only.
  125917. * @param mesh The mesh for which we need to use its material
  125918. */
  125919. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  125920. /**
  125921. * Remove a mesh from being rendered through its own material and not with emissive only.
  125922. * @param mesh The mesh for which we need to not use its material
  125923. */
  125924. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  125925. /**
  125926. * Free any resources and references associated to a mesh.
  125927. * Internal use
  125928. * @param mesh The mesh to free.
  125929. * @hidden
  125930. */
  125931. _disposeMesh(mesh: Mesh): void;
  125932. /**
  125933. * Gets the class name of the effect layer
  125934. * @returns the string with the class name of the effect layer
  125935. */
  125936. getClassName(): string;
  125937. /**
  125938. * Serializes this glow layer
  125939. * @returns a serialized glow layer object
  125940. */
  125941. serialize(): any;
  125942. /**
  125943. * Creates a Glow Layer from parsed glow layer data
  125944. * @param parsedGlowLayer defines glow layer data
  125945. * @param scene defines the current scene
  125946. * @param rootUrl defines the root URL containing the glow layer information
  125947. * @returns a parsed Glow Layer
  125948. */
  125949. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  125950. }
  125951. }
  125952. declare module BABYLON {
  125953. /** @hidden */
  125954. export var glowBlurPostProcessPixelShader: {
  125955. name: string;
  125956. shader: string;
  125957. };
  125958. }
  125959. declare module BABYLON {
  125960. interface AbstractScene {
  125961. /**
  125962. * Return a the first highlight layer of the scene with a given name.
  125963. * @param name The name of the highlight layer to look for.
  125964. * @return The highlight layer if found otherwise null.
  125965. */
  125966. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  125967. }
  125968. /**
  125969. * Highlight layer options. This helps customizing the behaviour
  125970. * of the highlight layer.
  125971. */
  125972. export interface IHighlightLayerOptions {
  125973. /**
  125974. * Multiplication factor apply to the canvas size to compute the render target size
  125975. * used to generated the glowing objects (the smaller the faster).
  125976. */
  125977. mainTextureRatio: number;
  125978. /**
  125979. * Enforces a fixed size texture to ensure resize independant blur.
  125980. */
  125981. mainTextureFixedSize?: number;
  125982. /**
  125983. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  125984. * of the picture to blur (the smaller the faster).
  125985. */
  125986. blurTextureSizeRatio: number;
  125987. /**
  125988. * How big in texel of the blur texture is the vertical blur.
  125989. */
  125990. blurVerticalSize: number;
  125991. /**
  125992. * How big in texel of the blur texture is the horizontal blur.
  125993. */
  125994. blurHorizontalSize: number;
  125995. /**
  125996. * Alpha blending mode used to apply the blur. Default is combine.
  125997. */
  125998. alphaBlendingMode: number;
  125999. /**
  126000. * The camera attached to the layer.
  126001. */
  126002. camera: Nullable<Camera>;
  126003. /**
  126004. * Should we display highlight as a solid stroke?
  126005. */
  126006. isStroke?: boolean;
  126007. /**
  126008. * The rendering group to draw the layer in.
  126009. */
  126010. renderingGroupId: number;
  126011. }
  126012. /**
  126013. * The highlight layer Helps adding a glow effect around a mesh.
  126014. *
  126015. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  126016. * glowy meshes to your scene.
  126017. *
  126018. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  126019. */
  126020. export class HighlightLayer extends EffectLayer {
  126021. name: string;
  126022. /**
  126023. * Effect Name of the highlight layer.
  126024. */
  126025. static readonly EffectName: string;
  126026. /**
  126027. * The neutral color used during the preparation of the glow effect.
  126028. * This is black by default as the blend operation is a blend operation.
  126029. */
  126030. static NeutralColor: Color4;
  126031. /**
  126032. * Stencil value used for glowing meshes.
  126033. */
  126034. static GlowingMeshStencilReference: number;
  126035. /**
  126036. * Stencil value used for the other meshes in the scene.
  126037. */
  126038. static NormalMeshStencilReference: number;
  126039. /**
  126040. * Specifies whether or not the inner glow is ACTIVE in the layer.
  126041. */
  126042. innerGlow: boolean;
  126043. /**
  126044. * Specifies whether or not the outer glow is ACTIVE in the layer.
  126045. */
  126046. outerGlow: boolean;
  126047. /**
  126048. * Specifies the horizontal size of the blur.
  126049. */
  126050. set blurHorizontalSize(value: number);
  126051. /**
  126052. * Specifies the vertical size of the blur.
  126053. */
  126054. set blurVerticalSize(value: number);
  126055. /**
  126056. * Gets the horizontal size of the blur.
  126057. */
  126058. get blurHorizontalSize(): number;
  126059. /**
  126060. * Gets the vertical size of the blur.
  126061. */
  126062. get blurVerticalSize(): number;
  126063. /**
  126064. * An event triggered when the highlight layer is being blurred.
  126065. */
  126066. onBeforeBlurObservable: Observable<HighlightLayer>;
  126067. /**
  126068. * An event triggered when the highlight layer has been blurred.
  126069. */
  126070. onAfterBlurObservable: Observable<HighlightLayer>;
  126071. private _instanceGlowingMeshStencilReference;
  126072. private _options;
  126073. private _downSamplePostprocess;
  126074. private _horizontalBlurPostprocess;
  126075. private _verticalBlurPostprocess;
  126076. private _blurTexture;
  126077. private _meshes;
  126078. private _excludedMeshes;
  126079. /**
  126080. * Instantiates a new highlight Layer and references it to the scene..
  126081. * @param name The name of the layer
  126082. * @param scene The scene to use the layer in
  126083. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  126084. */
  126085. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  126086. /**
  126087. * Get the effect name of the layer.
  126088. * @return The effect name
  126089. */
  126090. getEffectName(): string;
  126091. /**
  126092. * Create the merge effect. This is the shader use to blit the information back
  126093. * to the main canvas at the end of the scene rendering.
  126094. */
  126095. protected _createMergeEffect(): Effect;
  126096. /**
  126097. * Creates the render target textures and post processes used in the highlight layer.
  126098. */
  126099. protected _createTextureAndPostProcesses(): void;
  126100. /**
  126101. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  126102. */
  126103. needStencil(): boolean;
  126104. /**
  126105. * Checks for the readiness of the element composing the layer.
  126106. * @param subMesh the mesh to check for
  126107. * @param useInstances specify wether or not to use instances to render the mesh
  126108. * @param emissiveTexture the associated emissive texture used to generate the glow
  126109. * @return true if ready otherwise, false
  126110. */
  126111. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126112. /**
  126113. * Implementation specific of rendering the generating effect on the main canvas.
  126114. * @param effect The effect used to render through
  126115. */
  126116. protected _internalRender(effect: Effect): void;
  126117. /**
  126118. * Returns true if the layer contains information to display, otherwise false.
  126119. */
  126120. shouldRender(): boolean;
  126121. /**
  126122. * Returns true if the mesh should render, otherwise false.
  126123. * @param mesh The mesh to render
  126124. * @returns true if it should render otherwise false
  126125. */
  126126. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126127. /**
  126128. * Sets the required values for both the emissive texture and and the main color.
  126129. */
  126130. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126131. /**
  126132. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  126133. * @param mesh The mesh to exclude from the highlight layer
  126134. */
  126135. addExcludedMesh(mesh: Mesh): void;
  126136. /**
  126137. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  126138. * @param mesh The mesh to highlight
  126139. */
  126140. removeExcludedMesh(mesh: Mesh): void;
  126141. /**
  126142. * Determine if a given mesh will be highlighted by the current HighlightLayer
  126143. * @param mesh mesh to test
  126144. * @returns true if the mesh will be highlighted by the current HighlightLayer
  126145. */
  126146. hasMesh(mesh: AbstractMesh): boolean;
  126147. /**
  126148. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  126149. * @param mesh The mesh to highlight
  126150. * @param color The color of the highlight
  126151. * @param glowEmissiveOnly Extract the glow from the emissive texture
  126152. */
  126153. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  126154. /**
  126155. * Remove a mesh from the highlight layer in order to make it stop glowing.
  126156. * @param mesh The mesh to highlight
  126157. */
  126158. removeMesh(mesh: Mesh): void;
  126159. /**
  126160. * Force the stencil to the normal expected value for none glowing parts
  126161. */
  126162. private _defaultStencilReference;
  126163. /**
  126164. * Free any resources and references associated to a mesh.
  126165. * Internal use
  126166. * @param mesh The mesh to free.
  126167. * @hidden
  126168. */
  126169. _disposeMesh(mesh: Mesh): void;
  126170. /**
  126171. * Dispose the highlight layer and free resources.
  126172. */
  126173. dispose(): void;
  126174. /**
  126175. * Gets the class name of the effect layer
  126176. * @returns the string with the class name of the effect layer
  126177. */
  126178. getClassName(): string;
  126179. /**
  126180. * Serializes this Highlight layer
  126181. * @returns a serialized Highlight layer object
  126182. */
  126183. serialize(): any;
  126184. /**
  126185. * Creates a Highlight layer from parsed Highlight layer data
  126186. * @param parsedHightlightLayer defines the Highlight layer data
  126187. * @param scene defines the current scene
  126188. * @param rootUrl defines the root URL containing the Highlight layer information
  126189. * @returns a parsed Highlight layer
  126190. */
  126191. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  126192. }
  126193. }
  126194. declare module BABYLON {
  126195. interface AbstractScene {
  126196. /**
  126197. * The list of layers (background and foreground) of the scene
  126198. */
  126199. layers: Array<Layer>;
  126200. }
  126201. /**
  126202. * Defines the layer scene component responsible to manage any layers
  126203. * in a given scene.
  126204. */
  126205. export class LayerSceneComponent implements ISceneComponent {
  126206. /**
  126207. * The component name helpfull to identify the component in the list of scene components.
  126208. */
  126209. readonly name: string;
  126210. /**
  126211. * The scene the component belongs to.
  126212. */
  126213. scene: Scene;
  126214. private _engine;
  126215. /**
  126216. * Creates a new instance of the component for the given scene
  126217. * @param scene Defines the scene to register the component in
  126218. */
  126219. constructor(scene: Scene);
  126220. /**
  126221. * Registers the component in a given scene
  126222. */
  126223. register(): void;
  126224. /**
  126225. * Rebuilds the elements related to this component in case of
  126226. * context lost for instance.
  126227. */
  126228. rebuild(): void;
  126229. /**
  126230. * Disposes the component and the associated ressources.
  126231. */
  126232. dispose(): void;
  126233. private _draw;
  126234. private _drawCameraPredicate;
  126235. private _drawCameraBackground;
  126236. private _drawCameraForeground;
  126237. private _drawRenderTargetPredicate;
  126238. private _drawRenderTargetBackground;
  126239. private _drawRenderTargetForeground;
  126240. /**
  126241. * Adds all the elements from the container to the scene
  126242. * @param container the container holding the elements
  126243. */
  126244. addFromContainer(container: AbstractScene): void;
  126245. /**
  126246. * Removes all the elements in the container from the scene
  126247. * @param container contains the elements to remove
  126248. * @param dispose if the removed element should be disposed (default: false)
  126249. */
  126250. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126251. }
  126252. }
  126253. declare module BABYLON {
  126254. /** @hidden */
  126255. export var layerPixelShader: {
  126256. name: string;
  126257. shader: string;
  126258. };
  126259. }
  126260. declare module BABYLON {
  126261. /** @hidden */
  126262. export var layerVertexShader: {
  126263. name: string;
  126264. shader: string;
  126265. };
  126266. }
  126267. declare module BABYLON {
  126268. /**
  126269. * This represents a full screen 2d layer.
  126270. * This can be useful to display a picture in the background of your scene for instance.
  126271. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126272. */
  126273. export class Layer {
  126274. /**
  126275. * Define the name of the layer.
  126276. */
  126277. name: string;
  126278. /**
  126279. * Define the texture the layer should display.
  126280. */
  126281. texture: Nullable<Texture>;
  126282. /**
  126283. * Is the layer in background or foreground.
  126284. */
  126285. isBackground: boolean;
  126286. /**
  126287. * Define the color of the layer (instead of texture).
  126288. */
  126289. color: Color4;
  126290. /**
  126291. * Define the scale of the layer in order to zoom in out of the texture.
  126292. */
  126293. scale: Vector2;
  126294. /**
  126295. * Define an offset for the layer in order to shift the texture.
  126296. */
  126297. offset: Vector2;
  126298. /**
  126299. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  126300. */
  126301. alphaBlendingMode: number;
  126302. /**
  126303. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  126304. * Alpha test will not mix with the background color in case of transparency.
  126305. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  126306. */
  126307. alphaTest: boolean;
  126308. /**
  126309. * Define a mask to restrict the layer to only some of the scene cameras.
  126310. */
  126311. layerMask: number;
  126312. /**
  126313. * Define the list of render target the layer is visible into.
  126314. */
  126315. renderTargetTextures: RenderTargetTexture[];
  126316. /**
  126317. * Define if the layer is only used in renderTarget or if it also
  126318. * renders in the main frame buffer of the canvas.
  126319. */
  126320. renderOnlyInRenderTargetTextures: boolean;
  126321. private _scene;
  126322. private _vertexBuffers;
  126323. private _indexBuffer;
  126324. private _effect;
  126325. private _previousDefines;
  126326. /**
  126327. * An event triggered when the layer is disposed.
  126328. */
  126329. onDisposeObservable: Observable<Layer>;
  126330. private _onDisposeObserver;
  126331. /**
  126332. * Back compatibility with callback before the onDisposeObservable existed.
  126333. * The set callback will be triggered when the layer has been disposed.
  126334. */
  126335. set onDispose(callback: () => void);
  126336. /**
  126337. * An event triggered before rendering the scene
  126338. */
  126339. onBeforeRenderObservable: Observable<Layer>;
  126340. private _onBeforeRenderObserver;
  126341. /**
  126342. * Back compatibility with callback before the onBeforeRenderObservable existed.
  126343. * The set callback will be triggered just before rendering the layer.
  126344. */
  126345. set onBeforeRender(callback: () => void);
  126346. /**
  126347. * An event triggered after rendering the scene
  126348. */
  126349. onAfterRenderObservable: Observable<Layer>;
  126350. private _onAfterRenderObserver;
  126351. /**
  126352. * Back compatibility with callback before the onAfterRenderObservable existed.
  126353. * The set callback will be triggered just after rendering the layer.
  126354. */
  126355. set onAfterRender(callback: () => void);
  126356. /**
  126357. * Instantiates a new layer.
  126358. * This represents a full screen 2d layer.
  126359. * This can be useful to display a picture in the background of your scene for instance.
  126360. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126361. * @param name Define the name of the layer in the scene
  126362. * @param imgUrl Define the url of the texture to display in the layer
  126363. * @param scene Define the scene the layer belongs to
  126364. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  126365. * @param color Defines a color for the layer
  126366. */
  126367. constructor(
  126368. /**
  126369. * Define the name of the layer.
  126370. */
  126371. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  126372. private _createIndexBuffer;
  126373. /** @hidden */
  126374. _rebuild(): void;
  126375. /**
  126376. * Renders the layer in the scene.
  126377. */
  126378. render(): void;
  126379. /**
  126380. * Disposes and releases the associated ressources.
  126381. */
  126382. dispose(): void;
  126383. }
  126384. }
  126385. declare module BABYLON {
  126386. /** @hidden */
  126387. export var lensFlarePixelShader: {
  126388. name: string;
  126389. shader: string;
  126390. };
  126391. }
  126392. declare module BABYLON {
  126393. /** @hidden */
  126394. export var lensFlareVertexShader: {
  126395. name: string;
  126396. shader: string;
  126397. };
  126398. }
  126399. declare module BABYLON {
  126400. /**
  126401. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  126402. * It is usually composed of several `lensFlare`.
  126403. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126404. */
  126405. export class LensFlareSystem {
  126406. /**
  126407. * Define the name of the lens flare system
  126408. */
  126409. name: string;
  126410. /**
  126411. * List of lens flares used in this system.
  126412. */
  126413. lensFlares: LensFlare[];
  126414. /**
  126415. * Define a limit from the border the lens flare can be visible.
  126416. */
  126417. borderLimit: number;
  126418. /**
  126419. * Define a viewport border we do not want to see the lens flare in.
  126420. */
  126421. viewportBorder: number;
  126422. /**
  126423. * Define a predicate which could limit the list of meshes able to occlude the effect.
  126424. */
  126425. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  126426. /**
  126427. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  126428. */
  126429. layerMask: number;
  126430. /**
  126431. * Define the id of the lens flare system in the scene.
  126432. * (equal to name by default)
  126433. */
  126434. id: string;
  126435. private _scene;
  126436. private _emitter;
  126437. private _vertexBuffers;
  126438. private _indexBuffer;
  126439. private _effect;
  126440. private _positionX;
  126441. private _positionY;
  126442. private _isEnabled;
  126443. /** @hidden */
  126444. static _SceneComponentInitialization: (scene: Scene) => void;
  126445. /**
  126446. * Instantiates a lens flare system.
  126447. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  126448. * It is usually composed of several `lensFlare`.
  126449. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126450. * @param name Define the name of the lens flare system in the scene
  126451. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  126452. * @param scene Define the scene the lens flare system belongs to
  126453. */
  126454. constructor(
  126455. /**
  126456. * Define the name of the lens flare system
  126457. */
  126458. name: string, emitter: any, scene: Scene);
  126459. /**
  126460. * Define if the lens flare system is enabled.
  126461. */
  126462. get isEnabled(): boolean;
  126463. set isEnabled(value: boolean);
  126464. /**
  126465. * Get the scene the effects belongs to.
  126466. * @returns the scene holding the lens flare system
  126467. */
  126468. getScene(): Scene;
  126469. /**
  126470. * Get the emitter of the lens flare system.
  126471. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  126472. * @returns the emitter of the lens flare system
  126473. */
  126474. getEmitter(): any;
  126475. /**
  126476. * Set the emitter of the lens flare system.
  126477. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  126478. * @param newEmitter Define the new emitter of the system
  126479. */
  126480. setEmitter(newEmitter: any): void;
  126481. /**
  126482. * Get the lens flare system emitter position.
  126483. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  126484. * @returns the position
  126485. */
  126486. getEmitterPosition(): Vector3;
  126487. /**
  126488. * @hidden
  126489. */
  126490. computeEffectivePosition(globalViewport: Viewport): boolean;
  126491. /** @hidden */
  126492. _isVisible(): boolean;
  126493. /**
  126494. * @hidden
  126495. */
  126496. render(): boolean;
  126497. /**
  126498. * Dispose and release the lens flare with its associated resources.
  126499. */
  126500. dispose(): void;
  126501. /**
  126502. * Parse a lens flare system from a JSON repressentation
  126503. * @param parsedLensFlareSystem Define the JSON to parse
  126504. * @param scene Define the scene the parsed system should be instantiated in
  126505. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  126506. * @returns the parsed system
  126507. */
  126508. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  126509. /**
  126510. * Serialize the current Lens Flare System into a JSON representation.
  126511. * @returns the serialized JSON
  126512. */
  126513. serialize(): any;
  126514. }
  126515. }
  126516. declare module BABYLON {
  126517. /**
  126518. * This represents one of the lens effect in a `lensFlareSystem`.
  126519. * It controls one of the indiviual texture used in the effect.
  126520. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126521. */
  126522. export class LensFlare {
  126523. /**
  126524. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  126525. */
  126526. size: number;
  126527. /**
  126528. * 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.
  126529. */
  126530. position: number;
  126531. /**
  126532. * Define the lens color.
  126533. */
  126534. color: Color3;
  126535. /**
  126536. * Define the lens texture.
  126537. */
  126538. texture: Nullable<Texture>;
  126539. /**
  126540. * Define the alpha mode to render this particular lens.
  126541. */
  126542. alphaMode: number;
  126543. private _system;
  126544. /**
  126545. * Creates a new Lens Flare.
  126546. * This represents one of the lens effect in a `lensFlareSystem`.
  126547. * It controls one of the indiviual texture used in the effect.
  126548. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126549. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  126550. * @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.
  126551. * @param color Define the lens color
  126552. * @param imgUrl Define the lens texture url
  126553. * @param system Define the `lensFlareSystem` this flare is part of
  126554. * @returns The newly created Lens Flare
  126555. */
  126556. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  126557. /**
  126558. * Instantiates a new Lens Flare.
  126559. * This represents one of the lens effect in a `lensFlareSystem`.
  126560. * It controls one of the indiviual texture used in the effect.
  126561. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126562. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  126563. * @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.
  126564. * @param color Define the lens color
  126565. * @param imgUrl Define the lens texture url
  126566. * @param system Define the `lensFlareSystem` this flare is part of
  126567. */
  126568. constructor(
  126569. /**
  126570. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  126571. */
  126572. size: number,
  126573. /**
  126574. * 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.
  126575. */
  126576. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  126577. /**
  126578. * Dispose and release the lens flare with its associated resources.
  126579. */
  126580. dispose(): void;
  126581. }
  126582. }
  126583. declare module BABYLON {
  126584. interface AbstractScene {
  126585. /**
  126586. * The list of lens flare system added to the scene
  126587. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126588. */
  126589. lensFlareSystems: Array<LensFlareSystem>;
  126590. /**
  126591. * Removes the given lens flare system from this scene.
  126592. * @param toRemove The lens flare system to remove
  126593. * @returns The index of the removed lens flare system
  126594. */
  126595. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  126596. /**
  126597. * Adds the given lens flare system to this scene
  126598. * @param newLensFlareSystem The lens flare system to add
  126599. */
  126600. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  126601. /**
  126602. * Gets a lens flare system using its name
  126603. * @param name defines the name to look for
  126604. * @returns the lens flare system or null if not found
  126605. */
  126606. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  126607. /**
  126608. * Gets a lens flare system using its id
  126609. * @param id defines the id to look for
  126610. * @returns the lens flare system or null if not found
  126611. */
  126612. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  126613. }
  126614. /**
  126615. * Defines the lens flare scene component responsible to manage any lens flares
  126616. * in a given scene.
  126617. */
  126618. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  126619. /**
  126620. * The component name helpfull to identify the component in the list of scene components.
  126621. */
  126622. readonly name: string;
  126623. /**
  126624. * The scene the component belongs to.
  126625. */
  126626. scene: Scene;
  126627. /**
  126628. * Creates a new instance of the component for the given scene
  126629. * @param scene Defines the scene to register the component in
  126630. */
  126631. constructor(scene: Scene);
  126632. /**
  126633. * Registers the component in a given scene
  126634. */
  126635. register(): void;
  126636. /**
  126637. * Rebuilds the elements related to this component in case of
  126638. * context lost for instance.
  126639. */
  126640. rebuild(): void;
  126641. /**
  126642. * Adds all the elements from the container to the scene
  126643. * @param container the container holding the elements
  126644. */
  126645. addFromContainer(container: AbstractScene): void;
  126646. /**
  126647. * Removes all the elements in the container from the scene
  126648. * @param container contains the elements to remove
  126649. * @param dispose if the removed element should be disposed (default: false)
  126650. */
  126651. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126652. /**
  126653. * Serializes the component data to the specified json object
  126654. * @param serializationObject The object to serialize to
  126655. */
  126656. serialize(serializationObject: any): void;
  126657. /**
  126658. * Disposes the component and the associated ressources.
  126659. */
  126660. dispose(): void;
  126661. private _draw;
  126662. }
  126663. }
  126664. declare module BABYLON {
  126665. /** @hidden */
  126666. export var depthPixelShader: {
  126667. name: string;
  126668. shader: string;
  126669. };
  126670. }
  126671. declare module BABYLON {
  126672. /** @hidden */
  126673. export var depthVertexShader: {
  126674. name: string;
  126675. shader: string;
  126676. };
  126677. }
  126678. declare module BABYLON {
  126679. /**
  126680. * This represents a depth renderer in Babylon.
  126681. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  126682. */
  126683. export class DepthRenderer {
  126684. private _scene;
  126685. private _depthMap;
  126686. private _effect;
  126687. private readonly _storeNonLinearDepth;
  126688. private readonly _clearColor;
  126689. /** Get if the depth renderer is using packed depth or not */
  126690. readonly isPacked: boolean;
  126691. private _cachedDefines;
  126692. private _camera;
  126693. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  126694. enabled: boolean;
  126695. /**
  126696. * Specifiess that the depth renderer will only be used within
  126697. * the camera it is created for.
  126698. * This can help forcing its rendering during the camera processing.
  126699. */
  126700. useOnlyInActiveCamera: boolean;
  126701. /** @hidden */
  126702. static _SceneComponentInitialization: (scene: Scene) => void;
  126703. /**
  126704. * Instantiates a depth renderer
  126705. * @param scene The scene the renderer belongs to
  126706. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  126707. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  126708. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  126709. */
  126710. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  126711. /**
  126712. * Creates the depth rendering effect and checks if the effect is ready.
  126713. * @param subMesh The submesh to be used to render the depth map of
  126714. * @param useInstances If multiple world instances should be used
  126715. * @returns if the depth renderer is ready to render the depth map
  126716. */
  126717. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126718. /**
  126719. * Gets the texture which the depth map will be written to.
  126720. * @returns The depth map texture
  126721. */
  126722. getDepthMap(): RenderTargetTexture;
  126723. /**
  126724. * Disposes of the depth renderer.
  126725. */
  126726. dispose(): void;
  126727. }
  126728. }
  126729. declare module BABYLON {
  126730. /** @hidden */
  126731. export var minmaxReduxPixelShader: {
  126732. name: string;
  126733. shader: string;
  126734. };
  126735. }
  126736. declare module BABYLON {
  126737. /**
  126738. * This class computes a min/max reduction from a texture: it means it computes the minimum
  126739. * and maximum values from all values of the texture.
  126740. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  126741. * The source values are read from the red channel of the texture.
  126742. */
  126743. export class MinMaxReducer {
  126744. /**
  126745. * Observable triggered when the computation has been performed
  126746. */
  126747. onAfterReductionPerformed: Observable<{
  126748. min: number;
  126749. max: number;
  126750. }>;
  126751. protected _camera: Camera;
  126752. protected _sourceTexture: Nullable<RenderTargetTexture>;
  126753. protected _reductionSteps: Nullable<Array<PostProcess>>;
  126754. protected _postProcessManager: PostProcessManager;
  126755. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  126756. protected _forceFullscreenViewport: boolean;
  126757. /**
  126758. * Creates a min/max reducer
  126759. * @param camera The camera to use for the post processes
  126760. */
  126761. constructor(camera: Camera);
  126762. /**
  126763. * Gets the texture used to read the values from.
  126764. */
  126765. get sourceTexture(): Nullable<RenderTargetTexture>;
  126766. /**
  126767. * Sets the source texture to read the values from.
  126768. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  126769. * because in such textures '1' value must not be taken into account to compute the maximum
  126770. * as this value is used to clear the texture.
  126771. * Note that the computation is not activated by calling this function, you must call activate() for that!
  126772. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  126773. * @param depthRedux Indicates if the texture is a depth texture or not
  126774. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  126775. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  126776. */
  126777. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  126778. /**
  126779. * Defines the refresh rate of the computation.
  126780. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  126781. */
  126782. get refreshRate(): number;
  126783. set refreshRate(value: number);
  126784. protected _activated: boolean;
  126785. /**
  126786. * Gets the activation status of the reducer
  126787. */
  126788. get activated(): boolean;
  126789. /**
  126790. * Activates the reduction computation.
  126791. * When activated, the observers registered in onAfterReductionPerformed are
  126792. * called after the compuation is performed
  126793. */
  126794. activate(): void;
  126795. /**
  126796. * Deactivates the reduction computation.
  126797. */
  126798. deactivate(): void;
  126799. /**
  126800. * Disposes the min/max reducer
  126801. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  126802. */
  126803. dispose(disposeAll?: boolean): void;
  126804. }
  126805. }
  126806. declare module BABYLON {
  126807. /**
  126808. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  126809. */
  126810. export class DepthReducer extends MinMaxReducer {
  126811. private _depthRenderer;
  126812. private _depthRendererId;
  126813. /**
  126814. * Gets the depth renderer used for the computation.
  126815. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  126816. */
  126817. get depthRenderer(): Nullable<DepthRenderer>;
  126818. /**
  126819. * Creates a depth reducer
  126820. * @param camera The camera used to render the depth texture
  126821. */
  126822. constructor(camera: Camera);
  126823. /**
  126824. * Sets the depth renderer to use to generate the depth map
  126825. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  126826. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  126827. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  126828. */
  126829. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  126830. /** @hidden */
  126831. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  126832. /**
  126833. * Activates the reduction computation.
  126834. * When activated, the observers registered in onAfterReductionPerformed are
  126835. * called after the compuation is performed
  126836. */
  126837. activate(): void;
  126838. /**
  126839. * Deactivates the reduction computation.
  126840. */
  126841. deactivate(): void;
  126842. /**
  126843. * Disposes the depth reducer
  126844. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  126845. */
  126846. dispose(disposeAll?: boolean): void;
  126847. }
  126848. }
  126849. declare module BABYLON {
  126850. /**
  126851. * A CSM implementation allowing casting shadows on large scenes.
  126852. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  126853. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  126854. */
  126855. export class CascadedShadowGenerator extends ShadowGenerator {
  126856. private static readonly frustumCornersNDCSpace;
  126857. /**
  126858. * Name of the CSM class
  126859. */
  126860. static CLASSNAME: string;
  126861. /**
  126862. * Defines the default number of cascades used by the CSM.
  126863. */
  126864. static readonly DEFAULT_CASCADES_COUNT: number;
  126865. /**
  126866. * Defines the minimum number of cascades used by the CSM.
  126867. */
  126868. static readonly MIN_CASCADES_COUNT: number;
  126869. /**
  126870. * Defines the maximum number of cascades used by the CSM.
  126871. */
  126872. static readonly MAX_CASCADES_COUNT: number;
  126873. protected _validateFilter(filter: number): number;
  126874. /**
  126875. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  126876. */
  126877. penumbraDarkness: number;
  126878. private _numCascades;
  126879. /**
  126880. * Gets or set the number of cascades used by the CSM.
  126881. */
  126882. get numCascades(): number;
  126883. set numCascades(value: number);
  126884. /**
  126885. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  126886. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  126887. */
  126888. stabilizeCascades: boolean;
  126889. private _freezeShadowCastersBoundingInfo;
  126890. private _freezeShadowCastersBoundingInfoObservable;
  126891. /**
  126892. * Enables or disables the shadow casters bounding info computation.
  126893. * If your shadow casters don't move, you can disable this feature.
  126894. * If it is enabled, the bounding box computation is done every frame.
  126895. */
  126896. get freezeShadowCastersBoundingInfo(): boolean;
  126897. set freezeShadowCastersBoundingInfo(freeze: boolean);
  126898. private _scbiMin;
  126899. private _scbiMax;
  126900. protected _computeShadowCastersBoundingInfo(): void;
  126901. protected _shadowCastersBoundingInfo: BoundingInfo;
  126902. /**
  126903. * Gets or sets the shadow casters bounding info.
  126904. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  126905. * so that the system won't overwrite the bounds you provide
  126906. */
  126907. get shadowCastersBoundingInfo(): BoundingInfo;
  126908. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  126909. protected _breaksAreDirty: boolean;
  126910. protected _minDistance: number;
  126911. protected _maxDistance: number;
  126912. /**
  126913. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  126914. *
  126915. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  126916. * If you don't know these values, simply leave them to their defaults and don't call this function.
  126917. * @param min minimal distance for the breaks (default to 0.)
  126918. * @param max maximal distance for the breaks (default to 1.)
  126919. */
  126920. setMinMaxDistance(min: number, max: number): void;
  126921. /** Gets the minimal distance used in the cascade break computation */
  126922. get minDistance(): number;
  126923. /** Gets the maximal distance used in the cascade break computation */
  126924. get maxDistance(): number;
  126925. /**
  126926. * Gets the class name of that object
  126927. * @returns "CascadedShadowGenerator"
  126928. */
  126929. getClassName(): string;
  126930. private _cascadeMinExtents;
  126931. private _cascadeMaxExtents;
  126932. /**
  126933. * Gets a cascade minimum extents
  126934. * @param cascadeIndex index of the cascade
  126935. * @returns the minimum cascade extents
  126936. */
  126937. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  126938. /**
  126939. * Gets a cascade maximum extents
  126940. * @param cascadeIndex index of the cascade
  126941. * @returns the maximum cascade extents
  126942. */
  126943. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  126944. private _cascades;
  126945. private _currentLayer;
  126946. private _viewSpaceFrustumsZ;
  126947. private _viewMatrices;
  126948. private _projectionMatrices;
  126949. private _transformMatrices;
  126950. private _transformMatricesAsArray;
  126951. private _frustumLengths;
  126952. private _lightSizeUVCorrection;
  126953. private _depthCorrection;
  126954. private _frustumCornersWorldSpace;
  126955. private _frustumCenter;
  126956. private _shadowCameraPos;
  126957. private _shadowMaxZ;
  126958. /**
  126959. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  126960. * It defaults to camera.maxZ
  126961. */
  126962. get shadowMaxZ(): number;
  126963. /**
  126964. * Sets the shadow max z distance.
  126965. */
  126966. set shadowMaxZ(value: number);
  126967. protected _debug: boolean;
  126968. /**
  126969. * Gets or sets the debug flag.
  126970. * When enabled, the cascades are materialized by different colors on the screen.
  126971. */
  126972. get debug(): boolean;
  126973. set debug(dbg: boolean);
  126974. private _depthClamp;
  126975. /**
  126976. * Gets or sets the depth clamping value.
  126977. *
  126978. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  126979. * to account for the shadow casters far away.
  126980. *
  126981. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  126982. */
  126983. get depthClamp(): boolean;
  126984. set depthClamp(value: boolean);
  126985. private _cascadeBlendPercentage;
  126986. /**
  126987. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  126988. * It defaults to 0.1 (10% blending).
  126989. */
  126990. get cascadeBlendPercentage(): number;
  126991. set cascadeBlendPercentage(value: number);
  126992. private _lambda;
  126993. /**
  126994. * Gets or set the lambda parameter.
  126995. * This parameter is used to split the camera frustum and create the cascades.
  126996. * It's a value between 0. and 1.: If 0, the split is a uniform split of the frustum, if 1 it is a logarithmic split.
  126997. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  126998. */
  126999. get lambda(): number;
  127000. set lambda(value: number);
  127001. /**
  127002. * Gets the view matrix corresponding to a given cascade
  127003. * @param cascadeNum cascade to retrieve the view matrix from
  127004. * @returns the cascade view matrix
  127005. */
  127006. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  127007. /**
  127008. * Gets the projection matrix corresponding to a given cascade
  127009. * @param cascadeNum cascade to retrieve the projection matrix from
  127010. * @returns the cascade projection matrix
  127011. */
  127012. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  127013. /**
  127014. * Gets the transformation matrix corresponding to a given cascade
  127015. * @param cascadeNum cascade to retrieve the transformation matrix from
  127016. * @returns the cascade transformation matrix
  127017. */
  127018. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  127019. private _depthRenderer;
  127020. /**
  127021. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  127022. *
  127023. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  127024. *
  127025. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  127026. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  127027. * @param depthRenderer The depth renderer to use when autoCalcDepthBounds is enabled. If you pass null or don't call this function at all, a depth renderer will be automatically created
  127028. */
  127029. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  127030. private _depthReducer;
  127031. private _autoCalcDepthBounds;
  127032. /**
  127033. * Gets or sets the autoCalcDepthBounds property.
  127034. *
  127035. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  127036. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  127037. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  127038. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  127039. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  127040. */
  127041. get autoCalcDepthBounds(): boolean;
  127042. set autoCalcDepthBounds(value: boolean);
  127043. /**
  127044. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  127045. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127046. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  127047. * for setting the refresh rate on the renderer yourself!
  127048. */
  127049. get autoCalcDepthBoundsRefreshRate(): number;
  127050. set autoCalcDepthBoundsRefreshRate(value: number);
  127051. /**
  127052. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  127053. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  127054. * you change the camera near/far planes!
  127055. */
  127056. splitFrustum(): void;
  127057. private _splitFrustum;
  127058. private _computeMatrices;
  127059. private _computeFrustumInWorldSpace;
  127060. private _computeCascadeFrustum;
  127061. /** @hidden */
  127062. static _SceneComponentInitialization: (scene: Scene) => void;
  127063. /**
  127064. * Creates a Cascaded Shadow Generator object.
  127065. * A ShadowGenerator is the required tool to use the shadows.
  127066. * Each directional light casting shadows needs to use its own ShadowGenerator.
  127067. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127068. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  127069. * @param light The directional light object generating the shadows.
  127070. * @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.
  127071. */
  127072. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  127073. protected _initializeGenerator(): void;
  127074. protected _createTargetRenderTexture(): void;
  127075. protected _initializeShadowMap(): void;
  127076. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  127077. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  127078. /**
  127079. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  127080. * @param defines Defines of the material we want to update
  127081. * @param lightIndex Index of the light in the enabled light list of the material
  127082. */
  127083. prepareDefines(defines: any, lightIndex: number): void;
  127084. /**
  127085. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  127086. * defined in the generator but impacting the effect).
  127087. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  127088. * @param effect The effect we are binfing the information for
  127089. */
  127090. bindShadowLight(lightIndex: string, effect: Effect): void;
  127091. /**
  127092. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  127093. * (eq to view projection * shadow projection matrices)
  127094. * @returns The transform matrix used to create the shadow map
  127095. */
  127096. getTransformMatrix(): Matrix;
  127097. /**
  127098. * Disposes the ShadowGenerator.
  127099. * Returns nothing.
  127100. */
  127101. dispose(): void;
  127102. /**
  127103. * Serializes the shadow generator setup to a json object.
  127104. * @returns The serialized JSON object
  127105. */
  127106. serialize(): any;
  127107. /**
  127108. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  127109. * @param parsedShadowGenerator The JSON object to parse
  127110. * @param scene The scene to create the shadow map for
  127111. * @returns The parsed shadow generator
  127112. */
  127113. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  127114. }
  127115. }
  127116. declare module BABYLON {
  127117. /**
  127118. * Defines the shadow generator component responsible to manage any shadow generators
  127119. * in a given scene.
  127120. */
  127121. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  127122. /**
  127123. * The component name helpfull to identify the component in the list of scene components.
  127124. */
  127125. readonly name: string;
  127126. /**
  127127. * The scene the component belongs to.
  127128. */
  127129. scene: Scene;
  127130. /**
  127131. * Creates a new instance of the component for the given scene
  127132. * @param scene Defines the scene to register the component in
  127133. */
  127134. constructor(scene: Scene);
  127135. /**
  127136. * Registers the component in a given scene
  127137. */
  127138. register(): void;
  127139. /**
  127140. * Rebuilds the elements related to this component in case of
  127141. * context lost for instance.
  127142. */
  127143. rebuild(): void;
  127144. /**
  127145. * Serializes the component data to the specified json object
  127146. * @param serializationObject The object to serialize to
  127147. */
  127148. serialize(serializationObject: any): void;
  127149. /**
  127150. * Adds all the elements from the container to the scene
  127151. * @param container the container holding the elements
  127152. */
  127153. addFromContainer(container: AbstractScene): void;
  127154. /**
  127155. * Removes all the elements in the container from the scene
  127156. * @param container contains the elements to remove
  127157. * @param dispose if the removed element should be disposed (default: false)
  127158. */
  127159. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127160. /**
  127161. * Rebuilds the elements related to this component in case of
  127162. * context lost for instance.
  127163. */
  127164. dispose(): void;
  127165. private _gatherRenderTargets;
  127166. }
  127167. }
  127168. declare module BABYLON {
  127169. /**
  127170. * A point light is a light defined by an unique point in world space.
  127171. * The light is emitted in every direction from this point.
  127172. * A good example of a point light is a standard light bulb.
  127173. * Documentation: https://doc.babylonjs.com/babylon101/lights
  127174. */
  127175. export class PointLight extends ShadowLight {
  127176. private _shadowAngle;
  127177. /**
  127178. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127179. * This specifies what angle the shadow will use to be created.
  127180. *
  127181. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127182. */
  127183. get shadowAngle(): number;
  127184. /**
  127185. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127186. * This specifies what angle the shadow will use to be created.
  127187. *
  127188. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127189. */
  127190. set shadowAngle(value: number);
  127191. /**
  127192. * Gets the direction if it has been set.
  127193. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127194. */
  127195. get direction(): Vector3;
  127196. /**
  127197. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127198. */
  127199. set direction(value: Vector3);
  127200. /**
  127201. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  127202. * A PointLight emits the light in every direction.
  127203. * It can cast shadows.
  127204. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  127205. * ```javascript
  127206. * var pointLight = new PointLight("pl", camera.position, scene);
  127207. * ```
  127208. * Documentation : https://doc.babylonjs.com/babylon101/lights
  127209. * @param name The light friendly name
  127210. * @param position The position of the point light in the scene
  127211. * @param scene The scene the lights belongs to
  127212. */
  127213. constructor(name: string, position: Vector3, scene: Scene);
  127214. /**
  127215. * Returns the string "PointLight"
  127216. * @returns the class name
  127217. */
  127218. getClassName(): string;
  127219. /**
  127220. * Returns the integer 0.
  127221. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  127222. */
  127223. getTypeID(): number;
  127224. /**
  127225. * Specifies wether or not the shadowmap should be a cube texture.
  127226. * @returns true if the shadowmap needs to be a cube texture.
  127227. */
  127228. needCube(): boolean;
  127229. /**
  127230. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  127231. * @param faceIndex The index of the face we are computed the direction to generate shadow
  127232. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  127233. */
  127234. getShadowDirection(faceIndex?: number): Vector3;
  127235. /**
  127236. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  127237. * - fov = PI / 2
  127238. * - aspect ratio : 1.0
  127239. * - z-near and far equal to the active camera minZ and maxZ.
  127240. * Returns the PointLight.
  127241. */
  127242. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  127243. protected _buildUniformLayout(): void;
  127244. /**
  127245. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  127246. * @param effect The effect to update
  127247. * @param lightIndex The index of the light in the effect to update
  127248. * @returns The point light
  127249. */
  127250. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  127251. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  127252. /**
  127253. * Prepares the list of defines specific to the light type.
  127254. * @param defines the list of defines
  127255. * @param lightIndex defines the index of the light for the effect
  127256. */
  127257. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  127258. }
  127259. }
  127260. declare module BABYLON {
  127261. /**
  127262. * Header information of HDR texture files.
  127263. */
  127264. export interface HDRInfo {
  127265. /**
  127266. * The height of the texture in pixels.
  127267. */
  127268. height: number;
  127269. /**
  127270. * The width of the texture in pixels.
  127271. */
  127272. width: number;
  127273. /**
  127274. * The index of the beginning of the data in the binary file.
  127275. */
  127276. dataPosition: number;
  127277. }
  127278. /**
  127279. * This groups tools to convert HDR texture to native colors array.
  127280. */
  127281. export class HDRTools {
  127282. private static Ldexp;
  127283. private static Rgbe2float;
  127284. private static readStringLine;
  127285. /**
  127286. * Reads header information from an RGBE texture stored in a native array.
  127287. * More information on this format are available here:
  127288. * https://en.wikipedia.org/wiki/RGBE_image_format
  127289. *
  127290. * @param uint8array The binary file stored in native array.
  127291. * @return The header information.
  127292. */
  127293. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  127294. /**
  127295. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  127296. * This RGBE texture needs to store the information as a panorama.
  127297. *
  127298. * More information on this format are available here:
  127299. * https://en.wikipedia.org/wiki/RGBE_image_format
  127300. *
  127301. * @param buffer The binary file stored in an array buffer.
  127302. * @param size The expected size of the extracted cubemap.
  127303. * @return The Cube Map information.
  127304. */
  127305. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  127306. /**
  127307. * Returns the pixels data extracted from an RGBE texture.
  127308. * This pixels will be stored left to right up to down in the R G B order in one array.
  127309. *
  127310. * More information on this format are available here:
  127311. * https://en.wikipedia.org/wiki/RGBE_image_format
  127312. *
  127313. * @param uint8array The binary file stored in an array buffer.
  127314. * @param hdrInfo The header information of the file.
  127315. * @return The pixels data in RGB right to left up to down order.
  127316. */
  127317. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  127318. private static RGBE_ReadPixels_RLE;
  127319. }
  127320. }
  127321. declare module BABYLON {
  127322. /**
  127323. * This represents a texture coming from an HDR input.
  127324. *
  127325. * The only supported format is currently panorama picture stored in RGBE format.
  127326. * Example of such files can be found on HDRLib: http://hdrlib.com/
  127327. */
  127328. export class HDRCubeTexture extends BaseTexture {
  127329. private static _facesMapping;
  127330. private _generateHarmonics;
  127331. private _noMipmap;
  127332. private _textureMatrix;
  127333. private _size;
  127334. private _onLoad;
  127335. private _onError;
  127336. /**
  127337. * The texture URL.
  127338. */
  127339. url: string;
  127340. /**
  127341. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  127342. */
  127343. coordinatesMode: number;
  127344. protected _isBlocking: boolean;
  127345. /**
  127346. * Sets wether or not the texture is blocking during loading.
  127347. */
  127348. set isBlocking(value: boolean);
  127349. /**
  127350. * Gets wether or not the texture is blocking during loading.
  127351. */
  127352. get isBlocking(): boolean;
  127353. protected _rotationY: number;
  127354. /**
  127355. * Sets texture matrix rotation angle around Y axis in radians.
  127356. */
  127357. set rotationY(value: number);
  127358. /**
  127359. * Gets texture matrix rotation angle around Y axis radians.
  127360. */
  127361. get rotationY(): number;
  127362. /**
  127363. * Gets or sets the center of the bounding box associated with the cube texture
  127364. * It must define where the camera used to render the texture was set
  127365. */
  127366. boundingBoxPosition: Vector3;
  127367. private _boundingBoxSize;
  127368. /**
  127369. * Gets or sets the size of the bounding box associated with the cube texture
  127370. * When defined, the cubemap will switch to local mode
  127371. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  127372. * @example https://www.babylonjs-playground.com/#RNASML
  127373. */
  127374. set boundingBoxSize(value: Vector3);
  127375. get boundingBoxSize(): Vector3;
  127376. /**
  127377. * Instantiates an HDRTexture from the following parameters.
  127378. *
  127379. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  127380. * @param scene The scene the texture will be used in
  127381. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  127382. * @param noMipmap Forces to not generate the mipmap if true
  127383. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  127384. * @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)
  127385. * @param reserved Reserved flag for internal use.
  127386. */
  127387. 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>);
  127388. /**
  127389. * Get the current class name of the texture useful for serialization or dynamic coding.
  127390. * @returns "HDRCubeTexture"
  127391. */
  127392. getClassName(): string;
  127393. /**
  127394. * Occurs when the file is raw .hdr file.
  127395. */
  127396. private loadTexture;
  127397. clone(): HDRCubeTexture;
  127398. delayLoad(): void;
  127399. /**
  127400. * Get the texture reflection matrix used to rotate/transform the reflection.
  127401. * @returns the reflection matrix
  127402. */
  127403. getReflectionTextureMatrix(): Matrix;
  127404. /**
  127405. * Set the texture reflection matrix used to rotate/transform the reflection.
  127406. * @param value Define the reflection matrix to set
  127407. */
  127408. setReflectionTextureMatrix(value: Matrix): void;
  127409. /**
  127410. * Parses a JSON representation of an HDR Texture in order to create the texture
  127411. * @param parsedTexture Define the JSON representation
  127412. * @param scene Define the scene the texture should be created in
  127413. * @param rootUrl Define the root url in case we need to load relative dependencies
  127414. * @returns the newly created texture after parsing
  127415. */
  127416. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  127417. serialize(): any;
  127418. }
  127419. }
  127420. declare module BABYLON {
  127421. /**
  127422. * Class used to control physics engine
  127423. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  127424. */
  127425. export class PhysicsEngine implements IPhysicsEngine {
  127426. private _physicsPlugin;
  127427. /**
  127428. * Global value used to control the smallest number supported by the simulation
  127429. */
  127430. static Epsilon: number;
  127431. private _impostors;
  127432. private _joints;
  127433. private _subTimeStep;
  127434. /**
  127435. * Gets the gravity vector used by the simulation
  127436. */
  127437. gravity: Vector3;
  127438. /**
  127439. * Factory used to create the default physics plugin.
  127440. * @returns The default physics plugin
  127441. */
  127442. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  127443. /**
  127444. * Creates a new Physics Engine
  127445. * @param gravity defines the gravity vector used by the simulation
  127446. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  127447. */
  127448. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  127449. /**
  127450. * Sets the gravity vector used by the simulation
  127451. * @param gravity defines the gravity vector to use
  127452. */
  127453. setGravity(gravity: Vector3): void;
  127454. /**
  127455. * Set the time step of the physics engine.
  127456. * Default is 1/60.
  127457. * To slow it down, enter 1/600 for example.
  127458. * To speed it up, 1/30
  127459. * @param newTimeStep defines the new timestep to apply to this world.
  127460. */
  127461. setTimeStep(newTimeStep?: number): void;
  127462. /**
  127463. * Get the time step of the physics engine.
  127464. * @returns the current time step
  127465. */
  127466. getTimeStep(): number;
  127467. /**
  127468. * Set the sub time step of the physics engine.
  127469. * Default is 0 meaning there is no sub steps
  127470. * To increase physics resolution precision, set a small value (like 1 ms)
  127471. * @param subTimeStep defines the new sub timestep used for physics resolution.
  127472. */
  127473. setSubTimeStep(subTimeStep?: number): void;
  127474. /**
  127475. * Get the sub time step of the physics engine.
  127476. * @returns the current sub time step
  127477. */
  127478. getSubTimeStep(): number;
  127479. /**
  127480. * Release all resources
  127481. */
  127482. dispose(): void;
  127483. /**
  127484. * Gets the name of the current physics plugin
  127485. * @returns the name of the plugin
  127486. */
  127487. getPhysicsPluginName(): string;
  127488. /**
  127489. * Adding a new impostor for the impostor tracking.
  127490. * This will be done by the impostor itself.
  127491. * @param impostor the impostor to add
  127492. */
  127493. addImpostor(impostor: PhysicsImpostor): void;
  127494. /**
  127495. * Remove an impostor from the engine.
  127496. * This impostor and its mesh will not longer be updated by the physics engine.
  127497. * @param impostor the impostor to remove
  127498. */
  127499. removeImpostor(impostor: PhysicsImpostor): void;
  127500. /**
  127501. * Add a joint to the physics engine
  127502. * @param mainImpostor defines the main impostor to which the joint is added.
  127503. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  127504. * @param joint defines the joint that will connect both impostors.
  127505. */
  127506. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  127507. /**
  127508. * Removes a joint from the simulation
  127509. * @param mainImpostor defines the impostor used with the joint
  127510. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  127511. * @param joint defines the joint to remove
  127512. */
  127513. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  127514. /**
  127515. * Called by the scene. No need to call it.
  127516. * @param delta defines the timespam between frames
  127517. */
  127518. _step(delta: number): void;
  127519. /**
  127520. * Gets the current plugin used to run the simulation
  127521. * @returns current plugin
  127522. */
  127523. getPhysicsPlugin(): IPhysicsEnginePlugin;
  127524. /**
  127525. * Gets the list of physic impostors
  127526. * @returns an array of PhysicsImpostor
  127527. */
  127528. getImpostors(): Array<PhysicsImpostor>;
  127529. /**
  127530. * Gets the impostor for a physics enabled object
  127531. * @param object defines the object impersonated by the impostor
  127532. * @returns the PhysicsImpostor or null if not found
  127533. */
  127534. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  127535. /**
  127536. * Gets the impostor for a physics body object
  127537. * @param body defines physics body used by the impostor
  127538. * @returns the PhysicsImpostor or null if not found
  127539. */
  127540. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  127541. /**
  127542. * Does a raycast in the physics world
  127543. * @param from when should the ray start?
  127544. * @param to when should the ray end?
  127545. * @returns PhysicsRaycastResult
  127546. */
  127547. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  127548. }
  127549. }
  127550. declare module BABYLON {
  127551. /** @hidden */
  127552. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  127553. private _useDeltaForWorldStep;
  127554. world: any;
  127555. name: string;
  127556. private _physicsMaterials;
  127557. private _fixedTimeStep;
  127558. private _cannonRaycastResult;
  127559. private _raycastResult;
  127560. private _physicsBodysToRemoveAfterStep;
  127561. BJSCANNON: any;
  127562. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  127563. setGravity(gravity: Vector3): void;
  127564. setTimeStep(timeStep: number): void;
  127565. getTimeStep(): number;
  127566. executeStep(delta: number): void;
  127567. private _removeMarkedPhysicsBodiesFromWorld;
  127568. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  127569. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  127570. generatePhysicsBody(impostor: PhysicsImpostor): void;
  127571. private _processChildMeshes;
  127572. removePhysicsBody(impostor: PhysicsImpostor): void;
  127573. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  127574. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  127575. private _addMaterial;
  127576. private _checkWithEpsilon;
  127577. private _createShape;
  127578. private _createHeightmap;
  127579. private _minus90X;
  127580. private _plus90X;
  127581. private _tmpPosition;
  127582. private _tmpDeltaPosition;
  127583. private _tmpUnityRotation;
  127584. private _updatePhysicsBodyTransformation;
  127585. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  127586. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  127587. isSupported(): boolean;
  127588. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  127589. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  127590. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  127591. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  127592. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  127593. getBodyMass(impostor: PhysicsImpostor): number;
  127594. getBodyFriction(impostor: PhysicsImpostor): number;
  127595. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  127596. getBodyRestitution(impostor: PhysicsImpostor): number;
  127597. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  127598. sleepBody(impostor: PhysicsImpostor): void;
  127599. wakeUpBody(impostor: PhysicsImpostor): void;
  127600. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  127601. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  127602. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  127603. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  127604. getRadius(impostor: PhysicsImpostor): number;
  127605. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  127606. dispose(): void;
  127607. private _extendNamespace;
  127608. /**
  127609. * Does a raycast in the physics world
  127610. * @param from when should the ray start?
  127611. * @param to when should the ray end?
  127612. * @returns PhysicsRaycastResult
  127613. */
  127614. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  127615. }
  127616. }
  127617. declare module BABYLON {
  127618. /** @hidden */
  127619. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  127620. world: any;
  127621. name: string;
  127622. BJSOIMO: any;
  127623. private _raycastResult;
  127624. constructor(iterations?: number, oimoInjection?: any);
  127625. setGravity(gravity: Vector3): void;
  127626. setTimeStep(timeStep: number): void;
  127627. getTimeStep(): number;
  127628. private _tmpImpostorsArray;
  127629. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  127630. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  127631. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  127632. generatePhysicsBody(impostor: PhysicsImpostor): void;
  127633. private _tmpPositionVector;
  127634. removePhysicsBody(impostor: PhysicsImpostor): void;
  127635. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  127636. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  127637. isSupported(): boolean;
  127638. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  127639. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  127640. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  127641. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  127642. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  127643. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  127644. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  127645. getBodyMass(impostor: PhysicsImpostor): number;
  127646. getBodyFriction(impostor: PhysicsImpostor): number;
  127647. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  127648. getBodyRestitution(impostor: PhysicsImpostor): number;
  127649. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  127650. sleepBody(impostor: PhysicsImpostor): void;
  127651. wakeUpBody(impostor: PhysicsImpostor): void;
  127652. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  127653. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  127654. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  127655. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  127656. getRadius(impostor: PhysicsImpostor): number;
  127657. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  127658. dispose(): void;
  127659. /**
  127660. * Does a raycast in the physics world
  127661. * @param from when should the ray start?
  127662. * @param to when should the ray end?
  127663. * @returns PhysicsRaycastResult
  127664. */
  127665. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  127666. }
  127667. }
  127668. declare module BABYLON {
  127669. /**
  127670. * Class containing static functions to help procedurally build meshes
  127671. */
  127672. export class RibbonBuilder {
  127673. /**
  127674. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  127675. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  127676. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  127677. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  127678. * * 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
  127679. * * 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
  127680. * * 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
  127681. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127682. * * 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
  127683. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127684. * * 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
  127685. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  127686. * * 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
  127687. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  127688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127689. * @param name defines the name of the mesh
  127690. * @param options defines the options used to create the mesh
  127691. * @param scene defines the hosting scene
  127692. * @returns the ribbon mesh
  127693. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  127694. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127695. */
  127696. static CreateRibbon(name: string, options: {
  127697. pathArray: Vector3[][];
  127698. closeArray?: boolean;
  127699. closePath?: boolean;
  127700. offset?: number;
  127701. updatable?: boolean;
  127702. sideOrientation?: number;
  127703. frontUVs?: Vector4;
  127704. backUVs?: Vector4;
  127705. instance?: Mesh;
  127706. invertUV?: boolean;
  127707. uvs?: Vector2[];
  127708. colors?: Color4[];
  127709. }, scene?: Nullable<Scene>): Mesh;
  127710. }
  127711. }
  127712. declare module BABYLON {
  127713. /**
  127714. * Class containing static functions to help procedurally build meshes
  127715. */
  127716. export class ShapeBuilder {
  127717. /**
  127718. * 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.
  127719. * * 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.
  127720. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  127721. * * 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.
  127722. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  127723. * * 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
  127724. * * 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
  127725. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  127726. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127727. * * 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
  127728. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  127729. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127730. * @param name defines the name of the mesh
  127731. * @param options defines the options used to create the mesh
  127732. * @param scene defines the hosting scene
  127733. * @returns the extruded shape mesh
  127734. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127735. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  127736. */
  127737. static ExtrudeShape(name: string, options: {
  127738. shape: Vector3[];
  127739. path: Vector3[];
  127740. scale?: number;
  127741. rotation?: number;
  127742. cap?: number;
  127743. updatable?: boolean;
  127744. sideOrientation?: number;
  127745. frontUVs?: Vector4;
  127746. backUVs?: Vector4;
  127747. instance?: Mesh;
  127748. invertUV?: boolean;
  127749. }, scene?: Nullable<Scene>): Mesh;
  127750. /**
  127751. * Creates an custom extruded shape mesh.
  127752. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  127753. * * 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.
  127754. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  127755. * * 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
  127756. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  127757. * * 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
  127758. * * It must returns a float value that will be the scale value applied to the shape on each path point
  127759. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  127760. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  127761. * * 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
  127762. * * 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
  127763. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  127764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127765. * * 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
  127766. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127768. * @param name defines the name of the mesh
  127769. * @param options defines the options used to create the mesh
  127770. * @param scene defines the hosting scene
  127771. * @returns the custom extruded shape mesh
  127772. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  127773. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127774. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  127775. */
  127776. static ExtrudeShapeCustom(name: string, options: {
  127777. shape: Vector3[];
  127778. path: Vector3[];
  127779. scaleFunction?: any;
  127780. rotationFunction?: any;
  127781. ribbonCloseArray?: boolean;
  127782. ribbonClosePath?: boolean;
  127783. cap?: number;
  127784. updatable?: boolean;
  127785. sideOrientation?: number;
  127786. frontUVs?: Vector4;
  127787. backUVs?: Vector4;
  127788. instance?: Mesh;
  127789. invertUV?: boolean;
  127790. }, scene?: Nullable<Scene>): Mesh;
  127791. private static _ExtrudeShapeGeneric;
  127792. }
  127793. }
  127794. declare module BABYLON {
  127795. /**
  127796. * AmmoJS Physics plugin
  127797. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  127798. * @see https://github.com/kripken/ammo.js/
  127799. */
  127800. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  127801. private _useDeltaForWorldStep;
  127802. /**
  127803. * Reference to the Ammo library
  127804. */
  127805. bjsAMMO: any;
  127806. /**
  127807. * Created ammoJS world which physics bodies are added to
  127808. */
  127809. world: any;
  127810. /**
  127811. * Name of the plugin
  127812. */
  127813. name: string;
  127814. private _timeStep;
  127815. private _fixedTimeStep;
  127816. private _maxSteps;
  127817. private _tmpQuaternion;
  127818. private _tmpAmmoTransform;
  127819. private _tmpAmmoQuaternion;
  127820. private _tmpAmmoConcreteContactResultCallback;
  127821. private _collisionConfiguration;
  127822. private _dispatcher;
  127823. private _overlappingPairCache;
  127824. private _solver;
  127825. private _softBodySolver;
  127826. private _tmpAmmoVectorA;
  127827. private _tmpAmmoVectorB;
  127828. private _tmpAmmoVectorC;
  127829. private _tmpAmmoVectorD;
  127830. private _tmpContactCallbackResult;
  127831. private _tmpAmmoVectorRCA;
  127832. private _tmpAmmoVectorRCB;
  127833. private _raycastResult;
  127834. private static readonly DISABLE_COLLISION_FLAG;
  127835. private static readonly KINEMATIC_FLAG;
  127836. private static readonly DISABLE_DEACTIVATION_FLAG;
  127837. /**
  127838. * Initializes the ammoJS plugin
  127839. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  127840. * @param ammoInjection can be used to inject your own ammo reference
  127841. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  127842. */
  127843. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  127844. /**
  127845. * Sets the gravity of the physics world (m/(s^2))
  127846. * @param gravity Gravity to set
  127847. */
  127848. setGravity(gravity: Vector3): void;
  127849. /**
  127850. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  127851. * @param timeStep timestep to use in seconds
  127852. */
  127853. setTimeStep(timeStep: number): void;
  127854. /**
  127855. * 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)
  127856. * @param fixedTimeStep fixedTimeStep to use in seconds
  127857. */
  127858. setFixedTimeStep(fixedTimeStep: number): void;
  127859. /**
  127860. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  127861. * @param maxSteps the maximum number of steps by the physics engine per frame
  127862. */
  127863. setMaxSteps(maxSteps: number): void;
  127864. /**
  127865. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  127866. * @returns the current timestep in seconds
  127867. */
  127868. getTimeStep(): number;
  127869. /**
  127870. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  127871. */
  127872. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  127873. private _isImpostorInContact;
  127874. private _isImpostorPairInContact;
  127875. private _stepSimulation;
  127876. /**
  127877. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  127878. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  127879. * After the step the babylon meshes are set to the position of the physics imposters
  127880. * @param delta amount of time to step forward
  127881. * @param impostors array of imposters to update before/after the step
  127882. */
  127883. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  127884. /**
  127885. * Update babylon mesh to match physics world object
  127886. * @param impostor imposter to match
  127887. */
  127888. private _afterSoftStep;
  127889. /**
  127890. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  127891. * @param impostor imposter to match
  127892. */
  127893. private _ropeStep;
  127894. /**
  127895. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  127896. * @param impostor imposter to match
  127897. */
  127898. private _softbodyOrClothStep;
  127899. private _tmpVector;
  127900. private _tmpMatrix;
  127901. /**
  127902. * Applies an impulse on the imposter
  127903. * @param impostor imposter to apply impulse to
  127904. * @param force amount of force to be applied to the imposter
  127905. * @param contactPoint the location to apply the impulse on the imposter
  127906. */
  127907. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  127908. /**
  127909. * Applies a force on the imposter
  127910. * @param impostor imposter to apply force
  127911. * @param force amount of force to be applied to the imposter
  127912. * @param contactPoint the location to apply the force on the imposter
  127913. */
  127914. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  127915. /**
  127916. * Creates a physics body using the plugin
  127917. * @param impostor the imposter to create the physics body on
  127918. */
  127919. generatePhysicsBody(impostor: PhysicsImpostor): void;
  127920. /**
  127921. * Removes the physics body from the imposter and disposes of the body's memory
  127922. * @param impostor imposter to remove the physics body from
  127923. */
  127924. removePhysicsBody(impostor: PhysicsImpostor): void;
  127925. /**
  127926. * Generates a joint
  127927. * @param impostorJoint the imposter joint to create the joint with
  127928. */
  127929. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  127930. /**
  127931. * Removes a joint
  127932. * @param impostorJoint the imposter joint to remove the joint from
  127933. */
  127934. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  127935. private _addMeshVerts;
  127936. /**
  127937. * Initialise the soft body vertices to match its object's (mesh) vertices
  127938. * Softbody vertices (nodes) are in world space and to match this
  127939. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  127940. * @param impostor to create the softbody for
  127941. */
  127942. private _softVertexData;
  127943. /**
  127944. * Create an impostor's soft body
  127945. * @param impostor to create the softbody for
  127946. */
  127947. private _createSoftbody;
  127948. /**
  127949. * Create cloth for an impostor
  127950. * @param impostor to create the softbody for
  127951. */
  127952. private _createCloth;
  127953. /**
  127954. * Create rope for an impostor
  127955. * @param impostor to create the softbody for
  127956. */
  127957. private _createRope;
  127958. /**
  127959. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  127960. * @param impostor to create the custom physics shape for
  127961. */
  127962. private _createCustom;
  127963. private _addHullVerts;
  127964. private _createShape;
  127965. /**
  127966. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  127967. * @param impostor imposter containing the physics body and babylon object
  127968. */
  127969. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  127970. /**
  127971. * Sets the babylon object's position/rotation from the physics body's position/rotation
  127972. * @param impostor imposter containing the physics body and babylon object
  127973. * @param newPosition new position
  127974. * @param newRotation new rotation
  127975. */
  127976. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  127977. /**
  127978. * If this plugin is supported
  127979. * @returns true if its supported
  127980. */
  127981. isSupported(): boolean;
  127982. /**
  127983. * Sets the linear velocity of the physics body
  127984. * @param impostor imposter to set the velocity on
  127985. * @param velocity velocity to set
  127986. */
  127987. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  127988. /**
  127989. * Sets the angular velocity of the physics body
  127990. * @param impostor imposter to set the velocity on
  127991. * @param velocity velocity to set
  127992. */
  127993. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  127994. /**
  127995. * gets the linear velocity
  127996. * @param impostor imposter to get linear velocity from
  127997. * @returns linear velocity
  127998. */
  127999. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128000. /**
  128001. * gets the angular velocity
  128002. * @param impostor imposter to get angular velocity from
  128003. * @returns angular velocity
  128004. */
  128005. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128006. /**
  128007. * Sets the mass of physics body
  128008. * @param impostor imposter to set the mass on
  128009. * @param mass mass to set
  128010. */
  128011. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128012. /**
  128013. * Gets the mass of the physics body
  128014. * @param impostor imposter to get the mass from
  128015. * @returns mass
  128016. */
  128017. getBodyMass(impostor: PhysicsImpostor): number;
  128018. /**
  128019. * Gets friction of the impostor
  128020. * @param impostor impostor to get friction from
  128021. * @returns friction value
  128022. */
  128023. getBodyFriction(impostor: PhysicsImpostor): number;
  128024. /**
  128025. * Sets friction of the impostor
  128026. * @param impostor impostor to set friction on
  128027. * @param friction friction value
  128028. */
  128029. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128030. /**
  128031. * Gets restitution of the impostor
  128032. * @param impostor impostor to get restitution from
  128033. * @returns restitution value
  128034. */
  128035. getBodyRestitution(impostor: PhysicsImpostor): number;
  128036. /**
  128037. * Sets resitution of the impostor
  128038. * @param impostor impostor to set resitution on
  128039. * @param restitution resitution value
  128040. */
  128041. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128042. /**
  128043. * Gets pressure inside the impostor
  128044. * @param impostor impostor to get pressure from
  128045. * @returns pressure value
  128046. */
  128047. getBodyPressure(impostor: PhysicsImpostor): number;
  128048. /**
  128049. * Sets pressure inside a soft body impostor
  128050. * Cloth and rope must remain 0 pressure
  128051. * @param impostor impostor to set pressure on
  128052. * @param pressure pressure value
  128053. */
  128054. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  128055. /**
  128056. * Gets stiffness of the impostor
  128057. * @param impostor impostor to get stiffness from
  128058. * @returns pressure value
  128059. */
  128060. getBodyStiffness(impostor: PhysicsImpostor): number;
  128061. /**
  128062. * Sets stiffness of the impostor
  128063. * @param impostor impostor to set stiffness on
  128064. * @param stiffness stiffness value from 0 to 1
  128065. */
  128066. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  128067. /**
  128068. * Gets velocityIterations of the impostor
  128069. * @param impostor impostor to get velocity iterations from
  128070. * @returns velocityIterations value
  128071. */
  128072. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  128073. /**
  128074. * Sets velocityIterations of the impostor
  128075. * @param impostor impostor to set velocity iterations on
  128076. * @param velocityIterations velocityIterations value
  128077. */
  128078. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  128079. /**
  128080. * Gets positionIterations of the impostor
  128081. * @param impostor impostor to get position iterations from
  128082. * @returns positionIterations value
  128083. */
  128084. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  128085. /**
  128086. * Sets positionIterations of the impostor
  128087. * @param impostor impostor to set position on
  128088. * @param positionIterations positionIterations value
  128089. */
  128090. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  128091. /**
  128092. * Append an anchor to a cloth object
  128093. * @param impostor is the cloth impostor to add anchor to
  128094. * @param otherImpostor is the rigid impostor to anchor to
  128095. * @param width ratio across width from 0 to 1
  128096. * @param height ratio up height from 0 to 1
  128097. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  128098. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128099. */
  128100. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128101. /**
  128102. * Append an hook to a rope object
  128103. * @param impostor is the rope impostor to add hook to
  128104. * @param otherImpostor is the rigid impostor to hook to
  128105. * @param length ratio along the rope from 0 to 1
  128106. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  128107. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128108. */
  128109. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128110. /**
  128111. * Sleeps the physics body and stops it from being active
  128112. * @param impostor impostor to sleep
  128113. */
  128114. sleepBody(impostor: PhysicsImpostor): void;
  128115. /**
  128116. * Activates the physics body
  128117. * @param impostor impostor to activate
  128118. */
  128119. wakeUpBody(impostor: PhysicsImpostor): void;
  128120. /**
  128121. * Updates the distance parameters of the joint
  128122. * @param joint joint to update
  128123. * @param maxDistance maximum distance of the joint
  128124. * @param minDistance minimum distance of the joint
  128125. */
  128126. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128127. /**
  128128. * Sets a motor on the joint
  128129. * @param joint joint to set motor on
  128130. * @param speed speed of the motor
  128131. * @param maxForce maximum force of the motor
  128132. * @param motorIndex index of the motor
  128133. */
  128134. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128135. /**
  128136. * Sets the motors limit
  128137. * @param joint joint to set limit on
  128138. * @param upperLimit upper limit
  128139. * @param lowerLimit lower limit
  128140. */
  128141. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128142. /**
  128143. * Syncs the position and rotation of a mesh with the impostor
  128144. * @param mesh mesh to sync
  128145. * @param impostor impostor to update the mesh with
  128146. */
  128147. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128148. /**
  128149. * Gets the radius of the impostor
  128150. * @param impostor impostor to get radius from
  128151. * @returns the radius
  128152. */
  128153. getRadius(impostor: PhysicsImpostor): number;
  128154. /**
  128155. * Gets the box size of the impostor
  128156. * @param impostor impostor to get box size from
  128157. * @param result the resulting box size
  128158. */
  128159. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128160. /**
  128161. * Disposes of the impostor
  128162. */
  128163. dispose(): void;
  128164. /**
  128165. * Does a raycast in the physics world
  128166. * @param from when should the ray start?
  128167. * @param to when should the ray end?
  128168. * @returns PhysicsRaycastResult
  128169. */
  128170. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128171. }
  128172. }
  128173. declare module BABYLON {
  128174. interface AbstractScene {
  128175. /**
  128176. * The list of reflection probes added to the scene
  128177. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128178. */
  128179. reflectionProbes: Array<ReflectionProbe>;
  128180. /**
  128181. * Removes the given reflection probe from this scene.
  128182. * @param toRemove The reflection probe to remove
  128183. * @returns The index of the removed reflection probe
  128184. */
  128185. removeReflectionProbe(toRemove: ReflectionProbe): number;
  128186. /**
  128187. * Adds the given reflection probe to this scene.
  128188. * @param newReflectionProbe The reflection probe to add
  128189. */
  128190. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  128191. }
  128192. /**
  128193. * Class used to generate realtime reflection / refraction cube textures
  128194. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128195. */
  128196. export class ReflectionProbe {
  128197. /** defines the name of the probe */
  128198. name: string;
  128199. private _scene;
  128200. private _renderTargetTexture;
  128201. private _projectionMatrix;
  128202. private _viewMatrix;
  128203. private _target;
  128204. private _add;
  128205. private _attachedMesh;
  128206. private _invertYAxis;
  128207. /** Gets or sets probe position (center of the cube map) */
  128208. position: Vector3;
  128209. /**
  128210. * Creates a new reflection probe
  128211. * @param name defines the name of the probe
  128212. * @param size defines the texture resolution (for each face)
  128213. * @param scene defines the hosting scene
  128214. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  128215. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  128216. */
  128217. constructor(
  128218. /** defines the name of the probe */
  128219. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  128220. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  128221. get samples(): number;
  128222. set samples(value: number);
  128223. /** Gets or sets the refresh rate to use (on every frame by default) */
  128224. get refreshRate(): number;
  128225. set refreshRate(value: number);
  128226. /**
  128227. * Gets the hosting scene
  128228. * @returns a Scene
  128229. */
  128230. getScene(): Scene;
  128231. /** Gets the internal CubeTexture used to render to */
  128232. get cubeTexture(): RenderTargetTexture;
  128233. /** Gets the list of meshes to render */
  128234. get renderList(): Nullable<AbstractMesh[]>;
  128235. /**
  128236. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  128237. * @param mesh defines the mesh to attach to
  128238. */
  128239. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  128240. /**
  128241. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  128242. * @param renderingGroupId The rendering group id corresponding to its index
  128243. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  128244. */
  128245. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  128246. /**
  128247. * Clean all associated resources
  128248. */
  128249. dispose(): void;
  128250. /**
  128251. * Converts the reflection probe information to a readable string for debug purpose.
  128252. * @param fullDetails Supports for multiple levels of logging within scene loading
  128253. * @returns the human readable reflection probe info
  128254. */
  128255. toString(fullDetails?: boolean): string;
  128256. /**
  128257. * Get the class name of the relfection probe.
  128258. * @returns "ReflectionProbe"
  128259. */
  128260. getClassName(): string;
  128261. /**
  128262. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  128263. * @returns The JSON representation of the texture
  128264. */
  128265. serialize(): any;
  128266. /**
  128267. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  128268. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  128269. * @param scene Define the scene the parsed reflection probe should be instantiated in
  128270. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  128271. * @returns The parsed reflection probe if successful
  128272. */
  128273. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  128274. }
  128275. }
  128276. declare module BABYLON {
  128277. /** @hidden */
  128278. export var _BabylonLoaderRegistered: boolean;
  128279. /**
  128280. * Helps setting up some configuration for the babylon file loader.
  128281. */
  128282. export class BabylonFileLoaderConfiguration {
  128283. /**
  128284. * The loader does not allow injecting custom physix engine into the plugins.
  128285. * Unfortunately in ES6, we need to manually inject them into the plugin.
  128286. * So you could set this variable to your engine import to make it work.
  128287. */
  128288. static LoaderInjectedPhysicsEngine: any;
  128289. }
  128290. }
  128291. declare module BABYLON {
  128292. /**
  128293. * The Physically based simple base material of BJS.
  128294. *
  128295. * This enables better naming and convention enforcements on top of the pbrMaterial.
  128296. * It is used as the base class for both the specGloss and metalRough conventions.
  128297. */
  128298. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  128299. /**
  128300. * Number of Simultaneous lights allowed on the material.
  128301. */
  128302. maxSimultaneousLights: number;
  128303. /**
  128304. * If sets to true, disables all the lights affecting the material.
  128305. */
  128306. disableLighting: boolean;
  128307. /**
  128308. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  128309. */
  128310. environmentTexture: BaseTexture;
  128311. /**
  128312. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  128313. */
  128314. invertNormalMapX: boolean;
  128315. /**
  128316. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  128317. */
  128318. invertNormalMapY: boolean;
  128319. /**
  128320. * Normal map used in the model.
  128321. */
  128322. normalTexture: BaseTexture;
  128323. /**
  128324. * Emissivie color used to self-illuminate the model.
  128325. */
  128326. emissiveColor: Color3;
  128327. /**
  128328. * Emissivie texture used to self-illuminate the model.
  128329. */
  128330. emissiveTexture: BaseTexture;
  128331. /**
  128332. * Occlusion Channel Strenght.
  128333. */
  128334. occlusionStrength: number;
  128335. /**
  128336. * Occlusion Texture of the material (adding extra occlusion effects).
  128337. */
  128338. occlusionTexture: BaseTexture;
  128339. /**
  128340. * Defines the alpha limits in alpha test mode.
  128341. */
  128342. alphaCutOff: number;
  128343. /**
  128344. * Gets the current double sided mode.
  128345. */
  128346. get doubleSided(): boolean;
  128347. /**
  128348. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  128349. */
  128350. set doubleSided(value: boolean);
  128351. /**
  128352. * Stores the pre-calculated light information of a mesh in a texture.
  128353. */
  128354. lightmapTexture: BaseTexture;
  128355. /**
  128356. * If true, the light map contains occlusion information instead of lighting info.
  128357. */
  128358. useLightmapAsShadowmap: boolean;
  128359. /**
  128360. * Instantiates a new PBRMaterial instance.
  128361. *
  128362. * @param name The material name
  128363. * @param scene The scene the material will be use in.
  128364. */
  128365. constructor(name: string, scene: Scene);
  128366. getClassName(): string;
  128367. }
  128368. }
  128369. declare module BABYLON {
  128370. /**
  128371. * The PBR material of BJS following the metal roughness convention.
  128372. *
  128373. * This fits to the PBR convention in the GLTF definition:
  128374. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  128375. */
  128376. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  128377. /**
  128378. * The base color has two different interpretations depending on the value of metalness.
  128379. * When the material is a metal, the base color is the specific measured reflectance value
  128380. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  128381. * of the material.
  128382. */
  128383. baseColor: Color3;
  128384. /**
  128385. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  128386. * well as opacity information in the alpha channel.
  128387. */
  128388. baseTexture: BaseTexture;
  128389. /**
  128390. * Specifies the metallic scalar value of the material.
  128391. * Can also be used to scale the metalness values of the metallic texture.
  128392. */
  128393. metallic: number;
  128394. /**
  128395. * Specifies the roughness scalar value of the material.
  128396. * Can also be used to scale the roughness values of the metallic texture.
  128397. */
  128398. roughness: number;
  128399. /**
  128400. * Texture containing both the metallic value in the B channel and the
  128401. * roughness value in the G channel to keep better precision.
  128402. */
  128403. metallicRoughnessTexture: BaseTexture;
  128404. /**
  128405. * Instantiates a new PBRMetalRoughnessMaterial instance.
  128406. *
  128407. * @param name The material name
  128408. * @param scene The scene the material will be use in.
  128409. */
  128410. constructor(name: string, scene: Scene);
  128411. /**
  128412. * Return the currrent class name of the material.
  128413. */
  128414. getClassName(): string;
  128415. /**
  128416. * Makes a duplicate of the current material.
  128417. * @param name - name to use for the new material.
  128418. */
  128419. clone(name: string): PBRMetallicRoughnessMaterial;
  128420. /**
  128421. * Serialize the material to a parsable JSON object.
  128422. */
  128423. serialize(): any;
  128424. /**
  128425. * Parses a JSON object correponding to the serialize function.
  128426. */
  128427. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  128428. }
  128429. }
  128430. declare module BABYLON {
  128431. /**
  128432. * The PBR material of BJS following the specular glossiness convention.
  128433. *
  128434. * This fits to the PBR convention in the GLTF definition:
  128435. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  128436. */
  128437. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  128438. /**
  128439. * Specifies the diffuse color of the material.
  128440. */
  128441. diffuseColor: Color3;
  128442. /**
  128443. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  128444. * channel.
  128445. */
  128446. diffuseTexture: BaseTexture;
  128447. /**
  128448. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  128449. */
  128450. specularColor: Color3;
  128451. /**
  128452. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  128453. */
  128454. glossiness: number;
  128455. /**
  128456. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  128457. */
  128458. specularGlossinessTexture: BaseTexture;
  128459. /**
  128460. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  128461. *
  128462. * @param name The material name
  128463. * @param scene The scene the material will be use in.
  128464. */
  128465. constructor(name: string, scene: Scene);
  128466. /**
  128467. * Return the currrent class name of the material.
  128468. */
  128469. getClassName(): string;
  128470. /**
  128471. * Makes a duplicate of the current material.
  128472. * @param name - name to use for the new material.
  128473. */
  128474. clone(name: string): PBRSpecularGlossinessMaterial;
  128475. /**
  128476. * Serialize the material to a parsable JSON object.
  128477. */
  128478. serialize(): any;
  128479. /**
  128480. * Parses a JSON object correponding to the serialize function.
  128481. */
  128482. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  128483. }
  128484. }
  128485. declare module BABYLON {
  128486. /**
  128487. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  128488. * It can help converting any input color in a desired output one. This can then be used to create effects
  128489. * from sepia, black and white to sixties or futuristic rendering...
  128490. *
  128491. * The only supported format is currently 3dl.
  128492. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  128493. */
  128494. export class ColorGradingTexture extends BaseTexture {
  128495. /**
  128496. * The current texture matrix. (will always be identity in color grading texture)
  128497. */
  128498. private _textureMatrix;
  128499. /**
  128500. * The texture URL.
  128501. */
  128502. url: string;
  128503. /**
  128504. * Empty line regex stored for GC.
  128505. */
  128506. private static _noneEmptyLineRegex;
  128507. private _engine;
  128508. /**
  128509. * Instantiates a ColorGradingTexture from the following parameters.
  128510. *
  128511. * @param url The location of the color gradind data (currently only supporting 3dl)
  128512. * @param scene The scene the texture will be used in
  128513. */
  128514. constructor(url: string, scene: Scene);
  128515. /**
  128516. * Returns the texture matrix used in most of the material.
  128517. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  128518. */
  128519. getTextureMatrix(): Matrix;
  128520. /**
  128521. * Occurs when the file being loaded is a .3dl LUT file.
  128522. */
  128523. private load3dlTexture;
  128524. /**
  128525. * Starts the loading process of the texture.
  128526. */
  128527. private loadTexture;
  128528. /**
  128529. * Clones the color gradind texture.
  128530. */
  128531. clone(): ColorGradingTexture;
  128532. /**
  128533. * Called during delayed load for textures.
  128534. */
  128535. delayLoad(): void;
  128536. /**
  128537. * Parses a color grading texture serialized by Babylon.
  128538. * @param parsedTexture The texture information being parsedTexture
  128539. * @param scene The scene to load the texture in
  128540. * @param rootUrl The root url of the data assets to load
  128541. * @return A color gradind texture
  128542. */
  128543. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  128544. /**
  128545. * Serializes the LUT texture to json format.
  128546. */
  128547. serialize(): any;
  128548. }
  128549. }
  128550. declare module BABYLON {
  128551. /**
  128552. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  128553. */
  128554. export class EquiRectangularCubeTexture extends BaseTexture {
  128555. /** The six faces of the cube. */
  128556. private static _FacesMapping;
  128557. private _noMipmap;
  128558. private _onLoad;
  128559. private _onError;
  128560. /** The size of the cubemap. */
  128561. private _size;
  128562. /** The buffer of the image. */
  128563. private _buffer;
  128564. /** The width of the input image. */
  128565. private _width;
  128566. /** The height of the input image. */
  128567. private _height;
  128568. /** The URL to the image. */
  128569. url: string;
  128570. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  128571. coordinatesMode: number;
  128572. /**
  128573. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  128574. * @param url The location of the image
  128575. * @param scene The scene the texture will be used in
  128576. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  128577. * @param noMipmap Forces to not generate the mipmap if true
  128578. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  128579. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  128580. * @param onLoad — defines a callback called when texture is loaded
  128581. * @param onError — defines a callback called if there is an error
  128582. */
  128583. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  128584. /**
  128585. * Load the image data, by putting the image on a canvas and extracting its buffer.
  128586. */
  128587. private loadImage;
  128588. /**
  128589. * Convert the image buffer into a cubemap and create a CubeTexture.
  128590. */
  128591. private loadTexture;
  128592. /**
  128593. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  128594. * @param buffer The ArrayBuffer that should be converted.
  128595. * @returns The buffer as Float32Array.
  128596. */
  128597. private getFloat32ArrayFromArrayBuffer;
  128598. /**
  128599. * Get the current class name of the texture useful for serialization or dynamic coding.
  128600. * @returns "EquiRectangularCubeTexture"
  128601. */
  128602. getClassName(): string;
  128603. /**
  128604. * Create a clone of the current EquiRectangularCubeTexture and return it.
  128605. * @returns A clone of the current EquiRectangularCubeTexture.
  128606. */
  128607. clone(): EquiRectangularCubeTexture;
  128608. }
  128609. }
  128610. declare module BABYLON {
  128611. /**
  128612. * Based on jsTGALoader - Javascript loader for TGA file
  128613. * By Vincent Thibault
  128614. * @see http://blog.robrowser.com/javascript-tga-loader.html
  128615. */
  128616. export class TGATools {
  128617. private static _TYPE_INDEXED;
  128618. private static _TYPE_RGB;
  128619. private static _TYPE_GREY;
  128620. private static _TYPE_RLE_INDEXED;
  128621. private static _TYPE_RLE_RGB;
  128622. private static _TYPE_RLE_GREY;
  128623. private static _ORIGIN_MASK;
  128624. private static _ORIGIN_SHIFT;
  128625. private static _ORIGIN_BL;
  128626. private static _ORIGIN_BR;
  128627. private static _ORIGIN_UL;
  128628. private static _ORIGIN_UR;
  128629. /**
  128630. * Gets the header of a TGA file
  128631. * @param data defines the TGA data
  128632. * @returns the header
  128633. */
  128634. static GetTGAHeader(data: Uint8Array): any;
  128635. /**
  128636. * Uploads TGA content to a Babylon Texture
  128637. * @hidden
  128638. */
  128639. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  128640. /** @hidden */
  128641. 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;
  128642. /** @hidden */
  128643. 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;
  128644. /** @hidden */
  128645. 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;
  128646. /** @hidden */
  128647. 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;
  128648. /** @hidden */
  128649. 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;
  128650. /** @hidden */
  128651. 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;
  128652. }
  128653. }
  128654. declare module BABYLON {
  128655. /**
  128656. * Implementation of the TGA Texture Loader.
  128657. * @hidden
  128658. */
  128659. export class _TGATextureLoader implements IInternalTextureLoader {
  128660. /**
  128661. * Defines wether the loader supports cascade loading the different faces.
  128662. */
  128663. readonly supportCascades: boolean;
  128664. /**
  128665. * This returns if the loader support the current file information.
  128666. * @param extension defines the file extension of the file being loaded
  128667. * @param textureFormatInUse defines the current compressed format in use iun the engine
  128668. * @param fallback defines the fallback internal texture if any
  128669. * @param isBase64 defines whether the texture is encoded as a base64
  128670. * @param isBuffer defines whether the texture data are stored as a buffer
  128671. * @returns true if the loader can load the specified file
  128672. */
  128673. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  128674. /**
  128675. * Transform the url before loading if required.
  128676. * @param rootUrl the url of the texture
  128677. * @param textureFormatInUse defines the current compressed format in use iun the engine
  128678. * @returns the transformed texture
  128679. */
  128680. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  128681. /**
  128682. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  128683. * @param rootUrl the url of the texture
  128684. * @param textureFormatInUse defines the current compressed format in use iun the engine
  128685. * @returns the fallback texture
  128686. */
  128687. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  128688. /**
  128689. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  128690. * @param data contains the texture data
  128691. * @param texture defines the BabylonJS internal texture
  128692. * @param createPolynomials will be true if polynomials have been requested
  128693. * @param onLoad defines the callback to trigger once the texture is ready
  128694. * @param onError defines the callback to trigger in case of error
  128695. */
  128696. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  128697. /**
  128698. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  128699. * @param data contains the texture data
  128700. * @param texture defines the BabylonJS internal texture
  128701. * @param callback defines the method to call once ready to upload
  128702. */
  128703. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  128704. }
  128705. }
  128706. declare module BABYLON {
  128707. /**
  128708. * Info about the .basis files
  128709. */
  128710. class BasisFileInfo {
  128711. /**
  128712. * If the file has alpha
  128713. */
  128714. hasAlpha: boolean;
  128715. /**
  128716. * Info about each image of the basis file
  128717. */
  128718. images: Array<{
  128719. levels: Array<{
  128720. width: number;
  128721. height: number;
  128722. transcodedPixels: ArrayBufferView;
  128723. }>;
  128724. }>;
  128725. }
  128726. /**
  128727. * Result of transcoding a basis file
  128728. */
  128729. class TranscodeResult {
  128730. /**
  128731. * Info about the .basis file
  128732. */
  128733. fileInfo: BasisFileInfo;
  128734. /**
  128735. * Format to use when loading the file
  128736. */
  128737. format: number;
  128738. }
  128739. /**
  128740. * Configuration options for the Basis transcoder
  128741. */
  128742. export class BasisTranscodeConfiguration {
  128743. /**
  128744. * Supported compression formats used to determine the supported output format of the transcoder
  128745. */
  128746. supportedCompressionFormats?: {
  128747. /**
  128748. * etc1 compression format
  128749. */
  128750. etc1?: boolean;
  128751. /**
  128752. * s3tc compression format
  128753. */
  128754. s3tc?: boolean;
  128755. /**
  128756. * pvrtc compression format
  128757. */
  128758. pvrtc?: boolean;
  128759. /**
  128760. * etc2 compression format
  128761. */
  128762. etc2?: boolean;
  128763. };
  128764. /**
  128765. * If mipmap levels should be loaded for transcoded images (Default: true)
  128766. */
  128767. loadMipmapLevels?: boolean;
  128768. /**
  128769. * Index of a single image to load (Default: all images)
  128770. */
  128771. loadSingleImage?: number;
  128772. }
  128773. /**
  128774. * Used to load .Basis files
  128775. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  128776. */
  128777. export class BasisTools {
  128778. private static _IgnoreSupportedFormats;
  128779. /**
  128780. * URL to use when loading the basis transcoder
  128781. */
  128782. static JSModuleURL: string;
  128783. /**
  128784. * URL to use when loading the wasm module for the transcoder
  128785. */
  128786. static WasmModuleURL: string;
  128787. /**
  128788. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  128789. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  128790. * @returns internal format corresponding to the Basis format
  128791. */
  128792. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  128793. private static _WorkerPromise;
  128794. private static _Worker;
  128795. private static _actionId;
  128796. private static _CreateWorkerAsync;
  128797. /**
  128798. * Transcodes a loaded image file to compressed pixel data
  128799. * @param data image data to transcode
  128800. * @param config configuration options for the transcoding
  128801. * @returns a promise resulting in the transcoded image
  128802. */
  128803. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  128804. /**
  128805. * Loads a texture from the transcode result
  128806. * @param texture texture load to
  128807. * @param transcodeResult the result of transcoding the basis file to load from
  128808. */
  128809. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  128810. }
  128811. }
  128812. declare module BABYLON {
  128813. /**
  128814. * Loader for .basis file format
  128815. */
  128816. export class _BasisTextureLoader implements IInternalTextureLoader {
  128817. /**
  128818. * Defines whether the loader supports cascade loading the different faces.
  128819. */
  128820. readonly supportCascades: boolean;
  128821. /**
  128822. * This returns if the loader support the current file information.
  128823. * @param extension defines the file extension of the file being loaded
  128824. * @param textureFormatInUse defines the current compressed format in use iun the engine
  128825. * @param fallback defines the fallback internal texture if any
  128826. * @param isBase64 defines whether the texture is encoded as a base64
  128827. * @param isBuffer defines whether the texture data are stored as a buffer
  128828. * @returns true if the loader can load the specified file
  128829. */
  128830. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  128831. /**
  128832. * Transform the url before loading if required.
  128833. * @param rootUrl the url of the texture
  128834. * @param textureFormatInUse defines the current compressed format in use iun the engine
  128835. * @returns the transformed texture
  128836. */
  128837. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  128838. /**
  128839. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  128840. * @param rootUrl the url of the texture
  128841. * @param textureFormatInUse defines the current compressed format in use iun the engine
  128842. * @returns the fallback texture
  128843. */
  128844. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  128845. /**
  128846. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  128847. * @param data contains the texture data
  128848. * @param texture defines the BabylonJS internal texture
  128849. * @param createPolynomials will be true if polynomials have been requested
  128850. * @param onLoad defines the callback to trigger once the texture is ready
  128851. * @param onError defines the callback to trigger in case of error
  128852. */
  128853. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  128854. /**
  128855. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  128856. * @param data contains the texture data
  128857. * @param texture defines the BabylonJS internal texture
  128858. * @param callback defines the method to call once ready to upload
  128859. */
  128860. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  128861. }
  128862. }
  128863. declare module BABYLON {
  128864. /**
  128865. * 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.
  128866. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  128867. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  128868. */
  128869. export class CustomProceduralTexture extends ProceduralTexture {
  128870. private _animate;
  128871. private _time;
  128872. private _config;
  128873. private _texturePath;
  128874. /**
  128875. * Instantiates a new Custom Procedural Texture.
  128876. * 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.
  128877. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  128878. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  128879. * @param name Define the name of the texture
  128880. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  128881. * @param size Define the size of the texture to create
  128882. * @param scene Define the scene the texture belongs to
  128883. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  128884. * @param generateMipMaps Define if the texture should creates mip maps or not
  128885. */
  128886. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  128887. private _loadJson;
  128888. /**
  128889. * Is the texture ready to be used ? (rendered at least once)
  128890. * @returns true if ready, otherwise, false.
  128891. */
  128892. isReady(): boolean;
  128893. /**
  128894. * Render the texture to its associated render target.
  128895. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  128896. */
  128897. render(useCameraPostProcess?: boolean): void;
  128898. /**
  128899. * Update the list of dependant textures samplers in the shader.
  128900. */
  128901. updateTextures(): void;
  128902. /**
  128903. * Update the uniform values of the procedural texture in the shader.
  128904. */
  128905. updateShaderUniforms(): void;
  128906. /**
  128907. * Define if the texture animates or not.
  128908. */
  128909. get animate(): boolean;
  128910. set animate(value: boolean);
  128911. }
  128912. }
  128913. declare module BABYLON {
  128914. /** @hidden */
  128915. export var noisePixelShader: {
  128916. name: string;
  128917. shader: string;
  128918. };
  128919. }
  128920. declare module BABYLON {
  128921. /**
  128922. * Class used to generate noise procedural textures
  128923. */
  128924. export class NoiseProceduralTexture extends ProceduralTexture {
  128925. private _time;
  128926. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  128927. brightness: number;
  128928. /** Defines the number of octaves to process */
  128929. octaves: number;
  128930. /** Defines the level of persistence (0.8 by default) */
  128931. persistence: number;
  128932. /** Gets or sets animation speed factor (default is 1) */
  128933. animationSpeedFactor: number;
  128934. /**
  128935. * Creates a new NoiseProceduralTexture
  128936. * @param name defines the name fo the texture
  128937. * @param size defines the size of the texture (default is 256)
  128938. * @param scene defines the hosting scene
  128939. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  128940. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  128941. */
  128942. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  128943. private _updateShaderUniforms;
  128944. protected _getDefines(): string;
  128945. /** Generate the current state of the procedural texture */
  128946. render(useCameraPostProcess?: boolean): void;
  128947. /**
  128948. * Serializes this noise procedural texture
  128949. * @returns a serialized noise procedural texture object
  128950. */
  128951. serialize(): any;
  128952. /**
  128953. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  128954. * @param parsedTexture defines parsed texture data
  128955. * @param scene defines the current scene
  128956. * @param rootUrl defines the root URL containing noise procedural texture information
  128957. * @returns a parsed NoiseProceduralTexture
  128958. */
  128959. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  128960. }
  128961. }
  128962. declare module BABYLON {
  128963. /**
  128964. * Raw cube texture where the raw buffers are passed in
  128965. */
  128966. export class RawCubeTexture extends CubeTexture {
  128967. /**
  128968. * Creates a cube texture where the raw buffers are passed in.
  128969. * @param scene defines the scene the texture is attached to
  128970. * @param data defines the array of data to use to create each face
  128971. * @param size defines the size of the textures
  128972. * @param format defines the format of the data
  128973. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  128974. * @param generateMipMaps defines if the engine should generate the mip levels
  128975. * @param invertY defines if data must be stored with Y axis inverted
  128976. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  128977. * @param compression defines the compression used (null by default)
  128978. */
  128979. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  128980. /**
  128981. * Updates the raw cube texture.
  128982. * @param data defines the data to store
  128983. * @param format defines the data format
  128984. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  128985. * @param invertY defines if data must be stored with Y axis inverted
  128986. * @param compression defines the compression used (null by default)
  128987. * @param level defines which level of the texture to update
  128988. */
  128989. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  128990. /**
  128991. * Updates a raw cube texture with RGBD encoded data.
  128992. * @param data defines the array of data [mipmap][face] to use to create each face
  128993. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  128994. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  128995. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  128996. * @returns a promsie that resolves when the operation is complete
  128997. */
  128998. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  128999. /**
  129000. * Clones the raw cube texture.
  129001. * @return a new cube texture
  129002. */
  129003. clone(): CubeTexture;
  129004. /** @hidden */
  129005. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  129006. }
  129007. }
  129008. declare module BABYLON {
  129009. /**
  129010. * Class used to store 3D textures containing user data
  129011. */
  129012. export class RawTexture3D extends Texture {
  129013. /** Gets or sets the texture format to use */
  129014. format: number;
  129015. private _engine;
  129016. /**
  129017. * Create a new RawTexture3D
  129018. * @param data defines the data of the texture
  129019. * @param width defines the width of the texture
  129020. * @param height defines the height of the texture
  129021. * @param depth defines the depth of the texture
  129022. * @param format defines the texture format to use
  129023. * @param scene defines the hosting scene
  129024. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129025. * @param invertY defines if texture must be stored with Y axis inverted
  129026. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129027. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129028. */
  129029. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129030. /** Gets or sets the texture format to use */
  129031. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129032. /**
  129033. * Update the texture with new data
  129034. * @param data defines the data to store in the texture
  129035. */
  129036. update(data: ArrayBufferView): void;
  129037. }
  129038. }
  129039. declare module BABYLON {
  129040. /**
  129041. * Class used to store 2D array textures containing user data
  129042. */
  129043. export class RawTexture2DArray extends Texture {
  129044. /** Gets or sets the texture format to use */
  129045. format: number;
  129046. private _engine;
  129047. /**
  129048. * Create a new RawTexture2DArray
  129049. * @param data defines the data of the texture
  129050. * @param width defines the width of the texture
  129051. * @param height defines the height of the texture
  129052. * @param depth defines the number of layers of the texture
  129053. * @param format defines the texture format to use
  129054. * @param scene defines the hosting scene
  129055. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129056. * @param invertY defines if texture must be stored with Y axis inverted
  129057. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129058. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129059. */
  129060. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129061. /** Gets or sets the texture format to use */
  129062. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129063. /**
  129064. * Update the texture with new data
  129065. * @param data defines the data to store in the texture
  129066. */
  129067. update(data: ArrayBufferView): void;
  129068. }
  129069. }
  129070. declare module BABYLON {
  129071. /**
  129072. * Creates a refraction texture used by refraction channel of the standard material.
  129073. * It is like a mirror but to see through a material.
  129074. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129075. */
  129076. export class RefractionTexture extends RenderTargetTexture {
  129077. /**
  129078. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  129079. * 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.
  129080. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129081. */
  129082. refractionPlane: Plane;
  129083. /**
  129084. * Define how deep under the surface we should see.
  129085. */
  129086. depth: number;
  129087. /**
  129088. * Creates a refraction texture used by refraction channel of the standard material.
  129089. * It is like a mirror but to see through a material.
  129090. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129091. * @param name Define the texture name
  129092. * @param size Define the size of the underlying texture
  129093. * @param scene Define the scene the refraction belongs to
  129094. * @param generateMipMaps Define if we need to generate mips level for the refraction
  129095. */
  129096. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  129097. /**
  129098. * Clone the refraction texture.
  129099. * @returns the cloned texture
  129100. */
  129101. clone(): RefractionTexture;
  129102. /**
  129103. * Serialize the texture to a JSON representation you could use in Parse later on
  129104. * @returns the serialized JSON representation
  129105. */
  129106. serialize(): any;
  129107. }
  129108. }
  129109. declare module BABYLON {
  129110. /**
  129111. * Defines the options related to the creation of an HtmlElementTexture
  129112. */
  129113. export interface IHtmlElementTextureOptions {
  129114. /**
  129115. * Defines wether mip maps should be created or not.
  129116. */
  129117. generateMipMaps?: boolean;
  129118. /**
  129119. * Defines the sampling mode of the texture.
  129120. */
  129121. samplingMode?: number;
  129122. /**
  129123. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  129124. */
  129125. engine: Nullable<ThinEngine>;
  129126. /**
  129127. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  129128. */
  129129. scene: Nullable<Scene>;
  129130. }
  129131. /**
  129132. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  129133. * To be as efficient as possible depending on your constraints nothing aside the first upload
  129134. * is automatically managed.
  129135. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  129136. * in your application.
  129137. *
  129138. * As the update is not automatic, you need to call them manually.
  129139. */
  129140. export class HtmlElementTexture extends BaseTexture {
  129141. /**
  129142. * The texture URL.
  129143. */
  129144. element: HTMLVideoElement | HTMLCanvasElement;
  129145. private static readonly DefaultOptions;
  129146. private _textureMatrix;
  129147. private _engine;
  129148. private _isVideo;
  129149. private _generateMipMaps;
  129150. private _samplingMode;
  129151. /**
  129152. * Instantiates a HtmlElementTexture from the following parameters.
  129153. *
  129154. * @param name Defines the name of the texture
  129155. * @param element Defines the video or canvas the texture is filled with
  129156. * @param options Defines the other none mandatory texture creation options
  129157. */
  129158. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  129159. private _createInternalTexture;
  129160. /**
  129161. * Returns the texture matrix used in most of the material.
  129162. */
  129163. getTextureMatrix(): Matrix;
  129164. /**
  129165. * Updates the content of the texture.
  129166. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  129167. */
  129168. update(invertY?: Nullable<boolean>): void;
  129169. }
  129170. }
  129171. declare module BABYLON {
  129172. /**
  129173. * Enum used to define the target of a block
  129174. */
  129175. export enum NodeMaterialBlockTargets {
  129176. /** Vertex shader */
  129177. Vertex = 1,
  129178. /** Fragment shader */
  129179. Fragment = 2,
  129180. /** Neutral */
  129181. Neutral = 4,
  129182. /** Vertex and Fragment */
  129183. VertexAndFragment = 3
  129184. }
  129185. }
  129186. declare module BABYLON {
  129187. /**
  129188. * Defines the kind of connection point for node based material
  129189. */
  129190. export enum NodeMaterialBlockConnectionPointTypes {
  129191. /** Float */
  129192. Float = 1,
  129193. /** Int */
  129194. Int = 2,
  129195. /** Vector2 */
  129196. Vector2 = 4,
  129197. /** Vector3 */
  129198. Vector3 = 8,
  129199. /** Vector4 */
  129200. Vector4 = 16,
  129201. /** Color3 */
  129202. Color3 = 32,
  129203. /** Color4 */
  129204. Color4 = 64,
  129205. /** Matrix */
  129206. Matrix = 128,
  129207. /** Detect type based on connection */
  129208. AutoDetect = 1024,
  129209. /** Output type that will be defined by input type */
  129210. BasedOnInput = 2048
  129211. }
  129212. }
  129213. declare module BABYLON {
  129214. /**
  129215. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  129216. */
  129217. export enum NodeMaterialBlockConnectionPointMode {
  129218. /** Value is an uniform */
  129219. Uniform = 0,
  129220. /** Value is a mesh attribute */
  129221. Attribute = 1,
  129222. /** Value is a varying between vertex and fragment shaders */
  129223. Varying = 2,
  129224. /** Mode is undefined */
  129225. Undefined = 3
  129226. }
  129227. }
  129228. declare module BABYLON {
  129229. /**
  129230. * Enum used to define system values e.g. values automatically provided by the system
  129231. */
  129232. export enum NodeMaterialSystemValues {
  129233. /** World */
  129234. World = 1,
  129235. /** View */
  129236. View = 2,
  129237. /** Projection */
  129238. Projection = 3,
  129239. /** ViewProjection */
  129240. ViewProjection = 4,
  129241. /** WorldView */
  129242. WorldView = 5,
  129243. /** WorldViewProjection */
  129244. WorldViewProjection = 6,
  129245. /** CameraPosition */
  129246. CameraPosition = 7,
  129247. /** Fog Color */
  129248. FogColor = 8,
  129249. /** Delta time */
  129250. DeltaTime = 9
  129251. }
  129252. }
  129253. declare module BABYLON {
  129254. /**
  129255. * Root class for all node material optimizers
  129256. */
  129257. export class NodeMaterialOptimizer {
  129258. /**
  129259. * Function used to optimize a NodeMaterial graph
  129260. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  129261. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  129262. */
  129263. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  129264. }
  129265. }
  129266. declare module BABYLON {
  129267. /**
  129268. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  129269. */
  129270. export class TransformBlock extends NodeMaterialBlock {
  129271. /**
  129272. * Defines the value to use to complement W value to transform it to a Vector4
  129273. */
  129274. complementW: number;
  129275. /**
  129276. * Defines the value to use to complement z value to transform it to a Vector4
  129277. */
  129278. complementZ: number;
  129279. /**
  129280. * Creates a new TransformBlock
  129281. * @param name defines the block name
  129282. */
  129283. constructor(name: string);
  129284. /**
  129285. * Gets the current class name
  129286. * @returns the class name
  129287. */
  129288. getClassName(): string;
  129289. /**
  129290. * Gets the vector input
  129291. */
  129292. get vector(): NodeMaterialConnectionPoint;
  129293. /**
  129294. * Gets the output component
  129295. */
  129296. get output(): NodeMaterialConnectionPoint;
  129297. /**
  129298. * Gets the matrix transform input
  129299. */
  129300. get transform(): NodeMaterialConnectionPoint;
  129301. protected _buildBlock(state: NodeMaterialBuildState): this;
  129302. serialize(): any;
  129303. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  129304. protected _dumpPropertiesCode(): string;
  129305. }
  129306. }
  129307. declare module BABYLON {
  129308. /**
  129309. * Block used to output the vertex position
  129310. */
  129311. export class VertexOutputBlock extends NodeMaterialBlock {
  129312. /**
  129313. * Creates a new VertexOutputBlock
  129314. * @param name defines the block name
  129315. */
  129316. constructor(name: string);
  129317. /**
  129318. * Gets the current class name
  129319. * @returns the class name
  129320. */
  129321. getClassName(): string;
  129322. /**
  129323. * Gets the vector input component
  129324. */
  129325. get vector(): NodeMaterialConnectionPoint;
  129326. protected _buildBlock(state: NodeMaterialBuildState): this;
  129327. }
  129328. }
  129329. declare module BABYLON {
  129330. /**
  129331. * Block used to output the final color
  129332. */
  129333. export class FragmentOutputBlock extends NodeMaterialBlock {
  129334. /**
  129335. * Create a new FragmentOutputBlock
  129336. * @param name defines the block name
  129337. */
  129338. constructor(name: string);
  129339. /**
  129340. * Gets the current class name
  129341. * @returns the class name
  129342. */
  129343. getClassName(): string;
  129344. /**
  129345. * Gets the rgba input component
  129346. */
  129347. get rgba(): NodeMaterialConnectionPoint;
  129348. /**
  129349. * Gets the rgb input component
  129350. */
  129351. get rgb(): NodeMaterialConnectionPoint;
  129352. /**
  129353. * Gets the a input component
  129354. */
  129355. get a(): NodeMaterialConnectionPoint;
  129356. protected _buildBlock(state: NodeMaterialBuildState): this;
  129357. }
  129358. }
  129359. declare module BABYLON {
  129360. /**
  129361. * Block used to read a reflection texture from a sampler
  129362. */
  129363. export class ReflectionTextureBlock extends NodeMaterialBlock {
  129364. private _define3DName;
  129365. private _defineCubicName;
  129366. private _defineExplicitName;
  129367. private _defineProjectionName;
  129368. private _defineLocalCubicName;
  129369. private _defineSphericalName;
  129370. private _definePlanarName;
  129371. private _defineEquirectangularName;
  129372. private _defineMirroredEquirectangularFixedName;
  129373. private _defineEquirectangularFixedName;
  129374. private _defineSkyboxName;
  129375. private _cubeSamplerName;
  129376. private _2DSamplerName;
  129377. private _positionUVWName;
  129378. private _directionWName;
  129379. private _reflectionCoordsName;
  129380. private _reflection2DCoordsName;
  129381. private _reflectionColorName;
  129382. private _reflectionMatrixName;
  129383. /**
  129384. * Gets or sets the texture associated with the node
  129385. */
  129386. texture: Nullable<BaseTexture>;
  129387. /**
  129388. * Create a new TextureBlock
  129389. * @param name defines the block name
  129390. */
  129391. constructor(name: string);
  129392. /**
  129393. * Gets the current class name
  129394. * @returns the class name
  129395. */
  129396. getClassName(): string;
  129397. /**
  129398. * Gets the world position input component
  129399. */
  129400. get position(): NodeMaterialConnectionPoint;
  129401. /**
  129402. * Gets the world position input component
  129403. */
  129404. get worldPosition(): NodeMaterialConnectionPoint;
  129405. /**
  129406. * Gets the world normal input component
  129407. */
  129408. get worldNormal(): NodeMaterialConnectionPoint;
  129409. /**
  129410. * Gets the world input component
  129411. */
  129412. get world(): NodeMaterialConnectionPoint;
  129413. /**
  129414. * Gets the camera (or eye) position component
  129415. */
  129416. get cameraPosition(): NodeMaterialConnectionPoint;
  129417. /**
  129418. * Gets the view input component
  129419. */
  129420. get view(): NodeMaterialConnectionPoint;
  129421. /**
  129422. * Gets the rgb output component
  129423. */
  129424. get rgb(): NodeMaterialConnectionPoint;
  129425. /**
  129426. * Gets the r output component
  129427. */
  129428. get r(): NodeMaterialConnectionPoint;
  129429. /**
  129430. * Gets the g output component
  129431. */
  129432. get g(): NodeMaterialConnectionPoint;
  129433. /**
  129434. * Gets the b output component
  129435. */
  129436. get b(): NodeMaterialConnectionPoint;
  129437. autoConfigure(material: NodeMaterial): void;
  129438. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  129439. isReady(): boolean;
  129440. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  129441. private _injectVertexCode;
  129442. private _writeOutput;
  129443. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  129444. protected _dumpPropertiesCode(): string;
  129445. serialize(): any;
  129446. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  129447. }
  129448. }
  129449. declare module BABYLON {
  129450. /**
  129451. * Interface used to configure the node material editor
  129452. */
  129453. export interface INodeMaterialEditorOptions {
  129454. /** Define the URl to load node editor script */
  129455. editorURL?: string;
  129456. }
  129457. /** @hidden */
  129458. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  129459. NORMAL: boolean;
  129460. TANGENT: boolean;
  129461. UV1: boolean;
  129462. /** BONES */
  129463. NUM_BONE_INFLUENCERS: number;
  129464. BonesPerMesh: number;
  129465. BONETEXTURE: boolean;
  129466. /** MORPH TARGETS */
  129467. MORPHTARGETS: boolean;
  129468. MORPHTARGETS_NORMAL: boolean;
  129469. MORPHTARGETS_TANGENT: boolean;
  129470. MORPHTARGETS_UV: boolean;
  129471. NUM_MORPH_INFLUENCERS: number;
  129472. /** IMAGE PROCESSING */
  129473. IMAGEPROCESSING: boolean;
  129474. VIGNETTE: boolean;
  129475. VIGNETTEBLENDMODEMULTIPLY: boolean;
  129476. VIGNETTEBLENDMODEOPAQUE: boolean;
  129477. TONEMAPPING: boolean;
  129478. TONEMAPPING_ACES: boolean;
  129479. CONTRAST: boolean;
  129480. EXPOSURE: boolean;
  129481. COLORCURVES: boolean;
  129482. COLORGRADING: boolean;
  129483. COLORGRADING3D: boolean;
  129484. SAMPLER3DGREENDEPTH: boolean;
  129485. SAMPLER3DBGRMAP: boolean;
  129486. IMAGEPROCESSINGPOSTPROCESS: boolean;
  129487. /** MISC. */
  129488. BUMPDIRECTUV: number;
  129489. constructor();
  129490. setValue(name: string, value: boolean): void;
  129491. }
  129492. /**
  129493. * Class used to configure NodeMaterial
  129494. */
  129495. export interface INodeMaterialOptions {
  129496. /**
  129497. * Defines if blocks should emit comments
  129498. */
  129499. emitComments: boolean;
  129500. }
  129501. /**
  129502. * Class used to create a node based material built by assembling shader blocks
  129503. */
  129504. export class NodeMaterial extends PushMaterial {
  129505. private static _BuildIdGenerator;
  129506. private _options;
  129507. private _vertexCompilationState;
  129508. private _fragmentCompilationState;
  129509. private _sharedData;
  129510. private _buildId;
  129511. private _buildWasSuccessful;
  129512. private _cachedWorldViewMatrix;
  129513. private _cachedWorldViewProjectionMatrix;
  129514. private _optimizers;
  129515. private _animationFrame;
  129516. /** Define the Url to load node editor script */
  129517. static EditorURL: string;
  129518. /** Define the Url to load snippets */
  129519. static SnippetUrl: string;
  129520. private BJSNODEMATERIALEDITOR;
  129521. /** Get the inspector from bundle or global */
  129522. private _getGlobalNodeMaterialEditor;
  129523. /**
  129524. * Gets or sets data used by visual editor
  129525. * @see https://nme.babylonjs.com
  129526. */
  129527. editorData: any;
  129528. /**
  129529. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  129530. */
  129531. ignoreAlpha: boolean;
  129532. /**
  129533. * Defines the maximum number of lights that can be used in the material
  129534. */
  129535. maxSimultaneousLights: number;
  129536. /**
  129537. * Observable raised when the material is built
  129538. */
  129539. onBuildObservable: Observable<NodeMaterial>;
  129540. /**
  129541. * Gets or sets the root nodes of the material vertex shader
  129542. */
  129543. _vertexOutputNodes: NodeMaterialBlock[];
  129544. /**
  129545. * Gets or sets the root nodes of the material fragment (pixel) shader
  129546. */
  129547. _fragmentOutputNodes: NodeMaterialBlock[];
  129548. /** Gets or sets options to control the node material overall behavior */
  129549. get options(): INodeMaterialOptions;
  129550. set options(options: INodeMaterialOptions);
  129551. /**
  129552. * Default configuration related to image processing available in the standard Material.
  129553. */
  129554. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  129555. /**
  129556. * Gets the image processing configuration used either in this material.
  129557. */
  129558. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  129559. /**
  129560. * Sets the Default image processing configuration used either in the this material.
  129561. *
  129562. * If sets to null, the scene one is in use.
  129563. */
  129564. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  129565. /**
  129566. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  129567. */
  129568. attachedBlocks: NodeMaterialBlock[];
  129569. /**
  129570. * Create a new node based material
  129571. * @param name defines the material name
  129572. * @param scene defines the hosting scene
  129573. * @param options defines creation option
  129574. */
  129575. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  129576. /**
  129577. * Gets the current class name of the material e.g. "NodeMaterial"
  129578. * @returns the class name
  129579. */
  129580. getClassName(): string;
  129581. /**
  129582. * Keep track of the image processing observer to allow dispose and replace.
  129583. */
  129584. private _imageProcessingObserver;
  129585. /**
  129586. * Attaches a new image processing configuration to the Standard Material.
  129587. * @param configuration
  129588. */
  129589. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  129590. /**
  129591. * Get a block by its name
  129592. * @param name defines the name of the block to retrieve
  129593. * @returns the required block or null if not found
  129594. */
  129595. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  129596. /**
  129597. * Get a block by its name
  129598. * @param predicate defines the predicate used to find the good candidate
  129599. * @returns the required block or null if not found
  129600. */
  129601. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  129602. /**
  129603. * Get an input block by its name
  129604. * @param predicate defines the predicate used to find the good candidate
  129605. * @returns the required input block or null if not found
  129606. */
  129607. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  129608. /**
  129609. * Gets the list of input blocks attached to this material
  129610. * @returns an array of InputBlocks
  129611. */
  129612. getInputBlocks(): InputBlock[];
  129613. /**
  129614. * Adds a new optimizer to the list of optimizers
  129615. * @param optimizer defines the optimizers to add
  129616. * @returns the current material
  129617. */
  129618. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  129619. /**
  129620. * Remove an optimizer from the list of optimizers
  129621. * @param optimizer defines the optimizers to remove
  129622. * @returns the current material
  129623. */
  129624. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  129625. /**
  129626. * Add a new block to the list of output nodes
  129627. * @param node defines the node to add
  129628. * @returns the current material
  129629. */
  129630. addOutputNode(node: NodeMaterialBlock): this;
  129631. /**
  129632. * Remove a block from the list of root nodes
  129633. * @param node defines the node to remove
  129634. * @returns the current material
  129635. */
  129636. removeOutputNode(node: NodeMaterialBlock): this;
  129637. private _addVertexOutputNode;
  129638. private _removeVertexOutputNode;
  129639. private _addFragmentOutputNode;
  129640. private _removeFragmentOutputNode;
  129641. /**
  129642. * Specifies if the material will require alpha blending
  129643. * @returns a boolean specifying if alpha blending is needed
  129644. */
  129645. needAlphaBlending(): boolean;
  129646. /**
  129647. * Specifies if this material should be rendered in alpha test mode
  129648. * @returns a boolean specifying if an alpha test is needed.
  129649. */
  129650. needAlphaTesting(): boolean;
  129651. private _initializeBlock;
  129652. private _resetDualBlocks;
  129653. /**
  129654. * Remove a block from the current node material
  129655. * @param block defines the block to remove
  129656. */
  129657. removeBlock(block: NodeMaterialBlock): void;
  129658. /**
  129659. * Build the material and generates the inner effect
  129660. * @param verbose defines if the build should log activity
  129661. */
  129662. build(verbose?: boolean): void;
  129663. /**
  129664. * Runs an otpimization phase to try to improve the shader code
  129665. */
  129666. optimize(): void;
  129667. private _prepareDefinesForAttributes;
  129668. /**
  129669. * Get if the submesh is ready to be used and all its information available.
  129670. * Child classes can use it to update shaders
  129671. * @param mesh defines the mesh to check
  129672. * @param subMesh defines which submesh to check
  129673. * @param useInstances specifies that instances should be used
  129674. * @returns a boolean indicating that the submesh is ready or not
  129675. */
  129676. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  129677. /**
  129678. * Get a string representing the shaders built by the current node graph
  129679. */
  129680. get compiledShaders(): string;
  129681. /**
  129682. * Binds the world matrix to the material
  129683. * @param world defines the world transformation matrix
  129684. */
  129685. bindOnlyWorldMatrix(world: Matrix): void;
  129686. /**
  129687. * Binds the submesh to this material by preparing the effect and shader to draw
  129688. * @param world defines the world transformation matrix
  129689. * @param mesh defines the mesh containing the submesh
  129690. * @param subMesh defines the submesh to bind the material to
  129691. */
  129692. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  129693. /**
  129694. * Gets the active textures from the material
  129695. * @returns an array of textures
  129696. */
  129697. getActiveTextures(): BaseTexture[];
  129698. /**
  129699. * Gets the list of texture blocks
  129700. * @returns an array of texture blocks
  129701. */
  129702. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  129703. /**
  129704. * Specifies if the material uses a texture
  129705. * @param texture defines the texture to check against the material
  129706. * @returns a boolean specifying if the material uses the texture
  129707. */
  129708. hasTexture(texture: BaseTexture): boolean;
  129709. /**
  129710. * Disposes the material
  129711. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  129712. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  129713. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  129714. */
  129715. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  129716. /** Creates the node editor window. */
  129717. private _createNodeEditor;
  129718. /**
  129719. * Launch the node material editor
  129720. * @param config Define the configuration of the editor
  129721. * @return a promise fulfilled when the node editor is visible
  129722. */
  129723. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  129724. /**
  129725. * Clear the current material
  129726. */
  129727. clear(): void;
  129728. /**
  129729. * Clear the current material and set it to a default state
  129730. */
  129731. setToDefault(): void;
  129732. /**
  129733. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  129734. * @param url defines the url to load from
  129735. * @returns a promise that will fullfil when the material is fully loaded
  129736. */
  129737. loadAsync(url: string): Promise<void>;
  129738. private _gatherBlocks;
  129739. /**
  129740. * Generate a string containing the code declaration required to create an equivalent of this material
  129741. * @returns a string
  129742. */
  129743. generateCode(): string;
  129744. /**
  129745. * Serializes this material in a JSON representation
  129746. * @returns the serialized material object
  129747. */
  129748. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  129749. private _restoreConnections;
  129750. /**
  129751. * Clear the current graph and load a new one from a serialization object
  129752. * @param source defines the JSON representation of the material
  129753. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  129754. */
  129755. loadFromSerialization(source: any, rootUrl?: string): void;
  129756. /**
  129757. * Creates a node material from parsed material data
  129758. * @param source defines the JSON representation of the material
  129759. * @param scene defines the hosting scene
  129760. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  129761. * @returns a new node material
  129762. */
  129763. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  129764. /**
  129765. * Creates a node material from a snippet saved by the node material editor
  129766. * @param snippetId defines the snippet to load
  129767. * @param scene defines the hosting scene
  129768. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  129769. * @returns a promise that will resolve to the new node material
  129770. */
  129771. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  129772. /**
  129773. * Creates a new node material set to default basic configuration
  129774. * @param name defines the name of the material
  129775. * @param scene defines the hosting scene
  129776. * @returns a new NodeMaterial
  129777. */
  129778. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  129779. }
  129780. }
  129781. declare module BABYLON {
  129782. /**
  129783. * Block used to read a texture from a sampler
  129784. */
  129785. export class TextureBlock extends NodeMaterialBlock {
  129786. private _defineName;
  129787. private _linearDefineName;
  129788. private _tempTextureRead;
  129789. private _samplerName;
  129790. private _transformedUVName;
  129791. private _textureTransformName;
  129792. private _textureInfoName;
  129793. private _mainUVName;
  129794. private _mainUVDefineName;
  129795. /**
  129796. * Gets or sets the texture associated with the node
  129797. */
  129798. texture: Nullable<Texture>;
  129799. /**
  129800. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  129801. */
  129802. convertToGammaSpace: boolean;
  129803. /**
  129804. * Create a new TextureBlock
  129805. * @param name defines the block name
  129806. */
  129807. constructor(name: string);
  129808. /**
  129809. * Gets the current class name
  129810. * @returns the class name
  129811. */
  129812. getClassName(): string;
  129813. /**
  129814. * Gets the uv input component
  129815. */
  129816. get uv(): NodeMaterialConnectionPoint;
  129817. /**
  129818. * Gets the rgba output component
  129819. */
  129820. get rgba(): NodeMaterialConnectionPoint;
  129821. /**
  129822. * Gets the rgb output component
  129823. */
  129824. get rgb(): NodeMaterialConnectionPoint;
  129825. /**
  129826. * Gets the r output component
  129827. */
  129828. get r(): NodeMaterialConnectionPoint;
  129829. /**
  129830. * Gets the g output component
  129831. */
  129832. get g(): NodeMaterialConnectionPoint;
  129833. /**
  129834. * Gets the b output component
  129835. */
  129836. get b(): NodeMaterialConnectionPoint;
  129837. /**
  129838. * Gets the a output component
  129839. */
  129840. get a(): NodeMaterialConnectionPoint;
  129841. get target(): NodeMaterialBlockTargets;
  129842. autoConfigure(material: NodeMaterial): void;
  129843. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  129844. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  129845. isReady(): boolean;
  129846. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  129847. private get _isMixed();
  129848. private _injectVertexCode;
  129849. private _writeTextureRead;
  129850. private _writeOutput;
  129851. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  129852. protected _dumpPropertiesCode(): string;
  129853. serialize(): any;
  129854. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  129855. }
  129856. }
  129857. declare module BABYLON {
  129858. /**
  129859. * Class used to store shared data between 2 NodeMaterialBuildState
  129860. */
  129861. export class NodeMaterialBuildStateSharedData {
  129862. /**
  129863. * Gets the list of emitted varyings
  129864. */
  129865. temps: string[];
  129866. /**
  129867. * Gets the list of emitted varyings
  129868. */
  129869. varyings: string[];
  129870. /**
  129871. * Gets the varying declaration string
  129872. */
  129873. varyingDeclaration: string;
  129874. /**
  129875. * Input blocks
  129876. */
  129877. inputBlocks: InputBlock[];
  129878. /**
  129879. * Input blocks
  129880. */
  129881. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  129882. /**
  129883. * Bindable blocks (Blocks that need to set data to the effect)
  129884. */
  129885. bindableBlocks: NodeMaterialBlock[];
  129886. /**
  129887. * List of blocks that can provide a compilation fallback
  129888. */
  129889. blocksWithFallbacks: NodeMaterialBlock[];
  129890. /**
  129891. * List of blocks that can provide a define update
  129892. */
  129893. blocksWithDefines: NodeMaterialBlock[];
  129894. /**
  129895. * List of blocks that can provide a repeatable content
  129896. */
  129897. repeatableContentBlocks: NodeMaterialBlock[];
  129898. /**
  129899. * List of blocks that can provide a dynamic list of uniforms
  129900. */
  129901. dynamicUniformBlocks: NodeMaterialBlock[];
  129902. /**
  129903. * List of blocks that can block the isReady function for the material
  129904. */
  129905. blockingBlocks: NodeMaterialBlock[];
  129906. /**
  129907. * Gets the list of animated inputs
  129908. */
  129909. animatedInputs: InputBlock[];
  129910. /**
  129911. * Build Id used to avoid multiple recompilations
  129912. */
  129913. buildId: number;
  129914. /** List of emitted variables */
  129915. variableNames: {
  129916. [key: string]: number;
  129917. };
  129918. /** List of emitted defines */
  129919. defineNames: {
  129920. [key: string]: number;
  129921. };
  129922. /** Should emit comments? */
  129923. emitComments: boolean;
  129924. /** Emit build activity */
  129925. verbose: boolean;
  129926. /** Gets or sets the hosting scene */
  129927. scene: Scene;
  129928. /**
  129929. * Gets the compilation hints emitted at compilation time
  129930. */
  129931. hints: {
  129932. needWorldViewMatrix: boolean;
  129933. needWorldViewProjectionMatrix: boolean;
  129934. needAlphaBlending: boolean;
  129935. needAlphaTesting: boolean;
  129936. };
  129937. /**
  129938. * List of compilation checks
  129939. */
  129940. checks: {
  129941. emitVertex: boolean;
  129942. emitFragment: boolean;
  129943. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  129944. };
  129945. /** Creates a new shared data */
  129946. constructor();
  129947. /**
  129948. * Emits console errors and exceptions if there is a failing check
  129949. */
  129950. emitErrors(): void;
  129951. }
  129952. }
  129953. declare module BABYLON {
  129954. /**
  129955. * Class used to store node based material build state
  129956. */
  129957. export class NodeMaterialBuildState {
  129958. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  129959. supportUniformBuffers: boolean;
  129960. /**
  129961. * Gets the list of emitted attributes
  129962. */
  129963. attributes: string[];
  129964. /**
  129965. * Gets the list of emitted uniforms
  129966. */
  129967. uniforms: string[];
  129968. /**
  129969. * Gets the list of emitted constants
  129970. */
  129971. constants: string[];
  129972. /**
  129973. * Gets the list of emitted samplers
  129974. */
  129975. samplers: string[];
  129976. /**
  129977. * Gets the list of emitted functions
  129978. */
  129979. functions: {
  129980. [key: string]: string;
  129981. };
  129982. /**
  129983. * Gets the list of emitted extensions
  129984. */
  129985. extensions: {
  129986. [key: string]: string;
  129987. };
  129988. /**
  129989. * Gets the target of the compilation state
  129990. */
  129991. target: NodeMaterialBlockTargets;
  129992. /**
  129993. * Gets the list of emitted counters
  129994. */
  129995. counters: {
  129996. [key: string]: number;
  129997. };
  129998. /**
  129999. * Shared data between multiple NodeMaterialBuildState instances
  130000. */
  130001. sharedData: NodeMaterialBuildStateSharedData;
  130002. /** @hidden */
  130003. _vertexState: NodeMaterialBuildState;
  130004. /** @hidden */
  130005. _attributeDeclaration: string;
  130006. /** @hidden */
  130007. _uniformDeclaration: string;
  130008. /** @hidden */
  130009. _constantDeclaration: string;
  130010. /** @hidden */
  130011. _samplerDeclaration: string;
  130012. /** @hidden */
  130013. _varyingTransfer: string;
  130014. private _repeatableContentAnchorIndex;
  130015. /** @hidden */
  130016. _builtCompilationString: string;
  130017. /**
  130018. * Gets the emitted compilation strings
  130019. */
  130020. compilationString: string;
  130021. /**
  130022. * Finalize the compilation strings
  130023. * @param state defines the current compilation state
  130024. */
  130025. finalize(state: NodeMaterialBuildState): void;
  130026. /** @hidden */
  130027. get _repeatableContentAnchor(): string;
  130028. /** @hidden */
  130029. _getFreeVariableName(prefix: string): string;
  130030. /** @hidden */
  130031. _getFreeDefineName(prefix: string): string;
  130032. /** @hidden */
  130033. _excludeVariableName(name: string): void;
  130034. /** @hidden */
  130035. _emit2DSampler(name: string): void;
  130036. /** @hidden */
  130037. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  130038. /** @hidden */
  130039. _emitExtension(name: string, extension: string): void;
  130040. /** @hidden */
  130041. _emitFunction(name: string, code: string, comments: string): void;
  130042. /** @hidden */
  130043. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  130044. replaceStrings?: {
  130045. search: RegExp;
  130046. replace: string;
  130047. }[];
  130048. repeatKey?: string;
  130049. }): string;
  130050. /** @hidden */
  130051. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  130052. repeatKey?: string;
  130053. removeAttributes?: boolean;
  130054. removeUniforms?: boolean;
  130055. removeVaryings?: boolean;
  130056. removeIfDef?: boolean;
  130057. replaceStrings?: {
  130058. search: RegExp;
  130059. replace: string;
  130060. }[];
  130061. }, storeKey?: string): void;
  130062. /** @hidden */
  130063. _registerTempVariable(name: string): boolean;
  130064. /** @hidden */
  130065. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  130066. /** @hidden */
  130067. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  130068. /** @hidden */
  130069. _emitFloat(value: number): string;
  130070. }
  130071. }
  130072. declare module BABYLON {
  130073. /**
  130074. * Defines a block that can be used inside a node based material
  130075. */
  130076. export class NodeMaterialBlock {
  130077. private _buildId;
  130078. private _buildTarget;
  130079. private _target;
  130080. private _isFinalMerger;
  130081. private _isInput;
  130082. protected _isUnique: boolean;
  130083. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  130084. inputsAreExclusive: boolean;
  130085. /** @hidden */
  130086. _codeVariableName: string;
  130087. /** @hidden */
  130088. _inputs: NodeMaterialConnectionPoint[];
  130089. /** @hidden */
  130090. _outputs: NodeMaterialConnectionPoint[];
  130091. /** @hidden */
  130092. _preparationId: number;
  130093. /**
  130094. * Gets or sets the name of the block
  130095. */
  130096. name: string;
  130097. /**
  130098. * Gets or sets the unique id of the node
  130099. */
  130100. uniqueId: number;
  130101. /**
  130102. * Gets or sets the comments associated with this block
  130103. */
  130104. comments: string;
  130105. /**
  130106. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  130107. */
  130108. get isUnique(): boolean;
  130109. /**
  130110. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  130111. */
  130112. get isFinalMerger(): boolean;
  130113. /**
  130114. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  130115. */
  130116. get isInput(): boolean;
  130117. /**
  130118. * Gets or sets the build Id
  130119. */
  130120. get buildId(): number;
  130121. set buildId(value: number);
  130122. /**
  130123. * Gets or sets the target of the block
  130124. */
  130125. get target(): NodeMaterialBlockTargets;
  130126. set target(value: NodeMaterialBlockTargets);
  130127. /**
  130128. * Gets the list of input points
  130129. */
  130130. get inputs(): NodeMaterialConnectionPoint[];
  130131. /** Gets the list of output points */
  130132. get outputs(): NodeMaterialConnectionPoint[];
  130133. /**
  130134. * Find an input by its name
  130135. * @param name defines the name of the input to look for
  130136. * @returns the input or null if not found
  130137. */
  130138. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  130139. /**
  130140. * Find an output by its name
  130141. * @param name defines the name of the outputto look for
  130142. * @returns the output or null if not found
  130143. */
  130144. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  130145. /**
  130146. * Creates a new NodeMaterialBlock
  130147. * @param name defines the block name
  130148. * @param target defines the target of that block (Vertex by default)
  130149. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  130150. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  130151. */
  130152. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  130153. /**
  130154. * Initialize the block and prepare the context for build
  130155. * @param state defines the state that will be used for the build
  130156. */
  130157. initialize(state: NodeMaterialBuildState): void;
  130158. /**
  130159. * Bind data to effect. Will only be called for blocks with isBindable === true
  130160. * @param effect defines the effect to bind data to
  130161. * @param nodeMaterial defines the hosting NodeMaterial
  130162. * @param mesh defines the mesh that will be rendered
  130163. */
  130164. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130165. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  130166. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  130167. protected _writeFloat(value: number): string;
  130168. /**
  130169. * Gets the current class name e.g. "NodeMaterialBlock"
  130170. * @returns the class name
  130171. */
  130172. getClassName(): string;
  130173. /**
  130174. * Register a new input. Must be called inside a block constructor
  130175. * @param name defines the connection point name
  130176. * @param type defines the connection point type
  130177. * @param isOptional defines a boolean indicating that this input can be omitted
  130178. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  130179. * @returns the current block
  130180. */
  130181. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  130182. /**
  130183. * Register a new output. Must be called inside a block constructor
  130184. * @param name defines the connection point name
  130185. * @param type defines the connection point type
  130186. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  130187. * @returns the current block
  130188. */
  130189. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  130190. /**
  130191. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  130192. * @param forOutput defines an optional connection point to check compatibility with
  130193. * @returns the first available input or null
  130194. */
  130195. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  130196. /**
  130197. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  130198. * @param forBlock defines an optional block to check compatibility with
  130199. * @returns the first available input or null
  130200. */
  130201. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  130202. /**
  130203. * Gets the sibling of the given output
  130204. * @param current defines the current output
  130205. * @returns the next output in the list or null
  130206. */
  130207. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  130208. /**
  130209. * Connect current block with another block
  130210. * @param other defines the block to connect with
  130211. * @param options define the various options to help pick the right connections
  130212. * @returns the current block
  130213. */
  130214. connectTo(other: NodeMaterialBlock, options?: {
  130215. input?: string;
  130216. output?: string;
  130217. outputSwizzle?: string;
  130218. }): this | undefined;
  130219. protected _buildBlock(state: NodeMaterialBuildState): void;
  130220. /**
  130221. * Add uniforms, samplers and uniform buffers at compilation time
  130222. * @param state defines the state to update
  130223. * @param nodeMaterial defines the node material requesting the update
  130224. * @param defines defines the material defines to update
  130225. * @param uniformBuffers defines the list of uniform buffer names
  130226. */
  130227. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  130228. /**
  130229. * Add potential fallbacks if shader compilation fails
  130230. * @param mesh defines the mesh to be rendered
  130231. * @param fallbacks defines the current prioritized list of fallbacks
  130232. */
  130233. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  130234. /**
  130235. * Initialize defines for shader compilation
  130236. * @param mesh defines the mesh to be rendered
  130237. * @param nodeMaterial defines the node material requesting the update
  130238. * @param defines defines the material defines to update
  130239. * @param useInstances specifies that instances should be used
  130240. */
  130241. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130242. /**
  130243. * Update defines for shader compilation
  130244. * @param mesh defines the mesh to be rendered
  130245. * @param nodeMaterial defines the node material requesting the update
  130246. * @param defines defines the material defines to update
  130247. * @param useInstances specifies that instances should be used
  130248. */
  130249. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130250. /**
  130251. * Lets the block try to connect some inputs automatically
  130252. * @param material defines the hosting NodeMaterial
  130253. */
  130254. autoConfigure(material: NodeMaterial): void;
  130255. /**
  130256. * Function called when a block is declared as repeatable content generator
  130257. * @param vertexShaderState defines the current compilation state for the vertex shader
  130258. * @param fragmentShaderState defines the current compilation state for the fragment shader
  130259. * @param mesh defines the mesh to be rendered
  130260. * @param defines defines the material defines to update
  130261. */
  130262. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  130263. /**
  130264. * Checks if the block is ready
  130265. * @param mesh defines the mesh to be rendered
  130266. * @param nodeMaterial defines the node material requesting the update
  130267. * @param defines defines the material defines to update
  130268. * @param useInstances specifies that instances should be used
  130269. * @returns true if the block is ready
  130270. */
  130271. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  130272. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  130273. private _processBuild;
  130274. /**
  130275. * Compile the current node and generate the shader code
  130276. * @param state defines the current compilation state (uniforms, samplers, current string)
  130277. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  130278. * @returns true if already built
  130279. */
  130280. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  130281. protected _inputRename(name: string): string;
  130282. protected _outputRename(name: string): string;
  130283. protected _dumpPropertiesCode(): string;
  130284. /** @hidden */
  130285. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  130286. /** @hidden */
  130287. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  130288. /**
  130289. * Clone the current block to a new identical block
  130290. * @param scene defines the hosting scene
  130291. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130292. * @returns a copy of the current block
  130293. */
  130294. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  130295. /**
  130296. * Serializes this block in a JSON representation
  130297. * @returns the serialized block object
  130298. */
  130299. serialize(): any;
  130300. /** @hidden */
  130301. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130302. /**
  130303. * Release resources
  130304. */
  130305. dispose(): void;
  130306. }
  130307. }
  130308. declare module BABYLON {
  130309. /**
  130310. * Enum defining the type of animations supported by InputBlock
  130311. */
  130312. export enum AnimatedInputBlockTypes {
  130313. /** No animation */
  130314. None = 0,
  130315. /** Time based animation. Will only work for floats */
  130316. Time = 1
  130317. }
  130318. }
  130319. declare module BABYLON {
  130320. /**
  130321. * Block used to expose an input value
  130322. */
  130323. export class InputBlock extends NodeMaterialBlock {
  130324. private _mode;
  130325. private _associatedVariableName;
  130326. private _storedValue;
  130327. private _valueCallback;
  130328. private _type;
  130329. private _animationType;
  130330. /** Gets or set a value used to limit the range of float values */
  130331. min: number;
  130332. /** Gets or set a value used to limit the range of float values */
  130333. max: number;
  130334. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  130335. isBoolean: boolean;
  130336. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  130337. matrixMode: number;
  130338. /** @hidden */
  130339. _systemValue: Nullable<NodeMaterialSystemValues>;
  130340. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  130341. visibleInInspector: boolean;
  130342. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  130343. isConstant: boolean;
  130344. /** Gets or sets the group to use to display this block in the Inspector */
  130345. groupInInspector: string;
  130346. /**
  130347. * Gets or sets the connection point type (default is float)
  130348. */
  130349. get type(): NodeMaterialBlockConnectionPointTypes;
  130350. /**
  130351. * Creates a new InputBlock
  130352. * @param name defines the block name
  130353. * @param target defines the target of that block (Vertex by default)
  130354. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  130355. */
  130356. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  130357. /**
  130358. * Gets the output component
  130359. */
  130360. get output(): NodeMaterialConnectionPoint;
  130361. /**
  130362. * Set the source of this connection point to a vertex attribute
  130363. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  130364. * @returns the current connection point
  130365. */
  130366. setAsAttribute(attributeName?: string): InputBlock;
  130367. /**
  130368. * Set the source of this connection point to a system value
  130369. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  130370. * @returns the current connection point
  130371. */
  130372. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  130373. /**
  130374. * Gets or sets the value of that point.
  130375. * Please note that this value will be ignored if valueCallback is defined
  130376. */
  130377. get value(): any;
  130378. set value(value: any);
  130379. /**
  130380. * Gets or sets a callback used to get the value of that point.
  130381. * Please note that setting this value will force the connection point to ignore the value property
  130382. */
  130383. get valueCallback(): () => any;
  130384. set valueCallback(value: () => any);
  130385. /**
  130386. * Gets or sets the associated variable name in the shader
  130387. */
  130388. get associatedVariableName(): string;
  130389. set associatedVariableName(value: string);
  130390. /** Gets or sets the type of animation applied to the input */
  130391. get animationType(): AnimatedInputBlockTypes;
  130392. set animationType(value: AnimatedInputBlockTypes);
  130393. /**
  130394. * Gets a boolean indicating that this connection point not defined yet
  130395. */
  130396. get isUndefined(): boolean;
  130397. /**
  130398. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  130399. * In this case the connection point name must be the name of the uniform to use.
  130400. * Can only be set on inputs
  130401. */
  130402. get isUniform(): boolean;
  130403. set isUniform(value: boolean);
  130404. /**
  130405. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  130406. * In this case the connection point name must be the name of the attribute to use
  130407. * Can only be set on inputs
  130408. */
  130409. get isAttribute(): boolean;
  130410. set isAttribute(value: boolean);
  130411. /**
  130412. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  130413. * Can only be set on exit points
  130414. */
  130415. get isVarying(): boolean;
  130416. set isVarying(value: boolean);
  130417. /**
  130418. * Gets a boolean indicating that the current connection point is a system value
  130419. */
  130420. get isSystemValue(): boolean;
  130421. /**
  130422. * Gets or sets the current well known value or null if not defined as a system value
  130423. */
  130424. get systemValue(): Nullable<NodeMaterialSystemValues>;
  130425. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  130426. /**
  130427. * Gets the current class name
  130428. * @returns the class name
  130429. */
  130430. getClassName(): string;
  130431. /**
  130432. * Animate the input if animationType !== None
  130433. * @param scene defines the rendering scene
  130434. */
  130435. animate(scene: Scene): void;
  130436. private _emitDefine;
  130437. initialize(state: NodeMaterialBuildState): void;
  130438. /**
  130439. * Set the input block to its default value (based on its type)
  130440. */
  130441. setDefaultValue(): void;
  130442. private _emitConstant;
  130443. private _emit;
  130444. /** @hidden */
  130445. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  130446. /** @hidden */
  130447. _transmit(effect: Effect, scene: Scene): void;
  130448. protected _buildBlock(state: NodeMaterialBuildState): void;
  130449. protected _dumpPropertiesCode(): string;
  130450. serialize(): any;
  130451. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130452. }
  130453. }
  130454. declare module BABYLON {
  130455. /**
  130456. * Enum used to define the compatibility state between two connection points
  130457. */
  130458. export enum NodeMaterialConnectionPointCompatibilityStates {
  130459. /** Points are compatibles */
  130460. Compatible = 0,
  130461. /** Points are incompatible because of their types */
  130462. TypeIncompatible = 1,
  130463. /** Points are incompatible because of their targets (vertex vs fragment) */
  130464. TargetIncompatible = 2
  130465. }
  130466. /**
  130467. * Defines the direction of a connection point
  130468. */
  130469. export enum NodeMaterialConnectionPointDirection {
  130470. /** Input */
  130471. Input = 0,
  130472. /** Output */
  130473. Output = 1
  130474. }
  130475. /**
  130476. * Defines a connection point for a block
  130477. */
  130478. export class NodeMaterialConnectionPoint {
  130479. /** @hidden */
  130480. _ownerBlock: NodeMaterialBlock;
  130481. /** @hidden */
  130482. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  130483. private _endpoints;
  130484. private _associatedVariableName;
  130485. private _direction;
  130486. /** @hidden */
  130487. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  130488. /** @hidden */
  130489. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  130490. private _type;
  130491. /** @hidden */
  130492. _enforceAssociatedVariableName: boolean;
  130493. /** Gets the direction of the point */
  130494. get direction(): NodeMaterialConnectionPointDirection;
  130495. /**
  130496. * Gets or sets the additional types supported by this connection point
  130497. */
  130498. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  130499. /**
  130500. * Gets or sets the additional types excluded by this connection point
  130501. */
  130502. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  130503. /**
  130504. * Observable triggered when this point is connected
  130505. */
  130506. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  130507. /**
  130508. * Gets or sets the associated variable name in the shader
  130509. */
  130510. get associatedVariableName(): string;
  130511. set associatedVariableName(value: string);
  130512. /** Get the inner type (ie AutoDetect for isntance instead of the inferred one) */
  130513. get innerType(): NodeMaterialBlockConnectionPointTypes;
  130514. /**
  130515. * Gets or sets the connection point type (default is float)
  130516. */
  130517. get type(): NodeMaterialBlockConnectionPointTypes;
  130518. set type(value: NodeMaterialBlockConnectionPointTypes);
  130519. /**
  130520. * Gets or sets the connection point name
  130521. */
  130522. name: string;
  130523. /**
  130524. * Gets or sets a boolean indicating that this connection point can be omitted
  130525. */
  130526. isOptional: boolean;
  130527. /**
  130528. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  130529. */
  130530. define: string;
  130531. /** @hidden */
  130532. _prioritizeVertex: boolean;
  130533. private _target;
  130534. /** Gets or sets the target of that connection point */
  130535. get target(): NodeMaterialBlockTargets;
  130536. set target(value: NodeMaterialBlockTargets);
  130537. /**
  130538. * Gets a boolean indicating that the current point is connected
  130539. */
  130540. get isConnected(): boolean;
  130541. /**
  130542. * Gets a boolean indicating that the current point is connected to an input block
  130543. */
  130544. get isConnectedToInputBlock(): boolean;
  130545. /**
  130546. * Gets a the connected input block (if any)
  130547. */
  130548. get connectInputBlock(): Nullable<InputBlock>;
  130549. /** Get the other side of the connection (if any) */
  130550. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  130551. /** Get the block that owns this connection point */
  130552. get ownerBlock(): NodeMaterialBlock;
  130553. /** Get the block connected on the other side of this connection (if any) */
  130554. get sourceBlock(): Nullable<NodeMaterialBlock>;
  130555. /** Get the block connected on the endpoints of this connection (if any) */
  130556. get connectedBlocks(): Array<NodeMaterialBlock>;
  130557. /** Gets the list of connected endpoints */
  130558. get endpoints(): NodeMaterialConnectionPoint[];
  130559. /** Gets a boolean indicating if that output point is connected to at least one input */
  130560. get hasEndpoints(): boolean;
  130561. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  130562. get isConnectedInVertexShader(): boolean;
  130563. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  130564. get isConnectedInFragmentShader(): boolean;
  130565. /**
  130566. * Creates a new connection point
  130567. * @param name defines the connection point name
  130568. * @param ownerBlock defines the block hosting this connection point
  130569. * @param direction defines the direction of the connection point
  130570. */
  130571. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  130572. /**
  130573. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  130574. * @returns the class name
  130575. */
  130576. getClassName(): string;
  130577. /**
  130578. * Gets a boolean indicating if the current point can be connected to another point
  130579. * @param connectionPoint defines the other connection point
  130580. * @returns a boolean
  130581. */
  130582. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  130583. /**
  130584. * Gets a number indicating if the current point can be connected to another point
  130585. * @param connectionPoint defines the other connection point
  130586. * @returns a number defining the compatibility state
  130587. */
  130588. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  130589. /**
  130590. * Connect this point to another connection point
  130591. * @param connectionPoint defines the other connection point
  130592. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  130593. * @returns the current connection point
  130594. */
  130595. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  130596. /**
  130597. * Disconnect this point from one of his endpoint
  130598. * @param endpoint defines the other connection point
  130599. * @returns the current connection point
  130600. */
  130601. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  130602. /**
  130603. * Serializes this point in a JSON representation
  130604. * @returns the serialized point object
  130605. */
  130606. serialize(): any;
  130607. /**
  130608. * Release resources
  130609. */
  130610. dispose(): void;
  130611. }
  130612. }
  130613. declare module BABYLON {
  130614. /**
  130615. * Block used to add support for vertex skinning (bones)
  130616. */
  130617. export class BonesBlock extends NodeMaterialBlock {
  130618. /**
  130619. * Creates a new BonesBlock
  130620. * @param name defines the block name
  130621. */
  130622. constructor(name: string);
  130623. /**
  130624. * Initialize the block and prepare the context for build
  130625. * @param state defines the state that will be used for the build
  130626. */
  130627. initialize(state: NodeMaterialBuildState): void;
  130628. /**
  130629. * Gets the current class name
  130630. * @returns the class name
  130631. */
  130632. getClassName(): string;
  130633. /**
  130634. * Gets the matrix indices input component
  130635. */
  130636. get matricesIndices(): NodeMaterialConnectionPoint;
  130637. /**
  130638. * Gets the matrix weights input component
  130639. */
  130640. get matricesWeights(): NodeMaterialConnectionPoint;
  130641. /**
  130642. * Gets the extra matrix indices input component
  130643. */
  130644. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  130645. /**
  130646. * Gets the extra matrix weights input component
  130647. */
  130648. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  130649. /**
  130650. * Gets the world input component
  130651. */
  130652. get world(): NodeMaterialConnectionPoint;
  130653. /**
  130654. * Gets the output component
  130655. */
  130656. get output(): NodeMaterialConnectionPoint;
  130657. autoConfigure(material: NodeMaterial): void;
  130658. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  130659. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130660. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130661. protected _buildBlock(state: NodeMaterialBuildState): this;
  130662. }
  130663. }
  130664. declare module BABYLON {
  130665. /**
  130666. * Block used to add support for instances
  130667. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  130668. */
  130669. export class InstancesBlock extends NodeMaterialBlock {
  130670. /**
  130671. * Creates a new InstancesBlock
  130672. * @param name defines the block name
  130673. */
  130674. constructor(name: string);
  130675. /**
  130676. * Gets the current class name
  130677. * @returns the class name
  130678. */
  130679. getClassName(): string;
  130680. /**
  130681. * Gets the first world row input component
  130682. */
  130683. get world0(): NodeMaterialConnectionPoint;
  130684. /**
  130685. * Gets the second world row input component
  130686. */
  130687. get world1(): NodeMaterialConnectionPoint;
  130688. /**
  130689. * Gets the third world row input component
  130690. */
  130691. get world2(): NodeMaterialConnectionPoint;
  130692. /**
  130693. * Gets the forth world row input component
  130694. */
  130695. get world3(): NodeMaterialConnectionPoint;
  130696. /**
  130697. * Gets the world input component
  130698. */
  130699. get world(): NodeMaterialConnectionPoint;
  130700. /**
  130701. * Gets the output component
  130702. */
  130703. get output(): NodeMaterialConnectionPoint;
  130704. /**
  130705. * Gets the isntanceID component
  130706. */
  130707. get instanceID(): NodeMaterialConnectionPoint;
  130708. autoConfigure(material: NodeMaterial): void;
  130709. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130710. protected _buildBlock(state: NodeMaterialBuildState): this;
  130711. }
  130712. }
  130713. declare module BABYLON {
  130714. /**
  130715. * Block used to add morph targets support to vertex shader
  130716. */
  130717. export class MorphTargetsBlock extends NodeMaterialBlock {
  130718. private _repeatableContentAnchor;
  130719. /**
  130720. * Create a new MorphTargetsBlock
  130721. * @param name defines the block name
  130722. */
  130723. constructor(name: string);
  130724. /**
  130725. * Gets the current class name
  130726. * @returns the class name
  130727. */
  130728. getClassName(): string;
  130729. /**
  130730. * Gets the position input component
  130731. */
  130732. get position(): NodeMaterialConnectionPoint;
  130733. /**
  130734. * Gets the normal input component
  130735. */
  130736. get normal(): NodeMaterialConnectionPoint;
  130737. /**
  130738. * Gets the tangent input component
  130739. */
  130740. get tangent(): NodeMaterialConnectionPoint;
  130741. /**
  130742. * Gets the tangent input component
  130743. */
  130744. get uv(): NodeMaterialConnectionPoint;
  130745. /**
  130746. * Gets the position output component
  130747. */
  130748. get positionOutput(): NodeMaterialConnectionPoint;
  130749. /**
  130750. * Gets the normal output component
  130751. */
  130752. get normalOutput(): NodeMaterialConnectionPoint;
  130753. /**
  130754. * Gets the tangent output component
  130755. */
  130756. get tangentOutput(): NodeMaterialConnectionPoint;
  130757. /**
  130758. * Gets the tangent output component
  130759. */
  130760. get uvOutput(): NodeMaterialConnectionPoint;
  130761. initialize(state: NodeMaterialBuildState): void;
  130762. autoConfigure(material: NodeMaterial): void;
  130763. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130764. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130765. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  130766. protected _buildBlock(state: NodeMaterialBuildState): this;
  130767. }
  130768. }
  130769. declare module BABYLON {
  130770. /**
  130771. * Block used to get data information from a light
  130772. */
  130773. export class LightInformationBlock extends NodeMaterialBlock {
  130774. private _lightDataUniformName;
  130775. private _lightColorUniformName;
  130776. private _lightTypeDefineName;
  130777. /**
  130778. * Gets or sets the light associated with this block
  130779. */
  130780. light: Nullable<Light>;
  130781. /**
  130782. * Creates a new LightInformationBlock
  130783. * @param name defines the block name
  130784. */
  130785. constructor(name: string);
  130786. /**
  130787. * Gets the current class name
  130788. * @returns the class name
  130789. */
  130790. getClassName(): string;
  130791. /**
  130792. * Gets the world position input component
  130793. */
  130794. get worldPosition(): NodeMaterialConnectionPoint;
  130795. /**
  130796. * Gets the direction output component
  130797. */
  130798. get direction(): NodeMaterialConnectionPoint;
  130799. /**
  130800. * Gets the direction output component
  130801. */
  130802. get color(): NodeMaterialConnectionPoint;
  130803. /**
  130804. * Gets the direction output component
  130805. */
  130806. get intensity(): NodeMaterialConnectionPoint;
  130807. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130808. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130809. protected _buildBlock(state: NodeMaterialBuildState): this;
  130810. serialize(): any;
  130811. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130812. }
  130813. }
  130814. declare module BABYLON {
  130815. /**
  130816. * Block used to add image processing support to fragment shader
  130817. */
  130818. export class ImageProcessingBlock extends NodeMaterialBlock {
  130819. /**
  130820. * Create a new ImageProcessingBlock
  130821. * @param name defines the block name
  130822. */
  130823. constructor(name: string);
  130824. /**
  130825. * Gets the current class name
  130826. * @returns the class name
  130827. */
  130828. getClassName(): string;
  130829. /**
  130830. * Gets the color input component
  130831. */
  130832. get color(): NodeMaterialConnectionPoint;
  130833. /**
  130834. * Gets the output component
  130835. */
  130836. get output(): NodeMaterialConnectionPoint;
  130837. /**
  130838. * Initialize the block and prepare the context for build
  130839. * @param state defines the state that will be used for the build
  130840. */
  130841. initialize(state: NodeMaterialBuildState): void;
  130842. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  130843. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130844. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130845. protected _buildBlock(state: NodeMaterialBuildState): this;
  130846. }
  130847. }
  130848. declare module BABYLON {
  130849. /**
  130850. * Block used to pertub normals based on a normal map
  130851. */
  130852. export class PerturbNormalBlock extends NodeMaterialBlock {
  130853. private _tangentSpaceParameterName;
  130854. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  130855. invertX: boolean;
  130856. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  130857. invertY: boolean;
  130858. /**
  130859. * Create a new PerturbNormalBlock
  130860. * @param name defines the block name
  130861. */
  130862. constructor(name: string);
  130863. /**
  130864. * Gets the current class name
  130865. * @returns the class name
  130866. */
  130867. getClassName(): string;
  130868. /**
  130869. * Gets the world position input component
  130870. */
  130871. get worldPosition(): NodeMaterialConnectionPoint;
  130872. /**
  130873. * Gets the world normal input component
  130874. */
  130875. get worldNormal(): NodeMaterialConnectionPoint;
  130876. /**
  130877. * Gets the world tangent input component
  130878. */
  130879. get worldTangent(): NodeMaterialConnectionPoint;
  130880. /**
  130881. * Gets the uv input component
  130882. */
  130883. get uv(): NodeMaterialConnectionPoint;
  130884. /**
  130885. * Gets the normal map color input component
  130886. */
  130887. get normalMapColor(): NodeMaterialConnectionPoint;
  130888. /**
  130889. * Gets the strength input component
  130890. */
  130891. get strength(): NodeMaterialConnectionPoint;
  130892. /**
  130893. * Gets the output component
  130894. */
  130895. get output(): NodeMaterialConnectionPoint;
  130896. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130897. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130898. autoConfigure(material: NodeMaterial): void;
  130899. protected _buildBlock(state: NodeMaterialBuildState): this;
  130900. protected _dumpPropertiesCode(): string;
  130901. serialize(): any;
  130902. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130903. }
  130904. }
  130905. declare module BABYLON {
  130906. /**
  130907. * Block used to discard a pixel if a value is smaller than a cutoff
  130908. */
  130909. export class DiscardBlock extends NodeMaterialBlock {
  130910. /**
  130911. * Create a new DiscardBlock
  130912. * @param name defines the block name
  130913. */
  130914. constructor(name: string);
  130915. /**
  130916. * Gets the current class name
  130917. * @returns the class name
  130918. */
  130919. getClassName(): string;
  130920. /**
  130921. * Gets the color input component
  130922. */
  130923. get value(): NodeMaterialConnectionPoint;
  130924. /**
  130925. * Gets the cutoff input component
  130926. */
  130927. get cutoff(): NodeMaterialConnectionPoint;
  130928. protected _buildBlock(state: NodeMaterialBuildState): this;
  130929. }
  130930. }
  130931. declare module BABYLON {
  130932. /**
  130933. * Block used to test if the fragment shader is front facing
  130934. */
  130935. export class FrontFacingBlock extends NodeMaterialBlock {
  130936. /**
  130937. * Creates a new FrontFacingBlock
  130938. * @param name defines the block name
  130939. */
  130940. constructor(name: string);
  130941. /**
  130942. * Gets the current class name
  130943. * @returns the class name
  130944. */
  130945. getClassName(): string;
  130946. /**
  130947. * Gets the output component
  130948. */
  130949. get output(): NodeMaterialConnectionPoint;
  130950. protected _buildBlock(state: NodeMaterialBuildState): this;
  130951. }
  130952. }
  130953. declare module BABYLON {
  130954. /**
  130955. * Block used to get the derivative value on x and y of a given input
  130956. */
  130957. export class DerivativeBlock extends NodeMaterialBlock {
  130958. /**
  130959. * Create a new DerivativeBlock
  130960. * @param name defines the block name
  130961. */
  130962. constructor(name: string);
  130963. /**
  130964. * Gets the current class name
  130965. * @returns the class name
  130966. */
  130967. getClassName(): string;
  130968. /**
  130969. * Gets the input component
  130970. */
  130971. get input(): NodeMaterialConnectionPoint;
  130972. /**
  130973. * Gets the derivative output on x
  130974. */
  130975. get dx(): NodeMaterialConnectionPoint;
  130976. /**
  130977. * Gets the derivative output on y
  130978. */
  130979. get dy(): NodeMaterialConnectionPoint;
  130980. protected _buildBlock(state: NodeMaterialBuildState): this;
  130981. }
  130982. }
  130983. declare module BABYLON {
  130984. /**
  130985. * Block used to add support for scene fog
  130986. */
  130987. export class FogBlock extends NodeMaterialBlock {
  130988. private _fogDistanceName;
  130989. private _fogParameters;
  130990. /**
  130991. * Create a new FogBlock
  130992. * @param name defines the block name
  130993. */
  130994. constructor(name: string);
  130995. /**
  130996. * Gets the current class name
  130997. * @returns the class name
  130998. */
  130999. getClassName(): string;
  131000. /**
  131001. * Gets the world position input component
  131002. */
  131003. get worldPosition(): NodeMaterialConnectionPoint;
  131004. /**
  131005. * Gets the view input component
  131006. */
  131007. get view(): NodeMaterialConnectionPoint;
  131008. /**
  131009. * Gets the color input component
  131010. */
  131011. get input(): NodeMaterialConnectionPoint;
  131012. /**
  131013. * Gets the fog color input component
  131014. */
  131015. get fogColor(): NodeMaterialConnectionPoint;
  131016. /**
  131017. * Gets the output component
  131018. */
  131019. get output(): NodeMaterialConnectionPoint;
  131020. autoConfigure(material: NodeMaterial): void;
  131021. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131022. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131023. protected _buildBlock(state: NodeMaterialBuildState): this;
  131024. }
  131025. }
  131026. declare module BABYLON {
  131027. /**
  131028. * Block used to add light in the fragment shader
  131029. */
  131030. export class LightBlock extends NodeMaterialBlock {
  131031. private _lightId;
  131032. /**
  131033. * Gets or sets the light associated with this block
  131034. */
  131035. light: Nullable<Light>;
  131036. /**
  131037. * Create a new LightBlock
  131038. * @param name defines the block name
  131039. */
  131040. constructor(name: string);
  131041. /**
  131042. * Gets the current class name
  131043. * @returns the class name
  131044. */
  131045. getClassName(): string;
  131046. /**
  131047. * Gets the world position input component
  131048. */
  131049. get worldPosition(): NodeMaterialConnectionPoint;
  131050. /**
  131051. * Gets the world normal input component
  131052. */
  131053. get worldNormal(): NodeMaterialConnectionPoint;
  131054. /**
  131055. * Gets the camera (or eye) position component
  131056. */
  131057. get cameraPosition(): NodeMaterialConnectionPoint;
  131058. /**
  131059. * Gets the glossiness component
  131060. */
  131061. get glossiness(): NodeMaterialConnectionPoint;
  131062. /**
  131063. * Gets the glossinness power component
  131064. */
  131065. get glossPower(): NodeMaterialConnectionPoint;
  131066. /**
  131067. * Gets the diffuse color component
  131068. */
  131069. get diffuseColor(): NodeMaterialConnectionPoint;
  131070. /**
  131071. * Gets the specular color component
  131072. */
  131073. get specularColor(): NodeMaterialConnectionPoint;
  131074. /**
  131075. * Gets the diffuse output component
  131076. */
  131077. get diffuseOutput(): NodeMaterialConnectionPoint;
  131078. /**
  131079. * Gets the specular output component
  131080. */
  131081. get specularOutput(): NodeMaterialConnectionPoint;
  131082. /**
  131083. * Gets the shadow output component
  131084. */
  131085. get shadow(): NodeMaterialConnectionPoint;
  131086. autoConfigure(material: NodeMaterial): void;
  131087. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131088. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  131089. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131090. private _injectVertexCode;
  131091. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  131092. serialize(): any;
  131093. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131094. }
  131095. }
  131096. declare module BABYLON {
  131097. /**
  131098. * Block used to multiply 2 values
  131099. */
  131100. export class MultiplyBlock extends NodeMaterialBlock {
  131101. /**
  131102. * Creates a new MultiplyBlock
  131103. * @param name defines the block name
  131104. */
  131105. constructor(name: string);
  131106. /**
  131107. * Gets the current class name
  131108. * @returns the class name
  131109. */
  131110. getClassName(): string;
  131111. /**
  131112. * Gets the left operand input component
  131113. */
  131114. get left(): NodeMaterialConnectionPoint;
  131115. /**
  131116. * Gets the right operand input component
  131117. */
  131118. get right(): NodeMaterialConnectionPoint;
  131119. /**
  131120. * Gets the output component
  131121. */
  131122. get output(): NodeMaterialConnectionPoint;
  131123. protected _buildBlock(state: NodeMaterialBuildState): this;
  131124. }
  131125. }
  131126. declare module BABYLON {
  131127. /**
  131128. * Block used to add 2 vectors
  131129. */
  131130. export class AddBlock extends NodeMaterialBlock {
  131131. /**
  131132. * Creates a new AddBlock
  131133. * @param name defines the block name
  131134. */
  131135. constructor(name: string);
  131136. /**
  131137. * Gets the current class name
  131138. * @returns the class name
  131139. */
  131140. getClassName(): string;
  131141. /**
  131142. * Gets the left operand input component
  131143. */
  131144. get left(): NodeMaterialConnectionPoint;
  131145. /**
  131146. * Gets the right operand input component
  131147. */
  131148. get right(): NodeMaterialConnectionPoint;
  131149. /**
  131150. * Gets the output component
  131151. */
  131152. get output(): NodeMaterialConnectionPoint;
  131153. protected _buildBlock(state: NodeMaterialBuildState): this;
  131154. }
  131155. }
  131156. declare module BABYLON {
  131157. /**
  131158. * Block used to scale a vector by a float
  131159. */
  131160. export class ScaleBlock extends NodeMaterialBlock {
  131161. /**
  131162. * Creates a new ScaleBlock
  131163. * @param name defines the block name
  131164. */
  131165. constructor(name: string);
  131166. /**
  131167. * Gets the current class name
  131168. * @returns the class name
  131169. */
  131170. getClassName(): string;
  131171. /**
  131172. * Gets the input component
  131173. */
  131174. get input(): NodeMaterialConnectionPoint;
  131175. /**
  131176. * Gets the factor input component
  131177. */
  131178. get factor(): NodeMaterialConnectionPoint;
  131179. /**
  131180. * Gets the output component
  131181. */
  131182. get output(): NodeMaterialConnectionPoint;
  131183. protected _buildBlock(state: NodeMaterialBuildState): this;
  131184. }
  131185. }
  131186. declare module BABYLON {
  131187. /**
  131188. * Block used to clamp a float
  131189. */
  131190. export class ClampBlock extends NodeMaterialBlock {
  131191. /** Gets or sets the minimum range */
  131192. minimum: number;
  131193. /** Gets or sets the maximum range */
  131194. maximum: number;
  131195. /**
  131196. * Creates a new ClampBlock
  131197. * @param name defines the block name
  131198. */
  131199. constructor(name: string);
  131200. /**
  131201. * Gets the current class name
  131202. * @returns the class name
  131203. */
  131204. getClassName(): string;
  131205. /**
  131206. * Gets the value input component
  131207. */
  131208. get value(): NodeMaterialConnectionPoint;
  131209. /**
  131210. * Gets the output component
  131211. */
  131212. get output(): NodeMaterialConnectionPoint;
  131213. protected _buildBlock(state: NodeMaterialBuildState): this;
  131214. protected _dumpPropertiesCode(): string;
  131215. serialize(): any;
  131216. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131217. }
  131218. }
  131219. declare module BABYLON {
  131220. /**
  131221. * Block used to apply a cross product between 2 vectors
  131222. */
  131223. export class CrossBlock extends NodeMaterialBlock {
  131224. /**
  131225. * Creates a new CrossBlock
  131226. * @param name defines the block name
  131227. */
  131228. constructor(name: string);
  131229. /**
  131230. * Gets the current class name
  131231. * @returns the class name
  131232. */
  131233. getClassName(): string;
  131234. /**
  131235. * Gets the left operand input component
  131236. */
  131237. get left(): NodeMaterialConnectionPoint;
  131238. /**
  131239. * Gets the right operand input component
  131240. */
  131241. get right(): NodeMaterialConnectionPoint;
  131242. /**
  131243. * Gets the output component
  131244. */
  131245. get output(): NodeMaterialConnectionPoint;
  131246. protected _buildBlock(state: NodeMaterialBuildState): this;
  131247. }
  131248. }
  131249. declare module BABYLON {
  131250. /**
  131251. * Block used to apply a dot product between 2 vectors
  131252. */
  131253. export class DotBlock extends NodeMaterialBlock {
  131254. /**
  131255. * Creates a new DotBlock
  131256. * @param name defines the block name
  131257. */
  131258. constructor(name: string);
  131259. /**
  131260. * Gets the current class name
  131261. * @returns the class name
  131262. */
  131263. getClassName(): string;
  131264. /**
  131265. * Gets the left operand input component
  131266. */
  131267. get left(): NodeMaterialConnectionPoint;
  131268. /**
  131269. * Gets the right operand input component
  131270. */
  131271. get right(): NodeMaterialConnectionPoint;
  131272. /**
  131273. * Gets the output component
  131274. */
  131275. get output(): NodeMaterialConnectionPoint;
  131276. protected _buildBlock(state: NodeMaterialBuildState): this;
  131277. }
  131278. }
  131279. declare module BABYLON {
  131280. /**
  131281. * Block used to remap a float from a range to a new one
  131282. */
  131283. export class RemapBlock extends NodeMaterialBlock {
  131284. /**
  131285. * Gets or sets the source range
  131286. */
  131287. sourceRange: Vector2;
  131288. /**
  131289. * Gets or sets the target range
  131290. */
  131291. targetRange: Vector2;
  131292. /**
  131293. * Creates a new RemapBlock
  131294. * @param name defines the block name
  131295. */
  131296. constructor(name: string);
  131297. /**
  131298. * Gets the current class name
  131299. * @returns the class name
  131300. */
  131301. getClassName(): string;
  131302. /**
  131303. * Gets the input component
  131304. */
  131305. get input(): NodeMaterialConnectionPoint;
  131306. /**
  131307. * Gets the source min input component
  131308. */
  131309. get sourceMin(): NodeMaterialConnectionPoint;
  131310. /**
  131311. * Gets the source max input component
  131312. */
  131313. get sourceMax(): NodeMaterialConnectionPoint;
  131314. /**
  131315. * Gets the target min input component
  131316. */
  131317. get targetMin(): NodeMaterialConnectionPoint;
  131318. /**
  131319. * Gets the target max input component
  131320. */
  131321. get targetMax(): NodeMaterialConnectionPoint;
  131322. /**
  131323. * Gets the output component
  131324. */
  131325. get output(): NodeMaterialConnectionPoint;
  131326. protected _buildBlock(state: NodeMaterialBuildState): this;
  131327. protected _dumpPropertiesCode(): string;
  131328. serialize(): any;
  131329. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131330. }
  131331. }
  131332. declare module BABYLON {
  131333. /**
  131334. * Block used to normalize a vector
  131335. */
  131336. export class NormalizeBlock extends NodeMaterialBlock {
  131337. /**
  131338. * Creates a new NormalizeBlock
  131339. * @param name defines the block name
  131340. */
  131341. constructor(name: string);
  131342. /**
  131343. * Gets the current class name
  131344. * @returns the class name
  131345. */
  131346. getClassName(): string;
  131347. /**
  131348. * Gets the input component
  131349. */
  131350. get input(): NodeMaterialConnectionPoint;
  131351. /**
  131352. * Gets the output component
  131353. */
  131354. get output(): NodeMaterialConnectionPoint;
  131355. protected _buildBlock(state: NodeMaterialBuildState): this;
  131356. }
  131357. }
  131358. declare module BABYLON {
  131359. /**
  131360. * Operations supported by the Trigonometry block
  131361. */
  131362. export enum TrigonometryBlockOperations {
  131363. /** Cos */
  131364. Cos = 0,
  131365. /** Sin */
  131366. Sin = 1,
  131367. /** Abs */
  131368. Abs = 2,
  131369. /** Exp */
  131370. Exp = 3,
  131371. /** Exp2 */
  131372. Exp2 = 4,
  131373. /** Round */
  131374. Round = 5,
  131375. /** Floor */
  131376. Floor = 6,
  131377. /** Ceiling */
  131378. Ceiling = 7,
  131379. /** Square root */
  131380. Sqrt = 8,
  131381. /** Log */
  131382. Log = 9,
  131383. /** Tangent */
  131384. Tan = 10,
  131385. /** Arc tangent */
  131386. ArcTan = 11,
  131387. /** Arc cosinus */
  131388. ArcCos = 12,
  131389. /** Arc sinus */
  131390. ArcSin = 13,
  131391. /** Fraction */
  131392. Fract = 14,
  131393. /** Sign */
  131394. Sign = 15,
  131395. /** To radians (from degrees) */
  131396. Radians = 16,
  131397. /** To degrees (from radians) */
  131398. Degrees = 17
  131399. }
  131400. /**
  131401. * Block used to apply trigonometry operation to floats
  131402. */
  131403. export class TrigonometryBlock extends NodeMaterialBlock {
  131404. /**
  131405. * Gets or sets the operation applied by the block
  131406. */
  131407. operation: TrigonometryBlockOperations;
  131408. /**
  131409. * Creates a new TrigonometryBlock
  131410. * @param name defines the block name
  131411. */
  131412. constructor(name: string);
  131413. /**
  131414. * Gets the current class name
  131415. * @returns the class name
  131416. */
  131417. getClassName(): string;
  131418. /**
  131419. * Gets the input component
  131420. */
  131421. get input(): NodeMaterialConnectionPoint;
  131422. /**
  131423. * Gets the output component
  131424. */
  131425. get output(): NodeMaterialConnectionPoint;
  131426. protected _buildBlock(state: NodeMaterialBuildState): this;
  131427. serialize(): any;
  131428. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131429. protected _dumpPropertiesCode(): string;
  131430. }
  131431. }
  131432. declare module BABYLON {
  131433. /**
  131434. * Block used to create a Color3/4 out of individual inputs (one for each component)
  131435. */
  131436. export class ColorMergerBlock extends NodeMaterialBlock {
  131437. /**
  131438. * Create a new ColorMergerBlock
  131439. * @param name defines the block name
  131440. */
  131441. constructor(name: string);
  131442. /**
  131443. * Gets the current class name
  131444. * @returns the class name
  131445. */
  131446. getClassName(): string;
  131447. /**
  131448. * Gets the rgb component (input)
  131449. */
  131450. get rgbIn(): NodeMaterialConnectionPoint;
  131451. /**
  131452. * Gets the r component (input)
  131453. */
  131454. get r(): NodeMaterialConnectionPoint;
  131455. /**
  131456. * Gets the g component (input)
  131457. */
  131458. get g(): NodeMaterialConnectionPoint;
  131459. /**
  131460. * Gets the b component (input)
  131461. */
  131462. get b(): NodeMaterialConnectionPoint;
  131463. /**
  131464. * Gets the a component (input)
  131465. */
  131466. get a(): NodeMaterialConnectionPoint;
  131467. /**
  131468. * Gets the rgba component (output)
  131469. */
  131470. get rgba(): NodeMaterialConnectionPoint;
  131471. /**
  131472. * Gets the rgb component (output)
  131473. */
  131474. get rgbOut(): NodeMaterialConnectionPoint;
  131475. /**
  131476. * Gets the rgb component (output)
  131477. * @deprecated Please use rgbOut instead.
  131478. */
  131479. get rgb(): NodeMaterialConnectionPoint;
  131480. protected _buildBlock(state: NodeMaterialBuildState): this;
  131481. }
  131482. }
  131483. declare module BABYLON {
  131484. /**
  131485. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  131486. */
  131487. export class VectorMergerBlock extends NodeMaterialBlock {
  131488. /**
  131489. * Create a new VectorMergerBlock
  131490. * @param name defines the block name
  131491. */
  131492. constructor(name: string);
  131493. /**
  131494. * Gets the current class name
  131495. * @returns the class name
  131496. */
  131497. getClassName(): string;
  131498. /**
  131499. * Gets the xyz component (input)
  131500. */
  131501. get xyzIn(): NodeMaterialConnectionPoint;
  131502. /**
  131503. * Gets the xy component (input)
  131504. */
  131505. get xyIn(): NodeMaterialConnectionPoint;
  131506. /**
  131507. * Gets the x component (input)
  131508. */
  131509. get x(): NodeMaterialConnectionPoint;
  131510. /**
  131511. * Gets the y component (input)
  131512. */
  131513. get y(): NodeMaterialConnectionPoint;
  131514. /**
  131515. * Gets the z component (input)
  131516. */
  131517. get z(): NodeMaterialConnectionPoint;
  131518. /**
  131519. * Gets the w component (input)
  131520. */
  131521. get w(): NodeMaterialConnectionPoint;
  131522. /**
  131523. * Gets the xyzw component (output)
  131524. */
  131525. get xyzw(): NodeMaterialConnectionPoint;
  131526. /**
  131527. * Gets the xyz component (output)
  131528. */
  131529. get xyzOut(): NodeMaterialConnectionPoint;
  131530. /**
  131531. * Gets the xy component (output)
  131532. */
  131533. get xyOut(): NodeMaterialConnectionPoint;
  131534. /**
  131535. * Gets the xy component (output)
  131536. * @deprecated Please use xyOut instead.
  131537. */
  131538. get xy(): NodeMaterialConnectionPoint;
  131539. /**
  131540. * Gets the xyz component (output)
  131541. * @deprecated Please use xyzOut instead.
  131542. */
  131543. get xyz(): NodeMaterialConnectionPoint;
  131544. protected _buildBlock(state: NodeMaterialBuildState): this;
  131545. }
  131546. }
  131547. declare module BABYLON {
  131548. /**
  131549. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  131550. */
  131551. export class ColorSplitterBlock extends NodeMaterialBlock {
  131552. /**
  131553. * Create a new ColorSplitterBlock
  131554. * @param name defines the block name
  131555. */
  131556. constructor(name: string);
  131557. /**
  131558. * Gets the current class name
  131559. * @returns the class name
  131560. */
  131561. getClassName(): string;
  131562. /**
  131563. * Gets the rgba component (input)
  131564. */
  131565. get rgba(): NodeMaterialConnectionPoint;
  131566. /**
  131567. * Gets the rgb component (input)
  131568. */
  131569. get rgbIn(): NodeMaterialConnectionPoint;
  131570. /**
  131571. * Gets the rgb component (output)
  131572. */
  131573. get rgbOut(): NodeMaterialConnectionPoint;
  131574. /**
  131575. * Gets the r component (output)
  131576. */
  131577. get r(): NodeMaterialConnectionPoint;
  131578. /**
  131579. * Gets the g component (output)
  131580. */
  131581. get g(): NodeMaterialConnectionPoint;
  131582. /**
  131583. * Gets the b component (output)
  131584. */
  131585. get b(): NodeMaterialConnectionPoint;
  131586. /**
  131587. * Gets the a component (output)
  131588. */
  131589. get a(): NodeMaterialConnectionPoint;
  131590. protected _inputRename(name: string): string;
  131591. protected _outputRename(name: string): string;
  131592. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  131593. }
  131594. }
  131595. declare module BABYLON {
  131596. /**
  131597. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  131598. */
  131599. export class VectorSplitterBlock extends NodeMaterialBlock {
  131600. /**
  131601. * Create a new VectorSplitterBlock
  131602. * @param name defines the block name
  131603. */
  131604. constructor(name: string);
  131605. /**
  131606. * Gets the current class name
  131607. * @returns the class name
  131608. */
  131609. getClassName(): string;
  131610. /**
  131611. * Gets the xyzw component (input)
  131612. */
  131613. get xyzw(): NodeMaterialConnectionPoint;
  131614. /**
  131615. * Gets the xyz component (input)
  131616. */
  131617. get xyzIn(): NodeMaterialConnectionPoint;
  131618. /**
  131619. * Gets the xy component (input)
  131620. */
  131621. get xyIn(): NodeMaterialConnectionPoint;
  131622. /**
  131623. * Gets the xyz component (output)
  131624. */
  131625. get xyzOut(): NodeMaterialConnectionPoint;
  131626. /**
  131627. * Gets the xy component (output)
  131628. */
  131629. get xyOut(): NodeMaterialConnectionPoint;
  131630. /**
  131631. * Gets the x component (output)
  131632. */
  131633. get x(): NodeMaterialConnectionPoint;
  131634. /**
  131635. * Gets the y component (output)
  131636. */
  131637. get y(): NodeMaterialConnectionPoint;
  131638. /**
  131639. * Gets the z component (output)
  131640. */
  131641. get z(): NodeMaterialConnectionPoint;
  131642. /**
  131643. * Gets the w component (output)
  131644. */
  131645. get w(): NodeMaterialConnectionPoint;
  131646. protected _inputRename(name: string): string;
  131647. protected _outputRename(name: string): string;
  131648. protected _buildBlock(state: NodeMaterialBuildState): this;
  131649. }
  131650. }
  131651. declare module BABYLON {
  131652. /**
  131653. * Block used to lerp between 2 values
  131654. */
  131655. export class LerpBlock extends NodeMaterialBlock {
  131656. /**
  131657. * Creates a new LerpBlock
  131658. * @param name defines the block name
  131659. */
  131660. constructor(name: string);
  131661. /**
  131662. * Gets the current class name
  131663. * @returns the class name
  131664. */
  131665. getClassName(): string;
  131666. /**
  131667. * Gets the left operand input component
  131668. */
  131669. get left(): NodeMaterialConnectionPoint;
  131670. /**
  131671. * Gets the right operand input component
  131672. */
  131673. get right(): NodeMaterialConnectionPoint;
  131674. /**
  131675. * Gets the gradient operand input component
  131676. */
  131677. get gradient(): NodeMaterialConnectionPoint;
  131678. /**
  131679. * Gets the output component
  131680. */
  131681. get output(): NodeMaterialConnectionPoint;
  131682. protected _buildBlock(state: NodeMaterialBuildState): this;
  131683. }
  131684. }
  131685. declare module BABYLON {
  131686. /**
  131687. * Block used to divide 2 vectors
  131688. */
  131689. export class DivideBlock extends NodeMaterialBlock {
  131690. /**
  131691. * Creates a new DivideBlock
  131692. * @param name defines the block name
  131693. */
  131694. constructor(name: string);
  131695. /**
  131696. * Gets the current class name
  131697. * @returns the class name
  131698. */
  131699. getClassName(): string;
  131700. /**
  131701. * Gets the left operand input component
  131702. */
  131703. get left(): NodeMaterialConnectionPoint;
  131704. /**
  131705. * Gets the right operand input component
  131706. */
  131707. get right(): NodeMaterialConnectionPoint;
  131708. /**
  131709. * Gets the output component
  131710. */
  131711. get output(): NodeMaterialConnectionPoint;
  131712. protected _buildBlock(state: NodeMaterialBuildState): this;
  131713. }
  131714. }
  131715. declare module BABYLON {
  131716. /**
  131717. * Block used to subtract 2 vectors
  131718. */
  131719. export class SubtractBlock extends NodeMaterialBlock {
  131720. /**
  131721. * Creates a new SubtractBlock
  131722. * @param name defines the block name
  131723. */
  131724. constructor(name: string);
  131725. /**
  131726. * Gets the current class name
  131727. * @returns the class name
  131728. */
  131729. getClassName(): string;
  131730. /**
  131731. * Gets the left operand input component
  131732. */
  131733. get left(): NodeMaterialConnectionPoint;
  131734. /**
  131735. * Gets the right operand input component
  131736. */
  131737. get right(): NodeMaterialConnectionPoint;
  131738. /**
  131739. * Gets the output component
  131740. */
  131741. get output(): NodeMaterialConnectionPoint;
  131742. protected _buildBlock(state: NodeMaterialBuildState): this;
  131743. }
  131744. }
  131745. declare module BABYLON {
  131746. /**
  131747. * Block used to step a value
  131748. */
  131749. export class StepBlock extends NodeMaterialBlock {
  131750. /**
  131751. * Creates a new StepBlock
  131752. * @param name defines the block name
  131753. */
  131754. constructor(name: string);
  131755. /**
  131756. * Gets the current class name
  131757. * @returns the class name
  131758. */
  131759. getClassName(): string;
  131760. /**
  131761. * Gets the value operand input component
  131762. */
  131763. get value(): NodeMaterialConnectionPoint;
  131764. /**
  131765. * Gets the edge operand input component
  131766. */
  131767. get edge(): NodeMaterialConnectionPoint;
  131768. /**
  131769. * Gets the output component
  131770. */
  131771. get output(): NodeMaterialConnectionPoint;
  131772. protected _buildBlock(state: NodeMaterialBuildState): this;
  131773. }
  131774. }
  131775. declare module BABYLON {
  131776. /**
  131777. * Block used to get the opposite (1 - x) of a value
  131778. */
  131779. export class OneMinusBlock extends NodeMaterialBlock {
  131780. /**
  131781. * Creates a new OneMinusBlock
  131782. * @param name defines the block name
  131783. */
  131784. constructor(name: string);
  131785. /**
  131786. * Gets the current class name
  131787. * @returns the class name
  131788. */
  131789. getClassName(): string;
  131790. /**
  131791. * Gets the input component
  131792. */
  131793. get input(): NodeMaterialConnectionPoint;
  131794. /**
  131795. * Gets the output component
  131796. */
  131797. get output(): NodeMaterialConnectionPoint;
  131798. protected _buildBlock(state: NodeMaterialBuildState): this;
  131799. }
  131800. }
  131801. declare module BABYLON {
  131802. /**
  131803. * Block used to get the view direction
  131804. */
  131805. export class ViewDirectionBlock extends NodeMaterialBlock {
  131806. /**
  131807. * Creates a new ViewDirectionBlock
  131808. * @param name defines the block name
  131809. */
  131810. constructor(name: string);
  131811. /**
  131812. * Gets the current class name
  131813. * @returns the class name
  131814. */
  131815. getClassName(): string;
  131816. /**
  131817. * Gets the world position component
  131818. */
  131819. get worldPosition(): NodeMaterialConnectionPoint;
  131820. /**
  131821. * Gets the camera position component
  131822. */
  131823. get cameraPosition(): NodeMaterialConnectionPoint;
  131824. /**
  131825. * Gets the output component
  131826. */
  131827. get output(): NodeMaterialConnectionPoint;
  131828. autoConfigure(material: NodeMaterial): void;
  131829. protected _buildBlock(state: NodeMaterialBuildState): this;
  131830. }
  131831. }
  131832. declare module BABYLON {
  131833. /**
  131834. * Block used to compute fresnel value
  131835. */
  131836. export class FresnelBlock extends NodeMaterialBlock {
  131837. /**
  131838. * Create a new FresnelBlock
  131839. * @param name defines the block name
  131840. */
  131841. constructor(name: string);
  131842. /**
  131843. * Gets the current class name
  131844. * @returns the class name
  131845. */
  131846. getClassName(): string;
  131847. /**
  131848. * Gets the world normal input component
  131849. */
  131850. get worldNormal(): NodeMaterialConnectionPoint;
  131851. /**
  131852. * Gets the view direction input component
  131853. */
  131854. get viewDirection(): NodeMaterialConnectionPoint;
  131855. /**
  131856. * Gets the bias input component
  131857. */
  131858. get bias(): NodeMaterialConnectionPoint;
  131859. /**
  131860. * Gets the camera (or eye) position component
  131861. */
  131862. get power(): NodeMaterialConnectionPoint;
  131863. /**
  131864. * Gets the fresnel output component
  131865. */
  131866. get fresnel(): NodeMaterialConnectionPoint;
  131867. autoConfigure(material: NodeMaterial): void;
  131868. protected _buildBlock(state: NodeMaterialBuildState): this;
  131869. }
  131870. }
  131871. declare module BABYLON {
  131872. /**
  131873. * Block used to get the max of 2 values
  131874. */
  131875. export class MaxBlock extends NodeMaterialBlock {
  131876. /**
  131877. * Creates a new MaxBlock
  131878. * @param name defines the block name
  131879. */
  131880. constructor(name: string);
  131881. /**
  131882. * Gets the current class name
  131883. * @returns the class name
  131884. */
  131885. getClassName(): string;
  131886. /**
  131887. * Gets the left operand input component
  131888. */
  131889. get left(): NodeMaterialConnectionPoint;
  131890. /**
  131891. * Gets the right operand input component
  131892. */
  131893. get right(): NodeMaterialConnectionPoint;
  131894. /**
  131895. * Gets the output component
  131896. */
  131897. get output(): NodeMaterialConnectionPoint;
  131898. protected _buildBlock(state: NodeMaterialBuildState): this;
  131899. }
  131900. }
  131901. declare module BABYLON {
  131902. /**
  131903. * Block used to get the min of 2 values
  131904. */
  131905. export class MinBlock extends NodeMaterialBlock {
  131906. /**
  131907. * Creates a new MinBlock
  131908. * @param name defines the block name
  131909. */
  131910. constructor(name: string);
  131911. /**
  131912. * Gets the current class name
  131913. * @returns the class name
  131914. */
  131915. getClassName(): string;
  131916. /**
  131917. * Gets the left operand input component
  131918. */
  131919. get left(): NodeMaterialConnectionPoint;
  131920. /**
  131921. * Gets the right operand input component
  131922. */
  131923. get right(): NodeMaterialConnectionPoint;
  131924. /**
  131925. * Gets the output component
  131926. */
  131927. get output(): NodeMaterialConnectionPoint;
  131928. protected _buildBlock(state: NodeMaterialBuildState): this;
  131929. }
  131930. }
  131931. declare module BABYLON {
  131932. /**
  131933. * Block used to get the distance between 2 values
  131934. */
  131935. export class DistanceBlock extends NodeMaterialBlock {
  131936. /**
  131937. * Creates a new DistanceBlock
  131938. * @param name defines the block name
  131939. */
  131940. constructor(name: string);
  131941. /**
  131942. * Gets the current class name
  131943. * @returns the class name
  131944. */
  131945. getClassName(): string;
  131946. /**
  131947. * Gets the left operand input component
  131948. */
  131949. get left(): NodeMaterialConnectionPoint;
  131950. /**
  131951. * Gets the right operand input component
  131952. */
  131953. get right(): NodeMaterialConnectionPoint;
  131954. /**
  131955. * Gets the output component
  131956. */
  131957. get output(): NodeMaterialConnectionPoint;
  131958. protected _buildBlock(state: NodeMaterialBuildState): this;
  131959. }
  131960. }
  131961. declare module BABYLON {
  131962. /**
  131963. * Block used to get the length of a vector
  131964. */
  131965. export class LengthBlock extends NodeMaterialBlock {
  131966. /**
  131967. * Creates a new LengthBlock
  131968. * @param name defines the block name
  131969. */
  131970. constructor(name: string);
  131971. /**
  131972. * Gets the current class name
  131973. * @returns the class name
  131974. */
  131975. getClassName(): string;
  131976. /**
  131977. * Gets the value input component
  131978. */
  131979. get value(): NodeMaterialConnectionPoint;
  131980. /**
  131981. * Gets the output component
  131982. */
  131983. get output(): NodeMaterialConnectionPoint;
  131984. protected _buildBlock(state: NodeMaterialBuildState): this;
  131985. }
  131986. }
  131987. declare module BABYLON {
  131988. /**
  131989. * Block used to get negative version of a value (i.e. x * -1)
  131990. */
  131991. export class NegateBlock extends NodeMaterialBlock {
  131992. /**
  131993. * Creates a new NegateBlock
  131994. * @param name defines the block name
  131995. */
  131996. constructor(name: string);
  131997. /**
  131998. * Gets the current class name
  131999. * @returns the class name
  132000. */
  132001. getClassName(): string;
  132002. /**
  132003. * Gets the value input component
  132004. */
  132005. get value(): NodeMaterialConnectionPoint;
  132006. /**
  132007. * Gets the output component
  132008. */
  132009. get output(): NodeMaterialConnectionPoint;
  132010. protected _buildBlock(state: NodeMaterialBuildState): this;
  132011. }
  132012. }
  132013. declare module BABYLON {
  132014. /**
  132015. * Block used to get the value of the first parameter raised to the power of the second
  132016. */
  132017. export class PowBlock extends NodeMaterialBlock {
  132018. /**
  132019. * Creates a new PowBlock
  132020. * @param name defines the block name
  132021. */
  132022. constructor(name: string);
  132023. /**
  132024. * Gets the current class name
  132025. * @returns the class name
  132026. */
  132027. getClassName(): string;
  132028. /**
  132029. * Gets the value operand input component
  132030. */
  132031. get value(): NodeMaterialConnectionPoint;
  132032. /**
  132033. * Gets the power operand input component
  132034. */
  132035. get power(): NodeMaterialConnectionPoint;
  132036. /**
  132037. * Gets the output component
  132038. */
  132039. get output(): NodeMaterialConnectionPoint;
  132040. protected _buildBlock(state: NodeMaterialBuildState): this;
  132041. }
  132042. }
  132043. declare module BABYLON {
  132044. /**
  132045. * Block used to get a random number
  132046. */
  132047. export class RandomNumberBlock extends NodeMaterialBlock {
  132048. /**
  132049. * Creates a new RandomNumberBlock
  132050. * @param name defines the block name
  132051. */
  132052. constructor(name: string);
  132053. /**
  132054. * Gets the current class name
  132055. * @returns the class name
  132056. */
  132057. getClassName(): string;
  132058. /**
  132059. * Gets the seed input component
  132060. */
  132061. get seed(): NodeMaterialConnectionPoint;
  132062. /**
  132063. * Gets the output component
  132064. */
  132065. get output(): NodeMaterialConnectionPoint;
  132066. protected _buildBlock(state: NodeMaterialBuildState): this;
  132067. }
  132068. }
  132069. declare module BABYLON {
  132070. /**
  132071. * Block used to compute arc tangent of 2 values
  132072. */
  132073. export class ArcTan2Block extends NodeMaterialBlock {
  132074. /**
  132075. * Creates a new ArcTan2Block
  132076. * @param name defines the block name
  132077. */
  132078. constructor(name: string);
  132079. /**
  132080. * Gets the current class name
  132081. * @returns the class name
  132082. */
  132083. getClassName(): string;
  132084. /**
  132085. * Gets the x operand input component
  132086. */
  132087. get x(): NodeMaterialConnectionPoint;
  132088. /**
  132089. * Gets the y operand input component
  132090. */
  132091. get y(): NodeMaterialConnectionPoint;
  132092. /**
  132093. * Gets the output component
  132094. */
  132095. get output(): NodeMaterialConnectionPoint;
  132096. protected _buildBlock(state: NodeMaterialBuildState): this;
  132097. }
  132098. }
  132099. declare module BABYLON {
  132100. /**
  132101. * Block used to smooth step a value
  132102. */
  132103. export class SmoothStepBlock extends NodeMaterialBlock {
  132104. /**
  132105. * Creates a new SmoothStepBlock
  132106. * @param name defines the block name
  132107. */
  132108. constructor(name: string);
  132109. /**
  132110. * Gets the current class name
  132111. * @returns the class name
  132112. */
  132113. getClassName(): string;
  132114. /**
  132115. * Gets the value operand input component
  132116. */
  132117. get value(): NodeMaterialConnectionPoint;
  132118. /**
  132119. * Gets the first edge operand input component
  132120. */
  132121. get edge0(): NodeMaterialConnectionPoint;
  132122. /**
  132123. * Gets the second edge operand input component
  132124. */
  132125. get edge1(): NodeMaterialConnectionPoint;
  132126. /**
  132127. * Gets the output component
  132128. */
  132129. get output(): NodeMaterialConnectionPoint;
  132130. protected _buildBlock(state: NodeMaterialBuildState): this;
  132131. }
  132132. }
  132133. declare module BABYLON {
  132134. /**
  132135. * Block used to get the reciprocal (1 / x) of a value
  132136. */
  132137. export class ReciprocalBlock extends NodeMaterialBlock {
  132138. /**
  132139. * Creates a new ReciprocalBlock
  132140. * @param name defines the block name
  132141. */
  132142. constructor(name: string);
  132143. /**
  132144. * Gets the current class name
  132145. * @returns the class name
  132146. */
  132147. getClassName(): string;
  132148. /**
  132149. * Gets the input component
  132150. */
  132151. get input(): NodeMaterialConnectionPoint;
  132152. /**
  132153. * Gets the output component
  132154. */
  132155. get output(): NodeMaterialConnectionPoint;
  132156. protected _buildBlock(state: NodeMaterialBuildState): this;
  132157. }
  132158. }
  132159. declare module BABYLON {
  132160. /**
  132161. * Block used to replace a color by another one
  132162. */
  132163. export class ReplaceColorBlock extends NodeMaterialBlock {
  132164. /**
  132165. * Creates a new ReplaceColorBlock
  132166. * @param name defines the block name
  132167. */
  132168. constructor(name: string);
  132169. /**
  132170. * Gets the current class name
  132171. * @returns the class name
  132172. */
  132173. getClassName(): string;
  132174. /**
  132175. * Gets the value input component
  132176. */
  132177. get value(): NodeMaterialConnectionPoint;
  132178. /**
  132179. * Gets the reference input component
  132180. */
  132181. get reference(): NodeMaterialConnectionPoint;
  132182. /**
  132183. * Gets the distance input component
  132184. */
  132185. get distance(): NodeMaterialConnectionPoint;
  132186. /**
  132187. * Gets the replacement input component
  132188. */
  132189. get replacement(): NodeMaterialConnectionPoint;
  132190. /**
  132191. * Gets the output component
  132192. */
  132193. get output(): NodeMaterialConnectionPoint;
  132194. protected _buildBlock(state: NodeMaterialBuildState): this;
  132195. }
  132196. }
  132197. declare module BABYLON {
  132198. /**
  132199. * Block used to posterize a value
  132200. * @see https://en.wikipedia.org/wiki/Posterization
  132201. */
  132202. export class PosterizeBlock extends NodeMaterialBlock {
  132203. /**
  132204. * Creates a new PosterizeBlock
  132205. * @param name defines the block name
  132206. */
  132207. constructor(name: string);
  132208. /**
  132209. * Gets the current class name
  132210. * @returns the class name
  132211. */
  132212. getClassName(): string;
  132213. /**
  132214. * Gets the value input component
  132215. */
  132216. get value(): NodeMaterialConnectionPoint;
  132217. /**
  132218. * Gets the steps input component
  132219. */
  132220. get steps(): NodeMaterialConnectionPoint;
  132221. /**
  132222. * Gets the output component
  132223. */
  132224. get output(): NodeMaterialConnectionPoint;
  132225. protected _buildBlock(state: NodeMaterialBuildState): this;
  132226. }
  132227. }
  132228. declare module BABYLON {
  132229. /**
  132230. * Operations supported by the Wave block
  132231. */
  132232. export enum WaveBlockKind {
  132233. /** SawTooth */
  132234. SawTooth = 0,
  132235. /** Square */
  132236. Square = 1,
  132237. /** Triangle */
  132238. Triangle = 2
  132239. }
  132240. /**
  132241. * Block used to apply wave operation to floats
  132242. */
  132243. export class WaveBlock extends NodeMaterialBlock {
  132244. /**
  132245. * Gets or sets the kibnd of wave to be applied by the block
  132246. */
  132247. kind: WaveBlockKind;
  132248. /**
  132249. * Creates a new WaveBlock
  132250. * @param name defines the block name
  132251. */
  132252. constructor(name: string);
  132253. /**
  132254. * Gets the current class name
  132255. * @returns the class name
  132256. */
  132257. getClassName(): string;
  132258. /**
  132259. * Gets the input component
  132260. */
  132261. get input(): NodeMaterialConnectionPoint;
  132262. /**
  132263. * Gets the output component
  132264. */
  132265. get output(): NodeMaterialConnectionPoint;
  132266. protected _buildBlock(state: NodeMaterialBuildState): this;
  132267. serialize(): any;
  132268. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132269. }
  132270. }
  132271. declare module BABYLON {
  132272. /**
  132273. * Class used to store a color step for the GradientBlock
  132274. */
  132275. export class GradientBlockColorStep {
  132276. /**
  132277. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  132278. */
  132279. step: number;
  132280. /**
  132281. * Gets or sets the color associated with this step
  132282. */
  132283. color: Color3;
  132284. /**
  132285. * Creates a new GradientBlockColorStep
  132286. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  132287. * @param color defines the color associated with this step
  132288. */
  132289. constructor(
  132290. /**
  132291. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  132292. */
  132293. step: number,
  132294. /**
  132295. * Gets or sets the color associated with this step
  132296. */
  132297. color: Color3);
  132298. }
  132299. /**
  132300. * Block used to return a color from a gradient based on an input value between 0 and 1
  132301. */
  132302. export class GradientBlock extends NodeMaterialBlock {
  132303. /**
  132304. * Gets or sets the list of color steps
  132305. */
  132306. colorSteps: GradientBlockColorStep[];
  132307. /**
  132308. * Creates a new GradientBlock
  132309. * @param name defines the block name
  132310. */
  132311. constructor(name: string);
  132312. /**
  132313. * Gets the current class name
  132314. * @returns the class name
  132315. */
  132316. getClassName(): string;
  132317. /**
  132318. * Gets the gradient input component
  132319. */
  132320. get gradient(): NodeMaterialConnectionPoint;
  132321. /**
  132322. * Gets the output component
  132323. */
  132324. get output(): NodeMaterialConnectionPoint;
  132325. private _writeColorConstant;
  132326. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132327. serialize(): any;
  132328. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132329. protected _dumpPropertiesCode(): string;
  132330. }
  132331. }
  132332. declare module BABYLON {
  132333. /**
  132334. * Block used to normalize lerp between 2 values
  132335. */
  132336. export class NLerpBlock extends NodeMaterialBlock {
  132337. /**
  132338. * Creates a new NLerpBlock
  132339. * @param name defines the block name
  132340. */
  132341. constructor(name: string);
  132342. /**
  132343. * Gets the current class name
  132344. * @returns the class name
  132345. */
  132346. getClassName(): string;
  132347. /**
  132348. * Gets the left operand input component
  132349. */
  132350. get left(): NodeMaterialConnectionPoint;
  132351. /**
  132352. * Gets the right operand input component
  132353. */
  132354. get right(): NodeMaterialConnectionPoint;
  132355. /**
  132356. * Gets the gradient operand input component
  132357. */
  132358. get gradient(): NodeMaterialConnectionPoint;
  132359. /**
  132360. * Gets the output component
  132361. */
  132362. get output(): NodeMaterialConnectionPoint;
  132363. protected _buildBlock(state: NodeMaterialBuildState): this;
  132364. }
  132365. }
  132366. declare module BABYLON {
  132367. /**
  132368. * block used to Generate a Worley Noise 3D Noise Pattern
  132369. */
  132370. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  132371. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  132372. manhattanDistance: boolean;
  132373. /**
  132374. * Creates a new WorleyNoise3DBlock
  132375. * @param name defines the block name
  132376. */
  132377. constructor(name: string);
  132378. /**
  132379. * Gets the current class name
  132380. * @returns the class name
  132381. */
  132382. getClassName(): string;
  132383. /**
  132384. * Gets the seed input component
  132385. */
  132386. get seed(): NodeMaterialConnectionPoint;
  132387. /**
  132388. * Gets the jitter input component
  132389. */
  132390. get jitter(): NodeMaterialConnectionPoint;
  132391. /**
  132392. * Gets the output component
  132393. */
  132394. get output(): NodeMaterialConnectionPoint;
  132395. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132396. /**
  132397. * Exposes the properties to the UI?
  132398. */
  132399. protected _dumpPropertiesCode(): string;
  132400. /**
  132401. * Exposes the properties to the Seralize?
  132402. */
  132403. serialize(): any;
  132404. /**
  132405. * Exposes the properties to the deseralize?
  132406. */
  132407. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132408. }
  132409. }
  132410. declare module BABYLON {
  132411. /**
  132412. * block used to Generate a Simplex Perlin 3d Noise Pattern
  132413. */
  132414. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  132415. /**
  132416. * Creates a new SimplexPerlin3DBlock
  132417. * @param name defines the block name
  132418. */
  132419. constructor(name: string);
  132420. /**
  132421. * Gets the current class name
  132422. * @returns the class name
  132423. */
  132424. getClassName(): string;
  132425. /**
  132426. * Gets the seed operand input component
  132427. */
  132428. get seed(): NodeMaterialConnectionPoint;
  132429. /**
  132430. * Gets the output component
  132431. */
  132432. get output(): NodeMaterialConnectionPoint;
  132433. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132434. }
  132435. }
  132436. declare module BABYLON {
  132437. /**
  132438. * Block used to blend normals
  132439. */
  132440. export class NormalBlendBlock extends NodeMaterialBlock {
  132441. /**
  132442. * Creates a new NormalBlendBlock
  132443. * @param name defines the block name
  132444. */
  132445. constructor(name: string);
  132446. /**
  132447. * Gets the current class name
  132448. * @returns the class name
  132449. */
  132450. getClassName(): string;
  132451. /**
  132452. * Gets the first input component
  132453. */
  132454. get normalMap0(): NodeMaterialConnectionPoint;
  132455. /**
  132456. * Gets the second input component
  132457. */
  132458. get normalMap1(): NodeMaterialConnectionPoint;
  132459. /**
  132460. * Gets the output component
  132461. */
  132462. get output(): NodeMaterialConnectionPoint;
  132463. protected _buildBlock(state: NodeMaterialBuildState): this;
  132464. }
  132465. }
  132466. declare module BABYLON {
  132467. /**
  132468. * Block used to rotate a 2d vector by a given angle
  132469. */
  132470. export class Rotate2dBlock extends NodeMaterialBlock {
  132471. /**
  132472. * Creates a new Rotate2dBlock
  132473. * @param name defines the block name
  132474. */
  132475. constructor(name: string);
  132476. /**
  132477. * Gets the current class name
  132478. * @returns the class name
  132479. */
  132480. getClassName(): string;
  132481. /**
  132482. * Gets the input vector
  132483. */
  132484. get input(): NodeMaterialConnectionPoint;
  132485. /**
  132486. * Gets the input angle
  132487. */
  132488. get angle(): NodeMaterialConnectionPoint;
  132489. /**
  132490. * Gets the output component
  132491. */
  132492. get output(): NodeMaterialConnectionPoint;
  132493. autoConfigure(material: NodeMaterial): void;
  132494. protected _buildBlock(state: NodeMaterialBuildState): this;
  132495. }
  132496. }
  132497. declare module BABYLON {
  132498. /**
  132499. * Block used to get the reflected vector from a direction and a normal
  132500. */
  132501. export class ReflectBlock extends NodeMaterialBlock {
  132502. /**
  132503. * Creates a new ReflectBlock
  132504. * @param name defines the block name
  132505. */
  132506. constructor(name: string);
  132507. /**
  132508. * Gets the current class name
  132509. * @returns the class name
  132510. */
  132511. getClassName(): string;
  132512. /**
  132513. * Gets the incident component
  132514. */
  132515. get incident(): NodeMaterialConnectionPoint;
  132516. /**
  132517. * Gets the normal component
  132518. */
  132519. get normal(): NodeMaterialConnectionPoint;
  132520. /**
  132521. * Gets the output component
  132522. */
  132523. get output(): NodeMaterialConnectionPoint;
  132524. protected _buildBlock(state: NodeMaterialBuildState): this;
  132525. }
  132526. }
  132527. declare module BABYLON {
  132528. /**
  132529. * Block used to get the refracted vector from a direction and a normal
  132530. */
  132531. export class RefractBlock extends NodeMaterialBlock {
  132532. /**
  132533. * Creates a new RefractBlock
  132534. * @param name defines the block name
  132535. */
  132536. constructor(name: string);
  132537. /**
  132538. * Gets the current class name
  132539. * @returns the class name
  132540. */
  132541. getClassName(): string;
  132542. /**
  132543. * Gets the incident component
  132544. */
  132545. get incident(): NodeMaterialConnectionPoint;
  132546. /**
  132547. * Gets the normal component
  132548. */
  132549. get normal(): NodeMaterialConnectionPoint;
  132550. /**
  132551. * Gets the index of refraction component
  132552. */
  132553. get ior(): NodeMaterialConnectionPoint;
  132554. /**
  132555. * Gets the output component
  132556. */
  132557. get output(): NodeMaterialConnectionPoint;
  132558. protected _buildBlock(state: NodeMaterialBuildState): this;
  132559. }
  132560. }
  132561. declare module BABYLON {
  132562. /**
  132563. * Block used to desaturate a color
  132564. */
  132565. export class DesaturateBlock extends NodeMaterialBlock {
  132566. /**
  132567. * Creates a new DesaturateBlock
  132568. * @param name defines the block name
  132569. */
  132570. constructor(name: string);
  132571. /**
  132572. * Gets the current class name
  132573. * @returns the class name
  132574. */
  132575. getClassName(): string;
  132576. /**
  132577. * Gets the color operand input component
  132578. */
  132579. get color(): NodeMaterialConnectionPoint;
  132580. /**
  132581. * Gets the level operand input component
  132582. */
  132583. get level(): NodeMaterialConnectionPoint;
  132584. /**
  132585. * Gets the output component
  132586. */
  132587. get output(): NodeMaterialConnectionPoint;
  132588. protected _buildBlock(state: NodeMaterialBuildState): this;
  132589. }
  132590. }
  132591. declare module BABYLON {
  132592. /**
  132593. * Effect Render Options
  132594. */
  132595. export interface IEffectRendererOptions {
  132596. /**
  132597. * Defines the vertices positions.
  132598. */
  132599. positions?: number[];
  132600. /**
  132601. * Defines the indices.
  132602. */
  132603. indices?: number[];
  132604. }
  132605. /**
  132606. * Helper class to render one or more effects
  132607. */
  132608. export class EffectRenderer {
  132609. private engine;
  132610. private static _DefaultOptions;
  132611. private _vertexBuffers;
  132612. private _indexBuffer;
  132613. private _ringBufferIndex;
  132614. private _ringScreenBuffer;
  132615. private _fullscreenViewport;
  132616. private _getNextFrameBuffer;
  132617. /**
  132618. * Creates an effect renderer
  132619. * @param engine the engine to use for rendering
  132620. * @param options defines the options of the effect renderer
  132621. */
  132622. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  132623. /**
  132624. * Sets the current viewport in normalized coordinates 0-1
  132625. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  132626. */
  132627. setViewport(viewport?: Viewport): void;
  132628. /**
  132629. * Binds the embedded attributes buffer to the effect.
  132630. * @param effect Defines the effect to bind the attributes for
  132631. */
  132632. bindBuffers(effect: Effect): void;
  132633. /**
  132634. * Sets the current effect wrapper to use during draw.
  132635. * The effect needs to be ready before calling this api.
  132636. * This also sets the default full screen position attribute.
  132637. * @param effectWrapper Defines the effect to draw with
  132638. */
  132639. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  132640. /**
  132641. * Draws a full screen quad.
  132642. */
  132643. draw(): void;
  132644. /**
  132645. * renders one or more effects to a specified texture
  132646. * @param effectWrappers list of effects to renderer
  132647. * @param outputTexture texture to draw to, if null it will render to the screen
  132648. */
  132649. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  132650. /**
  132651. * Disposes of the effect renderer
  132652. */
  132653. dispose(): void;
  132654. }
  132655. /**
  132656. * Options to create an EffectWrapper
  132657. */
  132658. interface EffectWrapperCreationOptions {
  132659. /**
  132660. * Engine to use to create the effect
  132661. */
  132662. engine: ThinEngine;
  132663. /**
  132664. * Fragment shader for the effect
  132665. */
  132666. fragmentShader: string;
  132667. /**
  132668. * Vertex shader for the effect
  132669. */
  132670. vertexShader?: string;
  132671. /**
  132672. * Attributes to use in the shader
  132673. */
  132674. attributeNames?: Array<string>;
  132675. /**
  132676. * Uniforms to use in the shader
  132677. */
  132678. uniformNames?: Array<string>;
  132679. /**
  132680. * Texture sampler names to use in the shader
  132681. */
  132682. samplerNames?: Array<string>;
  132683. /**
  132684. * The friendly name of the effect displayed in Spector.
  132685. */
  132686. name?: string;
  132687. }
  132688. /**
  132689. * Wraps an effect to be used for rendering
  132690. */
  132691. export class EffectWrapper {
  132692. /**
  132693. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  132694. */
  132695. onApplyObservable: Observable<{}>;
  132696. /**
  132697. * The underlying effect
  132698. */
  132699. effect: Effect;
  132700. /**
  132701. * Creates an effect to be renderer
  132702. * @param creationOptions options to create the effect
  132703. */
  132704. constructor(creationOptions: EffectWrapperCreationOptions);
  132705. /**
  132706. * Disposes of the effect wrapper
  132707. */
  132708. dispose(): void;
  132709. }
  132710. }
  132711. declare module BABYLON {
  132712. /**
  132713. * Helper class to push actions to a pool of workers.
  132714. */
  132715. export class WorkerPool implements IDisposable {
  132716. private _workerInfos;
  132717. private _pendingActions;
  132718. /**
  132719. * Constructor
  132720. * @param workers Array of workers to use for actions
  132721. */
  132722. constructor(workers: Array<Worker>);
  132723. /**
  132724. * Terminates all workers and clears any pending actions.
  132725. */
  132726. dispose(): void;
  132727. /**
  132728. * Pushes an action to the worker pool. If all the workers are active, the action will be
  132729. * pended until a worker has completed its action.
  132730. * @param action The action to perform. Call onComplete when the action is complete.
  132731. */
  132732. push(action: (worker: Worker, onComplete: () => void) => void): void;
  132733. private _execute;
  132734. }
  132735. }
  132736. declare module BABYLON {
  132737. /**
  132738. * Configuration for Draco compression
  132739. */
  132740. export interface IDracoCompressionConfiguration {
  132741. /**
  132742. * Configuration for the decoder.
  132743. */
  132744. decoder: {
  132745. /**
  132746. * The url to the WebAssembly module.
  132747. */
  132748. wasmUrl?: string;
  132749. /**
  132750. * The url to the WebAssembly binary.
  132751. */
  132752. wasmBinaryUrl?: string;
  132753. /**
  132754. * The url to the fallback JavaScript module.
  132755. */
  132756. fallbackUrl?: string;
  132757. };
  132758. }
  132759. /**
  132760. * Draco compression (https://google.github.io/draco/)
  132761. *
  132762. * This class wraps the Draco module.
  132763. *
  132764. * **Encoder**
  132765. *
  132766. * The encoder is not currently implemented.
  132767. *
  132768. * **Decoder**
  132769. *
  132770. * 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.
  132771. *
  132772. * To update the configuration, use the following code:
  132773. * ```javascript
  132774. * DracoCompression.Configuration = {
  132775. * decoder: {
  132776. * wasmUrl: "<url to the WebAssembly library>",
  132777. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  132778. * fallbackUrl: "<url to the fallback JavaScript library>",
  132779. * }
  132780. * };
  132781. * ```
  132782. *
  132783. * 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.
  132784. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  132785. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  132786. *
  132787. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  132788. * ```javascript
  132789. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  132790. * ```
  132791. *
  132792. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  132793. */
  132794. export class DracoCompression implements IDisposable {
  132795. private _workerPoolPromise?;
  132796. private _decoderModulePromise?;
  132797. /**
  132798. * The configuration. Defaults to the following urls:
  132799. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  132800. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  132801. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  132802. */
  132803. static Configuration: IDracoCompressionConfiguration;
  132804. /**
  132805. * Returns true if the decoder configuration is available.
  132806. */
  132807. static get DecoderAvailable(): boolean;
  132808. /**
  132809. * Default number of workers to create when creating the draco compression object.
  132810. */
  132811. static DefaultNumWorkers: number;
  132812. private static GetDefaultNumWorkers;
  132813. private static _Default;
  132814. /**
  132815. * Default instance for the draco compression object.
  132816. */
  132817. static get Default(): DracoCompression;
  132818. /**
  132819. * Constructor
  132820. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  132821. */
  132822. constructor(numWorkers?: number);
  132823. /**
  132824. * Stop all async operations and release resources.
  132825. */
  132826. dispose(): void;
  132827. /**
  132828. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  132829. * @returns a promise that resolves when ready
  132830. */
  132831. whenReadyAsync(): Promise<void>;
  132832. /**
  132833. * Decode Draco compressed mesh data to vertex data.
  132834. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  132835. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  132836. * @returns A promise that resolves with the decoded vertex data
  132837. */
  132838. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  132839. [kind: string]: number;
  132840. }): Promise<VertexData>;
  132841. }
  132842. }
  132843. declare module BABYLON {
  132844. /**
  132845. * Class for building Constructive Solid Geometry
  132846. */
  132847. export class CSG {
  132848. private polygons;
  132849. /**
  132850. * The world matrix
  132851. */
  132852. matrix: Matrix;
  132853. /**
  132854. * Stores the position
  132855. */
  132856. position: Vector3;
  132857. /**
  132858. * Stores the rotation
  132859. */
  132860. rotation: Vector3;
  132861. /**
  132862. * Stores the rotation quaternion
  132863. */
  132864. rotationQuaternion: Nullable<Quaternion>;
  132865. /**
  132866. * Stores the scaling vector
  132867. */
  132868. scaling: Vector3;
  132869. /**
  132870. * Convert the Mesh to CSG
  132871. * @param mesh The Mesh to convert to CSG
  132872. * @returns A new CSG from the Mesh
  132873. */
  132874. static FromMesh(mesh: Mesh): CSG;
  132875. /**
  132876. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  132877. * @param polygons Polygons used to construct a CSG solid
  132878. */
  132879. private static FromPolygons;
  132880. /**
  132881. * Clones, or makes a deep copy, of the CSG
  132882. * @returns A new CSG
  132883. */
  132884. clone(): CSG;
  132885. /**
  132886. * Unions this CSG with another CSG
  132887. * @param csg The CSG to union against this CSG
  132888. * @returns The unioned CSG
  132889. */
  132890. union(csg: CSG): CSG;
  132891. /**
  132892. * Unions this CSG with another CSG in place
  132893. * @param csg The CSG to union against this CSG
  132894. */
  132895. unionInPlace(csg: CSG): void;
  132896. /**
  132897. * Subtracts this CSG with another CSG
  132898. * @param csg The CSG to subtract against this CSG
  132899. * @returns A new CSG
  132900. */
  132901. subtract(csg: CSG): CSG;
  132902. /**
  132903. * Subtracts this CSG with another CSG in place
  132904. * @param csg The CSG to subtact against this CSG
  132905. */
  132906. subtractInPlace(csg: CSG): void;
  132907. /**
  132908. * Intersect this CSG with another CSG
  132909. * @param csg The CSG to intersect against this CSG
  132910. * @returns A new CSG
  132911. */
  132912. intersect(csg: CSG): CSG;
  132913. /**
  132914. * Intersects this CSG with another CSG in place
  132915. * @param csg The CSG to intersect against this CSG
  132916. */
  132917. intersectInPlace(csg: CSG): void;
  132918. /**
  132919. * Return a new CSG solid with solid and empty space switched. This solid is
  132920. * not modified.
  132921. * @returns A new CSG solid with solid and empty space switched
  132922. */
  132923. inverse(): CSG;
  132924. /**
  132925. * Inverses the CSG in place
  132926. */
  132927. inverseInPlace(): void;
  132928. /**
  132929. * This is used to keep meshes transformations so they can be restored
  132930. * when we build back a Babylon Mesh
  132931. * NB : All CSG operations are performed in world coordinates
  132932. * @param csg The CSG to copy the transform attributes from
  132933. * @returns This CSG
  132934. */
  132935. copyTransformAttributes(csg: CSG): CSG;
  132936. /**
  132937. * Build Raw mesh from CSG
  132938. * Coordinates here are in world space
  132939. * @param name The name of the mesh geometry
  132940. * @param scene The Scene
  132941. * @param keepSubMeshes Specifies if the submeshes should be kept
  132942. * @returns A new Mesh
  132943. */
  132944. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  132945. /**
  132946. * Build Mesh from CSG taking material and transforms into account
  132947. * @param name The name of the Mesh
  132948. * @param material The material of the Mesh
  132949. * @param scene The Scene
  132950. * @param keepSubMeshes Specifies if submeshes should be kept
  132951. * @returns The new Mesh
  132952. */
  132953. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  132954. }
  132955. }
  132956. declare module BABYLON {
  132957. /**
  132958. * Class used to create a trail following a mesh
  132959. */
  132960. export class TrailMesh extends Mesh {
  132961. private _generator;
  132962. private _autoStart;
  132963. private _running;
  132964. private _diameter;
  132965. private _length;
  132966. private _sectionPolygonPointsCount;
  132967. private _sectionVectors;
  132968. private _sectionNormalVectors;
  132969. private _beforeRenderObserver;
  132970. /**
  132971. * @constructor
  132972. * @param name The value used by scene.getMeshByName() to do a lookup.
  132973. * @param generator The mesh or transform node to generate a trail.
  132974. * @param scene The scene to add this mesh to.
  132975. * @param diameter Diameter of trailing mesh. Default is 1.
  132976. * @param length Length of trailing mesh. Default is 60.
  132977. * @param autoStart Automatically start trailing mesh. Default true.
  132978. */
  132979. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  132980. /**
  132981. * "TrailMesh"
  132982. * @returns "TrailMesh"
  132983. */
  132984. getClassName(): string;
  132985. private _createMesh;
  132986. /**
  132987. * Start trailing mesh.
  132988. */
  132989. start(): void;
  132990. /**
  132991. * Stop trailing mesh.
  132992. */
  132993. stop(): void;
  132994. /**
  132995. * Update trailing mesh geometry.
  132996. */
  132997. update(): void;
  132998. /**
  132999. * Returns a new TrailMesh object.
  133000. * @param name is a string, the name given to the new mesh
  133001. * @param newGenerator use new generator object for cloned trail mesh
  133002. * @returns a new mesh
  133003. */
  133004. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  133005. /**
  133006. * Serializes this trail mesh
  133007. * @param serializationObject object to write serialization to
  133008. */
  133009. serialize(serializationObject: any): void;
  133010. /**
  133011. * Parses a serialized trail mesh
  133012. * @param parsedMesh the serialized mesh
  133013. * @param scene the scene to create the trail mesh in
  133014. * @returns the created trail mesh
  133015. */
  133016. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  133017. }
  133018. }
  133019. declare module BABYLON {
  133020. /**
  133021. * Class containing static functions to help procedurally build meshes
  133022. */
  133023. export class TiledBoxBuilder {
  133024. /**
  133025. * Creates a box mesh
  133026. * 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)
  133027. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133028. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133029. * * 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
  133030. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133031. * @param name defines the name of the mesh
  133032. * @param options defines the options used to create the mesh
  133033. * @param scene defines the hosting scene
  133034. * @returns the box mesh
  133035. */
  133036. static CreateTiledBox(name: string, options: {
  133037. pattern?: number;
  133038. width?: number;
  133039. height?: number;
  133040. depth?: number;
  133041. tileSize?: number;
  133042. tileWidth?: number;
  133043. tileHeight?: number;
  133044. alignHorizontal?: number;
  133045. alignVertical?: number;
  133046. faceUV?: Vector4[];
  133047. faceColors?: Color4[];
  133048. sideOrientation?: number;
  133049. updatable?: boolean;
  133050. }, scene?: Nullable<Scene>): Mesh;
  133051. }
  133052. }
  133053. declare module BABYLON {
  133054. /**
  133055. * Class containing static functions to help procedurally build meshes
  133056. */
  133057. export class TorusKnotBuilder {
  133058. /**
  133059. * Creates a torus knot mesh
  133060. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  133061. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  133062. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  133063. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  133064. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133065. * * 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
  133066. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133067. * @param name defines the name of the mesh
  133068. * @param options defines the options used to create the mesh
  133069. * @param scene defines the hosting scene
  133070. * @returns the torus knot mesh
  133071. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  133072. */
  133073. static CreateTorusKnot(name: string, options: {
  133074. radius?: number;
  133075. tube?: number;
  133076. radialSegments?: number;
  133077. tubularSegments?: number;
  133078. p?: number;
  133079. q?: number;
  133080. updatable?: boolean;
  133081. sideOrientation?: number;
  133082. frontUVs?: Vector4;
  133083. backUVs?: Vector4;
  133084. }, scene: any): Mesh;
  133085. }
  133086. }
  133087. declare module BABYLON {
  133088. /**
  133089. * Polygon
  133090. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  133091. */
  133092. export class Polygon {
  133093. /**
  133094. * Creates a rectangle
  133095. * @param xmin bottom X coord
  133096. * @param ymin bottom Y coord
  133097. * @param xmax top X coord
  133098. * @param ymax top Y coord
  133099. * @returns points that make the resulting rectation
  133100. */
  133101. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  133102. /**
  133103. * Creates a circle
  133104. * @param radius radius of circle
  133105. * @param cx scale in x
  133106. * @param cy scale in y
  133107. * @param numberOfSides number of sides that make up the circle
  133108. * @returns points that make the resulting circle
  133109. */
  133110. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  133111. /**
  133112. * Creates a polygon from input string
  133113. * @param input Input polygon data
  133114. * @returns the parsed points
  133115. */
  133116. static Parse(input: string): Vector2[];
  133117. /**
  133118. * Starts building a polygon from x and y coordinates
  133119. * @param x x coordinate
  133120. * @param y y coordinate
  133121. * @returns the started path2
  133122. */
  133123. static StartingAt(x: number, y: number): Path2;
  133124. }
  133125. /**
  133126. * Builds a polygon
  133127. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  133128. */
  133129. export class PolygonMeshBuilder {
  133130. private _points;
  133131. private _outlinepoints;
  133132. private _holes;
  133133. private _name;
  133134. private _scene;
  133135. private _epoints;
  133136. private _eholes;
  133137. private _addToepoint;
  133138. /**
  133139. * Babylon reference to the earcut plugin.
  133140. */
  133141. bjsEarcut: any;
  133142. /**
  133143. * Creates a PolygonMeshBuilder
  133144. * @param name name of the builder
  133145. * @param contours Path of the polygon
  133146. * @param scene scene to add to when creating the mesh
  133147. * @param earcutInjection can be used to inject your own earcut reference
  133148. */
  133149. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  133150. /**
  133151. * Adds a whole within the polygon
  133152. * @param hole Array of points defining the hole
  133153. * @returns this
  133154. */
  133155. addHole(hole: Vector2[]): PolygonMeshBuilder;
  133156. /**
  133157. * Creates the polygon
  133158. * @param updatable If the mesh should be updatable
  133159. * @param depth The depth of the mesh created
  133160. * @returns the created mesh
  133161. */
  133162. build(updatable?: boolean, depth?: number): Mesh;
  133163. /**
  133164. * Creates the polygon
  133165. * @param depth The depth of the mesh created
  133166. * @returns the created VertexData
  133167. */
  133168. buildVertexData(depth?: number): VertexData;
  133169. /**
  133170. * Adds a side to the polygon
  133171. * @param positions points that make the polygon
  133172. * @param normals normals of the polygon
  133173. * @param uvs uvs of the polygon
  133174. * @param indices indices of the polygon
  133175. * @param bounds bounds of the polygon
  133176. * @param points points of the polygon
  133177. * @param depth depth of the polygon
  133178. * @param flip flip of the polygon
  133179. */
  133180. private addSide;
  133181. }
  133182. }
  133183. declare module BABYLON {
  133184. /**
  133185. * Class containing static functions to help procedurally build meshes
  133186. */
  133187. export class PolygonBuilder {
  133188. /**
  133189. * Creates a polygon mesh
  133190. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  133191. * * 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
  133192. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  133193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133194. * * 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)
  133195. * * Remember you can only change the shape positions, not their number when updating a polygon
  133196. * @param name defines the name of the mesh
  133197. * @param options defines the options used to create the mesh
  133198. * @param scene defines the hosting scene
  133199. * @param earcutInjection can be used to inject your own earcut reference
  133200. * @returns the polygon mesh
  133201. */
  133202. static CreatePolygon(name: string, options: {
  133203. shape: Vector3[];
  133204. holes?: Vector3[][];
  133205. depth?: number;
  133206. faceUV?: Vector4[];
  133207. faceColors?: Color4[];
  133208. updatable?: boolean;
  133209. sideOrientation?: number;
  133210. frontUVs?: Vector4;
  133211. backUVs?: Vector4;
  133212. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  133213. /**
  133214. * Creates an extruded polygon mesh, with depth in the Y direction.
  133215. * * 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)
  133216. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133217. * @param name defines the name of the mesh
  133218. * @param options defines the options used to create the mesh
  133219. * @param scene defines the hosting scene
  133220. * @param earcutInjection can be used to inject your own earcut reference
  133221. * @returns the polygon mesh
  133222. */
  133223. static ExtrudePolygon(name: string, options: {
  133224. shape: Vector3[];
  133225. holes?: Vector3[][];
  133226. depth?: number;
  133227. faceUV?: Vector4[];
  133228. faceColors?: Color4[];
  133229. updatable?: boolean;
  133230. sideOrientation?: number;
  133231. frontUVs?: Vector4;
  133232. backUVs?: Vector4;
  133233. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  133234. }
  133235. }
  133236. declare module BABYLON {
  133237. /**
  133238. * Class containing static functions to help procedurally build meshes
  133239. */
  133240. export class LatheBuilder {
  133241. /**
  133242. * Creates lathe mesh.
  133243. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  133244. * * 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
  133245. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  133246. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  133247. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  133248. * * 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
  133249. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  133250. * * 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
  133251. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133252. * * 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
  133253. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  133254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133255. * @param name defines the name of the mesh
  133256. * @param options defines the options used to create the mesh
  133257. * @param scene defines the hosting scene
  133258. * @returns the lathe mesh
  133259. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  133260. */
  133261. static CreateLathe(name: string, options: {
  133262. shape: Vector3[];
  133263. radius?: number;
  133264. tessellation?: number;
  133265. clip?: number;
  133266. arc?: number;
  133267. closed?: boolean;
  133268. updatable?: boolean;
  133269. sideOrientation?: number;
  133270. frontUVs?: Vector4;
  133271. backUVs?: Vector4;
  133272. cap?: number;
  133273. invertUV?: boolean;
  133274. }, scene?: Nullable<Scene>): Mesh;
  133275. }
  133276. }
  133277. declare module BABYLON {
  133278. /**
  133279. * Class containing static functions to help procedurally build meshes
  133280. */
  133281. export class TiledPlaneBuilder {
  133282. /**
  133283. * Creates a tiled plane mesh
  133284. * * The parameter `pattern` will, depending on value, do nothing or
  133285. * * * flip (reflect about central vertical) alternate tiles across and up
  133286. * * * flip every tile on alternate rows
  133287. * * * rotate (180 degs) alternate tiles across and up
  133288. * * * rotate every tile on alternate rows
  133289. * * * flip and rotate alternate tiles across and up
  133290. * * * flip and rotate every tile on alternate rows
  133291. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  133292. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  133293. * * 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
  133294. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  133295. * * 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)
  133296. * * 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)
  133297. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  133298. * @param name defines the name of the mesh
  133299. * @param options defines the options used to create the mesh
  133300. * @param scene defines the hosting scene
  133301. * @returns the box mesh
  133302. */
  133303. static CreateTiledPlane(name: string, options: {
  133304. pattern?: number;
  133305. tileSize?: number;
  133306. tileWidth?: number;
  133307. tileHeight?: number;
  133308. size?: number;
  133309. width?: number;
  133310. height?: number;
  133311. alignHorizontal?: number;
  133312. alignVertical?: number;
  133313. sideOrientation?: number;
  133314. frontUVs?: Vector4;
  133315. backUVs?: Vector4;
  133316. updatable?: boolean;
  133317. }, scene?: Nullable<Scene>): Mesh;
  133318. }
  133319. }
  133320. declare module BABYLON {
  133321. /**
  133322. * Class containing static functions to help procedurally build meshes
  133323. */
  133324. export class TubeBuilder {
  133325. /**
  133326. * Creates a tube mesh.
  133327. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  133328. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  133329. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  133330. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  133331. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  133332. * * 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)
  133333. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  133334. * * 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
  133335. * * 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
  133336. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133337. * * 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
  133338. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  133339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133340. * @param name defines the name of the mesh
  133341. * @param options defines the options used to create the mesh
  133342. * @param scene defines the hosting scene
  133343. * @returns the tube mesh
  133344. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  133345. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  133346. */
  133347. static CreateTube(name: string, options: {
  133348. path: Vector3[];
  133349. radius?: number;
  133350. tessellation?: number;
  133351. radiusFunction?: {
  133352. (i: number, distance: number): number;
  133353. };
  133354. cap?: number;
  133355. arc?: number;
  133356. updatable?: boolean;
  133357. sideOrientation?: number;
  133358. frontUVs?: Vector4;
  133359. backUVs?: Vector4;
  133360. instance?: Mesh;
  133361. invertUV?: boolean;
  133362. }, scene?: Nullable<Scene>): Mesh;
  133363. }
  133364. }
  133365. declare module BABYLON {
  133366. /**
  133367. * Class containing static functions to help procedurally build meshes
  133368. */
  133369. export class IcoSphereBuilder {
  133370. /**
  133371. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  133372. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  133373. * * 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`)
  133374. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  133375. * * 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
  133376. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133377. * * 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
  133378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133379. * @param name defines the name of the mesh
  133380. * @param options defines the options used to create the mesh
  133381. * @param scene defines the hosting scene
  133382. * @returns the icosahedron mesh
  133383. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  133384. */
  133385. static CreateIcoSphere(name: string, options: {
  133386. radius?: number;
  133387. radiusX?: number;
  133388. radiusY?: number;
  133389. radiusZ?: number;
  133390. flat?: boolean;
  133391. subdivisions?: number;
  133392. sideOrientation?: number;
  133393. frontUVs?: Vector4;
  133394. backUVs?: Vector4;
  133395. updatable?: boolean;
  133396. }, scene?: Nullable<Scene>): Mesh;
  133397. }
  133398. }
  133399. declare module BABYLON {
  133400. /**
  133401. * Class containing static functions to help procedurally build meshes
  133402. */
  133403. export class DecalBuilder {
  133404. /**
  133405. * Creates a decal mesh.
  133406. * 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
  133407. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  133408. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  133409. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  133410. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  133411. * @param name defines the name of the mesh
  133412. * @param sourceMesh defines the mesh where the decal must be applied
  133413. * @param options defines the options used to create the mesh
  133414. * @param scene defines the hosting scene
  133415. * @returns the decal mesh
  133416. * @see https://doc.babylonjs.com/how_to/decals
  133417. */
  133418. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  133419. position?: Vector3;
  133420. normal?: Vector3;
  133421. size?: Vector3;
  133422. angle?: number;
  133423. }): Mesh;
  133424. }
  133425. }
  133426. declare module BABYLON {
  133427. /**
  133428. * Class containing static functions to help procedurally build meshes
  133429. */
  133430. export class MeshBuilder {
  133431. /**
  133432. * Creates a box mesh
  133433. * * The parameter `size` sets the size (float) of each box side (default 1)
  133434. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  133435. * * 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)
  133436. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133437. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133438. * * 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
  133439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133440. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  133441. * @param name defines the name of the mesh
  133442. * @param options defines the options used to create the mesh
  133443. * @param scene defines the hosting scene
  133444. * @returns the box mesh
  133445. */
  133446. static CreateBox(name: string, options: {
  133447. size?: number;
  133448. width?: number;
  133449. height?: number;
  133450. depth?: number;
  133451. faceUV?: Vector4[];
  133452. faceColors?: Color4[];
  133453. sideOrientation?: number;
  133454. frontUVs?: Vector4;
  133455. backUVs?: Vector4;
  133456. updatable?: boolean;
  133457. }, scene?: Nullable<Scene>): Mesh;
  133458. /**
  133459. * Creates a tiled box mesh
  133460. * * faceTiles sets the pattern, tile size and number of tiles for a face
  133461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133462. * @param name defines the name of the mesh
  133463. * @param options defines the options used to create the mesh
  133464. * @param scene defines the hosting scene
  133465. * @returns the tiled box mesh
  133466. */
  133467. static CreateTiledBox(name: string, options: {
  133468. pattern?: number;
  133469. size?: number;
  133470. width?: number;
  133471. height?: number;
  133472. depth: number;
  133473. tileSize?: number;
  133474. tileWidth?: number;
  133475. tileHeight?: number;
  133476. faceUV?: Vector4[];
  133477. faceColors?: Color4[];
  133478. alignHorizontal?: number;
  133479. alignVertical?: number;
  133480. sideOrientation?: number;
  133481. updatable?: boolean;
  133482. }, scene?: Nullable<Scene>): Mesh;
  133483. /**
  133484. * Creates a sphere mesh
  133485. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  133486. * * 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`)
  133487. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  133488. * * 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
  133489. * * 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)
  133490. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133491. * * 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
  133492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133493. * @param name defines the name of the mesh
  133494. * @param options defines the options used to create the mesh
  133495. * @param scene defines the hosting scene
  133496. * @returns the sphere mesh
  133497. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  133498. */
  133499. static CreateSphere(name: string, options: {
  133500. segments?: number;
  133501. diameter?: number;
  133502. diameterX?: number;
  133503. diameterY?: number;
  133504. diameterZ?: number;
  133505. arc?: number;
  133506. slice?: number;
  133507. sideOrientation?: number;
  133508. frontUVs?: Vector4;
  133509. backUVs?: Vector4;
  133510. updatable?: boolean;
  133511. }, scene?: Nullable<Scene>): Mesh;
  133512. /**
  133513. * Creates a plane polygonal mesh. By default, this is a disc
  133514. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  133515. * * 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
  133516. * * 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
  133517. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133518. * * 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
  133519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133520. * @param name defines the name of the mesh
  133521. * @param options defines the options used to create the mesh
  133522. * @param scene defines the hosting scene
  133523. * @returns the plane polygonal mesh
  133524. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  133525. */
  133526. static CreateDisc(name: string, options: {
  133527. radius?: number;
  133528. tessellation?: number;
  133529. arc?: number;
  133530. updatable?: boolean;
  133531. sideOrientation?: number;
  133532. frontUVs?: Vector4;
  133533. backUVs?: Vector4;
  133534. }, scene?: Nullable<Scene>): Mesh;
  133535. /**
  133536. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  133537. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  133538. * * 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`)
  133539. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  133540. * * 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
  133541. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133542. * * 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
  133543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133544. * @param name defines the name of the mesh
  133545. * @param options defines the options used to create the mesh
  133546. * @param scene defines the hosting scene
  133547. * @returns the icosahedron mesh
  133548. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  133549. */
  133550. static CreateIcoSphere(name: string, options: {
  133551. radius?: number;
  133552. radiusX?: number;
  133553. radiusY?: number;
  133554. radiusZ?: number;
  133555. flat?: boolean;
  133556. subdivisions?: number;
  133557. sideOrientation?: number;
  133558. frontUVs?: Vector4;
  133559. backUVs?: Vector4;
  133560. updatable?: boolean;
  133561. }, scene?: Nullable<Scene>): Mesh;
  133562. /**
  133563. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  133564. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  133565. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  133566. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  133567. * * 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
  133568. * * 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
  133569. * * 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
  133570. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133571. * * 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
  133572. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  133573. * * 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
  133574. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  133575. * * 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
  133576. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  133577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133578. * @param name defines the name of the mesh
  133579. * @param options defines the options used to create the mesh
  133580. * @param scene defines the hosting scene
  133581. * @returns the ribbon mesh
  133582. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  133583. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  133584. */
  133585. static CreateRibbon(name: string, options: {
  133586. pathArray: Vector3[][];
  133587. closeArray?: boolean;
  133588. closePath?: boolean;
  133589. offset?: number;
  133590. updatable?: boolean;
  133591. sideOrientation?: number;
  133592. frontUVs?: Vector4;
  133593. backUVs?: Vector4;
  133594. instance?: Mesh;
  133595. invertUV?: boolean;
  133596. uvs?: Vector2[];
  133597. colors?: Color4[];
  133598. }, scene?: Nullable<Scene>): Mesh;
  133599. /**
  133600. * Creates a cylinder or a cone mesh
  133601. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  133602. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  133603. * * 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.
  133604. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  133605. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  133606. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  133607. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  133608. * * 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).
  133609. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  133610. * * 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).
  133611. * * 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
  133612. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  133613. * * 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
  133614. * * 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.
  133615. * * If `enclose` is false, a ring surface is one element.
  133616. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  133617. * * 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
  133618. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133619. * * 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
  133620. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133621. * @param name defines the name of the mesh
  133622. * @param options defines the options used to create the mesh
  133623. * @param scene defines the hosting scene
  133624. * @returns the cylinder mesh
  133625. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  133626. */
  133627. static CreateCylinder(name: string, options: {
  133628. height?: number;
  133629. diameterTop?: number;
  133630. diameterBottom?: number;
  133631. diameter?: number;
  133632. tessellation?: number;
  133633. subdivisions?: number;
  133634. arc?: number;
  133635. faceColors?: Color4[];
  133636. faceUV?: Vector4[];
  133637. updatable?: boolean;
  133638. hasRings?: boolean;
  133639. enclose?: boolean;
  133640. cap?: number;
  133641. sideOrientation?: number;
  133642. frontUVs?: Vector4;
  133643. backUVs?: Vector4;
  133644. }, scene?: Nullable<Scene>): Mesh;
  133645. /**
  133646. * Creates a torus mesh
  133647. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  133648. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  133649. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  133650. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133651. * * 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
  133652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133653. * @param name defines the name of the mesh
  133654. * @param options defines the options used to create the mesh
  133655. * @param scene defines the hosting scene
  133656. * @returns the torus mesh
  133657. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  133658. */
  133659. static CreateTorus(name: string, options: {
  133660. diameter?: number;
  133661. thickness?: number;
  133662. tessellation?: number;
  133663. updatable?: boolean;
  133664. sideOrientation?: number;
  133665. frontUVs?: Vector4;
  133666. backUVs?: Vector4;
  133667. }, scene?: Nullable<Scene>): Mesh;
  133668. /**
  133669. * Creates a torus knot mesh
  133670. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  133671. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  133672. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  133673. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  133674. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133675. * * 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
  133676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133677. * @param name defines the name of the mesh
  133678. * @param options defines the options used to create the mesh
  133679. * @param scene defines the hosting scene
  133680. * @returns the torus knot mesh
  133681. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  133682. */
  133683. static CreateTorusKnot(name: string, options: {
  133684. radius?: number;
  133685. tube?: number;
  133686. radialSegments?: number;
  133687. tubularSegments?: number;
  133688. p?: number;
  133689. q?: number;
  133690. updatable?: boolean;
  133691. sideOrientation?: number;
  133692. frontUVs?: Vector4;
  133693. backUVs?: Vector4;
  133694. }, scene?: Nullable<Scene>): Mesh;
  133695. /**
  133696. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  133697. * * 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
  133698. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  133699. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  133700. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  133701. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  133702. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  133703. * * 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
  133704. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  133705. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133706. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  133707. * @param name defines the name of the new line system
  133708. * @param options defines the options used to create the line system
  133709. * @param scene defines the hosting scene
  133710. * @returns a new line system mesh
  133711. */
  133712. static CreateLineSystem(name: string, options: {
  133713. lines: Vector3[][];
  133714. updatable?: boolean;
  133715. instance?: Nullable<LinesMesh>;
  133716. colors?: Nullable<Color4[][]>;
  133717. useVertexAlpha?: boolean;
  133718. }, scene: Nullable<Scene>): LinesMesh;
  133719. /**
  133720. * Creates a line mesh
  133721. * 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
  133722. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  133723. * * The parameter `points` is an array successive Vector3
  133724. * * 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
  133725. * * The optional parameter `colors` is an array of successive Color4, one per line point
  133726. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  133727. * * When updating an instance, remember that only point positions can change, not the number of points
  133728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133729. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  133730. * @param name defines the name of the new line system
  133731. * @param options defines the options used to create the line system
  133732. * @param scene defines the hosting scene
  133733. * @returns a new line mesh
  133734. */
  133735. static CreateLines(name: string, options: {
  133736. points: Vector3[];
  133737. updatable?: boolean;
  133738. instance?: Nullable<LinesMesh>;
  133739. colors?: Color4[];
  133740. useVertexAlpha?: boolean;
  133741. }, scene?: Nullable<Scene>): LinesMesh;
  133742. /**
  133743. * Creates a dashed line mesh
  133744. * * 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
  133745. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  133746. * * The parameter `points` is an array successive Vector3
  133747. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  133748. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  133749. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  133750. * * 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
  133751. * * When updating an instance, remember that only point positions can change, not the number of points
  133752. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133753. * @param name defines the name of the mesh
  133754. * @param options defines the options used to create the mesh
  133755. * @param scene defines the hosting scene
  133756. * @returns the dashed line mesh
  133757. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  133758. */
  133759. static CreateDashedLines(name: string, options: {
  133760. points: Vector3[];
  133761. dashSize?: number;
  133762. gapSize?: number;
  133763. dashNb?: number;
  133764. updatable?: boolean;
  133765. instance?: LinesMesh;
  133766. }, scene?: Nullable<Scene>): LinesMesh;
  133767. /**
  133768. * 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.
  133769. * * 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.
  133770. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  133771. * * 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.
  133772. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  133773. * * 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
  133774. * * 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
  133775. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  133776. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133777. * * 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
  133778. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  133779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133780. * @param name defines the name of the mesh
  133781. * @param options defines the options used to create the mesh
  133782. * @param scene defines the hosting scene
  133783. * @returns the extruded shape mesh
  133784. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  133785. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  133786. */
  133787. static ExtrudeShape(name: string, options: {
  133788. shape: Vector3[];
  133789. path: Vector3[];
  133790. scale?: number;
  133791. rotation?: number;
  133792. cap?: number;
  133793. updatable?: boolean;
  133794. sideOrientation?: number;
  133795. frontUVs?: Vector4;
  133796. backUVs?: Vector4;
  133797. instance?: Mesh;
  133798. invertUV?: boolean;
  133799. }, scene?: Nullable<Scene>): Mesh;
  133800. /**
  133801. * Creates an custom extruded shape mesh.
  133802. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  133803. * * 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.
  133804. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  133805. * * 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
  133806. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  133807. * * 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
  133808. * * It must returns a float value that will be the scale value applied to the shape on each path point
  133809. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  133810. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  133811. * * 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
  133812. * * 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
  133813. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  133814. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133815. * * 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
  133816. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  133817. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133818. * @param name defines the name of the mesh
  133819. * @param options defines the options used to create the mesh
  133820. * @param scene defines the hosting scene
  133821. * @returns the custom extruded shape mesh
  133822. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  133823. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  133824. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  133825. */
  133826. static ExtrudeShapeCustom(name: string, options: {
  133827. shape: Vector3[];
  133828. path: Vector3[];
  133829. scaleFunction?: any;
  133830. rotationFunction?: any;
  133831. ribbonCloseArray?: boolean;
  133832. ribbonClosePath?: boolean;
  133833. cap?: number;
  133834. updatable?: boolean;
  133835. sideOrientation?: number;
  133836. frontUVs?: Vector4;
  133837. backUVs?: Vector4;
  133838. instance?: Mesh;
  133839. invertUV?: boolean;
  133840. }, scene?: Nullable<Scene>): Mesh;
  133841. /**
  133842. * Creates lathe mesh.
  133843. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  133844. * * 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
  133845. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  133846. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  133847. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  133848. * * 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
  133849. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  133850. * * 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
  133851. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133852. * * 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
  133853. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  133854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133855. * @param name defines the name of the mesh
  133856. * @param options defines the options used to create the mesh
  133857. * @param scene defines the hosting scene
  133858. * @returns the lathe mesh
  133859. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  133860. */
  133861. static CreateLathe(name: string, options: {
  133862. shape: Vector3[];
  133863. radius?: number;
  133864. tessellation?: number;
  133865. clip?: number;
  133866. arc?: number;
  133867. closed?: boolean;
  133868. updatable?: boolean;
  133869. sideOrientation?: number;
  133870. frontUVs?: Vector4;
  133871. backUVs?: Vector4;
  133872. cap?: number;
  133873. invertUV?: boolean;
  133874. }, scene?: Nullable<Scene>): Mesh;
  133875. /**
  133876. * Creates a tiled plane mesh
  133877. * * You can set a limited pattern arrangement with the tiles
  133878. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133879. * * 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
  133880. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133881. * @param name defines the name of the mesh
  133882. * @param options defines the options used to create the mesh
  133883. * @param scene defines the hosting scene
  133884. * @returns the plane mesh
  133885. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  133886. */
  133887. static CreateTiledPlane(name: string, options: {
  133888. pattern?: number;
  133889. tileSize?: number;
  133890. tileWidth?: number;
  133891. tileHeight?: number;
  133892. size?: number;
  133893. width?: number;
  133894. height?: number;
  133895. alignHorizontal?: number;
  133896. alignVertical?: number;
  133897. sideOrientation?: number;
  133898. frontUVs?: Vector4;
  133899. backUVs?: Vector4;
  133900. updatable?: boolean;
  133901. }, scene?: Nullable<Scene>): Mesh;
  133902. /**
  133903. * Creates a plane mesh
  133904. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  133905. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  133906. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  133907. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133908. * * 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
  133909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133910. * @param name defines the name of the mesh
  133911. * @param options defines the options used to create the mesh
  133912. * @param scene defines the hosting scene
  133913. * @returns the plane mesh
  133914. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  133915. */
  133916. static CreatePlane(name: string, options: {
  133917. size?: number;
  133918. width?: number;
  133919. height?: number;
  133920. sideOrientation?: number;
  133921. frontUVs?: Vector4;
  133922. backUVs?: Vector4;
  133923. updatable?: boolean;
  133924. sourcePlane?: Plane;
  133925. }, scene?: Nullable<Scene>): Mesh;
  133926. /**
  133927. * Creates a ground mesh
  133928. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  133929. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  133930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133931. * @param name defines the name of the mesh
  133932. * @param options defines the options used to create the mesh
  133933. * @param scene defines the hosting scene
  133934. * @returns the ground mesh
  133935. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  133936. */
  133937. static CreateGround(name: string, options: {
  133938. width?: number;
  133939. height?: number;
  133940. subdivisions?: number;
  133941. subdivisionsX?: number;
  133942. subdivisionsY?: number;
  133943. updatable?: boolean;
  133944. }, scene?: Nullable<Scene>): Mesh;
  133945. /**
  133946. * Creates a tiled ground mesh
  133947. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  133948. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  133949. * * 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
  133950. * * 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
  133951. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133952. * @param name defines the name of the mesh
  133953. * @param options defines the options used to create the mesh
  133954. * @param scene defines the hosting scene
  133955. * @returns the tiled ground mesh
  133956. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  133957. */
  133958. static CreateTiledGround(name: string, options: {
  133959. xmin: number;
  133960. zmin: number;
  133961. xmax: number;
  133962. zmax: number;
  133963. subdivisions?: {
  133964. w: number;
  133965. h: number;
  133966. };
  133967. precision?: {
  133968. w: number;
  133969. h: number;
  133970. };
  133971. updatable?: boolean;
  133972. }, scene?: Nullable<Scene>): Mesh;
  133973. /**
  133974. * Creates a ground mesh from a height map
  133975. * * The parameter `url` sets the URL of the height map image resource.
  133976. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  133977. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  133978. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  133979. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  133980. * * 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.
  133981. * * 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).
  133982. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  133983. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133984. * @param name defines the name of the mesh
  133985. * @param url defines the url to the height map
  133986. * @param options defines the options used to create the mesh
  133987. * @param scene defines the hosting scene
  133988. * @returns the ground mesh
  133989. * @see https://doc.babylonjs.com/babylon101/height_map
  133990. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  133991. */
  133992. static CreateGroundFromHeightMap(name: string, url: string, options: {
  133993. width?: number;
  133994. height?: number;
  133995. subdivisions?: number;
  133996. minHeight?: number;
  133997. maxHeight?: number;
  133998. colorFilter?: Color3;
  133999. alphaFilter?: number;
  134000. updatable?: boolean;
  134001. onReady?: (mesh: GroundMesh) => void;
  134002. }, scene?: Nullable<Scene>): GroundMesh;
  134003. /**
  134004. * Creates a polygon mesh
  134005. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  134006. * * 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
  134007. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134009. * * 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)
  134010. * * Remember you can only change the shape positions, not their number when updating a polygon
  134011. * @param name defines the name of the mesh
  134012. * @param options defines the options used to create the mesh
  134013. * @param scene defines the hosting scene
  134014. * @param earcutInjection can be used to inject your own earcut reference
  134015. * @returns the polygon mesh
  134016. */
  134017. static CreatePolygon(name: string, options: {
  134018. shape: Vector3[];
  134019. holes?: Vector3[][];
  134020. depth?: number;
  134021. faceUV?: Vector4[];
  134022. faceColors?: Color4[];
  134023. updatable?: boolean;
  134024. sideOrientation?: number;
  134025. frontUVs?: Vector4;
  134026. backUVs?: Vector4;
  134027. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134028. /**
  134029. * Creates an extruded polygon mesh, with depth in the Y direction.
  134030. * * 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)
  134031. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134032. * @param name defines the name of the mesh
  134033. * @param options defines the options used to create the mesh
  134034. * @param scene defines the hosting scene
  134035. * @param earcutInjection can be used to inject your own earcut reference
  134036. * @returns the polygon mesh
  134037. */
  134038. static ExtrudePolygon(name: string, options: {
  134039. shape: Vector3[];
  134040. holes?: Vector3[][];
  134041. depth?: number;
  134042. faceUV?: Vector4[];
  134043. faceColors?: Color4[];
  134044. updatable?: boolean;
  134045. sideOrientation?: number;
  134046. frontUVs?: Vector4;
  134047. backUVs?: Vector4;
  134048. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134049. /**
  134050. * Creates a tube mesh.
  134051. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134052. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134053. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134054. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134055. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134056. * * 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)
  134057. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134058. * * 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
  134059. * * 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
  134060. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134061. * * 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
  134062. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134064. * @param name defines the name of the mesh
  134065. * @param options defines the options used to create the mesh
  134066. * @param scene defines the hosting scene
  134067. * @returns the tube mesh
  134068. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134069. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134070. */
  134071. static CreateTube(name: string, options: {
  134072. path: Vector3[];
  134073. radius?: number;
  134074. tessellation?: number;
  134075. radiusFunction?: {
  134076. (i: number, distance: number): number;
  134077. };
  134078. cap?: number;
  134079. arc?: number;
  134080. updatable?: boolean;
  134081. sideOrientation?: number;
  134082. frontUVs?: Vector4;
  134083. backUVs?: Vector4;
  134084. instance?: Mesh;
  134085. invertUV?: boolean;
  134086. }, scene?: Nullable<Scene>): Mesh;
  134087. /**
  134088. * Creates a polyhedron mesh
  134089. * * 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
  134090. * * The parameter `size` (positive float, default 1) sets the polygon size
  134091. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  134092. * * 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`
  134093. * * 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
  134094. * * 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)`)
  134095. * * 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
  134096. * * 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
  134097. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134098. * * 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
  134099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134100. * @param name defines the name of the mesh
  134101. * @param options defines the options used to create the mesh
  134102. * @param scene defines the hosting scene
  134103. * @returns the polyhedron mesh
  134104. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  134105. */
  134106. static CreatePolyhedron(name: string, options: {
  134107. type?: number;
  134108. size?: number;
  134109. sizeX?: number;
  134110. sizeY?: number;
  134111. sizeZ?: number;
  134112. custom?: any;
  134113. faceUV?: Vector4[];
  134114. faceColors?: Color4[];
  134115. flat?: boolean;
  134116. updatable?: boolean;
  134117. sideOrientation?: number;
  134118. frontUVs?: Vector4;
  134119. backUVs?: Vector4;
  134120. }, scene?: Nullable<Scene>): Mesh;
  134121. /**
  134122. * Creates a decal mesh.
  134123. * 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
  134124. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134125. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134126. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134127. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134128. * @param name defines the name of the mesh
  134129. * @param sourceMesh defines the mesh where the decal must be applied
  134130. * @param options defines the options used to create the mesh
  134131. * @param scene defines the hosting scene
  134132. * @returns the decal mesh
  134133. * @see https://doc.babylonjs.com/how_to/decals
  134134. */
  134135. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134136. position?: Vector3;
  134137. normal?: Vector3;
  134138. size?: Vector3;
  134139. angle?: number;
  134140. }): Mesh;
  134141. }
  134142. }
  134143. declare module BABYLON {
  134144. /**
  134145. * A simplifier interface for future simplification implementations
  134146. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134147. */
  134148. export interface ISimplifier {
  134149. /**
  134150. * Simplification of a given mesh according to the given settings.
  134151. * Since this requires computation, it is assumed that the function runs async.
  134152. * @param settings The settings of the simplification, including quality and distance
  134153. * @param successCallback A callback that will be called after the mesh was simplified.
  134154. * @param errorCallback in case of an error, this callback will be called. optional.
  134155. */
  134156. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  134157. }
  134158. /**
  134159. * Expected simplification settings.
  134160. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  134161. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134162. */
  134163. export interface ISimplificationSettings {
  134164. /**
  134165. * Gets or sets the expected quality
  134166. */
  134167. quality: number;
  134168. /**
  134169. * Gets or sets the distance when this optimized version should be used
  134170. */
  134171. distance: number;
  134172. /**
  134173. * Gets an already optimized mesh
  134174. */
  134175. optimizeMesh?: boolean;
  134176. }
  134177. /**
  134178. * Class used to specify simplification options
  134179. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134180. */
  134181. export class SimplificationSettings implements ISimplificationSettings {
  134182. /** expected quality */
  134183. quality: number;
  134184. /** distance when this optimized version should be used */
  134185. distance: number;
  134186. /** already optimized mesh */
  134187. optimizeMesh?: boolean | undefined;
  134188. /**
  134189. * Creates a SimplificationSettings
  134190. * @param quality expected quality
  134191. * @param distance distance when this optimized version should be used
  134192. * @param optimizeMesh already optimized mesh
  134193. */
  134194. constructor(
  134195. /** expected quality */
  134196. quality: number,
  134197. /** distance when this optimized version should be used */
  134198. distance: number,
  134199. /** already optimized mesh */
  134200. optimizeMesh?: boolean | undefined);
  134201. }
  134202. /**
  134203. * Interface used to define a simplification task
  134204. */
  134205. export interface ISimplificationTask {
  134206. /**
  134207. * Array of settings
  134208. */
  134209. settings: Array<ISimplificationSettings>;
  134210. /**
  134211. * Simplification type
  134212. */
  134213. simplificationType: SimplificationType;
  134214. /**
  134215. * Mesh to simplify
  134216. */
  134217. mesh: Mesh;
  134218. /**
  134219. * Callback called on success
  134220. */
  134221. successCallback?: () => void;
  134222. /**
  134223. * Defines if parallel processing can be used
  134224. */
  134225. parallelProcessing: boolean;
  134226. }
  134227. /**
  134228. * Queue used to order the simplification tasks
  134229. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134230. */
  134231. export class SimplificationQueue {
  134232. private _simplificationArray;
  134233. /**
  134234. * Gets a boolean indicating that the process is still running
  134235. */
  134236. running: boolean;
  134237. /**
  134238. * Creates a new queue
  134239. */
  134240. constructor();
  134241. /**
  134242. * Adds a new simplification task
  134243. * @param task defines a task to add
  134244. */
  134245. addTask(task: ISimplificationTask): void;
  134246. /**
  134247. * Execute next task
  134248. */
  134249. executeNext(): void;
  134250. /**
  134251. * Execute a simplification task
  134252. * @param task defines the task to run
  134253. */
  134254. runSimplification(task: ISimplificationTask): void;
  134255. private getSimplifier;
  134256. }
  134257. /**
  134258. * The implemented types of simplification
  134259. * At the moment only Quadratic Error Decimation is implemented
  134260. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134261. */
  134262. export enum SimplificationType {
  134263. /** Quadratic error decimation */
  134264. QUADRATIC = 0
  134265. }
  134266. }
  134267. declare module BABYLON {
  134268. interface Scene {
  134269. /** @hidden (Backing field) */
  134270. _simplificationQueue: SimplificationQueue;
  134271. /**
  134272. * Gets or sets the simplification queue attached to the scene
  134273. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134274. */
  134275. simplificationQueue: SimplificationQueue;
  134276. }
  134277. interface Mesh {
  134278. /**
  134279. * Simplify the mesh according to the given array of settings.
  134280. * Function will return immediately and will simplify async
  134281. * @param settings a collection of simplification settings
  134282. * @param parallelProcessing should all levels calculate parallel or one after the other
  134283. * @param simplificationType the type of simplification to run
  134284. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  134285. * @returns the current mesh
  134286. */
  134287. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  134288. }
  134289. /**
  134290. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  134291. * created in a scene
  134292. */
  134293. export class SimplicationQueueSceneComponent implements ISceneComponent {
  134294. /**
  134295. * The component name helpfull to identify the component in the list of scene components.
  134296. */
  134297. readonly name: string;
  134298. /**
  134299. * The scene the component belongs to.
  134300. */
  134301. scene: Scene;
  134302. /**
  134303. * Creates a new instance of the component for the given scene
  134304. * @param scene Defines the scene to register the component in
  134305. */
  134306. constructor(scene: Scene);
  134307. /**
  134308. * Registers the component in a given scene
  134309. */
  134310. register(): void;
  134311. /**
  134312. * Rebuilds the elements related to this component in case of
  134313. * context lost for instance.
  134314. */
  134315. rebuild(): void;
  134316. /**
  134317. * Disposes the component and the associated ressources
  134318. */
  134319. dispose(): void;
  134320. private _beforeCameraUpdate;
  134321. }
  134322. }
  134323. declare module BABYLON {
  134324. /**
  134325. * Navigation plugin interface to add navigation constrained by a navigation mesh
  134326. */
  134327. export interface INavigationEnginePlugin {
  134328. /**
  134329. * plugin name
  134330. */
  134331. name: string;
  134332. /**
  134333. * Creates a navigation mesh
  134334. * @param meshes array of all the geometry used to compute the navigatio mesh
  134335. * @param parameters bunch of parameters used to filter geometry
  134336. */
  134337. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  134338. /**
  134339. * Create a navigation mesh debug mesh
  134340. * @param scene is where the mesh will be added
  134341. * @returns debug display mesh
  134342. */
  134343. createDebugNavMesh(scene: Scene): Mesh;
  134344. /**
  134345. * Get a navigation mesh constrained position, closest to the parameter position
  134346. * @param position world position
  134347. * @returns the closest point to position constrained by the navigation mesh
  134348. */
  134349. getClosestPoint(position: Vector3): Vector3;
  134350. /**
  134351. * Get a navigation mesh constrained position, within a particular radius
  134352. * @param position world position
  134353. * @param maxRadius the maximum distance to the constrained world position
  134354. * @returns the closest point to position constrained by the navigation mesh
  134355. */
  134356. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  134357. /**
  134358. * Compute the final position from a segment made of destination-position
  134359. * @param position world position
  134360. * @param destination world position
  134361. * @returns the resulting point along the navmesh
  134362. */
  134363. moveAlong(position: Vector3, destination: Vector3): Vector3;
  134364. /**
  134365. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  134366. * @param start world position
  134367. * @param end world position
  134368. * @returns array containing world position composing the path
  134369. */
  134370. computePath(start: Vector3, end: Vector3): Vector3[];
  134371. /**
  134372. * If this plugin is supported
  134373. * @returns true if plugin is supported
  134374. */
  134375. isSupported(): boolean;
  134376. /**
  134377. * Create a new Crowd so you can add agents
  134378. * @param maxAgents the maximum agent count in the crowd
  134379. * @param maxAgentRadius the maximum radius an agent can have
  134380. * @param scene to attach the crowd to
  134381. * @returns the crowd you can add agents to
  134382. */
  134383. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  134384. /**
  134385. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  134386. * The queries will try to find a solution within those bounds
  134387. * default is (1,1,1)
  134388. * @param extent x,y,z value that define the extent around the queries point of reference
  134389. */
  134390. setDefaultQueryExtent(extent: Vector3): void;
  134391. /**
  134392. * Get the Bounding box extent specified by setDefaultQueryExtent
  134393. * @returns the box extent values
  134394. */
  134395. getDefaultQueryExtent(): Vector3;
  134396. /**
  134397. * Release all resources
  134398. */
  134399. dispose(): void;
  134400. }
  134401. /**
  134402. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  134403. */
  134404. export interface ICrowd {
  134405. /**
  134406. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  134407. * You can attach anything to that node. The node position is updated in the scene update tick.
  134408. * @param pos world position that will be constrained by the navigation mesh
  134409. * @param parameters agent parameters
  134410. * @param transform hooked to the agent that will be update by the scene
  134411. * @returns agent index
  134412. */
  134413. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  134414. /**
  134415. * Returns the agent position in world space
  134416. * @param index agent index returned by addAgent
  134417. * @returns world space position
  134418. */
  134419. getAgentPosition(index: number): Vector3;
  134420. /**
  134421. * Gets the agent velocity in world space
  134422. * @param index agent index returned by addAgent
  134423. * @returns world space velocity
  134424. */
  134425. getAgentVelocity(index: number): Vector3;
  134426. /**
  134427. * remove a particular agent previously created
  134428. * @param index agent index returned by addAgent
  134429. */
  134430. removeAgent(index: number): void;
  134431. /**
  134432. * get the list of all agents attached to this crowd
  134433. * @returns list of agent indices
  134434. */
  134435. getAgents(): number[];
  134436. /**
  134437. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  134438. * @param deltaTime in seconds
  134439. */
  134440. update(deltaTime: number): void;
  134441. /**
  134442. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  134443. * @param index agent index returned by addAgent
  134444. * @param destination targeted world position
  134445. */
  134446. agentGoto(index: number, destination: Vector3): void;
  134447. /**
  134448. * Teleport the agent to a new position
  134449. * @param index agent index returned by addAgent
  134450. * @param destination targeted world position
  134451. */
  134452. agentTeleport(index: number, destination: Vector3): void;
  134453. /**
  134454. * Update agent parameters
  134455. * @param index agent index returned by addAgent
  134456. * @param parameters agent parameters
  134457. */
  134458. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  134459. /**
  134460. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  134461. * The queries will try to find a solution within those bounds
  134462. * default is (1,1,1)
  134463. * @param extent x,y,z value that define the extent around the queries point of reference
  134464. */
  134465. setDefaultQueryExtent(extent: Vector3): void;
  134466. /**
  134467. * Get the Bounding box extent specified by setDefaultQueryExtent
  134468. * @returns the box extent values
  134469. */
  134470. getDefaultQueryExtent(): Vector3;
  134471. /**
  134472. * Release all resources
  134473. */
  134474. dispose(): void;
  134475. }
  134476. /**
  134477. * Configures an agent
  134478. */
  134479. export interface IAgentParameters {
  134480. /**
  134481. * Agent radius. [Limit: >= 0]
  134482. */
  134483. radius: number;
  134484. /**
  134485. * Agent height. [Limit: > 0]
  134486. */
  134487. height: number;
  134488. /**
  134489. * Maximum allowed acceleration. [Limit: >= 0]
  134490. */
  134491. maxAcceleration: number;
  134492. /**
  134493. * Maximum allowed speed. [Limit: >= 0]
  134494. */
  134495. maxSpeed: number;
  134496. /**
  134497. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  134498. */
  134499. collisionQueryRange: number;
  134500. /**
  134501. * The path visibility optimization range. [Limit: > 0]
  134502. */
  134503. pathOptimizationRange: number;
  134504. /**
  134505. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  134506. */
  134507. separationWeight: number;
  134508. }
  134509. /**
  134510. * Configures the navigation mesh creation
  134511. */
  134512. export interface INavMeshParameters {
  134513. /**
  134514. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  134515. */
  134516. cs: number;
  134517. /**
  134518. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  134519. */
  134520. ch: number;
  134521. /**
  134522. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  134523. */
  134524. walkableSlopeAngle: number;
  134525. /**
  134526. * Minimum floor to 'ceiling' height that will still allow the floor area to
  134527. * be considered walkable. [Limit: >= 3] [Units: vx]
  134528. */
  134529. walkableHeight: number;
  134530. /**
  134531. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  134532. */
  134533. walkableClimb: number;
  134534. /**
  134535. * The distance to erode/shrink the walkable area of the heightfield away from
  134536. * obstructions. [Limit: >=0] [Units: vx]
  134537. */
  134538. walkableRadius: number;
  134539. /**
  134540. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  134541. */
  134542. maxEdgeLen: number;
  134543. /**
  134544. * The maximum distance a simplfied contour's border edges should deviate
  134545. * the original raw contour. [Limit: >=0] [Units: vx]
  134546. */
  134547. maxSimplificationError: number;
  134548. /**
  134549. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  134550. */
  134551. minRegionArea: number;
  134552. /**
  134553. * Any regions with a span count smaller than this value will, if possible,
  134554. * be merged with larger regions. [Limit: >=0] [Units: vx]
  134555. */
  134556. mergeRegionArea: number;
  134557. /**
  134558. * The maximum number of vertices allowed for polygons generated during the
  134559. * contour to polygon conversion process. [Limit: >= 3]
  134560. */
  134561. maxVertsPerPoly: number;
  134562. /**
  134563. * Sets the sampling distance to use when generating the detail mesh.
  134564. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  134565. */
  134566. detailSampleDist: number;
  134567. /**
  134568. * The maximum distance the detail mesh surface should deviate from heightfield
  134569. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  134570. */
  134571. detailSampleMaxError: number;
  134572. }
  134573. }
  134574. declare module BABYLON {
  134575. /**
  134576. * RecastJS navigation plugin
  134577. */
  134578. export class RecastJSPlugin implements INavigationEnginePlugin {
  134579. /**
  134580. * Reference to the Recast library
  134581. */
  134582. bjsRECAST: any;
  134583. /**
  134584. * plugin name
  134585. */
  134586. name: string;
  134587. /**
  134588. * the first navmesh created. We might extend this to support multiple navmeshes
  134589. */
  134590. navMesh: any;
  134591. /**
  134592. * Initializes the recastJS plugin
  134593. * @param recastInjection can be used to inject your own recast reference
  134594. */
  134595. constructor(recastInjection?: any);
  134596. /**
  134597. * Creates a navigation mesh
  134598. * @param meshes array of all the geometry used to compute the navigatio mesh
  134599. * @param parameters bunch of parameters used to filter geometry
  134600. */
  134601. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  134602. /**
  134603. * Create a navigation mesh debug mesh
  134604. * @param scene is where the mesh will be added
  134605. * @returns debug display mesh
  134606. */
  134607. createDebugNavMesh(scene: Scene): Mesh;
  134608. /**
  134609. * Get a navigation mesh constrained position, closest to the parameter position
  134610. * @param position world position
  134611. * @returns the closest point to position constrained by the navigation mesh
  134612. */
  134613. getClosestPoint(position: Vector3): Vector3;
  134614. /**
  134615. * Get a navigation mesh constrained position, within a particular radius
  134616. * @param position world position
  134617. * @param maxRadius the maximum distance to the constrained world position
  134618. * @returns the closest point to position constrained by the navigation mesh
  134619. */
  134620. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  134621. /**
  134622. * Compute the final position from a segment made of destination-position
  134623. * @param position world position
  134624. * @param destination world position
  134625. * @returns the resulting point along the navmesh
  134626. */
  134627. moveAlong(position: Vector3, destination: Vector3): Vector3;
  134628. /**
  134629. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  134630. * @param start world position
  134631. * @param end world position
  134632. * @returns array containing world position composing the path
  134633. */
  134634. computePath(start: Vector3, end: Vector3): Vector3[];
  134635. /**
  134636. * Create a new Crowd so you can add agents
  134637. * @param maxAgents the maximum agent count in the crowd
  134638. * @param maxAgentRadius the maximum radius an agent can have
  134639. * @param scene to attach the crowd to
  134640. * @returns the crowd you can add agents to
  134641. */
  134642. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  134643. /**
  134644. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  134645. * The queries will try to find a solution within those bounds
  134646. * default is (1,1,1)
  134647. * @param extent x,y,z value that define the extent around the queries point of reference
  134648. */
  134649. setDefaultQueryExtent(extent: Vector3): void;
  134650. /**
  134651. * Get the Bounding box extent specified by setDefaultQueryExtent
  134652. * @returns the box extent values
  134653. */
  134654. getDefaultQueryExtent(): Vector3;
  134655. /**
  134656. * Disposes
  134657. */
  134658. dispose(): void;
  134659. /**
  134660. * If this plugin is supported
  134661. * @returns true if plugin is supported
  134662. */
  134663. isSupported(): boolean;
  134664. }
  134665. /**
  134666. * Recast detour crowd implementation
  134667. */
  134668. export class RecastJSCrowd implements ICrowd {
  134669. /**
  134670. * Recast/detour plugin
  134671. */
  134672. bjsRECASTPlugin: RecastJSPlugin;
  134673. /**
  134674. * Link to the detour crowd
  134675. */
  134676. recastCrowd: any;
  134677. /**
  134678. * One transform per agent
  134679. */
  134680. transforms: TransformNode[];
  134681. /**
  134682. * All agents created
  134683. */
  134684. agents: number[];
  134685. /**
  134686. * Link to the scene is kept to unregister the crowd from the scene
  134687. */
  134688. private _scene;
  134689. /**
  134690. * Observer for crowd updates
  134691. */
  134692. private _onBeforeAnimationsObserver;
  134693. /**
  134694. * Constructor
  134695. * @param plugin recastJS plugin
  134696. * @param maxAgents the maximum agent count in the crowd
  134697. * @param maxAgentRadius the maximum radius an agent can have
  134698. * @param scene to attach the crowd to
  134699. * @returns the crowd you can add agents to
  134700. */
  134701. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  134702. /**
  134703. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  134704. * You can attach anything to that node. The node position is updated in the scene update tick.
  134705. * @param pos world position that will be constrained by the navigation mesh
  134706. * @param parameters agent parameters
  134707. * @param transform hooked to the agent that will be update by the scene
  134708. * @returns agent index
  134709. */
  134710. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  134711. /**
  134712. * Returns the agent position in world space
  134713. * @param index agent index returned by addAgent
  134714. * @returns world space position
  134715. */
  134716. getAgentPosition(index: number): Vector3;
  134717. /**
  134718. * Returns the agent velocity in world space
  134719. * @param index agent index returned by addAgent
  134720. * @returns world space velocity
  134721. */
  134722. getAgentVelocity(index: number): Vector3;
  134723. /**
  134724. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  134725. * @param index agent index returned by addAgent
  134726. * @param destination targeted world position
  134727. */
  134728. agentGoto(index: number, destination: Vector3): void;
  134729. /**
  134730. * Teleport the agent to a new position
  134731. * @param index agent index returned by addAgent
  134732. * @param destination targeted world position
  134733. */
  134734. agentTeleport(index: number, destination: Vector3): void;
  134735. /**
  134736. * Update agent parameters
  134737. * @param index agent index returned by addAgent
  134738. * @param parameters agent parameters
  134739. */
  134740. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  134741. /**
  134742. * remove a particular agent previously created
  134743. * @param index agent index returned by addAgent
  134744. */
  134745. removeAgent(index: number): void;
  134746. /**
  134747. * get the list of all agents attached to this crowd
  134748. * @returns list of agent indices
  134749. */
  134750. getAgents(): number[];
  134751. /**
  134752. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  134753. * @param deltaTime in seconds
  134754. */
  134755. update(deltaTime: number): void;
  134756. /**
  134757. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  134758. * The queries will try to find a solution within those bounds
  134759. * default is (1,1,1)
  134760. * @param extent x,y,z value that define the extent around the queries point of reference
  134761. */
  134762. setDefaultQueryExtent(extent: Vector3): void;
  134763. /**
  134764. * Get the Bounding box extent specified by setDefaultQueryExtent
  134765. * @returns the box extent values
  134766. */
  134767. getDefaultQueryExtent(): Vector3;
  134768. /**
  134769. * Release all resources
  134770. */
  134771. dispose(): void;
  134772. }
  134773. }
  134774. declare module BABYLON {
  134775. /**
  134776. * Class used to enable access to IndexedDB
  134777. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  134778. */
  134779. export class Database implements IOfflineProvider {
  134780. private _callbackManifestChecked;
  134781. private _currentSceneUrl;
  134782. private _db;
  134783. private _enableSceneOffline;
  134784. private _enableTexturesOffline;
  134785. private _manifestVersionFound;
  134786. private _mustUpdateRessources;
  134787. private _hasReachedQuota;
  134788. private _isSupported;
  134789. private _idbFactory;
  134790. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  134791. private static IsUASupportingBlobStorage;
  134792. /**
  134793. * Gets a boolean indicating if Database storate is enabled (off by default)
  134794. */
  134795. static IDBStorageEnabled: boolean;
  134796. /**
  134797. * Gets a boolean indicating if scene must be saved in the database
  134798. */
  134799. get enableSceneOffline(): boolean;
  134800. /**
  134801. * Gets a boolean indicating if textures must be saved in the database
  134802. */
  134803. get enableTexturesOffline(): boolean;
  134804. /**
  134805. * Creates a new Database
  134806. * @param urlToScene defines the url to load the scene
  134807. * @param callbackManifestChecked defines the callback to use when manifest is checked
  134808. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  134809. */
  134810. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  134811. private static _ParseURL;
  134812. private static _ReturnFullUrlLocation;
  134813. private _checkManifestFile;
  134814. /**
  134815. * Open the database and make it available
  134816. * @param successCallback defines the callback to call on success
  134817. * @param errorCallback defines the callback to call on error
  134818. */
  134819. open(successCallback: () => void, errorCallback: () => void): void;
  134820. /**
  134821. * Loads an image from the database
  134822. * @param url defines the url to load from
  134823. * @param image defines the target DOM image
  134824. */
  134825. loadImage(url: string, image: HTMLImageElement): void;
  134826. private _loadImageFromDBAsync;
  134827. private _saveImageIntoDBAsync;
  134828. private _checkVersionFromDB;
  134829. private _loadVersionFromDBAsync;
  134830. private _saveVersionIntoDBAsync;
  134831. /**
  134832. * Loads a file from database
  134833. * @param url defines the URL to load from
  134834. * @param sceneLoaded defines a callback to call on success
  134835. * @param progressCallBack defines a callback to call when progress changed
  134836. * @param errorCallback defines a callback to call on error
  134837. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  134838. */
  134839. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  134840. private _loadFileAsync;
  134841. private _saveFileAsync;
  134842. /**
  134843. * Validates if xhr data is correct
  134844. * @param xhr defines the request to validate
  134845. * @param dataType defines the expected data type
  134846. * @returns true if data is correct
  134847. */
  134848. private static _ValidateXHRData;
  134849. }
  134850. }
  134851. declare module BABYLON {
  134852. /** @hidden */
  134853. export var gpuUpdateParticlesPixelShader: {
  134854. name: string;
  134855. shader: string;
  134856. };
  134857. }
  134858. declare module BABYLON {
  134859. /** @hidden */
  134860. export var gpuUpdateParticlesVertexShader: {
  134861. name: string;
  134862. shader: string;
  134863. };
  134864. }
  134865. declare module BABYLON {
  134866. /** @hidden */
  134867. export var clipPlaneFragmentDeclaration2: {
  134868. name: string;
  134869. shader: string;
  134870. };
  134871. }
  134872. declare module BABYLON {
  134873. /** @hidden */
  134874. export var gpuRenderParticlesPixelShader: {
  134875. name: string;
  134876. shader: string;
  134877. };
  134878. }
  134879. declare module BABYLON {
  134880. /** @hidden */
  134881. export var clipPlaneVertexDeclaration2: {
  134882. name: string;
  134883. shader: string;
  134884. };
  134885. }
  134886. declare module BABYLON {
  134887. /** @hidden */
  134888. export var gpuRenderParticlesVertexShader: {
  134889. name: string;
  134890. shader: string;
  134891. };
  134892. }
  134893. declare module BABYLON {
  134894. /**
  134895. * This represents a GPU particle system in Babylon
  134896. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  134897. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  134898. */
  134899. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  134900. /**
  134901. * The layer mask we are rendering the particles through.
  134902. */
  134903. layerMask: number;
  134904. private _capacity;
  134905. private _activeCount;
  134906. private _currentActiveCount;
  134907. private _accumulatedCount;
  134908. private _renderEffect;
  134909. private _updateEffect;
  134910. private _buffer0;
  134911. private _buffer1;
  134912. private _spriteBuffer;
  134913. private _updateVAO;
  134914. private _renderVAO;
  134915. private _targetIndex;
  134916. private _sourceBuffer;
  134917. private _targetBuffer;
  134918. private _engine;
  134919. private _currentRenderId;
  134920. private _started;
  134921. private _stopped;
  134922. private _timeDelta;
  134923. private _randomTexture;
  134924. private _randomTexture2;
  134925. private _attributesStrideSize;
  134926. private _updateEffectOptions;
  134927. private _randomTextureSize;
  134928. private _actualFrame;
  134929. private readonly _rawTextureWidth;
  134930. /**
  134931. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  134932. */
  134933. static get IsSupported(): boolean;
  134934. /**
  134935. * An event triggered when the system is disposed.
  134936. */
  134937. onDisposeObservable: Observable<GPUParticleSystem>;
  134938. /**
  134939. * Gets the maximum number of particles active at the same time.
  134940. * @returns The max number of active particles.
  134941. */
  134942. getCapacity(): number;
  134943. /**
  134944. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  134945. * to override the particles.
  134946. */
  134947. forceDepthWrite: boolean;
  134948. /**
  134949. * Gets or set the number of active particles
  134950. */
  134951. get activeParticleCount(): number;
  134952. set activeParticleCount(value: number);
  134953. private _preWarmDone;
  134954. /**
  134955. * Is this system ready to be used/rendered
  134956. * @return true if the system is ready
  134957. */
  134958. isReady(): boolean;
  134959. /**
  134960. * Gets if the system has been started. (Note: this will still be true after stop is called)
  134961. * @returns True if it has been started, otherwise false.
  134962. */
  134963. isStarted(): boolean;
  134964. /**
  134965. * Starts the particle system and begins to emit
  134966. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  134967. */
  134968. start(delay?: number): void;
  134969. /**
  134970. * Stops the particle system.
  134971. */
  134972. stop(): void;
  134973. /**
  134974. * Remove all active particles
  134975. */
  134976. reset(): void;
  134977. /**
  134978. * Returns the string "GPUParticleSystem"
  134979. * @returns a string containing the class name
  134980. */
  134981. getClassName(): string;
  134982. private _colorGradientsTexture;
  134983. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  134984. /**
  134985. * Adds a new color gradient
  134986. * @param gradient defines the gradient to use (between 0 and 1)
  134987. * @param color1 defines the color to affect to the specified gradient
  134988. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  134989. * @returns the current particle system
  134990. */
  134991. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  134992. /**
  134993. * Remove a specific color gradient
  134994. * @param gradient defines the gradient to remove
  134995. * @returns the current particle system
  134996. */
  134997. removeColorGradient(gradient: number): GPUParticleSystem;
  134998. private _angularSpeedGradientsTexture;
  134999. private _sizeGradientsTexture;
  135000. private _velocityGradientsTexture;
  135001. private _limitVelocityGradientsTexture;
  135002. private _dragGradientsTexture;
  135003. private _addFactorGradient;
  135004. /**
  135005. * Adds a new size gradient
  135006. * @param gradient defines the gradient to use (between 0 and 1)
  135007. * @param factor defines the size factor to affect to the specified gradient
  135008. * @returns the current particle system
  135009. */
  135010. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  135011. /**
  135012. * Remove a specific size gradient
  135013. * @param gradient defines the gradient to remove
  135014. * @returns the current particle system
  135015. */
  135016. removeSizeGradient(gradient: number): GPUParticleSystem;
  135017. /**
  135018. * Adds a new angular speed gradient
  135019. * @param gradient defines the gradient to use (between 0 and 1)
  135020. * @param factor defines the angular speed to affect to the specified gradient
  135021. * @returns the current particle system
  135022. */
  135023. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  135024. /**
  135025. * Remove a specific angular speed gradient
  135026. * @param gradient defines the gradient to remove
  135027. * @returns the current particle system
  135028. */
  135029. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  135030. /**
  135031. * Adds a new velocity gradient
  135032. * @param gradient defines the gradient to use (between 0 and 1)
  135033. * @param factor defines the velocity to affect to the specified gradient
  135034. * @returns the current particle system
  135035. */
  135036. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135037. /**
  135038. * Remove a specific velocity gradient
  135039. * @param gradient defines the gradient to remove
  135040. * @returns the current particle system
  135041. */
  135042. removeVelocityGradient(gradient: number): GPUParticleSystem;
  135043. /**
  135044. * Adds a new limit velocity gradient
  135045. * @param gradient defines the gradient to use (between 0 and 1)
  135046. * @param factor defines the limit velocity value to affect to the specified gradient
  135047. * @returns the current particle system
  135048. */
  135049. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135050. /**
  135051. * Remove a specific limit velocity gradient
  135052. * @param gradient defines the gradient to remove
  135053. * @returns the current particle system
  135054. */
  135055. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  135056. /**
  135057. * Adds a new drag gradient
  135058. * @param gradient defines the gradient to use (between 0 and 1)
  135059. * @param factor defines the drag value to affect to the specified gradient
  135060. * @returns the current particle system
  135061. */
  135062. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  135063. /**
  135064. * Remove a specific drag gradient
  135065. * @param gradient defines the gradient to remove
  135066. * @returns the current particle system
  135067. */
  135068. removeDragGradient(gradient: number): GPUParticleSystem;
  135069. /**
  135070. * Not supported by GPUParticleSystem
  135071. * @param gradient defines the gradient to use (between 0 and 1)
  135072. * @param factor defines the emit rate value to affect to the specified gradient
  135073. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135074. * @returns the current particle system
  135075. */
  135076. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135077. /**
  135078. * Not supported by GPUParticleSystem
  135079. * @param gradient defines the gradient to remove
  135080. * @returns the current particle system
  135081. */
  135082. removeEmitRateGradient(gradient: number): IParticleSystem;
  135083. /**
  135084. * Not supported by GPUParticleSystem
  135085. * @param gradient defines the gradient to use (between 0 and 1)
  135086. * @param factor defines the start size value to affect to the specified gradient
  135087. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135088. * @returns the current particle system
  135089. */
  135090. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135091. /**
  135092. * Not supported by GPUParticleSystem
  135093. * @param gradient defines the gradient to remove
  135094. * @returns the current particle system
  135095. */
  135096. removeStartSizeGradient(gradient: number): IParticleSystem;
  135097. /**
  135098. * Not supported by GPUParticleSystem
  135099. * @param gradient defines the gradient to use (between 0 and 1)
  135100. * @param min defines the color remap minimal range
  135101. * @param max defines the color remap maximal range
  135102. * @returns the current particle system
  135103. */
  135104. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  135105. /**
  135106. * Not supported by GPUParticleSystem
  135107. * @param gradient defines the gradient to remove
  135108. * @returns the current particle system
  135109. */
  135110. removeColorRemapGradient(): IParticleSystem;
  135111. /**
  135112. * Not supported by GPUParticleSystem
  135113. * @param gradient defines the gradient to use (between 0 and 1)
  135114. * @param min defines the alpha remap minimal range
  135115. * @param max defines the alpha remap maximal range
  135116. * @returns the current particle system
  135117. */
  135118. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  135119. /**
  135120. * Not supported by GPUParticleSystem
  135121. * @param gradient defines the gradient to remove
  135122. * @returns the current particle system
  135123. */
  135124. removeAlphaRemapGradient(): IParticleSystem;
  135125. /**
  135126. * Not supported by GPUParticleSystem
  135127. * @param gradient defines the gradient to use (between 0 and 1)
  135128. * @param color defines the color to affect to the specified gradient
  135129. * @returns the current particle system
  135130. */
  135131. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  135132. /**
  135133. * Not supported by GPUParticleSystem
  135134. * @param gradient defines the gradient to remove
  135135. * @returns the current particle system
  135136. */
  135137. removeRampGradient(): IParticleSystem;
  135138. /**
  135139. * Not supported by GPUParticleSystem
  135140. * @returns the list of ramp gradients
  135141. */
  135142. getRampGradients(): Nullable<Array<Color3Gradient>>;
  135143. /**
  135144. * Not supported by GPUParticleSystem
  135145. * Gets or sets a boolean indicating that ramp gradients must be used
  135146. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  135147. */
  135148. get useRampGradients(): boolean;
  135149. set useRampGradients(value: boolean);
  135150. /**
  135151. * Not supported by GPUParticleSystem
  135152. * @param gradient defines the gradient to use (between 0 and 1)
  135153. * @param factor defines the life time factor to affect to the specified gradient
  135154. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135155. * @returns the current particle system
  135156. */
  135157. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135158. /**
  135159. * Not supported by GPUParticleSystem
  135160. * @param gradient defines the gradient to remove
  135161. * @returns the current particle system
  135162. */
  135163. removeLifeTimeGradient(gradient: number): IParticleSystem;
  135164. /**
  135165. * Instantiates a GPU particle system.
  135166. * 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.
  135167. * @param name The name of the particle system
  135168. * @param options The options used to create the system
  135169. * @param scene The scene the particle system belongs to
  135170. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  135171. */
  135172. constructor(name: string, options: Partial<{
  135173. capacity: number;
  135174. randomTextureSize: number;
  135175. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  135176. protected _reset(): void;
  135177. private _createUpdateVAO;
  135178. private _createRenderVAO;
  135179. private _initialize;
  135180. /** @hidden */
  135181. _recreateUpdateEffect(): void;
  135182. /** @hidden */
  135183. _recreateRenderEffect(): void;
  135184. /**
  135185. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  135186. * @param preWarm defines if we are in the pre-warmimg phase
  135187. */
  135188. animate(preWarm?: boolean): void;
  135189. private _createFactorGradientTexture;
  135190. private _createSizeGradientTexture;
  135191. private _createAngularSpeedGradientTexture;
  135192. private _createVelocityGradientTexture;
  135193. private _createLimitVelocityGradientTexture;
  135194. private _createDragGradientTexture;
  135195. private _createColorGradientTexture;
  135196. /**
  135197. * Renders the particle system in its current state
  135198. * @param preWarm defines if the system should only update the particles but not render them
  135199. * @returns the current number of particles
  135200. */
  135201. render(preWarm?: boolean): number;
  135202. /**
  135203. * Rebuilds the particle system
  135204. */
  135205. rebuild(): void;
  135206. private _releaseBuffers;
  135207. private _releaseVAOs;
  135208. /**
  135209. * Disposes the particle system and free the associated resources
  135210. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  135211. */
  135212. dispose(disposeTexture?: boolean): void;
  135213. /**
  135214. * Clones the particle system.
  135215. * @param name The name of the cloned object
  135216. * @param newEmitter The new emitter to use
  135217. * @returns the cloned particle system
  135218. */
  135219. clone(name: string, newEmitter: any): GPUParticleSystem;
  135220. /**
  135221. * Serializes the particle system to a JSON object.
  135222. * @returns the JSON object
  135223. */
  135224. serialize(): any;
  135225. /**
  135226. * Parses a JSON object to create a GPU particle system.
  135227. * @param parsedParticleSystem The JSON object to parse
  135228. * @param scene The scene to create the particle system in
  135229. * @param rootUrl The root url to use to load external dependencies like texture
  135230. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  135231. * @returns the parsed GPU particle system
  135232. */
  135233. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  135234. }
  135235. }
  135236. declare module BABYLON {
  135237. /**
  135238. * Represents a set of particle systems working together to create a specific effect
  135239. */
  135240. export class ParticleSystemSet implements IDisposable {
  135241. /**
  135242. * Gets or sets base Assets URL
  135243. */
  135244. static BaseAssetsUrl: string;
  135245. private _emitterCreationOptions;
  135246. private _emitterNode;
  135247. /**
  135248. * Gets the particle system list
  135249. */
  135250. systems: IParticleSystem[];
  135251. /**
  135252. * Gets the emitter node used with this set
  135253. */
  135254. get emitterNode(): Nullable<TransformNode>;
  135255. /**
  135256. * Creates a new emitter mesh as a sphere
  135257. * @param options defines the options used to create the sphere
  135258. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  135259. * @param scene defines the hosting scene
  135260. */
  135261. setEmitterAsSphere(options: {
  135262. diameter: number;
  135263. segments: number;
  135264. color: Color3;
  135265. }, renderingGroupId: number, scene: Scene): void;
  135266. /**
  135267. * Starts all particle systems of the set
  135268. * @param emitter defines an optional mesh to use as emitter for the particle systems
  135269. */
  135270. start(emitter?: AbstractMesh): void;
  135271. /**
  135272. * Release all associated resources
  135273. */
  135274. dispose(): void;
  135275. /**
  135276. * Serialize the set into a JSON compatible object
  135277. * @returns a JSON compatible representation of the set
  135278. */
  135279. serialize(): any;
  135280. /**
  135281. * Parse a new ParticleSystemSet from a serialized source
  135282. * @param data defines a JSON compatible representation of the set
  135283. * @param scene defines the hosting scene
  135284. * @param gpu defines if we want GPU particles or CPU particles
  135285. * @returns a new ParticleSystemSet
  135286. */
  135287. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  135288. }
  135289. }
  135290. declare module BABYLON {
  135291. /**
  135292. * This class is made for on one-liner static method to help creating particle system set.
  135293. */
  135294. export class ParticleHelper {
  135295. /**
  135296. * Gets or sets base Assets URL
  135297. */
  135298. static BaseAssetsUrl: string;
  135299. /**
  135300. * Create a default particle system that you can tweak
  135301. * @param emitter defines the emitter to use
  135302. * @param capacity defines the system capacity (default is 500 particles)
  135303. * @param scene defines the hosting scene
  135304. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  135305. * @returns the new Particle system
  135306. */
  135307. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  135308. /**
  135309. * This is the main static method (one-liner) of this helper to create different particle systems
  135310. * @param type This string represents the type to the particle system to create
  135311. * @param scene The scene where the particle system should live
  135312. * @param gpu If the system will use gpu
  135313. * @returns the ParticleSystemSet created
  135314. */
  135315. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  135316. /**
  135317. * Static function used to export a particle system to a ParticleSystemSet variable.
  135318. * Please note that the emitter shape is not exported
  135319. * @param systems defines the particle systems to export
  135320. * @returns the created particle system set
  135321. */
  135322. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  135323. }
  135324. }
  135325. declare module BABYLON {
  135326. interface Engine {
  135327. /**
  135328. * Create an effect to use with particle systems.
  135329. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  135330. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  135331. * @param uniformsNames defines a list of attribute names
  135332. * @param samplers defines an array of string used to represent textures
  135333. * @param defines defines the string containing the defines to use to compile the shaders
  135334. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  135335. * @param onCompiled defines a function to call when the effect creation is successful
  135336. * @param onError defines a function to call when the effect creation has failed
  135337. * @returns the new Effect
  135338. */
  135339. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  135340. }
  135341. interface Mesh {
  135342. /**
  135343. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  135344. * @returns an array of IParticleSystem
  135345. */
  135346. getEmittedParticleSystems(): IParticleSystem[];
  135347. /**
  135348. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  135349. * @returns an array of IParticleSystem
  135350. */
  135351. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  135352. }
  135353. /**
  135354. * @hidden
  135355. */
  135356. export var _IDoNeedToBeInTheBuild: number;
  135357. }
  135358. declare module BABYLON {
  135359. /** Defines the 4 color options */
  135360. export enum PointColor {
  135361. /** color value */
  135362. Color = 2,
  135363. /** uv value */
  135364. UV = 1,
  135365. /** random value */
  135366. Random = 0,
  135367. /** stated value */
  135368. Stated = 3
  135369. }
  135370. /**
  135371. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  135372. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  135373. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  135374. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  135375. *
  135376. * Full documentation here : TO BE ENTERED
  135377. */
  135378. export class PointsCloudSystem implements IDisposable {
  135379. /**
  135380. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  135381. * Example : var p = SPS.particles[i];
  135382. */
  135383. particles: CloudPoint[];
  135384. /**
  135385. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  135386. */
  135387. nbParticles: number;
  135388. /**
  135389. * This a counter for your own usage. It's not set by any SPS functions.
  135390. */
  135391. counter: number;
  135392. /**
  135393. * The PCS name. This name is also given to the underlying mesh.
  135394. */
  135395. name: string;
  135396. /**
  135397. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  135398. */
  135399. mesh: Mesh;
  135400. /**
  135401. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  135402. * Please read :
  135403. */
  135404. vars: any;
  135405. /**
  135406. * @hidden
  135407. */
  135408. _size: number;
  135409. private _scene;
  135410. private _promises;
  135411. private _positions;
  135412. private _indices;
  135413. private _normals;
  135414. private _colors;
  135415. private _uvs;
  135416. private _indices32;
  135417. private _positions32;
  135418. private _colors32;
  135419. private _uvs32;
  135420. private _updatable;
  135421. private _isVisibilityBoxLocked;
  135422. private _alwaysVisible;
  135423. private _groups;
  135424. private _groupCounter;
  135425. private _computeParticleColor;
  135426. private _computeParticleTexture;
  135427. private _computeParticleRotation;
  135428. private _computeBoundingBox;
  135429. private _isReady;
  135430. /**
  135431. * Creates a PCS (Points Cloud System) object
  135432. * @param name (String) is the PCS name, this will be the underlying mesh name
  135433. * @param pointSize (number) is the size for each point
  135434. * @param scene (Scene) is the scene in which the PCS is added
  135435. * @param options defines the options of the PCS e.g.
  135436. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  135437. */
  135438. constructor(name: string, pointSize: number, scene: Scene, options?: {
  135439. updatable?: boolean;
  135440. });
  135441. /**
  135442. * Builds the PCS underlying mesh. Returns a standard Mesh.
  135443. * If no points were added to the PCS, the returned mesh is just a single point.
  135444. * @returns a promise for the created mesh
  135445. */
  135446. buildMeshAsync(): Promise<Mesh>;
  135447. /**
  135448. * @hidden
  135449. */
  135450. private _buildMesh;
  135451. private _addParticle;
  135452. private _randomUnitVector;
  135453. private _getColorIndicesForCoord;
  135454. private _setPointsColorOrUV;
  135455. private _colorFromTexture;
  135456. private _calculateDensity;
  135457. /**
  135458. * Adds points to the PCS in random positions within a unit sphere
  135459. * @param nb (positive integer) the number of particles to be created from this model
  135460. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  135461. * @returns the number of groups in the system
  135462. */
  135463. addPoints(nb: number, pointFunction?: any): number;
  135464. /**
  135465. * Adds points to the PCS from the surface of the model shape
  135466. * @param mesh is any Mesh object that will be used as a surface model for the points
  135467. * @param nb (positive integer) the number of particles to be created from this model
  135468. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  135469. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  135470. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  135471. * @returns the number of groups in the system
  135472. */
  135473. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  135474. /**
  135475. * Adds points to the PCS inside the model shape
  135476. * @param mesh is any Mesh object that will be used as a surface model for the points
  135477. * @param nb (positive integer) the number of particles to be created from this model
  135478. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  135479. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  135480. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  135481. * @returns the number of groups in the system
  135482. */
  135483. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  135484. /**
  135485. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  135486. * This method calls `updateParticle()` for each particle of the SPS.
  135487. * For an animated SPS, it is usually called within the render loop.
  135488. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  135489. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  135490. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  135491. * @returns the PCS.
  135492. */
  135493. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  135494. /**
  135495. * Disposes the PCS.
  135496. */
  135497. dispose(): void;
  135498. /**
  135499. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  135500. * doc :
  135501. * @returns the PCS.
  135502. */
  135503. refreshVisibleSize(): PointsCloudSystem;
  135504. /**
  135505. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  135506. * @param size the size (float) of the visibility box
  135507. * note : this doesn't lock the PCS mesh bounding box.
  135508. * doc :
  135509. */
  135510. setVisibilityBox(size: number): void;
  135511. /**
  135512. * Gets whether the PCS is always visible or not
  135513. * doc :
  135514. */
  135515. get isAlwaysVisible(): boolean;
  135516. /**
  135517. * Sets the PCS as always visible or not
  135518. * doc :
  135519. */
  135520. set isAlwaysVisible(val: boolean);
  135521. /**
  135522. * Tells to `setParticles()` to compute the particle rotations or not
  135523. * Default value : false. The PCS is faster when it's set to false
  135524. * Note : particle rotations are only applied to parent particles
  135525. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  135526. */
  135527. set computeParticleRotation(val: boolean);
  135528. /**
  135529. * Tells to `setParticles()` to compute the particle colors or not.
  135530. * Default value : true. The PCS is faster when it's set to false.
  135531. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  135532. */
  135533. set computeParticleColor(val: boolean);
  135534. set computeParticleTexture(val: boolean);
  135535. /**
  135536. * Gets if `setParticles()` computes the particle colors or not.
  135537. * Default value : false. The PCS is faster when it's set to false.
  135538. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  135539. */
  135540. get computeParticleColor(): boolean;
  135541. /**
  135542. * Gets if `setParticles()` computes the particle textures or not.
  135543. * Default value : false. The PCS is faster when it's set to false.
  135544. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  135545. */
  135546. get computeParticleTexture(): boolean;
  135547. /**
  135548. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  135549. */
  135550. set computeBoundingBox(val: boolean);
  135551. /**
  135552. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  135553. */
  135554. get computeBoundingBox(): boolean;
  135555. /**
  135556. * This function does nothing. It may be overwritten to set all the particle first values.
  135557. * The PCS doesn't call this function, you may have to call it by your own.
  135558. * doc :
  135559. */
  135560. initParticles(): void;
  135561. /**
  135562. * This function does nothing. It may be overwritten to recycle a particle
  135563. * The PCS doesn't call this function, you can to call it
  135564. * doc :
  135565. * @param particle The particle to recycle
  135566. * @returns the recycled particle
  135567. */
  135568. recycleParticle(particle: CloudPoint): CloudPoint;
  135569. /**
  135570. * Updates a particle : this function should be overwritten by the user.
  135571. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  135572. * doc :
  135573. * @example : just set a particle position or velocity and recycle conditions
  135574. * @param particle The particle to update
  135575. * @returns the updated particle
  135576. */
  135577. updateParticle(particle: CloudPoint): CloudPoint;
  135578. /**
  135579. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  135580. * This does nothing and may be overwritten by the user.
  135581. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  135582. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  135583. * @param update the boolean update value actually passed to setParticles()
  135584. */
  135585. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  135586. /**
  135587. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  135588. * This will be passed three parameters.
  135589. * This does nothing and may be overwritten by the user.
  135590. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  135591. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  135592. * @param update the boolean update value actually passed to setParticles()
  135593. */
  135594. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  135595. }
  135596. }
  135597. declare module BABYLON {
  135598. /**
  135599. * Represents one particle of a points cloud system.
  135600. */
  135601. export class CloudPoint {
  135602. /**
  135603. * particle global index
  135604. */
  135605. idx: number;
  135606. /**
  135607. * The color of the particle
  135608. */
  135609. color: Nullable<Color4>;
  135610. /**
  135611. * The world space position of the particle.
  135612. */
  135613. position: Vector3;
  135614. /**
  135615. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  135616. */
  135617. rotation: Vector3;
  135618. /**
  135619. * The world space rotation quaternion of the particle.
  135620. */
  135621. rotationQuaternion: Nullable<Quaternion>;
  135622. /**
  135623. * The uv of the particle.
  135624. */
  135625. uv: Nullable<Vector2>;
  135626. /**
  135627. * The current speed of the particle.
  135628. */
  135629. velocity: Vector3;
  135630. /**
  135631. * The pivot point in the particle local space.
  135632. */
  135633. pivot: Vector3;
  135634. /**
  135635. * Must the particle be translated from its pivot point in its local space ?
  135636. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  135637. * Default : false
  135638. */
  135639. translateFromPivot: boolean;
  135640. /**
  135641. * Index of this particle in the global "positions" array (Internal use)
  135642. * @hidden
  135643. */
  135644. _pos: number;
  135645. /**
  135646. * @hidden Index of this particle in the global "indices" array (Internal use)
  135647. */
  135648. _ind: number;
  135649. /**
  135650. * Group this particle belongs to
  135651. */
  135652. _group: PointsGroup;
  135653. /**
  135654. * Group id of this particle
  135655. */
  135656. groupId: number;
  135657. /**
  135658. * Index of the particle in its group id (Internal use)
  135659. */
  135660. idxInGroup: number;
  135661. /**
  135662. * @hidden Particle BoundingInfo object (Internal use)
  135663. */
  135664. _boundingInfo: BoundingInfo;
  135665. /**
  135666. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  135667. */
  135668. _pcs: PointsCloudSystem;
  135669. /**
  135670. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  135671. */
  135672. _stillInvisible: boolean;
  135673. /**
  135674. * @hidden Last computed particle rotation matrix
  135675. */
  135676. _rotationMatrix: number[];
  135677. /**
  135678. * Parent particle Id, if any.
  135679. * Default null.
  135680. */
  135681. parentId: Nullable<number>;
  135682. /**
  135683. * @hidden Internal global position in the PCS.
  135684. */
  135685. _globalPosition: Vector3;
  135686. /**
  135687. * Creates a Point Cloud object.
  135688. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  135689. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  135690. * @param group (PointsGroup) is the group the particle belongs to
  135691. * @param groupId (integer) is the group identifier in the PCS.
  135692. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  135693. * @param pcs defines the PCS it is associated to
  135694. */
  135695. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  135696. /**
  135697. * get point size
  135698. */
  135699. get size(): Vector3;
  135700. /**
  135701. * Set point size
  135702. */
  135703. set size(scale: Vector3);
  135704. /**
  135705. * Legacy support, changed quaternion to rotationQuaternion
  135706. */
  135707. get quaternion(): Nullable<Quaternion>;
  135708. /**
  135709. * Legacy support, changed quaternion to rotationQuaternion
  135710. */
  135711. set quaternion(q: Nullable<Quaternion>);
  135712. /**
  135713. * Returns a boolean. True if the particle intersects a mesh, else false
  135714. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  135715. * @param target is the object (point or mesh) what the intersection is computed against
  135716. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  135717. * @returns true if it intersects
  135718. */
  135719. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  135720. /**
  135721. * get the rotation matrix of the particle
  135722. * @hidden
  135723. */
  135724. getRotationMatrix(m: Matrix): void;
  135725. }
  135726. /**
  135727. * Represents a group of points in a points cloud system
  135728. * * PCS internal tool, don't use it manually.
  135729. */
  135730. export class PointsGroup {
  135731. /**
  135732. * The group id
  135733. * @hidden
  135734. */
  135735. groupID: number;
  135736. /**
  135737. * image data for group (internal use)
  135738. * @hidden
  135739. */
  135740. _groupImageData: Nullable<ArrayBufferView>;
  135741. /**
  135742. * Image Width (internal use)
  135743. * @hidden
  135744. */
  135745. _groupImgWidth: number;
  135746. /**
  135747. * Image Height (internal use)
  135748. * @hidden
  135749. */
  135750. _groupImgHeight: number;
  135751. /**
  135752. * Custom position function (internal use)
  135753. * @hidden
  135754. */
  135755. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  135756. /**
  135757. * density per facet for surface points
  135758. * @hidden
  135759. */
  135760. _groupDensity: number[];
  135761. /**
  135762. * Only when points are colored by texture carries pointer to texture list array
  135763. * @hidden
  135764. */
  135765. _textureNb: number;
  135766. /**
  135767. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  135768. * PCS internal tool, don't use it manually.
  135769. * @hidden
  135770. */
  135771. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  135772. }
  135773. }
  135774. declare module BABYLON {
  135775. interface Scene {
  135776. /** @hidden (Backing field) */
  135777. _physicsEngine: Nullable<IPhysicsEngine>;
  135778. /** @hidden */
  135779. _physicsTimeAccumulator: number;
  135780. /**
  135781. * Gets the current physics engine
  135782. * @returns a IPhysicsEngine or null if none attached
  135783. */
  135784. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  135785. /**
  135786. * Enables physics to the current scene
  135787. * @param gravity defines the scene's gravity for the physics engine
  135788. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  135789. * @return a boolean indicating if the physics engine was initialized
  135790. */
  135791. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  135792. /**
  135793. * Disables and disposes the physics engine associated with the scene
  135794. */
  135795. disablePhysicsEngine(): void;
  135796. /**
  135797. * Gets a boolean indicating if there is an active physics engine
  135798. * @returns a boolean indicating if there is an active physics engine
  135799. */
  135800. isPhysicsEnabled(): boolean;
  135801. /**
  135802. * Deletes a physics compound impostor
  135803. * @param compound defines the compound to delete
  135804. */
  135805. deleteCompoundImpostor(compound: any): void;
  135806. /**
  135807. * An event triggered when physic simulation is about to be run
  135808. */
  135809. onBeforePhysicsObservable: Observable<Scene>;
  135810. /**
  135811. * An event triggered when physic simulation has been done
  135812. */
  135813. onAfterPhysicsObservable: Observable<Scene>;
  135814. }
  135815. interface AbstractMesh {
  135816. /** @hidden */
  135817. _physicsImpostor: Nullable<PhysicsImpostor>;
  135818. /**
  135819. * Gets or sets impostor used for physic simulation
  135820. * @see http://doc.babylonjs.com/features/physics_engine
  135821. */
  135822. physicsImpostor: Nullable<PhysicsImpostor>;
  135823. /**
  135824. * Gets the current physics impostor
  135825. * @see http://doc.babylonjs.com/features/physics_engine
  135826. * @returns a physics impostor or null
  135827. */
  135828. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  135829. /** Apply a physic impulse to the mesh
  135830. * @param force defines the force to apply
  135831. * @param contactPoint defines where to apply the force
  135832. * @returns the current mesh
  135833. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  135834. */
  135835. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  135836. /**
  135837. * Creates a physic joint between two meshes
  135838. * @param otherMesh defines the other mesh to use
  135839. * @param pivot1 defines the pivot to use on this mesh
  135840. * @param pivot2 defines the pivot to use on the other mesh
  135841. * @param options defines additional options (can be plugin dependent)
  135842. * @returns the current mesh
  135843. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  135844. */
  135845. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  135846. /** @hidden */
  135847. _disposePhysicsObserver: Nullable<Observer<Node>>;
  135848. }
  135849. /**
  135850. * Defines the physics engine scene component responsible to manage a physics engine
  135851. */
  135852. export class PhysicsEngineSceneComponent implements ISceneComponent {
  135853. /**
  135854. * The component name helpful to identify the component in the list of scene components.
  135855. */
  135856. readonly name: string;
  135857. /**
  135858. * The scene the component belongs to.
  135859. */
  135860. scene: Scene;
  135861. /**
  135862. * Creates a new instance of the component for the given scene
  135863. * @param scene Defines the scene to register the component in
  135864. */
  135865. constructor(scene: Scene);
  135866. /**
  135867. * Registers the component in a given scene
  135868. */
  135869. register(): void;
  135870. /**
  135871. * Rebuilds the elements related to this component in case of
  135872. * context lost for instance.
  135873. */
  135874. rebuild(): void;
  135875. /**
  135876. * Disposes the component and the associated ressources
  135877. */
  135878. dispose(): void;
  135879. }
  135880. }
  135881. declare module BABYLON {
  135882. /**
  135883. * A helper for physics simulations
  135884. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  135885. */
  135886. export class PhysicsHelper {
  135887. private _scene;
  135888. private _physicsEngine;
  135889. /**
  135890. * Initializes the Physics helper
  135891. * @param scene Babylon.js scene
  135892. */
  135893. constructor(scene: Scene);
  135894. /**
  135895. * Applies a radial explosion impulse
  135896. * @param origin the origin of the explosion
  135897. * @param radiusOrEventOptions the radius or the options of radial explosion
  135898. * @param strength the explosion strength
  135899. * @param falloff possible options: Constant & Linear. Defaults to Constant
  135900. * @returns A physics radial explosion event, or null
  135901. */
  135902. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  135903. /**
  135904. * Applies a radial explosion force
  135905. * @param origin the origin of the explosion
  135906. * @param radiusOrEventOptions the radius or the options of radial explosion
  135907. * @param strength the explosion strength
  135908. * @param falloff possible options: Constant & Linear. Defaults to Constant
  135909. * @returns A physics radial explosion event, or null
  135910. */
  135911. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  135912. /**
  135913. * Creates a gravitational field
  135914. * @param origin the origin of the explosion
  135915. * @param radiusOrEventOptions the radius or the options of radial explosion
  135916. * @param strength the explosion strength
  135917. * @param falloff possible options: Constant & Linear. Defaults to Constant
  135918. * @returns A physics gravitational field event, or null
  135919. */
  135920. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  135921. /**
  135922. * Creates a physics updraft event
  135923. * @param origin the origin of the updraft
  135924. * @param radiusOrEventOptions the radius or the options of the updraft
  135925. * @param strength the strength of the updraft
  135926. * @param height the height of the updraft
  135927. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  135928. * @returns A physics updraft event, or null
  135929. */
  135930. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  135931. /**
  135932. * Creates a physics vortex event
  135933. * @param origin the of the vortex
  135934. * @param radiusOrEventOptions the radius or the options of the vortex
  135935. * @param strength the strength of the vortex
  135936. * @param height the height of the vortex
  135937. * @returns a Physics vortex event, or null
  135938. * A physics vortex event or null
  135939. */
  135940. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  135941. }
  135942. /**
  135943. * Represents a physics radial explosion event
  135944. */
  135945. class PhysicsRadialExplosionEvent {
  135946. private _scene;
  135947. private _options;
  135948. private _sphere;
  135949. private _dataFetched;
  135950. /**
  135951. * Initializes a radial explosioin event
  135952. * @param _scene BabylonJS scene
  135953. * @param _options The options for the vortex event
  135954. */
  135955. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  135956. /**
  135957. * Returns the data related to the radial explosion event (sphere).
  135958. * @returns The radial explosion event data
  135959. */
  135960. getData(): PhysicsRadialExplosionEventData;
  135961. /**
  135962. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  135963. * @param impostor A physics imposter
  135964. * @param origin the origin of the explosion
  135965. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  135966. */
  135967. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  135968. /**
  135969. * Triggers affecterd impostors callbacks
  135970. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  135971. */
  135972. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  135973. /**
  135974. * Disposes the sphere.
  135975. * @param force Specifies if the sphere should be disposed by force
  135976. */
  135977. dispose(force?: boolean): void;
  135978. /*** Helpers ***/
  135979. private _prepareSphere;
  135980. private _intersectsWithSphere;
  135981. }
  135982. /**
  135983. * Represents a gravitational field event
  135984. */
  135985. class PhysicsGravitationalFieldEvent {
  135986. private _physicsHelper;
  135987. private _scene;
  135988. private _origin;
  135989. private _options;
  135990. private _tickCallback;
  135991. private _sphere;
  135992. private _dataFetched;
  135993. /**
  135994. * Initializes the physics gravitational field event
  135995. * @param _physicsHelper A physics helper
  135996. * @param _scene BabylonJS scene
  135997. * @param _origin The origin position of the gravitational field event
  135998. * @param _options The options for the vortex event
  135999. */
  136000. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  136001. /**
  136002. * Returns the data related to the gravitational field event (sphere).
  136003. * @returns A gravitational field event
  136004. */
  136005. getData(): PhysicsGravitationalFieldEventData;
  136006. /**
  136007. * Enables the gravitational field.
  136008. */
  136009. enable(): void;
  136010. /**
  136011. * Disables the gravitational field.
  136012. */
  136013. disable(): void;
  136014. /**
  136015. * Disposes the sphere.
  136016. * @param force The force to dispose from the gravitational field event
  136017. */
  136018. dispose(force?: boolean): void;
  136019. private _tick;
  136020. }
  136021. /**
  136022. * Represents a physics updraft event
  136023. */
  136024. class PhysicsUpdraftEvent {
  136025. private _scene;
  136026. private _origin;
  136027. private _options;
  136028. private _physicsEngine;
  136029. private _originTop;
  136030. private _originDirection;
  136031. private _tickCallback;
  136032. private _cylinder;
  136033. private _cylinderPosition;
  136034. private _dataFetched;
  136035. /**
  136036. * Initializes the physics updraft event
  136037. * @param _scene BabylonJS scene
  136038. * @param _origin The origin position of the updraft
  136039. * @param _options The options for the updraft event
  136040. */
  136041. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  136042. /**
  136043. * Returns the data related to the updraft event (cylinder).
  136044. * @returns A physics updraft event
  136045. */
  136046. getData(): PhysicsUpdraftEventData;
  136047. /**
  136048. * Enables the updraft.
  136049. */
  136050. enable(): void;
  136051. /**
  136052. * Disables the updraft.
  136053. */
  136054. disable(): void;
  136055. /**
  136056. * Disposes the cylinder.
  136057. * @param force Specifies if the updraft should be disposed by force
  136058. */
  136059. dispose(force?: boolean): void;
  136060. private getImpostorHitData;
  136061. private _tick;
  136062. /*** Helpers ***/
  136063. private _prepareCylinder;
  136064. private _intersectsWithCylinder;
  136065. }
  136066. /**
  136067. * Represents a physics vortex event
  136068. */
  136069. class PhysicsVortexEvent {
  136070. private _scene;
  136071. private _origin;
  136072. private _options;
  136073. private _physicsEngine;
  136074. private _originTop;
  136075. private _tickCallback;
  136076. private _cylinder;
  136077. private _cylinderPosition;
  136078. private _dataFetched;
  136079. /**
  136080. * Initializes the physics vortex event
  136081. * @param _scene The BabylonJS scene
  136082. * @param _origin The origin position of the vortex
  136083. * @param _options The options for the vortex event
  136084. */
  136085. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  136086. /**
  136087. * Returns the data related to the vortex event (cylinder).
  136088. * @returns The physics vortex event data
  136089. */
  136090. getData(): PhysicsVortexEventData;
  136091. /**
  136092. * Enables the vortex.
  136093. */
  136094. enable(): void;
  136095. /**
  136096. * Disables the cortex.
  136097. */
  136098. disable(): void;
  136099. /**
  136100. * Disposes the sphere.
  136101. * @param force
  136102. */
  136103. dispose(force?: boolean): void;
  136104. private getImpostorHitData;
  136105. private _tick;
  136106. /*** Helpers ***/
  136107. private _prepareCylinder;
  136108. private _intersectsWithCylinder;
  136109. }
  136110. /**
  136111. * Options fot the radial explosion event
  136112. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136113. */
  136114. export class PhysicsRadialExplosionEventOptions {
  136115. /**
  136116. * The radius of the sphere for the radial explosion.
  136117. */
  136118. radius: number;
  136119. /**
  136120. * The strenth of the explosion.
  136121. */
  136122. strength: number;
  136123. /**
  136124. * The strenght of the force in correspondence to the distance of the affected object
  136125. */
  136126. falloff: PhysicsRadialImpulseFalloff;
  136127. /**
  136128. * Sphere options for the radial explosion.
  136129. */
  136130. sphere: {
  136131. segments: number;
  136132. diameter: number;
  136133. };
  136134. /**
  136135. * Sphere options for the radial explosion.
  136136. */
  136137. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  136138. }
  136139. /**
  136140. * Options fot the updraft event
  136141. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136142. */
  136143. export class PhysicsUpdraftEventOptions {
  136144. /**
  136145. * The radius of the cylinder for the vortex
  136146. */
  136147. radius: number;
  136148. /**
  136149. * The strenth of the updraft.
  136150. */
  136151. strength: number;
  136152. /**
  136153. * The height of the cylinder for the updraft.
  136154. */
  136155. height: number;
  136156. /**
  136157. * The mode for the the updraft.
  136158. */
  136159. updraftMode: PhysicsUpdraftMode;
  136160. }
  136161. /**
  136162. * Options fot the vortex event
  136163. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136164. */
  136165. export class PhysicsVortexEventOptions {
  136166. /**
  136167. * The radius of the cylinder for the vortex
  136168. */
  136169. radius: number;
  136170. /**
  136171. * The strenth of the vortex.
  136172. */
  136173. strength: number;
  136174. /**
  136175. * The height of the cylinder for the vortex.
  136176. */
  136177. height: number;
  136178. /**
  136179. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  136180. */
  136181. centripetalForceThreshold: number;
  136182. /**
  136183. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  136184. */
  136185. centripetalForceMultiplier: number;
  136186. /**
  136187. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  136188. */
  136189. centrifugalForceMultiplier: number;
  136190. /**
  136191. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  136192. */
  136193. updraftForceMultiplier: number;
  136194. }
  136195. /**
  136196. * The strenght of the force in correspondence to the distance of the affected object
  136197. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136198. */
  136199. export enum PhysicsRadialImpulseFalloff {
  136200. /** Defines that impulse is constant in strength across it's whole radius */
  136201. Constant = 0,
  136202. /** Defines that impulse gets weaker if it's further from the origin */
  136203. Linear = 1
  136204. }
  136205. /**
  136206. * The strength of the force in correspondence to the distance of the affected object
  136207. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136208. */
  136209. export enum PhysicsUpdraftMode {
  136210. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  136211. Center = 0,
  136212. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  136213. Perpendicular = 1
  136214. }
  136215. /**
  136216. * Interface for a physics hit data
  136217. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136218. */
  136219. export interface PhysicsHitData {
  136220. /**
  136221. * The force applied at the contact point
  136222. */
  136223. force: Vector3;
  136224. /**
  136225. * The contact point
  136226. */
  136227. contactPoint: Vector3;
  136228. /**
  136229. * The distance from the origin to the contact point
  136230. */
  136231. distanceFromOrigin: number;
  136232. }
  136233. /**
  136234. * Interface for radial explosion event data
  136235. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136236. */
  136237. export interface PhysicsRadialExplosionEventData {
  136238. /**
  136239. * A sphere used for the radial explosion event
  136240. */
  136241. sphere: Mesh;
  136242. }
  136243. /**
  136244. * Interface for gravitational field event data
  136245. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136246. */
  136247. export interface PhysicsGravitationalFieldEventData {
  136248. /**
  136249. * A sphere mesh used for the gravitational field event
  136250. */
  136251. sphere: Mesh;
  136252. }
  136253. /**
  136254. * Interface for updraft event data
  136255. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136256. */
  136257. export interface PhysicsUpdraftEventData {
  136258. /**
  136259. * A cylinder used for the updraft event
  136260. */
  136261. cylinder: Mesh;
  136262. }
  136263. /**
  136264. * Interface for vortex event data
  136265. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136266. */
  136267. export interface PhysicsVortexEventData {
  136268. /**
  136269. * A cylinder used for the vortex event
  136270. */
  136271. cylinder: Mesh;
  136272. }
  136273. /**
  136274. * Interface for an affected physics impostor
  136275. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136276. */
  136277. export interface PhysicsAffectedImpostorWithData {
  136278. /**
  136279. * The impostor affected by the effect
  136280. */
  136281. impostor: PhysicsImpostor;
  136282. /**
  136283. * The data about the hit/horce from the explosion
  136284. */
  136285. hitData: PhysicsHitData;
  136286. }
  136287. }
  136288. declare module BABYLON {
  136289. /** @hidden */
  136290. export var blackAndWhitePixelShader: {
  136291. name: string;
  136292. shader: string;
  136293. };
  136294. }
  136295. declare module BABYLON {
  136296. /**
  136297. * Post process used to render in black and white
  136298. */
  136299. export class BlackAndWhitePostProcess extends PostProcess {
  136300. /**
  136301. * Linear about to convert he result to black and white (default: 1)
  136302. */
  136303. degree: number;
  136304. /**
  136305. * Creates a black and white post process
  136306. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  136307. * @param name The name of the effect.
  136308. * @param options The required width/height ratio to downsize to before computing the render pass.
  136309. * @param camera The camera to apply the render pass to.
  136310. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136311. * @param engine The engine which the post process will be applied. (default: current engine)
  136312. * @param reusable If the post process can be reused on the same frame. (default: false)
  136313. */
  136314. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  136315. }
  136316. }
  136317. declare module BABYLON {
  136318. /**
  136319. * This represents a set of one or more post processes in Babylon.
  136320. * A post process can be used to apply a shader to a texture after it is rendered.
  136321. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  136322. */
  136323. export class PostProcessRenderEffect {
  136324. private _postProcesses;
  136325. private _getPostProcesses;
  136326. private _singleInstance;
  136327. private _cameras;
  136328. private _indicesForCamera;
  136329. /**
  136330. * Name of the effect
  136331. * @hidden
  136332. */
  136333. _name: string;
  136334. /**
  136335. * Instantiates a post process render effect.
  136336. * A post process can be used to apply a shader to a texture after it is rendered.
  136337. * @param engine The engine the effect is tied to
  136338. * @param name The name of the effect
  136339. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  136340. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  136341. */
  136342. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  136343. /**
  136344. * Checks if all the post processes in the effect are supported.
  136345. */
  136346. get isSupported(): boolean;
  136347. /**
  136348. * Updates the current state of the effect
  136349. * @hidden
  136350. */
  136351. _update(): void;
  136352. /**
  136353. * Attaches the effect on cameras
  136354. * @param cameras The camera to attach to.
  136355. * @hidden
  136356. */
  136357. _attachCameras(cameras: Camera): void;
  136358. /**
  136359. * Attaches the effect on cameras
  136360. * @param cameras The camera to attach to.
  136361. * @hidden
  136362. */
  136363. _attachCameras(cameras: Camera[]): void;
  136364. /**
  136365. * Detaches the effect on cameras
  136366. * @param cameras The camera to detatch from.
  136367. * @hidden
  136368. */
  136369. _detachCameras(cameras: Camera): void;
  136370. /**
  136371. * Detatches the effect on cameras
  136372. * @param cameras The camera to detatch from.
  136373. * @hidden
  136374. */
  136375. _detachCameras(cameras: Camera[]): void;
  136376. /**
  136377. * Enables the effect on given cameras
  136378. * @param cameras The camera to enable.
  136379. * @hidden
  136380. */
  136381. _enable(cameras: Camera): void;
  136382. /**
  136383. * Enables the effect on given cameras
  136384. * @param cameras The camera to enable.
  136385. * @hidden
  136386. */
  136387. _enable(cameras: Nullable<Camera[]>): void;
  136388. /**
  136389. * Disables the effect on the given cameras
  136390. * @param cameras The camera to disable.
  136391. * @hidden
  136392. */
  136393. _disable(cameras: Camera): void;
  136394. /**
  136395. * Disables the effect on the given cameras
  136396. * @param cameras The camera to disable.
  136397. * @hidden
  136398. */
  136399. _disable(cameras: Nullable<Camera[]>): void;
  136400. /**
  136401. * Gets a list of the post processes contained in the effect.
  136402. * @param camera The camera to get the post processes on.
  136403. * @returns The list of the post processes in the effect.
  136404. */
  136405. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  136406. }
  136407. }
  136408. declare module BABYLON {
  136409. /** @hidden */
  136410. export var extractHighlightsPixelShader: {
  136411. name: string;
  136412. shader: string;
  136413. };
  136414. }
  136415. declare module BABYLON {
  136416. /**
  136417. * 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.
  136418. */
  136419. export class ExtractHighlightsPostProcess extends PostProcess {
  136420. /**
  136421. * The luminance threshold, pixels below this value will be set to black.
  136422. */
  136423. threshold: number;
  136424. /** @hidden */
  136425. _exposure: number;
  136426. /**
  136427. * Post process which has the input texture to be used when performing highlight extraction
  136428. * @hidden
  136429. */
  136430. _inputPostProcess: Nullable<PostProcess>;
  136431. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  136432. }
  136433. }
  136434. declare module BABYLON {
  136435. /** @hidden */
  136436. export var bloomMergePixelShader: {
  136437. name: string;
  136438. shader: string;
  136439. };
  136440. }
  136441. declare module BABYLON {
  136442. /**
  136443. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  136444. */
  136445. export class BloomMergePostProcess extends PostProcess {
  136446. /** Weight of the bloom to be added to the original input. */
  136447. weight: number;
  136448. /**
  136449. * Creates a new instance of @see BloomMergePostProcess
  136450. * @param name The name of the effect.
  136451. * @param originalFromInput Post process which's input will be used for the merge.
  136452. * @param blurred Blurred highlights post process which's output will be used.
  136453. * @param weight Weight of the bloom to be added to the original input.
  136454. * @param options The required width/height ratio to downsize to before computing the render pass.
  136455. * @param camera The camera to apply the render pass to.
  136456. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136457. * @param engine The engine which the post process will be applied. (default: current engine)
  136458. * @param reusable If the post process can be reused on the same frame. (default: false)
  136459. * @param textureType Type of textures used when performing the post process. (default: 0)
  136460. * @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)
  136461. */
  136462. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  136463. /** Weight of the bloom to be added to the original input. */
  136464. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  136465. }
  136466. }
  136467. declare module BABYLON {
  136468. /**
  136469. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  136470. */
  136471. export class BloomEffect extends PostProcessRenderEffect {
  136472. private bloomScale;
  136473. /**
  136474. * @hidden Internal
  136475. */
  136476. _effects: Array<PostProcess>;
  136477. /**
  136478. * @hidden Internal
  136479. */
  136480. _downscale: ExtractHighlightsPostProcess;
  136481. private _blurX;
  136482. private _blurY;
  136483. private _merge;
  136484. /**
  136485. * The luminance threshold to find bright areas of the image to bloom.
  136486. */
  136487. get threshold(): number;
  136488. set threshold(value: number);
  136489. /**
  136490. * The strength of the bloom.
  136491. */
  136492. get weight(): number;
  136493. set weight(value: number);
  136494. /**
  136495. * Specifies the size of the bloom blur kernel, relative to the final output size
  136496. */
  136497. get kernel(): number;
  136498. set kernel(value: number);
  136499. /**
  136500. * Creates a new instance of @see BloomEffect
  136501. * @param scene The scene the effect belongs to.
  136502. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  136503. * @param bloomKernel The size of the kernel to be used when applying the blur.
  136504. * @param bloomWeight The the strength of bloom.
  136505. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  136506. * @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)
  136507. */
  136508. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  136509. /**
  136510. * Disposes each of the internal effects for a given camera.
  136511. * @param camera The camera to dispose the effect on.
  136512. */
  136513. disposeEffects(camera: Camera): void;
  136514. /**
  136515. * @hidden Internal
  136516. */
  136517. _updateEffects(): void;
  136518. /**
  136519. * Internal
  136520. * @returns if all the contained post processes are ready.
  136521. * @hidden
  136522. */
  136523. _isReady(): boolean;
  136524. }
  136525. }
  136526. declare module BABYLON {
  136527. /** @hidden */
  136528. export var chromaticAberrationPixelShader: {
  136529. name: string;
  136530. shader: string;
  136531. };
  136532. }
  136533. declare module BABYLON {
  136534. /**
  136535. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  136536. */
  136537. export class ChromaticAberrationPostProcess extends PostProcess {
  136538. /**
  136539. * The amount of seperation of rgb channels (default: 30)
  136540. */
  136541. aberrationAmount: number;
  136542. /**
  136543. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  136544. */
  136545. radialIntensity: number;
  136546. /**
  136547. * 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))
  136548. */
  136549. direction: Vector2;
  136550. /**
  136551. * 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))
  136552. */
  136553. centerPosition: Vector2;
  136554. /**
  136555. * Creates a new instance ChromaticAberrationPostProcess
  136556. * @param name The name of the effect.
  136557. * @param screenWidth The width of the screen to apply the effect on.
  136558. * @param screenHeight The height of the screen to apply the effect on.
  136559. * @param options The required width/height ratio to downsize to before computing the render pass.
  136560. * @param camera The camera to apply the render pass to.
  136561. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136562. * @param engine The engine which the post process will be applied. (default: current engine)
  136563. * @param reusable If the post process can be reused on the same frame. (default: false)
  136564. * @param textureType Type of textures used when performing the post process. (default: 0)
  136565. * @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)
  136566. */
  136567. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  136568. }
  136569. }
  136570. declare module BABYLON {
  136571. /** @hidden */
  136572. export var circleOfConfusionPixelShader: {
  136573. name: string;
  136574. shader: string;
  136575. };
  136576. }
  136577. declare module BABYLON {
  136578. /**
  136579. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  136580. */
  136581. export class CircleOfConfusionPostProcess extends PostProcess {
  136582. /**
  136583. * 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.
  136584. */
  136585. lensSize: number;
  136586. /**
  136587. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  136588. */
  136589. fStop: number;
  136590. /**
  136591. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  136592. */
  136593. focusDistance: number;
  136594. /**
  136595. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  136596. */
  136597. focalLength: number;
  136598. private _depthTexture;
  136599. /**
  136600. * Creates a new instance CircleOfConfusionPostProcess
  136601. * @param name The name of the effect.
  136602. * @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.
  136603. * @param options The required width/height ratio to downsize to before computing the render pass.
  136604. * @param camera The camera to apply the render pass to.
  136605. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136606. * @param engine The engine which the post process will be applied. (default: current engine)
  136607. * @param reusable If the post process can be reused on the same frame. (default: false)
  136608. * @param textureType Type of textures used when performing the post process. (default: 0)
  136609. * @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)
  136610. */
  136611. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  136612. /**
  136613. * 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.
  136614. */
  136615. set depthTexture(value: RenderTargetTexture);
  136616. }
  136617. }
  136618. declare module BABYLON {
  136619. /** @hidden */
  136620. export var colorCorrectionPixelShader: {
  136621. name: string;
  136622. shader: string;
  136623. };
  136624. }
  136625. declare module BABYLON {
  136626. /**
  136627. *
  136628. * This post-process allows the modification of rendered colors by using
  136629. * a 'look-up table' (LUT). This effect is also called Color Grading.
  136630. *
  136631. * The object needs to be provided an url to a texture containing the color
  136632. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  136633. * Use an image editing software to tweak the LUT to match your needs.
  136634. *
  136635. * For an example of a color LUT, see here:
  136636. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  136637. * For explanations on color grading, see here:
  136638. * @see http://udn.epicgames.com/Three/ColorGrading.html
  136639. *
  136640. */
  136641. export class ColorCorrectionPostProcess extends PostProcess {
  136642. private _colorTableTexture;
  136643. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  136644. }
  136645. }
  136646. declare module BABYLON {
  136647. /** @hidden */
  136648. export var convolutionPixelShader: {
  136649. name: string;
  136650. shader: string;
  136651. };
  136652. }
  136653. declare module BABYLON {
  136654. /**
  136655. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  136656. * input texture to perform effects such as edge detection or sharpening
  136657. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  136658. */
  136659. export class ConvolutionPostProcess extends PostProcess {
  136660. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  136661. kernel: number[];
  136662. /**
  136663. * Creates a new instance ConvolutionPostProcess
  136664. * @param name The name of the effect.
  136665. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  136666. * @param options The required width/height ratio to downsize to before computing the render pass.
  136667. * @param camera The camera to apply the render pass to.
  136668. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136669. * @param engine The engine which the post process will be applied. (default: current engine)
  136670. * @param reusable If the post process can be reused on the same frame. (default: false)
  136671. * @param textureType Type of textures used when performing the post process. (default: 0)
  136672. */
  136673. constructor(name: string,
  136674. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  136675. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  136676. /**
  136677. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  136678. */
  136679. static EdgeDetect0Kernel: number[];
  136680. /**
  136681. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  136682. */
  136683. static EdgeDetect1Kernel: number[];
  136684. /**
  136685. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  136686. */
  136687. static EdgeDetect2Kernel: number[];
  136688. /**
  136689. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  136690. */
  136691. static SharpenKernel: number[];
  136692. /**
  136693. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  136694. */
  136695. static EmbossKernel: number[];
  136696. /**
  136697. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  136698. */
  136699. static GaussianKernel: number[];
  136700. }
  136701. }
  136702. declare module BABYLON {
  136703. /**
  136704. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  136705. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  136706. * based on samples that have a large difference in distance than the center pixel.
  136707. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  136708. */
  136709. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  136710. direction: Vector2;
  136711. /**
  136712. * Creates a new instance CircleOfConfusionPostProcess
  136713. * @param name The name of the effect.
  136714. * @param scene The scene the effect belongs to.
  136715. * @param direction The direction the blur should be applied.
  136716. * @param kernel The size of the kernel used to blur.
  136717. * @param options The required width/height ratio to downsize to before computing the render pass.
  136718. * @param camera The camera to apply the render pass to.
  136719. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  136720. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  136721. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136722. * @param engine The engine which the post process will be applied. (default: current engine)
  136723. * @param reusable If the post process can be reused on the same frame. (default: false)
  136724. * @param textureType Type of textures used when performing the post process. (default: 0)
  136725. * @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)
  136726. */
  136727. 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);
  136728. }
  136729. }
  136730. declare module BABYLON {
  136731. /** @hidden */
  136732. export var depthOfFieldMergePixelShader: {
  136733. name: string;
  136734. shader: string;
  136735. };
  136736. }
  136737. declare module BABYLON {
  136738. /**
  136739. * Options to be set when merging outputs from the default pipeline.
  136740. */
  136741. export class DepthOfFieldMergePostProcessOptions {
  136742. /**
  136743. * The original image to merge on top of
  136744. */
  136745. originalFromInput: PostProcess;
  136746. /**
  136747. * Parameters to perform the merge of the depth of field effect
  136748. */
  136749. depthOfField?: {
  136750. circleOfConfusion: PostProcess;
  136751. blurSteps: Array<PostProcess>;
  136752. };
  136753. /**
  136754. * Parameters to perform the merge of bloom effect
  136755. */
  136756. bloom?: {
  136757. blurred: PostProcess;
  136758. weight: number;
  136759. };
  136760. }
  136761. /**
  136762. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  136763. */
  136764. export class DepthOfFieldMergePostProcess extends PostProcess {
  136765. private blurSteps;
  136766. /**
  136767. * Creates a new instance of DepthOfFieldMergePostProcess
  136768. * @param name The name of the effect.
  136769. * @param originalFromInput Post process which's input will be used for the merge.
  136770. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  136771. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  136772. * @param options The required width/height ratio to downsize to before computing the render pass.
  136773. * @param camera The camera to apply the render pass to.
  136774. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136775. * @param engine The engine which the post process will be applied. (default: current engine)
  136776. * @param reusable If the post process can be reused on the same frame. (default: false)
  136777. * @param textureType Type of textures used when performing the post process. (default: 0)
  136778. * @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)
  136779. */
  136780. 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);
  136781. /**
  136782. * Updates the effect with the current post process compile time values and recompiles the shader.
  136783. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  136784. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  136785. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  136786. * @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
  136787. * @param onCompiled Called when the shader has been compiled.
  136788. * @param onError Called if there is an error when compiling a shader.
  136789. */
  136790. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  136791. }
  136792. }
  136793. declare module BABYLON {
  136794. /**
  136795. * Specifies the level of max blur that should be applied when using the depth of field effect
  136796. */
  136797. export enum DepthOfFieldEffectBlurLevel {
  136798. /**
  136799. * Subtle blur
  136800. */
  136801. Low = 0,
  136802. /**
  136803. * Medium blur
  136804. */
  136805. Medium = 1,
  136806. /**
  136807. * Large blur
  136808. */
  136809. High = 2
  136810. }
  136811. /**
  136812. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  136813. */
  136814. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  136815. private _circleOfConfusion;
  136816. /**
  136817. * @hidden Internal, blurs from high to low
  136818. */
  136819. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  136820. private _depthOfFieldBlurY;
  136821. private _dofMerge;
  136822. /**
  136823. * @hidden Internal post processes in depth of field effect
  136824. */
  136825. _effects: Array<PostProcess>;
  136826. /**
  136827. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  136828. */
  136829. set focalLength(value: number);
  136830. get focalLength(): number;
  136831. /**
  136832. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  136833. */
  136834. set fStop(value: number);
  136835. get fStop(): number;
  136836. /**
  136837. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  136838. */
  136839. set focusDistance(value: number);
  136840. get focusDistance(): number;
  136841. /**
  136842. * 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.
  136843. */
  136844. set lensSize(value: number);
  136845. get lensSize(): number;
  136846. /**
  136847. * Creates a new instance DepthOfFieldEffect
  136848. * @param scene The scene the effect belongs to.
  136849. * @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.
  136850. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  136851. * @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)
  136852. */
  136853. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  136854. /**
  136855. * Get the current class name of the current effet
  136856. * @returns "DepthOfFieldEffect"
  136857. */
  136858. getClassName(): string;
  136859. /**
  136860. * 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.
  136861. */
  136862. set depthTexture(value: RenderTargetTexture);
  136863. /**
  136864. * Disposes each of the internal effects for a given camera.
  136865. * @param camera The camera to dispose the effect on.
  136866. */
  136867. disposeEffects(camera: Camera): void;
  136868. /**
  136869. * @hidden Internal
  136870. */
  136871. _updateEffects(): void;
  136872. /**
  136873. * Internal
  136874. * @returns if all the contained post processes are ready.
  136875. * @hidden
  136876. */
  136877. _isReady(): boolean;
  136878. }
  136879. }
  136880. declare module BABYLON {
  136881. /** @hidden */
  136882. export var displayPassPixelShader: {
  136883. name: string;
  136884. shader: string;
  136885. };
  136886. }
  136887. declare module BABYLON {
  136888. /**
  136889. * DisplayPassPostProcess which produces an output the same as it's input
  136890. */
  136891. export class DisplayPassPostProcess extends PostProcess {
  136892. /**
  136893. * Creates the DisplayPassPostProcess
  136894. * @param name The name of the effect.
  136895. * @param options The required width/height ratio to downsize to before computing the render pass.
  136896. * @param camera The camera to apply the render pass to.
  136897. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136898. * @param engine The engine which the post process will be applied. (default: current engine)
  136899. * @param reusable If the post process can be reused on the same frame. (default: false)
  136900. */
  136901. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  136902. }
  136903. }
  136904. declare module BABYLON {
  136905. /** @hidden */
  136906. export var filterPixelShader: {
  136907. name: string;
  136908. shader: string;
  136909. };
  136910. }
  136911. declare module BABYLON {
  136912. /**
  136913. * Applies a kernel filter to the image
  136914. */
  136915. export class FilterPostProcess extends PostProcess {
  136916. /** The matrix to be applied to the image */
  136917. kernelMatrix: Matrix;
  136918. /**
  136919. *
  136920. * @param name The name of the effect.
  136921. * @param kernelMatrix The matrix to be applied to the image
  136922. * @param options The required width/height ratio to downsize to before computing the render pass.
  136923. * @param camera The camera to apply the render pass to.
  136924. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136925. * @param engine The engine which the post process will be applied. (default: current engine)
  136926. * @param reusable If the post process can be reused on the same frame. (default: false)
  136927. */
  136928. constructor(name: string,
  136929. /** The matrix to be applied to the image */
  136930. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  136931. }
  136932. }
  136933. declare module BABYLON {
  136934. /** @hidden */
  136935. export var fxaaPixelShader: {
  136936. name: string;
  136937. shader: string;
  136938. };
  136939. }
  136940. declare module BABYLON {
  136941. /** @hidden */
  136942. export var fxaaVertexShader: {
  136943. name: string;
  136944. shader: string;
  136945. };
  136946. }
  136947. declare module BABYLON {
  136948. /**
  136949. * Fxaa post process
  136950. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  136951. */
  136952. export class FxaaPostProcess extends PostProcess {
  136953. /** @hidden */
  136954. texelWidth: number;
  136955. /** @hidden */
  136956. texelHeight: number;
  136957. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  136958. private _getDefines;
  136959. }
  136960. }
  136961. declare module BABYLON {
  136962. /** @hidden */
  136963. export var grainPixelShader: {
  136964. name: string;
  136965. shader: string;
  136966. };
  136967. }
  136968. declare module BABYLON {
  136969. /**
  136970. * The GrainPostProcess adds noise to the image at mid luminance levels
  136971. */
  136972. export class GrainPostProcess extends PostProcess {
  136973. /**
  136974. * The intensity of the grain added (default: 30)
  136975. */
  136976. intensity: number;
  136977. /**
  136978. * If the grain should be randomized on every frame
  136979. */
  136980. animated: boolean;
  136981. /**
  136982. * Creates a new instance of @see GrainPostProcess
  136983. * @param name The name of the effect.
  136984. * @param options The required width/height ratio to downsize to before computing the render pass.
  136985. * @param camera The camera to apply the render pass to.
  136986. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136987. * @param engine The engine which the post process will be applied. (default: current engine)
  136988. * @param reusable If the post process can be reused on the same frame. (default: false)
  136989. * @param textureType Type of textures used when performing the post process. (default: 0)
  136990. * @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)
  136991. */
  136992. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  136993. }
  136994. }
  136995. declare module BABYLON {
  136996. /** @hidden */
  136997. export var highlightsPixelShader: {
  136998. name: string;
  136999. shader: string;
  137000. };
  137001. }
  137002. declare module BABYLON {
  137003. /**
  137004. * Extracts highlights from the image
  137005. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137006. */
  137007. export class HighlightsPostProcess extends PostProcess {
  137008. /**
  137009. * Extracts highlights from the image
  137010. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137011. * @param name The name of the effect.
  137012. * @param options The required width/height ratio to downsize to before computing the render pass.
  137013. * @param camera The camera to apply the render pass to.
  137014. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137015. * @param engine The engine which the post process will be applied. (default: current engine)
  137016. * @param reusable If the post process can be reused on the same frame. (default: false)
  137017. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  137018. */
  137019. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137020. }
  137021. }
  137022. declare module BABYLON {
  137023. /** @hidden */
  137024. export var mrtFragmentDeclaration: {
  137025. name: string;
  137026. shader: string;
  137027. };
  137028. }
  137029. declare module BABYLON {
  137030. /** @hidden */
  137031. export var geometryPixelShader: {
  137032. name: string;
  137033. shader: string;
  137034. };
  137035. }
  137036. declare module BABYLON {
  137037. /** @hidden */
  137038. export var geometryVertexShader: {
  137039. name: string;
  137040. shader: string;
  137041. };
  137042. }
  137043. declare module BABYLON {
  137044. /** @hidden */
  137045. interface ISavedTransformationMatrix {
  137046. world: Matrix;
  137047. viewProjection: Matrix;
  137048. }
  137049. /**
  137050. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  137051. */
  137052. export class GeometryBufferRenderer {
  137053. /**
  137054. * Constant used to retrieve the position texture index in the G-Buffer textures array
  137055. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  137056. */
  137057. static readonly POSITION_TEXTURE_TYPE: number;
  137058. /**
  137059. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  137060. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  137061. */
  137062. static readonly VELOCITY_TEXTURE_TYPE: number;
  137063. /**
  137064. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  137065. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  137066. */
  137067. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  137068. /**
  137069. * Dictionary used to store the previous transformation matrices of each rendered mesh
  137070. * in order to compute objects velocities when enableVelocity is set to "true"
  137071. * @hidden
  137072. */
  137073. _previousTransformationMatrices: {
  137074. [index: number]: ISavedTransformationMatrix;
  137075. };
  137076. /**
  137077. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  137078. * in order to compute objects velocities when enableVelocity is set to "true"
  137079. * @hidden
  137080. */
  137081. _previousBonesTransformationMatrices: {
  137082. [index: number]: Float32Array;
  137083. };
  137084. /**
  137085. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  137086. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  137087. */
  137088. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  137089. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  137090. renderTransparentMeshes: boolean;
  137091. private _scene;
  137092. private _multiRenderTarget;
  137093. private _ratio;
  137094. private _enablePosition;
  137095. private _enableVelocity;
  137096. private _enableReflectivity;
  137097. private _positionIndex;
  137098. private _velocityIndex;
  137099. private _reflectivityIndex;
  137100. protected _effect: Effect;
  137101. protected _cachedDefines: string;
  137102. /**
  137103. * Set the render list (meshes to be rendered) used in the G buffer.
  137104. */
  137105. set renderList(meshes: Mesh[]);
  137106. /**
  137107. * Gets wether or not G buffer are supported by the running hardware.
  137108. * This requires draw buffer supports
  137109. */
  137110. get isSupported(): boolean;
  137111. /**
  137112. * Returns the index of the given texture type in the G-Buffer textures array
  137113. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  137114. * @returns the index of the given texture type in the G-Buffer textures array
  137115. */
  137116. getTextureIndex(textureType: number): number;
  137117. /**
  137118. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  137119. */
  137120. get enablePosition(): boolean;
  137121. /**
  137122. * Sets whether or not objects positions are enabled for the G buffer.
  137123. */
  137124. set enablePosition(enable: boolean);
  137125. /**
  137126. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  137127. */
  137128. get enableVelocity(): boolean;
  137129. /**
  137130. * Sets wether or not objects velocities are enabled for the G buffer.
  137131. */
  137132. set enableVelocity(enable: boolean);
  137133. /**
  137134. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  137135. */
  137136. get enableReflectivity(): boolean;
  137137. /**
  137138. * Sets wether or not objects roughness are enabled for the G buffer.
  137139. */
  137140. set enableReflectivity(enable: boolean);
  137141. /**
  137142. * Gets the scene associated with the buffer.
  137143. */
  137144. get scene(): Scene;
  137145. /**
  137146. * Gets the ratio used by the buffer during its creation.
  137147. * How big is the buffer related to the main canvas.
  137148. */
  137149. get ratio(): number;
  137150. /** @hidden */
  137151. static _SceneComponentInitialization: (scene: Scene) => void;
  137152. /**
  137153. * Creates a new G Buffer for the scene
  137154. * @param scene The scene the buffer belongs to
  137155. * @param ratio How big is the buffer related to the main canvas.
  137156. */
  137157. constructor(scene: Scene, ratio?: number);
  137158. /**
  137159. * Checks wether everything is ready to render a submesh to the G buffer.
  137160. * @param subMesh the submesh to check readiness for
  137161. * @param useInstances is the mesh drawn using instance or not
  137162. * @returns true if ready otherwise false
  137163. */
  137164. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137165. /**
  137166. * Gets the current underlying G Buffer.
  137167. * @returns the buffer
  137168. */
  137169. getGBuffer(): MultiRenderTarget;
  137170. /**
  137171. * Gets the number of samples used to render the buffer (anti aliasing).
  137172. */
  137173. get samples(): number;
  137174. /**
  137175. * Sets the number of samples used to render the buffer (anti aliasing).
  137176. */
  137177. set samples(value: number);
  137178. /**
  137179. * Disposes the renderer and frees up associated resources.
  137180. */
  137181. dispose(): void;
  137182. protected _createRenderTargets(): void;
  137183. private _copyBonesTransformationMatrices;
  137184. }
  137185. }
  137186. declare module BABYLON {
  137187. interface Scene {
  137188. /** @hidden (Backing field) */
  137189. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  137190. /**
  137191. * Gets or Sets the current geometry buffer associated to the scene.
  137192. */
  137193. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  137194. /**
  137195. * Enables a GeometryBufferRender and associates it with the scene
  137196. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  137197. * @returns the GeometryBufferRenderer
  137198. */
  137199. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  137200. /**
  137201. * Disables the GeometryBufferRender associated with the scene
  137202. */
  137203. disableGeometryBufferRenderer(): void;
  137204. }
  137205. /**
  137206. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  137207. * in several rendering techniques.
  137208. */
  137209. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  137210. /**
  137211. * The component name helpful to identify the component in the list of scene components.
  137212. */
  137213. readonly name: string;
  137214. /**
  137215. * The scene the component belongs to.
  137216. */
  137217. scene: Scene;
  137218. /**
  137219. * Creates a new instance of the component for the given scene
  137220. * @param scene Defines the scene to register the component in
  137221. */
  137222. constructor(scene: Scene);
  137223. /**
  137224. * Registers the component in a given scene
  137225. */
  137226. register(): void;
  137227. /**
  137228. * Rebuilds the elements related to this component in case of
  137229. * context lost for instance.
  137230. */
  137231. rebuild(): void;
  137232. /**
  137233. * Disposes the component and the associated ressources
  137234. */
  137235. dispose(): void;
  137236. private _gatherRenderTargets;
  137237. }
  137238. }
  137239. declare module BABYLON {
  137240. /** @hidden */
  137241. export var motionBlurPixelShader: {
  137242. name: string;
  137243. shader: string;
  137244. };
  137245. }
  137246. declare module BABYLON {
  137247. /**
  137248. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  137249. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  137250. * As an example, all you have to do is to create the post-process:
  137251. * var mb = new BABYLON.MotionBlurPostProcess(
  137252. * 'mb', // The name of the effect.
  137253. * scene, // The scene containing the objects to blur according to their velocity.
  137254. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  137255. * camera // The camera to apply the render pass to.
  137256. * );
  137257. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  137258. */
  137259. export class MotionBlurPostProcess extends PostProcess {
  137260. /**
  137261. * Defines how much the image is blurred by the movement. Default value is equal to 1
  137262. */
  137263. motionStrength: number;
  137264. /**
  137265. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  137266. */
  137267. get motionBlurSamples(): number;
  137268. /**
  137269. * Sets the number of iterations to be used for motion blur quality
  137270. */
  137271. set motionBlurSamples(samples: number);
  137272. private _motionBlurSamples;
  137273. private _geometryBufferRenderer;
  137274. /**
  137275. * Creates a new instance MotionBlurPostProcess
  137276. * @param name The name of the effect.
  137277. * @param scene The scene containing the objects to blur according to their velocity.
  137278. * @param options The required width/height ratio to downsize to before computing the render pass.
  137279. * @param camera The camera to apply the render pass to.
  137280. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137281. * @param engine The engine which the post process will be applied. (default: current engine)
  137282. * @param reusable If the post process can be reused on the same frame. (default: false)
  137283. * @param textureType Type of textures used when performing the post process. (default: 0)
  137284. * @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)
  137285. */
  137286. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137287. /**
  137288. * Excludes the given skinned mesh from computing bones velocities.
  137289. * 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.
  137290. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  137291. */
  137292. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  137293. /**
  137294. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  137295. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  137296. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  137297. */
  137298. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  137299. /**
  137300. * Disposes the post process.
  137301. * @param camera The camera to dispose the post process on.
  137302. */
  137303. dispose(camera?: Camera): void;
  137304. }
  137305. }
  137306. declare module BABYLON {
  137307. /** @hidden */
  137308. export var refractionPixelShader: {
  137309. name: string;
  137310. shader: string;
  137311. };
  137312. }
  137313. declare module BABYLON {
  137314. /**
  137315. * Post process which applies a refractin texture
  137316. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  137317. */
  137318. export class RefractionPostProcess extends PostProcess {
  137319. /** the base color of the refraction (used to taint the rendering) */
  137320. color: Color3;
  137321. /** simulated refraction depth */
  137322. depth: number;
  137323. /** the coefficient of the base color (0 to remove base color tainting) */
  137324. colorLevel: number;
  137325. private _refTexture;
  137326. private _ownRefractionTexture;
  137327. /**
  137328. * Gets or sets the refraction texture
  137329. * Please note that you are responsible for disposing the texture if you set it manually
  137330. */
  137331. get refractionTexture(): Texture;
  137332. set refractionTexture(value: Texture);
  137333. /**
  137334. * Initializes the RefractionPostProcess
  137335. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  137336. * @param name The name of the effect.
  137337. * @param refractionTextureUrl Url of the refraction texture to use
  137338. * @param color the base color of the refraction (used to taint the rendering)
  137339. * @param depth simulated refraction depth
  137340. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  137341. * @param camera The camera to apply the render pass to.
  137342. * @param options The required width/height ratio to downsize to before computing the render pass.
  137343. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137344. * @param engine The engine which the post process will be applied. (default: current engine)
  137345. * @param reusable If the post process can be reused on the same frame. (default: false)
  137346. */
  137347. constructor(name: string, refractionTextureUrl: string,
  137348. /** the base color of the refraction (used to taint the rendering) */
  137349. color: Color3,
  137350. /** simulated refraction depth */
  137351. depth: number,
  137352. /** the coefficient of the base color (0 to remove base color tainting) */
  137353. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137354. /**
  137355. * Disposes of the post process
  137356. * @param camera Camera to dispose post process on
  137357. */
  137358. dispose(camera: Camera): void;
  137359. }
  137360. }
  137361. declare module BABYLON {
  137362. /** @hidden */
  137363. export var sharpenPixelShader: {
  137364. name: string;
  137365. shader: string;
  137366. };
  137367. }
  137368. declare module BABYLON {
  137369. /**
  137370. * The SharpenPostProcess applies a sharpen kernel to every pixel
  137371. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  137372. */
  137373. export class SharpenPostProcess extends PostProcess {
  137374. /**
  137375. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  137376. */
  137377. colorAmount: number;
  137378. /**
  137379. * How much sharpness should be applied (default: 0.3)
  137380. */
  137381. edgeAmount: number;
  137382. /**
  137383. * Creates a new instance ConvolutionPostProcess
  137384. * @param name The name of the effect.
  137385. * @param options The required width/height ratio to downsize to before computing the render pass.
  137386. * @param camera The camera to apply the render pass to.
  137387. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137388. * @param engine The engine which the post process will be applied. (default: current engine)
  137389. * @param reusable If the post process can be reused on the same frame. (default: false)
  137390. * @param textureType Type of textures used when performing the post process. (default: 0)
  137391. * @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)
  137392. */
  137393. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137394. }
  137395. }
  137396. declare module BABYLON {
  137397. /**
  137398. * PostProcessRenderPipeline
  137399. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137400. */
  137401. export class PostProcessRenderPipeline {
  137402. private engine;
  137403. private _renderEffects;
  137404. private _renderEffectsForIsolatedPass;
  137405. /**
  137406. * List of inspectable custom properties (used by the Inspector)
  137407. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  137408. */
  137409. inspectableCustomProperties: IInspectable[];
  137410. /**
  137411. * @hidden
  137412. */
  137413. protected _cameras: Camera[];
  137414. /** @hidden */
  137415. _name: string;
  137416. /**
  137417. * Gets pipeline name
  137418. */
  137419. get name(): string;
  137420. /** Gets the list of attached cameras */
  137421. get cameras(): Camera[];
  137422. /**
  137423. * Initializes a PostProcessRenderPipeline
  137424. * @param engine engine to add the pipeline to
  137425. * @param name name of the pipeline
  137426. */
  137427. constructor(engine: Engine, name: string);
  137428. /**
  137429. * Gets the class name
  137430. * @returns "PostProcessRenderPipeline"
  137431. */
  137432. getClassName(): string;
  137433. /**
  137434. * If all the render effects in the pipeline are supported
  137435. */
  137436. get isSupported(): boolean;
  137437. /**
  137438. * Adds an effect to the pipeline
  137439. * @param renderEffect the effect to add
  137440. */
  137441. addEffect(renderEffect: PostProcessRenderEffect): void;
  137442. /** @hidden */
  137443. _rebuild(): void;
  137444. /** @hidden */
  137445. _enableEffect(renderEffectName: string, cameras: Camera): void;
  137446. /** @hidden */
  137447. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  137448. /** @hidden */
  137449. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  137450. /** @hidden */
  137451. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  137452. /** @hidden */
  137453. _attachCameras(cameras: Camera, unique: boolean): void;
  137454. /** @hidden */
  137455. _attachCameras(cameras: Camera[], unique: boolean): void;
  137456. /** @hidden */
  137457. _detachCameras(cameras: Camera): void;
  137458. /** @hidden */
  137459. _detachCameras(cameras: Nullable<Camera[]>): void;
  137460. /** @hidden */
  137461. _update(): void;
  137462. /** @hidden */
  137463. _reset(): void;
  137464. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  137465. /**
  137466. * Disposes of the pipeline
  137467. */
  137468. dispose(): void;
  137469. }
  137470. }
  137471. declare module BABYLON {
  137472. /**
  137473. * PostProcessRenderPipelineManager class
  137474. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137475. */
  137476. export class PostProcessRenderPipelineManager {
  137477. private _renderPipelines;
  137478. /**
  137479. * Initializes a PostProcessRenderPipelineManager
  137480. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137481. */
  137482. constructor();
  137483. /**
  137484. * Gets the list of supported render pipelines
  137485. */
  137486. get supportedPipelines(): PostProcessRenderPipeline[];
  137487. /**
  137488. * Adds a pipeline to the manager
  137489. * @param renderPipeline The pipeline to add
  137490. */
  137491. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  137492. /**
  137493. * Attaches a camera to the pipeline
  137494. * @param renderPipelineName The name of the pipeline to attach to
  137495. * @param cameras the camera to attach
  137496. * @param unique if the camera can be attached multiple times to the pipeline
  137497. */
  137498. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  137499. /**
  137500. * Detaches a camera from the pipeline
  137501. * @param renderPipelineName The name of the pipeline to detach from
  137502. * @param cameras the camera to detach
  137503. */
  137504. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  137505. /**
  137506. * Enables an effect by name on a pipeline
  137507. * @param renderPipelineName the name of the pipeline to enable the effect in
  137508. * @param renderEffectName the name of the effect to enable
  137509. * @param cameras the cameras that the effect should be enabled on
  137510. */
  137511. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  137512. /**
  137513. * Disables an effect by name on a pipeline
  137514. * @param renderPipelineName the name of the pipeline to disable the effect in
  137515. * @param renderEffectName the name of the effect to disable
  137516. * @param cameras the cameras that the effect should be disabled on
  137517. */
  137518. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  137519. /**
  137520. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  137521. */
  137522. update(): void;
  137523. /** @hidden */
  137524. _rebuild(): void;
  137525. /**
  137526. * Disposes of the manager and pipelines
  137527. */
  137528. dispose(): void;
  137529. }
  137530. }
  137531. declare module BABYLON {
  137532. interface Scene {
  137533. /** @hidden (Backing field) */
  137534. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  137535. /**
  137536. * Gets the postprocess render pipeline manager
  137537. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137538. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  137539. */
  137540. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  137541. }
  137542. /**
  137543. * Defines the Render Pipeline scene component responsible to rendering pipelines
  137544. */
  137545. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  137546. /**
  137547. * The component name helpfull to identify the component in the list of scene components.
  137548. */
  137549. readonly name: string;
  137550. /**
  137551. * The scene the component belongs to.
  137552. */
  137553. scene: Scene;
  137554. /**
  137555. * Creates a new instance of the component for the given scene
  137556. * @param scene Defines the scene to register the component in
  137557. */
  137558. constructor(scene: Scene);
  137559. /**
  137560. * Registers the component in a given scene
  137561. */
  137562. register(): void;
  137563. /**
  137564. * Rebuilds the elements related to this component in case of
  137565. * context lost for instance.
  137566. */
  137567. rebuild(): void;
  137568. /**
  137569. * Disposes the component and the associated ressources
  137570. */
  137571. dispose(): void;
  137572. private _gatherRenderTargets;
  137573. }
  137574. }
  137575. declare module BABYLON {
  137576. /**
  137577. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  137578. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  137579. */
  137580. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  137581. private _scene;
  137582. private _camerasToBeAttached;
  137583. /**
  137584. * ID of the sharpen post process,
  137585. */
  137586. private readonly SharpenPostProcessId;
  137587. /**
  137588. * @ignore
  137589. * ID of the image processing post process;
  137590. */
  137591. readonly ImageProcessingPostProcessId: string;
  137592. /**
  137593. * @ignore
  137594. * ID of the Fast Approximate Anti-Aliasing post process;
  137595. */
  137596. readonly FxaaPostProcessId: string;
  137597. /**
  137598. * ID of the chromatic aberration post process,
  137599. */
  137600. private readonly ChromaticAberrationPostProcessId;
  137601. /**
  137602. * ID of the grain post process
  137603. */
  137604. private readonly GrainPostProcessId;
  137605. /**
  137606. * Sharpen post process which will apply a sharpen convolution to enhance edges
  137607. */
  137608. sharpen: SharpenPostProcess;
  137609. private _sharpenEffect;
  137610. private bloom;
  137611. /**
  137612. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  137613. */
  137614. depthOfField: DepthOfFieldEffect;
  137615. /**
  137616. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  137617. */
  137618. fxaa: FxaaPostProcess;
  137619. /**
  137620. * Image post processing pass used to perform operations such as tone mapping or color grading.
  137621. */
  137622. imageProcessing: ImageProcessingPostProcess;
  137623. /**
  137624. * Chromatic aberration post process which will shift rgb colors in the image
  137625. */
  137626. chromaticAberration: ChromaticAberrationPostProcess;
  137627. private _chromaticAberrationEffect;
  137628. /**
  137629. * Grain post process which add noise to the image
  137630. */
  137631. grain: GrainPostProcess;
  137632. private _grainEffect;
  137633. /**
  137634. * Glow post process which adds a glow to emissive areas of the image
  137635. */
  137636. private _glowLayer;
  137637. /**
  137638. * Animations which can be used to tweak settings over a period of time
  137639. */
  137640. animations: Animation[];
  137641. private _imageProcessingConfigurationObserver;
  137642. private _sharpenEnabled;
  137643. private _bloomEnabled;
  137644. private _depthOfFieldEnabled;
  137645. private _depthOfFieldBlurLevel;
  137646. private _fxaaEnabled;
  137647. private _imageProcessingEnabled;
  137648. private _defaultPipelineTextureType;
  137649. private _bloomScale;
  137650. private _chromaticAberrationEnabled;
  137651. private _grainEnabled;
  137652. private _buildAllowed;
  137653. /**
  137654. * Gets active scene
  137655. */
  137656. get scene(): Scene;
  137657. /**
  137658. * Enable or disable the sharpen process from the pipeline
  137659. */
  137660. set sharpenEnabled(enabled: boolean);
  137661. get sharpenEnabled(): boolean;
  137662. private _resizeObserver;
  137663. private _hardwareScaleLevel;
  137664. private _bloomKernel;
  137665. /**
  137666. * Specifies the size of the bloom blur kernel, relative to the final output size
  137667. */
  137668. get bloomKernel(): number;
  137669. set bloomKernel(value: number);
  137670. /**
  137671. * Specifies the weight of the bloom in the final rendering
  137672. */
  137673. private _bloomWeight;
  137674. /**
  137675. * Specifies the luma threshold for the area that will be blurred by the bloom
  137676. */
  137677. private _bloomThreshold;
  137678. private _hdr;
  137679. /**
  137680. * The strength of the bloom.
  137681. */
  137682. set bloomWeight(value: number);
  137683. get bloomWeight(): number;
  137684. /**
  137685. * The strength of the bloom.
  137686. */
  137687. set bloomThreshold(value: number);
  137688. get bloomThreshold(): number;
  137689. /**
  137690. * The scale of the bloom, lower value will provide better performance.
  137691. */
  137692. set bloomScale(value: number);
  137693. get bloomScale(): number;
  137694. /**
  137695. * Enable or disable the bloom from the pipeline
  137696. */
  137697. set bloomEnabled(enabled: boolean);
  137698. get bloomEnabled(): boolean;
  137699. private _rebuildBloom;
  137700. /**
  137701. * If the depth of field is enabled.
  137702. */
  137703. get depthOfFieldEnabled(): boolean;
  137704. set depthOfFieldEnabled(enabled: boolean);
  137705. /**
  137706. * Blur level of the depth of field effect. (Higher blur will effect performance)
  137707. */
  137708. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  137709. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  137710. /**
  137711. * If the anti aliasing is enabled.
  137712. */
  137713. set fxaaEnabled(enabled: boolean);
  137714. get fxaaEnabled(): boolean;
  137715. private _samples;
  137716. /**
  137717. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  137718. */
  137719. set samples(sampleCount: number);
  137720. get samples(): number;
  137721. /**
  137722. * If image processing is enabled.
  137723. */
  137724. set imageProcessingEnabled(enabled: boolean);
  137725. get imageProcessingEnabled(): boolean;
  137726. /**
  137727. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  137728. */
  137729. set glowLayerEnabled(enabled: boolean);
  137730. get glowLayerEnabled(): boolean;
  137731. /**
  137732. * Gets the glow layer (or null if not defined)
  137733. */
  137734. get glowLayer(): Nullable<GlowLayer>;
  137735. /**
  137736. * Enable or disable the chromaticAberration process from the pipeline
  137737. */
  137738. set chromaticAberrationEnabled(enabled: boolean);
  137739. get chromaticAberrationEnabled(): boolean;
  137740. /**
  137741. * Enable or disable the grain process from the pipeline
  137742. */
  137743. set grainEnabled(enabled: boolean);
  137744. get grainEnabled(): boolean;
  137745. /**
  137746. * @constructor
  137747. * @param name - The rendering pipeline name (default: "")
  137748. * @param hdr - If high dynamic range textures should be used (default: true)
  137749. * @param scene - The scene linked to this pipeline (default: the last created scene)
  137750. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  137751. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  137752. */
  137753. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  137754. /**
  137755. * Get the class name
  137756. * @returns "DefaultRenderingPipeline"
  137757. */
  137758. getClassName(): string;
  137759. /**
  137760. * Force the compilation of the entire pipeline.
  137761. */
  137762. prepare(): void;
  137763. private _hasCleared;
  137764. private _prevPostProcess;
  137765. private _prevPrevPostProcess;
  137766. private _setAutoClearAndTextureSharing;
  137767. private _depthOfFieldSceneObserver;
  137768. private _buildPipeline;
  137769. private _disposePostProcesses;
  137770. /**
  137771. * Adds a camera to the pipeline
  137772. * @param camera the camera to be added
  137773. */
  137774. addCamera(camera: Camera): void;
  137775. /**
  137776. * Removes a camera from the pipeline
  137777. * @param camera the camera to remove
  137778. */
  137779. removeCamera(camera: Camera): void;
  137780. /**
  137781. * Dispose of the pipeline and stop all post processes
  137782. */
  137783. dispose(): void;
  137784. /**
  137785. * Serialize the rendering pipeline (Used when exporting)
  137786. * @returns the serialized object
  137787. */
  137788. serialize(): any;
  137789. /**
  137790. * Parse the serialized pipeline
  137791. * @param source Source pipeline.
  137792. * @param scene The scene to load the pipeline to.
  137793. * @param rootUrl The URL of the serialized pipeline.
  137794. * @returns An instantiated pipeline from the serialized object.
  137795. */
  137796. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  137797. }
  137798. }
  137799. declare module BABYLON {
  137800. /** @hidden */
  137801. export var lensHighlightsPixelShader: {
  137802. name: string;
  137803. shader: string;
  137804. };
  137805. }
  137806. declare module BABYLON {
  137807. /** @hidden */
  137808. export var depthOfFieldPixelShader: {
  137809. name: string;
  137810. shader: string;
  137811. };
  137812. }
  137813. declare module BABYLON {
  137814. /**
  137815. * BABYLON.JS Chromatic Aberration GLSL Shader
  137816. * Author: Olivier Guyot
  137817. * Separates very slightly R, G and B colors on the edges of the screen
  137818. * Inspired by Francois Tarlier & Martins Upitis
  137819. */
  137820. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  137821. /**
  137822. * @ignore
  137823. * The chromatic aberration PostProcess id in the pipeline
  137824. */
  137825. LensChromaticAberrationEffect: string;
  137826. /**
  137827. * @ignore
  137828. * The highlights enhancing PostProcess id in the pipeline
  137829. */
  137830. HighlightsEnhancingEffect: string;
  137831. /**
  137832. * @ignore
  137833. * The depth-of-field PostProcess id in the pipeline
  137834. */
  137835. LensDepthOfFieldEffect: string;
  137836. private _scene;
  137837. private _depthTexture;
  137838. private _grainTexture;
  137839. private _chromaticAberrationPostProcess;
  137840. private _highlightsPostProcess;
  137841. private _depthOfFieldPostProcess;
  137842. private _edgeBlur;
  137843. private _grainAmount;
  137844. private _chromaticAberration;
  137845. private _distortion;
  137846. private _highlightsGain;
  137847. private _highlightsThreshold;
  137848. private _dofDistance;
  137849. private _dofAperture;
  137850. private _dofDarken;
  137851. private _dofPentagon;
  137852. private _blurNoise;
  137853. /**
  137854. * @constructor
  137855. *
  137856. * Effect parameters are as follow:
  137857. * {
  137858. * chromatic_aberration: number; // from 0 to x (1 for realism)
  137859. * edge_blur: number; // from 0 to x (1 for realism)
  137860. * distortion: number; // from 0 to x (1 for realism)
  137861. * grain_amount: number; // from 0 to 1
  137862. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  137863. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  137864. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  137865. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  137866. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  137867. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  137868. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  137869. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  137870. * }
  137871. * Note: if an effect parameter is unset, effect is disabled
  137872. *
  137873. * @param name The rendering pipeline name
  137874. * @param parameters - An object containing all parameters (see above)
  137875. * @param scene The scene linked to this pipeline
  137876. * @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)
  137877. * @param cameras The array of cameras that the rendering pipeline will be attached to
  137878. */
  137879. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  137880. /**
  137881. * Get the class name
  137882. * @returns "LensRenderingPipeline"
  137883. */
  137884. getClassName(): string;
  137885. /**
  137886. * Gets associated scene
  137887. */
  137888. get scene(): Scene;
  137889. /**
  137890. * Gets or sets the edge blur
  137891. */
  137892. get edgeBlur(): number;
  137893. set edgeBlur(value: number);
  137894. /**
  137895. * Gets or sets the grain amount
  137896. */
  137897. get grainAmount(): number;
  137898. set grainAmount(value: number);
  137899. /**
  137900. * Gets or sets the chromatic aberration amount
  137901. */
  137902. get chromaticAberration(): number;
  137903. set chromaticAberration(value: number);
  137904. /**
  137905. * Gets or sets the depth of field aperture
  137906. */
  137907. get dofAperture(): number;
  137908. set dofAperture(value: number);
  137909. /**
  137910. * Gets or sets the edge distortion
  137911. */
  137912. get edgeDistortion(): number;
  137913. set edgeDistortion(value: number);
  137914. /**
  137915. * Gets or sets the depth of field distortion
  137916. */
  137917. get dofDistortion(): number;
  137918. set dofDistortion(value: number);
  137919. /**
  137920. * Gets or sets the darken out of focus amount
  137921. */
  137922. get darkenOutOfFocus(): number;
  137923. set darkenOutOfFocus(value: number);
  137924. /**
  137925. * Gets or sets a boolean indicating if blur noise is enabled
  137926. */
  137927. get blurNoise(): boolean;
  137928. set blurNoise(value: boolean);
  137929. /**
  137930. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  137931. */
  137932. get pentagonBokeh(): boolean;
  137933. set pentagonBokeh(value: boolean);
  137934. /**
  137935. * Gets or sets the highlight grain amount
  137936. */
  137937. get highlightsGain(): number;
  137938. set highlightsGain(value: number);
  137939. /**
  137940. * Gets or sets the highlight threshold
  137941. */
  137942. get highlightsThreshold(): number;
  137943. set highlightsThreshold(value: number);
  137944. /**
  137945. * Sets the amount of blur at the edges
  137946. * @param amount blur amount
  137947. */
  137948. setEdgeBlur(amount: number): void;
  137949. /**
  137950. * Sets edge blur to 0
  137951. */
  137952. disableEdgeBlur(): void;
  137953. /**
  137954. * Sets the amout of grain
  137955. * @param amount Amount of grain
  137956. */
  137957. setGrainAmount(amount: number): void;
  137958. /**
  137959. * Set grain amount to 0
  137960. */
  137961. disableGrain(): void;
  137962. /**
  137963. * Sets the chromatic aberration amount
  137964. * @param amount amount of chromatic aberration
  137965. */
  137966. setChromaticAberration(amount: number): void;
  137967. /**
  137968. * Sets chromatic aberration amount to 0
  137969. */
  137970. disableChromaticAberration(): void;
  137971. /**
  137972. * Sets the EdgeDistortion amount
  137973. * @param amount amount of EdgeDistortion
  137974. */
  137975. setEdgeDistortion(amount: number): void;
  137976. /**
  137977. * Sets edge distortion to 0
  137978. */
  137979. disableEdgeDistortion(): void;
  137980. /**
  137981. * Sets the FocusDistance amount
  137982. * @param amount amount of FocusDistance
  137983. */
  137984. setFocusDistance(amount: number): void;
  137985. /**
  137986. * Disables depth of field
  137987. */
  137988. disableDepthOfField(): void;
  137989. /**
  137990. * Sets the Aperture amount
  137991. * @param amount amount of Aperture
  137992. */
  137993. setAperture(amount: number): void;
  137994. /**
  137995. * Sets the DarkenOutOfFocus amount
  137996. * @param amount amount of DarkenOutOfFocus
  137997. */
  137998. setDarkenOutOfFocus(amount: number): void;
  137999. private _pentagonBokehIsEnabled;
  138000. /**
  138001. * Creates a pentagon bokeh effect
  138002. */
  138003. enablePentagonBokeh(): void;
  138004. /**
  138005. * Disables the pentagon bokeh effect
  138006. */
  138007. disablePentagonBokeh(): void;
  138008. /**
  138009. * Enables noise blur
  138010. */
  138011. enableNoiseBlur(): void;
  138012. /**
  138013. * Disables noise blur
  138014. */
  138015. disableNoiseBlur(): void;
  138016. /**
  138017. * Sets the HighlightsGain amount
  138018. * @param amount amount of HighlightsGain
  138019. */
  138020. setHighlightsGain(amount: number): void;
  138021. /**
  138022. * Sets the HighlightsThreshold amount
  138023. * @param amount amount of HighlightsThreshold
  138024. */
  138025. setHighlightsThreshold(amount: number): void;
  138026. /**
  138027. * Disables highlights
  138028. */
  138029. disableHighlights(): void;
  138030. /**
  138031. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  138032. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  138033. */
  138034. dispose(disableDepthRender?: boolean): void;
  138035. private _createChromaticAberrationPostProcess;
  138036. private _createHighlightsPostProcess;
  138037. private _createDepthOfFieldPostProcess;
  138038. private _createGrainTexture;
  138039. }
  138040. }
  138041. declare module BABYLON {
  138042. /** @hidden */
  138043. export var ssao2PixelShader: {
  138044. name: string;
  138045. shader: string;
  138046. };
  138047. }
  138048. declare module BABYLON {
  138049. /** @hidden */
  138050. export var ssaoCombinePixelShader: {
  138051. name: string;
  138052. shader: string;
  138053. };
  138054. }
  138055. declare module BABYLON {
  138056. /**
  138057. * Render pipeline to produce ssao effect
  138058. */
  138059. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  138060. /**
  138061. * @ignore
  138062. * The PassPostProcess id in the pipeline that contains the original scene color
  138063. */
  138064. SSAOOriginalSceneColorEffect: string;
  138065. /**
  138066. * @ignore
  138067. * The SSAO PostProcess id in the pipeline
  138068. */
  138069. SSAORenderEffect: string;
  138070. /**
  138071. * @ignore
  138072. * The horizontal blur PostProcess id in the pipeline
  138073. */
  138074. SSAOBlurHRenderEffect: string;
  138075. /**
  138076. * @ignore
  138077. * The vertical blur PostProcess id in the pipeline
  138078. */
  138079. SSAOBlurVRenderEffect: string;
  138080. /**
  138081. * @ignore
  138082. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  138083. */
  138084. SSAOCombineRenderEffect: string;
  138085. /**
  138086. * The output strength of the SSAO post-process. Default value is 1.0.
  138087. */
  138088. totalStrength: number;
  138089. /**
  138090. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  138091. */
  138092. maxZ: number;
  138093. /**
  138094. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  138095. */
  138096. minZAspect: number;
  138097. private _samples;
  138098. /**
  138099. * Number of samples used for the SSAO calculations. Default value is 8
  138100. */
  138101. set samples(n: number);
  138102. get samples(): number;
  138103. private _textureSamples;
  138104. /**
  138105. * Number of samples to use for antialiasing
  138106. */
  138107. set textureSamples(n: number);
  138108. get textureSamples(): number;
  138109. /**
  138110. * Ratio object used for SSAO ratio and blur ratio
  138111. */
  138112. private _ratio;
  138113. /**
  138114. * Dynamically generated sphere sampler.
  138115. */
  138116. private _sampleSphere;
  138117. /**
  138118. * Blur filter offsets
  138119. */
  138120. private _samplerOffsets;
  138121. private _expensiveBlur;
  138122. /**
  138123. * If bilateral blur should be used
  138124. */
  138125. set expensiveBlur(b: boolean);
  138126. get expensiveBlur(): boolean;
  138127. /**
  138128. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  138129. */
  138130. radius: number;
  138131. /**
  138132. * The base color of the SSAO post-process
  138133. * The final result is "base + ssao" between [0, 1]
  138134. */
  138135. base: number;
  138136. /**
  138137. * Support test.
  138138. */
  138139. static get IsSupported(): boolean;
  138140. private _scene;
  138141. private _depthTexture;
  138142. private _normalTexture;
  138143. private _randomTexture;
  138144. private _originalColorPostProcess;
  138145. private _ssaoPostProcess;
  138146. private _blurHPostProcess;
  138147. private _blurVPostProcess;
  138148. private _ssaoCombinePostProcess;
  138149. /**
  138150. * Gets active scene
  138151. */
  138152. get scene(): Scene;
  138153. /**
  138154. * @constructor
  138155. * @param name The rendering pipeline name
  138156. * @param scene The scene linked to this pipeline
  138157. * @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 }
  138158. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138159. */
  138160. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  138161. /**
  138162. * Get the class name
  138163. * @returns "SSAO2RenderingPipeline"
  138164. */
  138165. getClassName(): string;
  138166. /**
  138167. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  138168. */
  138169. dispose(disableGeometryBufferRenderer?: boolean): void;
  138170. private _createBlurPostProcess;
  138171. /** @hidden */
  138172. _rebuild(): void;
  138173. private _bits;
  138174. private _radicalInverse_VdC;
  138175. private _hammersley;
  138176. private _hemisphereSample_uniform;
  138177. private _generateHemisphere;
  138178. private _createSSAOPostProcess;
  138179. private _createSSAOCombinePostProcess;
  138180. private _createRandomTexture;
  138181. /**
  138182. * Serialize the rendering pipeline (Used when exporting)
  138183. * @returns the serialized object
  138184. */
  138185. serialize(): any;
  138186. /**
  138187. * Parse the serialized pipeline
  138188. * @param source Source pipeline.
  138189. * @param scene The scene to load the pipeline to.
  138190. * @param rootUrl The URL of the serialized pipeline.
  138191. * @returns An instantiated pipeline from the serialized object.
  138192. */
  138193. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  138194. }
  138195. }
  138196. declare module BABYLON {
  138197. /** @hidden */
  138198. export var ssaoPixelShader: {
  138199. name: string;
  138200. shader: string;
  138201. };
  138202. }
  138203. declare module BABYLON {
  138204. /**
  138205. * Render pipeline to produce ssao effect
  138206. */
  138207. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  138208. /**
  138209. * @ignore
  138210. * The PassPostProcess id in the pipeline that contains the original scene color
  138211. */
  138212. SSAOOriginalSceneColorEffect: string;
  138213. /**
  138214. * @ignore
  138215. * The SSAO PostProcess id in the pipeline
  138216. */
  138217. SSAORenderEffect: string;
  138218. /**
  138219. * @ignore
  138220. * The horizontal blur PostProcess id in the pipeline
  138221. */
  138222. SSAOBlurHRenderEffect: string;
  138223. /**
  138224. * @ignore
  138225. * The vertical blur PostProcess id in the pipeline
  138226. */
  138227. SSAOBlurVRenderEffect: string;
  138228. /**
  138229. * @ignore
  138230. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  138231. */
  138232. SSAOCombineRenderEffect: string;
  138233. /**
  138234. * The output strength of the SSAO post-process. Default value is 1.0.
  138235. */
  138236. totalStrength: number;
  138237. /**
  138238. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  138239. */
  138240. radius: number;
  138241. /**
  138242. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  138243. * Must not be equal to fallOff and superior to fallOff.
  138244. * Default value is 0.0075
  138245. */
  138246. area: number;
  138247. /**
  138248. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  138249. * Must not be equal to area and inferior to area.
  138250. * Default value is 0.000001
  138251. */
  138252. fallOff: number;
  138253. /**
  138254. * The base color of the SSAO post-process
  138255. * The final result is "base + ssao" between [0, 1]
  138256. */
  138257. base: number;
  138258. private _scene;
  138259. private _depthTexture;
  138260. private _randomTexture;
  138261. private _originalColorPostProcess;
  138262. private _ssaoPostProcess;
  138263. private _blurHPostProcess;
  138264. private _blurVPostProcess;
  138265. private _ssaoCombinePostProcess;
  138266. private _firstUpdate;
  138267. /**
  138268. * Gets active scene
  138269. */
  138270. get scene(): Scene;
  138271. /**
  138272. * @constructor
  138273. * @param name - The rendering pipeline name
  138274. * @param scene - The scene linked to this pipeline
  138275. * @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 }
  138276. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  138277. */
  138278. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  138279. /**
  138280. * Get the class name
  138281. * @returns "SSAORenderingPipeline"
  138282. */
  138283. getClassName(): string;
  138284. /**
  138285. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  138286. */
  138287. dispose(disableDepthRender?: boolean): void;
  138288. private _createBlurPostProcess;
  138289. /** @hidden */
  138290. _rebuild(): void;
  138291. private _createSSAOPostProcess;
  138292. private _createSSAOCombinePostProcess;
  138293. private _createRandomTexture;
  138294. }
  138295. }
  138296. declare module BABYLON {
  138297. /** @hidden */
  138298. export var screenSpaceReflectionPixelShader: {
  138299. name: string;
  138300. shader: string;
  138301. };
  138302. }
  138303. declare module BABYLON {
  138304. /**
  138305. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  138306. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  138307. */
  138308. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  138309. /**
  138310. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  138311. */
  138312. threshold: number;
  138313. /**
  138314. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  138315. */
  138316. strength: number;
  138317. /**
  138318. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  138319. */
  138320. reflectionSpecularFalloffExponent: number;
  138321. /**
  138322. * Gets or sets the step size used to iterate until the effect finds the color of the reflection's pixel. Typically in interval [0.1, 1.0]
  138323. */
  138324. step: number;
  138325. /**
  138326. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  138327. */
  138328. roughnessFactor: number;
  138329. private _geometryBufferRenderer;
  138330. private _enableSmoothReflections;
  138331. private _reflectionSamples;
  138332. private _smoothSteps;
  138333. /**
  138334. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  138335. * @param name The name of the effect.
  138336. * @param scene The scene containing the objects to calculate reflections.
  138337. * @param options The required width/height ratio to downsize to before computing the render pass.
  138338. * @param camera The camera to apply the render pass to.
  138339. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138340. * @param engine The engine which the post process will be applied. (default: current engine)
  138341. * @param reusable If the post process can be reused on the same frame. (default: false)
  138342. * @param textureType Type of textures used when performing the post process. (default: 0)
  138343. * @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)
  138344. */
  138345. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138346. /**
  138347. * Gets wether or not smoothing reflections is enabled.
  138348. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  138349. */
  138350. get enableSmoothReflections(): boolean;
  138351. /**
  138352. * Sets wether or not smoothing reflections is enabled.
  138353. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  138354. */
  138355. set enableSmoothReflections(enabled: boolean);
  138356. /**
  138357. * Gets the number of samples taken while computing reflections. More samples count is high,
  138358. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  138359. */
  138360. get reflectionSamples(): number;
  138361. /**
  138362. * Sets the number of samples taken while computing reflections. More samples count is high,
  138363. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  138364. */
  138365. set reflectionSamples(samples: number);
  138366. /**
  138367. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  138368. * more the post-process will require GPU power and can generate a drop in FPS.
  138369. * Default value (5.0) work pretty well in all cases but can be adjusted.
  138370. */
  138371. get smoothSteps(): number;
  138372. set smoothSteps(steps: number);
  138373. private _updateEffectDefines;
  138374. }
  138375. }
  138376. declare module BABYLON {
  138377. /** @hidden */
  138378. export var standardPixelShader: {
  138379. name: string;
  138380. shader: string;
  138381. };
  138382. }
  138383. declare module BABYLON {
  138384. /**
  138385. * Standard rendering pipeline
  138386. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  138387. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  138388. */
  138389. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  138390. /**
  138391. * Public members
  138392. */
  138393. /**
  138394. * Post-process which contains the original scene color before the pipeline applies all the effects
  138395. */
  138396. originalPostProcess: Nullable<PostProcess>;
  138397. /**
  138398. * Post-process used to down scale an image x4
  138399. */
  138400. downSampleX4PostProcess: Nullable<PostProcess>;
  138401. /**
  138402. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  138403. */
  138404. brightPassPostProcess: Nullable<PostProcess>;
  138405. /**
  138406. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  138407. */
  138408. blurHPostProcesses: PostProcess[];
  138409. /**
  138410. * Post-process array storing all the vertical blur post-processes used by the pipeline
  138411. */
  138412. blurVPostProcesses: PostProcess[];
  138413. /**
  138414. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  138415. */
  138416. textureAdderPostProcess: Nullable<PostProcess>;
  138417. /**
  138418. * Post-process used to create volumetric lighting effect
  138419. */
  138420. volumetricLightPostProcess: Nullable<PostProcess>;
  138421. /**
  138422. * Post-process used to smooth the previous volumetric light post-process on the X axis
  138423. */
  138424. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  138425. /**
  138426. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  138427. */
  138428. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  138429. /**
  138430. * Post-process used to merge the volumetric light effect and the real scene color
  138431. */
  138432. volumetricLightMergePostProces: Nullable<PostProcess>;
  138433. /**
  138434. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  138435. */
  138436. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  138437. /**
  138438. * Base post-process used to calculate the average luminance of the final image for HDR
  138439. */
  138440. luminancePostProcess: Nullable<PostProcess>;
  138441. /**
  138442. * Post-processes used to create down sample post-processes in order to get
  138443. * the average luminance of the final image for HDR
  138444. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  138445. */
  138446. luminanceDownSamplePostProcesses: PostProcess[];
  138447. /**
  138448. * Post-process used to create a HDR effect (light adaptation)
  138449. */
  138450. hdrPostProcess: Nullable<PostProcess>;
  138451. /**
  138452. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  138453. */
  138454. textureAdderFinalPostProcess: Nullable<PostProcess>;
  138455. /**
  138456. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  138457. */
  138458. lensFlareFinalPostProcess: Nullable<PostProcess>;
  138459. /**
  138460. * Post-process used to merge the final HDR post-process and the real scene color
  138461. */
  138462. hdrFinalPostProcess: Nullable<PostProcess>;
  138463. /**
  138464. * Post-process used to create a lens flare effect
  138465. */
  138466. lensFlarePostProcess: Nullable<PostProcess>;
  138467. /**
  138468. * Post-process that merges the result of the lens flare post-process and the real scene color
  138469. */
  138470. lensFlareComposePostProcess: Nullable<PostProcess>;
  138471. /**
  138472. * Post-process used to create a motion blur effect
  138473. */
  138474. motionBlurPostProcess: Nullable<PostProcess>;
  138475. /**
  138476. * Post-process used to create a depth of field effect
  138477. */
  138478. depthOfFieldPostProcess: Nullable<PostProcess>;
  138479. /**
  138480. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  138481. */
  138482. fxaaPostProcess: Nullable<FxaaPostProcess>;
  138483. /**
  138484. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  138485. */
  138486. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  138487. /**
  138488. * Represents the brightness threshold in order to configure the illuminated surfaces
  138489. */
  138490. brightThreshold: number;
  138491. /**
  138492. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  138493. */
  138494. blurWidth: number;
  138495. /**
  138496. * Sets if the blur for highlighted surfaces must be only horizontal
  138497. */
  138498. horizontalBlur: boolean;
  138499. /**
  138500. * Gets the overall exposure used by the pipeline
  138501. */
  138502. get exposure(): number;
  138503. /**
  138504. * Sets the overall exposure used by the pipeline
  138505. */
  138506. set exposure(value: number);
  138507. /**
  138508. * Texture used typically to simulate "dirty" on camera lens
  138509. */
  138510. lensTexture: Nullable<Texture>;
  138511. /**
  138512. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  138513. */
  138514. volumetricLightCoefficient: number;
  138515. /**
  138516. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  138517. */
  138518. volumetricLightPower: number;
  138519. /**
  138520. * Used the set the blur intensity to smooth the volumetric lights
  138521. */
  138522. volumetricLightBlurScale: number;
  138523. /**
  138524. * Light (spot or directional) used to generate the volumetric lights rays
  138525. * The source light must have a shadow generate so the pipeline can get its
  138526. * depth map
  138527. */
  138528. sourceLight: Nullable<SpotLight | DirectionalLight>;
  138529. /**
  138530. * For eye adaptation, represents the minimum luminance the eye can see
  138531. */
  138532. hdrMinimumLuminance: number;
  138533. /**
  138534. * For eye adaptation, represents the decrease luminance speed
  138535. */
  138536. hdrDecreaseRate: number;
  138537. /**
  138538. * For eye adaptation, represents the increase luminance speed
  138539. */
  138540. hdrIncreaseRate: number;
  138541. /**
  138542. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  138543. */
  138544. get hdrAutoExposure(): boolean;
  138545. /**
  138546. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  138547. */
  138548. set hdrAutoExposure(value: boolean);
  138549. /**
  138550. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  138551. */
  138552. lensColorTexture: Nullable<Texture>;
  138553. /**
  138554. * The overall strengh for the lens flare effect
  138555. */
  138556. lensFlareStrength: number;
  138557. /**
  138558. * Dispersion coefficient for lens flare ghosts
  138559. */
  138560. lensFlareGhostDispersal: number;
  138561. /**
  138562. * Main lens flare halo width
  138563. */
  138564. lensFlareHaloWidth: number;
  138565. /**
  138566. * Based on the lens distortion effect, defines how much the lens flare result
  138567. * is distorted
  138568. */
  138569. lensFlareDistortionStrength: number;
  138570. /**
  138571. * Configures the blur intensity used for for lens flare (halo)
  138572. */
  138573. lensFlareBlurWidth: number;
  138574. /**
  138575. * Lens star texture must be used to simulate rays on the flares and is available
  138576. * in the documentation
  138577. */
  138578. lensStarTexture: Nullable<Texture>;
  138579. /**
  138580. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  138581. * flare effect by taking account of the dirt texture
  138582. */
  138583. lensFlareDirtTexture: Nullable<Texture>;
  138584. /**
  138585. * Represents the focal length for the depth of field effect
  138586. */
  138587. depthOfFieldDistance: number;
  138588. /**
  138589. * Represents the blur intensity for the blurred part of the depth of field effect
  138590. */
  138591. depthOfFieldBlurWidth: number;
  138592. /**
  138593. * Gets how much the image is blurred by the movement while using the motion blur post-process
  138594. */
  138595. get motionStrength(): number;
  138596. /**
  138597. * Sets how much the image is blurred by the movement while using the motion blur post-process
  138598. */
  138599. set motionStrength(strength: number);
  138600. /**
  138601. * Gets wether or not the motion blur post-process is object based or screen based.
  138602. */
  138603. get objectBasedMotionBlur(): boolean;
  138604. /**
  138605. * Sets wether or not the motion blur post-process should be object based or screen based
  138606. */
  138607. set objectBasedMotionBlur(value: boolean);
  138608. /**
  138609. * List of animations for the pipeline (IAnimatable implementation)
  138610. */
  138611. animations: Animation[];
  138612. /**
  138613. * Private members
  138614. */
  138615. private _scene;
  138616. private _currentDepthOfFieldSource;
  138617. private _basePostProcess;
  138618. private _fixedExposure;
  138619. private _currentExposure;
  138620. private _hdrAutoExposure;
  138621. private _hdrCurrentLuminance;
  138622. private _motionStrength;
  138623. private _isObjectBasedMotionBlur;
  138624. private _floatTextureType;
  138625. private _camerasToBeAttached;
  138626. private _ratio;
  138627. private _bloomEnabled;
  138628. private _depthOfFieldEnabled;
  138629. private _vlsEnabled;
  138630. private _lensFlareEnabled;
  138631. private _hdrEnabled;
  138632. private _motionBlurEnabled;
  138633. private _fxaaEnabled;
  138634. private _screenSpaceReflectionsEnabled;
  138635. private _motionBlurSamples;
  138636. private _volumetricLightStepsCount;
  138637. private _samples;
  138638. /**
  138639. * @ignore
  138640. * Specifies if the bloom pipeline is enabled
  138641. */
  138642. get BloomEnabled(): boolean;
  138643. set BloomEnabled(enabled: boolean);
  138644. /**
  138645. * @ignore
  138646. * Specifies if the depth of field pipeline is enabed
  138647. */
  138648. get DepthOfFieldEnabled(): boolean;
  138649. set DepthOfFieldEnabled(enabled: boolean);
  138650. /**
  138651. * @ignore
  138652. * Specifies if the lens flare pipeline is enabed
  138653. */
  138654. get LensFlareEnabled(): boolean;
  138655. set LensFlareEnabled(enabled: boolean);
  138656. /**
  138657. * @ignore
  138658. * Specifies if the HDR pipeline is enabled
  138659. */
  138660. get HDREnabled(): boolean;
  138661. set HDREnabled(enabled: boolean);
  138662. /**
  138663. * @ignore
  138664. * Specifies if the volumetric lights scattering effect is enabled
  138665. */
  138666. get VLSEnabled(): boolean;
  138667. set VLSEnabled(enabled: boolean);
  138668. /**
  138669. * @ignore
  138670. * Specifies if the motion blur effect is enabled
  138671. */
  138672. get MotionBlurEnabled(): boolean;
  138673. set MotionBlurEnabled(enabled: boolean);
  138674. /**
  138675. * Specifies if anti-aliasing is enabled
  138676. */
  138677. get fxaaEnabled(): boolean;
  138678. set fxaaEnabled(enabled: boolean);
  138679. /**
  138680. * Specifies if screen space reflections are enabled.
  138681. */
  138682. get screenSpaceReflectionsEnabled(): boolean;
  138683. set screenSpaceReflectionsEnabled(enabled: boolean);
  138684. /**
  138685. * Specifies the number of steps used to calculate the volumetric lights
  138686. * Typically in interval [50, 200]
  138687. */
  138688. get volumetricLightStepsCount(): number;
  138689. set volumetricLightStepsCount(count: number);
  138690. /**
  138691. * Specifies the number of samples used for the motion blur effect
  138692. * Typically in interval [16, 64]
  138693. */
  138694. get motionBlurSamples(): number;
  138695. set motionBlurSamples(samples: number);
  138696. /**
  138697. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  138698. */
  138699. get samples(): number;
  138700. set samples(sampleCount: number);
  138701. /**
  138702. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  138703. * @constructor
  138704. * @param name The rendering pipeline name
  138705. * @param scene The scene linked to this pipeline
  138706. * @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)
  138707. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  138708. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138709. */
  138710. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  138711. private _buildPipeline;
  138712. private _createDownSampleX4PostProcess;
  138713. private _createBrightPassPostProcess;
  138714. private _createBlurPostProcesses;
  138715. private _createTextureAdderPostProcess;
  138716. private _createVolumetricLightPostProcess;
  138717. private _createLuminancePostProcesses;
  138718. private _createHdrPostProcess;
  138719. private _createLensFlarePostProcess;
  138720. private _createDepthOfFieldPostProcess;
  138721. private _createMotionBlurPostProcess;
  138722. private _getDepthTexture;
  138723. private _disposePostProcesses;
  138724. /**
  138725. * Dispose of the pipeline and stop all post processes
  138726. */
  138727. dispose(): void;
  138728. /**
  138729. * Serialize the rendering pipeline (Used when exporting)
  138730. * @returns the serialized object
  138731. */
  138732. serialize(): any;
  138733. /**
  138734. * Parse the serialized pipeline
  138735. * @param source Source pipeline.
  138736. * @param scene The scene to load the pipeline to.
  138737. * @param rootUrl The URL of the serialized pipeline.
  138738. * @returns An instantiated pipeline from the serialized object.
  138739. */
  138740. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  138741. /**
  138742. * Luminance steps
  138743. */
  138744. static LuminanceSteps: number;
  138745. }
  138746. }
  138747. declare module BABYLON {
  138748. /** @hidden */
  138749. export var tonemapPixelShader: {
  138750. name: string;
  138751. shader: string;
  138752. };
  138753. }
  138754. declare module BABYLON {
  138755. /** Defines operator used for tonemapping */
  138756. export enum TonemappingOperator {
  138757. /** Hable */
  138758. Hable = 0,
  138759. /** Reinhard */
  138760. Reinhard = 1,
  138761. /** HejiDawson */
  138762. HejiDawson = 2,
  138763. /** Photographic */
  138764. Photographic = 3
  138765. }
  138766. /**
  138767. * Defines a post process to apply tone mapping
  138768. */
  138769. export class TonemapPostProcess extends PostProcess {
  138770. private _operator;
  138771. /** Defines the required exposure adjustement */
  138772. exposureAdjustment: number;
  138773. /**
  138774. * Creates a new TonemapPostProcess
  138775. * @param name defines the name of the postprocess
  138776. * @param _operator defines the operator to use
  138777. * @param exposureAdjustment defines the required exposure adjustement
  138778. * @param camera defines the camera to use (can be null)
  138779. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  138780. * @param engine defines the hosting engine (can be ignore if camera is set)
  138781. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  138782. */
  138783. constructor(name: string, _operator: TonemappingOperator,
  138784. /** Defines the required exposure adjustement */
  138785. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  138786. }
  138787. }
  138788. declare module BABYLON {
  138789. /** @hidden */
  138790. export var volumetricLightScatteringPixelShader: {
  138791. name: string;
  138792. shader: string;
  138793. };
  138794. }
  138795. declare module BABYLON {
  138796. /** @hidden */
  138797. export var volumetricLightScatteringPassVertexShader: {
  138798. name: string;
  138799. shader: string;
  138800. };
  138801. }
  138802. declare module BABYLON {
  138803. /** @hidden */
  138804. export var volumetricLightScatteringPassPixelShader: {
  138805. name: string;
  138806. shader: string;
  138807. };
  138808. }
  138809. declare module BABYLON {
  138810. /**
  138811. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  138812. */
  138813. export class VolumetricLightScatteringPostProcess extends PostProcess {
  138814. private _volumetricLightScatteringPass;
  138815. private _volumetricLightScatteringRTT;
  138816. private _viewPort;
  138817. private _screenCoordinates;
  138818. private _cachedDefines;
  138819. /**
  138820. * If not undefined, the mesh position is computed from the attached node position
  138821. */
  138822. attachedNode: {
  138823. position: Vector3;
  138824. };
  138825. /**
  138826. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  138827. */
  138828. customMeshPosition: Vector3;
  138829. /**
  138830. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  138831. */
  138832. useCustomMeshPosition: boolean;
  138833. /**
  138834. * If the post-process should inverse the light scattering direction
  138835. */
  138836. invert: boolean;
  138837. /**
  138838. * The internal mesh used by the post-process
  138839. */
  138840. mesh: Mesh;
  138841. /**
  138842. * @hidden
  138843. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  138844. */
  138845. get useDiffuseColor(): boolean;
  138846. set useDiffuseColor(useDiffuseColor: boolean);
  138847. /**
  138848. * Array containing the excluded meshes not rendered in the internal pass
  138849. */
  138850. excludedMeshes: AbstractMesh[];
  138851. /**
  138852. * Controls the overall intensity of the post-process
  138853. */
  138854. exposure: number;
  138855. /**
  138856. * Dissipates each sample's contribution in range [0, 1]
  138857. */
  138858. decay: number;
  138859. /**
  138860. * Controls the overall intensity of each sample
  138861. */
  138862. weight: number;
  138863. /**
  138864. * Controls the density of each sample
  138865. */
  138866. density: number;
  138867. /**
  138868. * @constructor
  138869. * @param name The post-process name
  138870. * @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)
  138871. * @param camera The camera that the post-process will be attached to
  138872. * @param mesh The mesh used to create the light scattering
  138873. * @param samples The post-process quality, default 100
  138874. * @param samplingModeThe post-process filtering mode
  138875. * @param engine The babylon engine
  138876. * @param reusable If the post-process is reusable
  138877. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  138878. */
  138879. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  138880. /**
  138881. * Returns the string "VolumetricLightScatteringPostProcess"
  138882. * @returns "VolumetricLightScatteringPostProcess"
  138883. */
  138884. getClassName(): string;
  138885. private _isReady;
  138886. /**
  138887. * Sets the new light position for light scattering effect
  138888. * @param position The new custom light position
  138889. */
  138890. setCustomMeshPosition(position: Vector3): void;
  138891. /**
  138892. * Returns the light position for light scattering effect
  138893. * @return Vector3 The custom light position
  138894. */
  138895. getCustomMeshPosition(): Vector3;
  138896. /**
  138897. * Disposes the internal assets and detaches the post-process from the camera
  138898. */
  138899. dispose(camera: Camera): void;
  138900. /**
  138901. * Returns the render target texture used by the post-process
  138902. * @return the render target texture used by the post-process
  138903. */
  138904. getPass(): RenderTargetTexture;
  138905. private _meshExcluded;
  138906. private _createPass;
  138907. private _updateMeshScreenCoordinates;
  138908. /**
  138909. * Creates a default mesh for the Volumeric Light Scattering post-process
  138910. * @param name The mesh name
  138911. * @param scene The scene where to create the mesh
  138912. * @return the default mesh
  138913. */
  138914. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  138915. }
  138916. }
  138917. declare module BABYLON {
  138918. interface Scene {
  138919. /** @hidden (Backing field) */
  138920. _boundingBoxRenderer: BoundingBoxRenderer;
  138921. /** @hidden (Backing field) */
  138922. _forceShowBoundingBoxes: boolean;
  138923. /**
  138924. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  138925. */
  138926. forceShowBoundingBoxes: boolean;
  138927. /**
  138928. * Gets the bounding box renderer associated with the scene
  138929. * @returns a BoundingBoxRenderer
  138930. */
  138931. getBoundingBoxRenderer(): BoundingBoxRenderer;
  138932. }
  138933. interface AbstractMesh {
  138934. /** @hidden (Backing field) */
  138935. _showBoundingBox: boolean;
  138936. /**
  138937. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  138938. */
  138939. showBoundingBox: boolean;
  138940. }
  138941. /**
  138942. * Component responsible of rendering the bounding box of the meshes in a scene.
  138943. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  138944. */
  138945. export class BoundingBoxRenderer implements ISceneComponent {
  138946. /**
  138947. * The component name helpfull to identify the component in the list of scene components.
  138948. */
  138949. readonly name: string;
  138950. /**
  138951. * The scene the component belongs to.
  138952. */
  138953. scene: Scene;
  138954. /**
  138955. * Color of the bounding box lines placed in front of an object
  138956. */
  138957. frontColor: Color3;
  138958. /**
  138959. * Color of the bounding box lines placed behind an object
  138960. */
  138961. backColor: Color3;
  138962. /**
  138963. * Defines if the renderer should show the back lines or not
  138964. */
  138965. showBackLines: boolean;
  138966. /**
  138967. * @hidden
  138968. */
  138969. renderList: SmartArray<BoundingBox>;
  138970. private _colorShader;
  138971. private _vertexBuffers;
  138972. private _indexBuffer;
  138973. private _fillIndexBuffer;
  138974. private _fillIndexData;
  138975. /**
  138976. * Instantiates a new bounding box renderer in a scene.
  138977. * @param scene the scene the renderer renders in
  138978. */
  138979. constructor(scene: Scene);
  138980. /**
  138981. * Registers the component in a given scene
  138982. */
  138983. register(): void;
  138984. private _evaluateSubMesh;
  138985. private _activeMesh;
  138986. private _prepareRessources;
  138987. private _createIndexBuffer;
  138988. /**
  138989. * Rebuilds the elements related to this component in case of
  138990. * context lost for instance.
  138991. */
  138992. rebuild(): void;
  138993. /**
  138994. * @hidden
  138995. */
  138996. reset(): void;
  138997. /**
  138998. * Render the bounding boxes of a specific rendering group
  138999. * @param renderingGroupId defines the rendering group to render
  139000. */
  139001. render(renderingGroupId: number): void;
  139002. /**
  139003. * In case of occlusion queries, we can render the occlusion bounding box through this method
  139004. * @param mesh Define the mesh to render the occlusion bounding box for
  139005. */
  139006. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  139007. /**
  139008. * Dispose and release the resources attached to this renderer.
  139009. */
  139010. dispose(): void;
  139011. }
  139012. }
  139013. declare module BABYLON {
  139014. interface Scene {
  139015. /** @hidden (Backing field) */
  139016. _depthRenderer: {
  139017. [id: string]: DepthRenderer;
  139018. };
  139019. /**
  139020. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  139021. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  139022. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  139023. * @returns the created depth renderer
  139024. */
  139025. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  139026. /**
  139027. * Disables a depth renderer for a given camera
  139028. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  139029. */
  139030. disableDepthRenderer(camera?: Nullable<Camera>): void;
  139031. }
  139032. /**
  139033. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  139034. * in several rendering techniques.
  139035. */
  139036. export class DepthRendererSceneComponent implements ISceneComponent {
  139037. /**
  139038. * The component name helpfull to identify the component in the list of scene components.
  139039. */
  139040. readonly name: string;
  139041. /**
  139042. * The scene the component belongs to.
  139043. */
  139044. scene: Scene;
  139045. /**
  139046. * Creates a new instance of the component for the given scene
  139047. * @param scene Defines the scene to register the component in
  139048. */
  139049. constructor(scene: Scene);
  139050. /**
  139051. * Registers the component in a given scene
  139052. */
  139053. register(): void;
  139054. /**
  139055. * Rebuilds the elements related to this component in case of
  139056. * context lost for instance.
  139057. */
  139058. rebuild(): void;
  139059. /**
  139060. * Disposes the component and the associated ressources
  139061. */
  139062. dispose(): void;
  139063. private _gatherRenderTargets;
  139064. private _gatherActiveCameraRenderTargets;
  139065. }
  139066. }
  139067. declare module BABYLON {
  139068. /** @hidden */
  139069. export var outlinePixelShader: {
  139070. name: string;
  139071. shader: string;
  139072. };
  139073. }
  139074. declare module BABYLON {
  139075. /** @hidden */
  139076. export var outlineVertexShader: {
  139077. name: string;
  139078. shader: string;
  139079. };
  139080. }
  139081. declare module BABYLON {
  139082. interface Scene {
  139083. /** @hidden */
  139084. _outlineRenderer: OutlineRenderer;
  139085. /**
  139086. * Gets the outline renderer associated with the scene
  139087. * @returns a OutlineRenderer
  139088. */
  139089. getOutlineRenderer(): OutlineRenderer;
  139090. }
  139091. interface AbstractMesh {
  139092. /** @hidden (Backing field) */
  139093. _renderOutline: boolean;
  139094. /**
  139095. * Gets or sets a boolean indicating if the outline must be rendered as well
  139096. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  139097. */
  139098. renderOutline: boolean;
  139099. /** @hidden (Backing field) */
  139100. _renderOverlay: boolean;
  139101. /**
  139102. * Gets or sets a boolean indicating if the overlay must be rendered as well
  139103. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  139104. */
  139105. renderOverlay: boolean;
  139106. }
  139107. /**
  139108. * This class is responsible to draw bothe outline/overlay of meshes.
  139109. * It should not be used directly but through the available method on mesh.
  139110. */
  139111. export class OutlineRenderer implements ISceneComponent {
  139112. /**
  139113. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  139114. */
  139115. private static _StencilReference;
  139116. /**
  139117. * The name of the component. Each component must have a unique name.
  139118. */
  139119. name: string;
  139120. /**
  139121. * The scene the component belongs to.
  139122. */
  139123. scene: Scene;
  139124. /**
  139125. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  139126. */
  139127. zOffset: number;
  139128. private _engine;
  139129. private _effect;
  139130. private _cachedDefines;
  139131. private _savedDepthWrite;
  139132. /**
  139133. * Instantiates a new outline renderer. (There could be only one per scene).
  139134. * @param scene Defines the scene it belongs to
  139135. */
  139136. constructor(scene: Scene);
  139137. /**
  139138. * Register the component to one instance of a scene.
  139139. */
  139140. register(): void;
  139141. /**
  139142. * Rebuilds the elements related to this component in case of
  139143. * context lost for instance.
  139144. */
  139145. rebuild(): void;
  139146. /**
  139147. * Disposes the component and the associated ressources.
  139148. */
  139149. dispose(): void;
  139150. /**
  139151. * Renders the outline in the canvas.
  139152. * @param subMesh Defines the sumesh to render
  139153. * @param batch Defines the batch of meshes in case of instances
  139154. * @param useOverlay Defines if the rendering is for the overlay or the outline
  139155. */
  139156. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  139157. /**
  139158. * Returns whether or not the outline renderer is ready for a given submesh.
  139159. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  139160. * @param subMesh Defines the submesh to check readyness for
  139161. * @param useInstances Defines wheter wee are trying to render instances or not
  139162. * @returns true if ready otherwise false
  139163. */
  139164. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139165. private _beforeRenderingMesh;
  139166. private _afterRenderingMesh;
  139167. }
  139168. }
  139169. declare module BABYLON {
  139170. /**
  139171. * Defines the basic options interface of a Sprite Frame Source Size.
  139172. */
  139173. export interface ISpriteJSONSpriteSourceSize {
  139174. /**
  139175. * number of the original width of the Frame
  139176. */
  139177. w: number;
  139178. /**
  139179. * number of the original height of the Frame
  139180. */
  139181. h: number;
  139182. }
  139183. /**
  139184. * Defines the basic options interface of a Sprite Frame Data.
  139185. */
  139186. export interface ISpriteJSONSpriteFrameData {
  139187. /**
  139188. * number of the x offset of the Frame
  139189. */
  139190. x: number;
  139191. /**
  139192. * number of the y offset of the Frame
  139193. */
  139194. y: number;
  139195. /**
  139196. * number of the width of the Frame
  139197. */
  139198. w: number;
  139199. /**
  139200. * number of the height of the Frame
  139201. */
  139202. h: number;
  139203. }
  139204. /**
  139205. * Defines the basic options interface of a JSON Sprite.
  139206. */
  139207. export interface ISpriteJSONSprite {
  139208. /**
  139209. * string name of the Frame
  139210. */
  139211. filename: string;
  139212. /**
  139213. * ISpriteJSONSpriteFrame basic object of the frame data
  139214. */
  139215. frame: ISpriteJSONSpriteFrameData;
  139216. /**
  139217. * boolean to flag is the frame was rotated.
  139218. */
  139219. rotated: boolean;
  139220. /**
  139221. * boolean to flag is the frame was trimmed.
  139222. */
  139223. trimmed: boolean;
  139224. /**
  139225. * ISpriteJSONSpriteFrame basic object of the source data
  139226. */
  139227. spriteSourceSize: ISpriteJSONSpriteFrameData;
  139228. /**
  139229. * ISpriteJSONSpriteFrame basic object of the source data
  139230. */
  139231. sourceSize: ISpriteJSONSpriteSourceSize;
  139232. }
  139233. /**
  139234. * Defines the basic options interface of a JSON atlas.
  139235. */
  139236. export interface ISpriteJSONAtlas {
  139237. /**
  139238. * Array of objects that contain the frame data.
  139239. */
  139240. frames: Array<ISpriteJSONSprite>;
  139241. /**
  139242. * object basic object containing the sprite meta data.
  139243. */
  139244. meta?: object;
  139245. }
  139246. }
  139247. declare module BABYLON {
  139248. /** @hidden */
  139249. export var spriteMapPixelShader: {
  139250. name: string;
  139251. shader: string;
  139252. };
  139253. }
  139254. declare module BABYLON {
  139255. /** @hidden */
  139256. export var spriteMapVertexShader: {
  139257. name: string;
  139258. shader: string;
  139259. };
  139260. }
  139261. declare module BABYLON {
  139262. /**
  139263. * Defines the basic options interface of a SpriteMap
  139264. */
  139265. export interface ISpriteMapOptions {
  139266. /**
  139267. * Vector2 of the number of cells in the grid.
  139268. */
  139269. stageSize?: Vector2;
  139270. /**
  139271. * Vector2 of the size of the output plane in World Units.
  139272. */
  139273. outputSize?: Vector2;
  139274. /**
  139275. * Vector3 of the position of the output plane in World Units.
  139276. */
  139277. outputPosition?: Vector3;
  139278. /**
  139279. * Vector3 of the rotation of the output plane.
  139280. */
  139281. outputRotation?: Vector3;
  139282. /**
  139283. * number of layers that the system will reserve in resources.
  139284. */
  139285. layerCount?: number;
  139286. /**
  139287. * number of max animation frames a single cell will reserve in resources.
  139288. */
  139289. maxAnimationFrames?: number;
  139290. /**
  139291. * number cell index of the base tile when the system compiles.
  139292. */
  139293. baseTile?: number;
  139294. /**
  139295. * boolean flip the sprite after its been repositioned by the framing data.
  139296. */
  139297. flipU?: boolean;
  139298. /**
  139299. * Vector3 scalar of the global RGB values of the SpriteMap.
  139300. */
  139301. colorMultiply?: Vector3;
  139302. }
  139303. /**
  139304. * Defines the IDisposable interface in order to be cleanable from resources.
  139305. */
  139306. export interface ISpriteMap extends IDisposable {
  139307. /**
  139308. * String name of the SpriteMap.
  139309. */
  139310. name: string;
  139311. /**
  139312. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  139313. */
  139314. atlasJSON: ISpriteJSONAtlas;
  139315. /**
  139316. * Texture of the SpriteMap.
  139317. */
  139318. spriteSheet: Texture;
  139319. /**
  139320. * The parameters to initialize the SpriteMap with.
  139321. */
  139322. options: ISpriteMapOptions;
  139323. }
  139324. /**
  139325. * Class used to manage a grid restricted sprite deployment on an Output plane.
  139326. */
  139327. export class SpriteMap implements ISpriteMap {
  139328. /** The Name of the spriteMap */
  139329. name: string;
  139330. /** The JSON file with the frame and meta data */
  139331. atlasJSON: ISpriteJSONAtlas;
  139332. /** The systems Sprite Sheet Texture */
  139333. spriteSheet: Texture;
  139334. /** Arguments passed with the Constructor */
  139335. options: ISpriteMapOptions;
  139336. /** Public Sprite Storage array, parsed from atlasJSON */
  139337. sprites: Array<ISpriteJSONSprite>;
  139338. /** Returns the Number of Sprites in the System */
  139339. get spriteCount(): number;
  139340. /** Returns the Position of Output Plane*/
  139341. get position(): Vector3;
  139342. /** Returns the Position of Output Plane*/
  139343. set position(v: Vector3);
  139344. /** Returns the Rotation of Output Plane*/
  139345. get rotation(): Vector3;
  139346. /** Returns the Rotation of Output Plane*/
  139347. set rotation(v: Vector3);
  139348. /** Sets the AnimationMap*/
  139349. get animationMap(): RawTexture;
  139350. /** Sets the AnimationMap*/
  139351. set animationMap(v: RawTexture);
  139352. /** Scene that the SpriteMap was created in */
  139353. private _scene;
  139354. /** Texture Buffer of Float32 that holds tile frame data*/
  139355. private _frameMap;
  139356. /** Texture Buffers of Float32 that holds tileMap data*/
  139357. private _tileMaps;
  139358. /** Texture Buffer of Float32 that holds Animation Data*/
  139359. private _animationMap;
  139360. /** Custom ShaderMaterial Central to the System*/
  139361. private _material;
  139362. /** Custom ShaderMaterial Central to the System*/
  139363. private _output;
  139364. /** Systems Time Ticker*/
  139365. private _time;
  139366. /**
  139367. * Creates a new SpriteMap
  139368. * @param name defines the SpriteMaps Name
  139369. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  139370. * @param spriteSheet is the Texture that the Sprites are on.
  139371. * @param options a basic deployment configuration
  139372. * @param scene The Scene that the map is deployed on
  139373. */
  139374. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  139375. /**
  139376. * Returns tileID location
  139377. * @returns Vector2 the cell position ID
  139378. */
  139379. getTileID(): Vector2;
  139380. /**
  139381. * Gets the UV location of the mouse over the SpriteMap.
  139382. * @returns Vector2 the UV position of the mouse interaction
  139383. */
  139384. getMousePosition(): Vector2;
  139385. /**
  139386. * Creates the "frame" texture Buffer
  139387. * -------------------------------------
  139388. * Structure of frames
  139389. * "filename": "Falling-Water-2.png",
  139390. * "frame": {"x":69,"y":103,"w":24,"h":32},
  139391. * "rotated": true,
  139392. * "trimmed": true,
  139393. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  139394. * "sourceSize": {"w":32,"h":32}
  139395. * @returns RawTexture of the frameMap
  139396. */
  139397. private _createFrameBuffer;
  139398. /**
  139399. * Creates the tileMap texture Buffer
  139400. * @param buffer normally and array of numbers, or a false to generate from scratch
  139401. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  139402. * @returns RawTexture of the tileMap
  139403. */
  139404. private _createTileBuffer;
  139405. /**
  139406. * Modifies the data of the tileMaps
  139407. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  139408. * @param pos is the iVector2 Coordinates of the Tile
  139409. * @param tile The SpriteIndex of the new Tile
  139410. */
  139411. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  139412. /**
  139413. * Creates the animationMap texture Buffer
  139414. * @param buffer normally and array of numbers, or a false to generate from scratch
  139415. * @returns RawTexture of the animationMap
  139416. */
  139417. private _createTileAnimationBuffer;
  139418. /**
  139419. * Modifies the data of the animationMap
  139420. * @param cellID is the Index of the Sprite
  139421. * @param _frame is the target Animation frame
  139422. * @param toCell is the Target Index of the next frame of the animation
  139423. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  139424. * @param speed is a global scalar of the time variable on the map.
  139425. */
  139426. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  139427. /**
  139428. * Exports the .tilemaps file
  139429. */
  139430. saveTileMaps(): void;
  139431. /**
  139432. * Imports the .tilemaps file
  139433. * @param url of the .tilemaps file
  139434. */
  139435. loadTileMaps(url: string): void;
  139436. /**
  139437. * Release associated resources
  139438. */
  139439. dispose(): void;
  139440. }
  139441. }
  139442. declare module BABYLON {
  139443. /**
  139444. * Class used to manage multiple sprites of different sizes on the same spritesheet
  139445. * @see http://doc.babylonjs.com/babylon101/sprites
  139446. */
  139447. export class SpritePackedManager extends SpriteManager {
  139448. /** defines the packed manager's name */
  139449. name: string;
  139450. /**
  139451. * Creates a new sprite manager from a packed sprite sheet
  139452. * @param name defines the manager's name
  139453. * @param imgUrl defines the sprite sheet url
  139454. * @param capacity defines the maximum allowed number of sprites
  139455. * @param scene defines the hosting scene
  139456. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  139457. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  139458. * @param samplingMode defines the smapling mode to use with spritesheet
  139459. * @param fromPacked set to true; do not alter
  139460. */
  139461. constructor(
  139462. /** defines the packed manager's name */
  139463. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  139464. }
  139465. }
  139466. declare module BABYLON {
  139467. /**
  139468. * Defines the list of states available for a task inside a AssetsManager
  139469. */
  139470. export enum AssetTaskState {
  139471. /**
  139472. * Initialization
  139473. */
  139474. INIT = 0,
  139475. /**
  139476. * Running
  139477. */
  139478. RUNNING = 1,
  139479. /**
  139480. * Done
  139481. */
  139482. DONE = 2,
  139483. /**
  139484. * Error
  139485. */
  139486. ERROR = 3
  139487. }
  139488. /**
  139489. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  139490. */
  139491. export abstract class AbstractAssetTask {
  139492. /**
  139493. * Task name
  139494. */ name: string;
  139495. /**
  139496. * Callback called when the task is successful
  139497. */
  139498. onSuccess: (task: any) => void;
  139499. /**
  139500. * Callback called when the task is not successful
  139501. */
  139502. onError: (task: any, message?: string, exception?: any) => void;
  139503. /**
  139504. * Creates a new AssetsManager
  139505. * @param name defines the name of the task
  139506. */
  139507. constructor(
  139508. /**
  139509. * Task name
  139510. */ name: string);
  139511. private _isCompleted;
  139512. private _taskState;
  139513. private _errorObject;
  139514. /**
  139515. * Get if the task is completed
  139516. */
  139517. get isCompleted(): boolean;
  139518. /**
  139519. * Gets the current state of the task
  139520. */
  139521. get taskState(): AssetTaskState;
  139522. /**
  139523. * Gets the current error object (if task is in error)
  139524. */
  139525. get errorObject(): {
  139526. message?: string;
  139527. exception?: any;
  139528. };
  139529. /**
  139530. * Internal only
  139531. * @hidden
  139532. */
  139533. _setErrorObject(message?: string, exception?: any): void;
  139534. /**
  139535. * Execute the current task
  139536. * @param scene defines the scene where you want your assets to be loaded
  139537. * @param onSuccess is a callback called when the task is successfully executed
  139538. * @param onError is a callback called if an error occurs
  139539. */
  139540. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139541. /**
  139542. * Execute the current task
  139543. * @param scene defines the scene where you want your assets to be loaded
  139544. * @param onSuccess is a callback called when the task is successfully executed
  139545. * @param onError is a callback called if an error occurs
  139546. */
  139547. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139548. /**
  139549. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  139550. * This can be used with failed tasks that have the reason for failure fixed.
  139551. */
  139552. reset(): void;
  139553. private onErrorCallback;
  139554. private onDoneCallback;
  139555. }
  139556. /**
  139557. * Define the interface used by progress events raised during assets loading
  139558. */
  139559. export interface IAssetsProgressEvent {
  139560. /**
  139561. * Defines the number of remaining tasks to process
  139562. */
  139563. remainingCount: number;
  139564. /**
  139565. * Defines the total number of tasks
  139566. */
  139567. totalCount: number;
  139568. /**
  139569. * Defines the task that was just processed
  139570. */
  139571. task: AbstractAssetTask;
  139572. }
  139573. /**
  139574. * Class used to share progress information about assets loading
  139575. */
  139576. export class AssetsProgressEvent implements IAssetsProgressEvent {
  139577. /**
  139578. * Defines the number of remaining tasks to process
  139579. */
  139580. remainingCount: number;
  139581. /**
  139582. * Defines the total number of tasks
  139583. */
  139584. totalCount: number;
  139585. /**
  139586. * Defines the task that was just processed
  139587. */
  139588. task: AbstractAssetTask;
  139589. /**
  139590. * Creates a AssetsProgressEvent
  139591. * @param remainingCount defines the number of remaining tasks to process
  139592. * @param totalCount defines the total number of tasks
  139593. * @param task defines the task that was just processed
  139594. */
  139595. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  139596. }
  139597. /**
  139598. * Define a task used by AssetsManager to load meshes
  139599. */
  139600. export class MeshAssetTask extends AbstractAssetTask {
  139601. /**
  139602. * Defines the name of the task
  139603. */
  139604. name: string;
  139605. /**
  139606. * Defines the list of mesh's names you want to load
  139607. */
  139608. meshesNames: any;
  139609. /**
  139610. * Defines the root url to use as a base to load your meshes and associated resources
  139611. */
  139612. rootUrl: string;
  139613. /**
  139614. * Defines the filename of the scene to load from
  139615. */
  139616. sceneFilename: string;
  139617. /**
  139618. * Gets the list of loaded meshes
  139619. */
  139620. loadedMeshes: Array<AbstractMesh>;
  139621. /**
  139622. * Gets the list of loaded particle systems
  139623. */
  139624. loadedParticleSystems: Array<IParticleSystem>;
  139625. /**
  139626. * Gets the list of loaded skeletons
  139627. */
  139628. loadedSkeletons: Array<Skeleton>;
  139629. /**
  139630. * Gets the list of loaded animation groups
  139631. */
  139632. loadedAnimationGroups: Array<AnimationGroup>;
  139633. /**
  139634. * Callback called when the task is successful
  139635. */
  139636. onSuccess: (task: MeshAssetTask) => void;
  139637. /**
  139638. * Callback called when the task is successful
  139639. */
  139640. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  139641. /**
  139642. * Creates a new MeshAssetTask
  139643. * @param name defines the name of the task
  139644. * @param meshesNames defines the list of mesh's names you want to load
  139645. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  139646. * @param sceneFilename defines the filename of the scene to load from
  139647. */
  139648. constructor(
  139649. /**
  139650. * Defines the name of the task
  139651. */
  139652. name: string,
  139653. /**
  139654. * Defines the list of mesh's names you want to load
  139655. */
  139656. meshesNames: any,
  139657. /**
  139658. * Defines the root url to use as a base to load your meshes and associated resources
  139659. */
  139660. rootUrl: string,
  139661. /**
  139662. * Defines the filename of the scene to load from
  139663. */
  139664. sceneFilename: string);
  139665. /**
  139666. * Execute the current task
  139667. * @param scene defines the scene where you want your assets to be loaded
  139668. * @param onSuccess is a callback called when the task is successfully executed
  139669. * @param onError is a callback called if an error occurs
  139670. */
  139671. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139672. }
  139673. /**
  139674. * Define a task used by AssetsManager to load text content
  139675. */
  139676. export class TextFileAssetTask extends AbstractAssetTask {
  139677. /**
  139678. * Defines the name of the task
  139679. */
  139680. name: string;
  139681. /**
  139682. * Defines the location of the file to load
  139683. */
  139684. url: string;
  139685. /**
  139686. * Gets the loaded text string
  139687. */
  139688. text: string;
  139689. /**
  139690. * Callback called when the task is successful
  139691. */
  139692. onSuccess: (task: TextFileAssetTask) => void;
  139693. /**
  139694. * Callback called when the task is successful
  139695. */
  139696. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  139697. /**
  139698. * Creates a new TextFileAssetTask object
  139699. * @param name defines the name of the task
  139700. * @param url defines the location of the file to load
  139701. */
  139702. constructor(
  139703. /**
  139704. * Defines the name of the task
  139705. */
  139706. name: string,
  139707. /**
  139708. * Defines the location of the file to load
  139709. */
  139710. url: string);
  139711. /**
  139712. * Execute the current task
  139713. * @param scene defines the scene where you want your assets to be loaded
  139714. * @param onSuccess is a callback called when the task is successfully executed
  139715. * @param onError is a callback called if an error occurs
  139716. */
  139717. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139718. }
  139719. /**
  139720. * Define a task used by AssetsManager to load binary data
  139721. */
  139722. export class BinaryFileAssetTask extends AbstractAssetTask {
  139723. /**
  139724. * Defines the name of the task
  139725. */
  139726. name: string;
  139727. /**
  139728. * Defines the location of the file to load
  139729. */
  139730. url: string;
  139731. /**
  139732. * Gets the lodaded data (as an array buffer)
  139733. */
  139734. data: ArrayBuffer;
  139735. /**
  139736. * Callback called when the task is successful
  139737. */
  139738. onSuccess: (task: BinaryFileAssetTask) => void;
  139739. /**
  139740. * Callback called when the task is successful
  139741. */
  139742. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  139743. /**
  139744. * Creates a new BinaryFileAssetTask object
  139745. * @param name defines the name of the new task
  139746. * @param url defines the location of the file to load
  139747. */
  139748. constructor(
  139749. /**
  139750. * Defines the name of the task
  139751. */
  139752. name: string,
  139753. /**
  139754. * Defines the location of the file to load
  139755. */
  139756. url: string);
  139757. /**
  139758. * Execute the current task
  139759. * @param scene defines the scene where you want your assets to be loaded
  139760. * @param onSuccess is a callback called when the task is successfully executed
  139761. * @param onError is a callback called if an error occurs
  139762. */
  139763. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139764. }
  139765. /**
  139766. * Define a task used by AssetsManager to load images
  139767. */
  139768. export class ImageAssetTask extends AbstractAssetTask {
  139769. /**
  139770. * Defines the name of the task
  139771. */
  139772. name: string;
  139773. /**
  139774. * Defines the location of the image to load
  139775. */
  139776. url: string;
  139777. /**
  139778. * Gets the loaded images
  139779. */
  139780. image: HTMLImageElement;
  139781. /**
  139782. * Callback called when the task is successful
  139783. */
  139784. onSuccess: (task: ImageAssetTask) => void;
  139785. /**
  139786. * Callback called when the task is successful
  139787. */
  139788. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  139789. /**
  139790. * Creates a new ImageAssetTask
  139791. * @param name defines the name of the task
  139792. * @param url defines the location of the image to load
  139793. */
  139794. constructor(
  139795. /**
  139796. * Defines the name of the task
  139797. */
  139798. name: string,
  139799. /**
  139800. * Defines the location of the image to load
  139801. */
  139802. url: string);
  139803. /**
  139804. * Execute the current task
  139805. * @param scene defines the scene where you want your assets to be loaded
  139806. * @param onSuccess is a callback called when the task is successfully executed
  139807. * @param onError is a callback called if an error occurs
  139808. */
  139809. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139810. }
  139811. /**
  139812. * Defines the interface used by texture loading tasks
  139813. */
  139814. export interface ITextureAssetTask<TEX extends BaseTexture> {
  139815. /**
  139816. * Gets the loaded texture
  139817. */
  139818. texture: TEX;
  139819. }
  139820. /**
  139821. * Define a task used by AssetsManager to load 2D textures
  139822. */
  139823. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  139824. /**
  139825. * Defines the name of the task
  139826. */
  139827. name: string;
  139828. /**
  139829. * Defines the location of the file to load
  139830. */
  139831. url: string;
  139832. /**
  139833. * Defines if mipmap should not be generated (default is false)
  139834. */
  139835. noMipmap?: boolean | undefined;
  139836. /**
  139837. * Defines if texture must be inverted on Y axis (default is false)
  139838. */
  139839. invertY?: boolean | undefined;
  139840. /**
  139841. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  139842. */
  139843. samplingMode: number;
  139844. /**
  139845. * Gets the loaded texture
  139846. */
  139847. texture: Texture;
  139848. /**
  139849. * Callback called when the task is successful
  139850. */
  139851. onSuccess: (task: TextureAssetTask) => void;
  139852. /**
  139853. * Callback called when the task is successful
  139854. */
  139855. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  139856. /**
  139857. * Creates a new TextureAssetTask object
  139858. * @param name defines the name of the task
  139859. * @param url defines the location of the file to load
  139860. * @param noMipmap defines if mipmap should not be generated (default is false)
  139861. * @param invertY defines if texture must be inverted on Y axis (default is false)
  139862. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  139863. */
  139864. constructor(
  139865. /**
  139866. * Defines the name of the task
  139867. */
  139868. name: string,
  139869. /**
  139870. * Defines the location of the file to load
  139871. */
  139872. url: string,
  139873. /**
  139874. * Defines if mipmap should not be generated (default is false)
  139875. */
  139876. noMipmap?: boolean | undefined,
  139877. /**
  139878. * Defines if texture must be inverted on Y axis (default is false)
  139879. */
  139880. invertY?: boolean | undefined,
  139881. /**
  139882. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  139883. */
  139884. samplingMode?: number);
  139885. /**
  139886. * Execute the current task
  139887. * @param scene defines the scene where you want your assets to be loaded
  139888. * @param onSuccess is a callback called when the task is successfully executed
  139889. * @param onError is a callback called if an error occurs
  139890. */
  139891. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139892. }
  139893. /**
  139894. * Define a task used by AssetsManager to load cube textures
  139895. */
  139896. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  139897. /**
  139898. * Defines the name of the task
  139899. */
  139900. name: string;
  139901. /**
  139902. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  139903. */
  139904. url: string;
  139905. /**
  139906. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  139907. */
  139908. extensions?: string[] | undefined;
  139909. /**
  139910. * Defines if mipmaps should not be generated (default is false)
  139911. */
  139912. noMipmap?: boolean | undefined;
  139913. /**
  139914. * Defines the explicit list of files (undefined by default)
  139915. */
  139916. files?: string[] | undefined;
  139917. /**
  139918. * Gets the loaded texture
  139919. */
  139920. texture: CubeTexture;
  139921. /**
  139922. * Callback called when the task is successful
  139923. */
  139924. onSuccess: (task: CubeTextureAssetTask) => void;
  139925. /**
  139926. * Callback called when the task is successful
  139927. */
  139928. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  139929. /**
  139930. * Creates a new CubeTextureAssetTask
  139931. * @param name defines the name of the task
  139932. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  139933. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  139934. * @param noMipmap defines if mipmaps should not be generated (default is false)
  139935. * @param files defines the explicit list of files (undefined by default)
  139936. */
  139937. constructor(
  139938. /**
  139939. * Defines the name of the task
  139940. */
  139941. name: string,
  139942. /**
  139943. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  139944. */
  139945. url: string,
  139946. /**
  139947. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  139948. */
  139949. extensions?: string[] | undefined,
  139950. /**
  139951. * Defines if mipmaps should not be generated (default is false)
  139952. */
  139953. noMipmap?: boolean | undefined,
  139954. /**
  139955. * Defines the explicit list of files (undefined by default)
  139956. */
  139957. files?: string[] | undefined);
  139958. /**
  139959. * Execute the current task
  139960. * @param scene defines the scene where you want your assets to be loaded
  139961. * @param onSuccess is a callback called when the task is successfully executed
  139962. * @param onError is a callback called if an error occurs
  139963. */
  139964. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  139965. }
  139966. /**
  139967. * Define a task used by AssetsManager to load HDR cube textures
  139968. */
  139969. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  139970. /**
  139971. * Defines the name of the task
  139972. */
  139973. name: string;
  139974. /**
  139975. * Defines the location of the file to load
  139976. */
  139977. url: string;
  139978. /**
  139979. * Defines the desired size (the more it increases the longer the generation will be)
  139980. */
  139981. size: number;
  139982. /**
  139983. * Defines if mipmaps should not be generated (default is false)
  139984. */
  139985. noMipmap: boolean;
  139986. /**
  139987. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  139988. */
  139989. generateHarmonics: boolean;
  139990. /**
  139991. * 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)
  139992. */
  139993. gammaSpace: boolean;
  139994. /**
  139995. * Internal Use Only
  139996. */
  139997. reserved: boolean;
  139998. /**
  139999. * Gets the loaded texture
  140000. */
  140001. texture: HDRCubeTexture;
  140002. /**
  140003. * Callback called when the task is successful
  140004. */
  140005. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  140006. /**
  140007. * Callback called when the task is successful
  140008. */
  140009. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  140010. /**
  140011. * Creates a new HDRCubeTextureAssetTask object
  140012. * @param name defines the name of the task
  140013. * @param url defines the location of the file to load
  140014. * @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.
  140015. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140016. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140017. * @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)
  140018. * @param reserved Internal use only
  140019. */
  140020. constructor(
  140021. /**
  140022. * Defines the name of the task
  140023. */
  140024. name: string,
  140025. /**
  140026. * Defines the location of the file to load
  140027. */
  140028. url: string,
  140029. /**
  140030. * Defines the desired size (the more it increases the longer the generation will be)
  140031. */
  140032. size: number,
  140033. /**
  140034. * Defines if mipmaps should not be generated (default is false)
  140035. */
  140036. noMipmap?: boolean,
  140037. /**
  140038. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140039. */
  140040. generateHarmonics?: boolean,
  140041. /**
  140042. * 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)
  140043. */
  140044. gammaSpace?: boolean,
  140045. /**
  140046. * Internal Use Only
  140047. */
  140048. reserved?: boolean);
  140049. /**
  140050. * Execute the current task
  140051. * @param scene defines the scene where you want your assets to be loaded
  140052. * @param onSuccess is a callback called when the task is successfully executed
  140053. * @param onError is a callback called if an error occurs
  140054. */
  140055. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140056. }
  140057. /**
  140058. * Define a task used by AssetsManager to load Equirectangular cube textures
  140059. */
  140060. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  140061. /**
  140062. * Defines the name of the task
  140063. */
  140064. name: string;
  140065. /**
  140066. * Defines the location of the file to load
  140067. */
  140068. url: string;
  140069. /**
  140070. * Defines the desired size (the more it increases the longer the generation will be)
  140071. */
  140072. size: number;
  140073. /**
  140074. * Defines if mipmaps should not be generated (default is false)
  140075. */
  140076. noMipmap: boolean;
  140077. /**
  140078. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  140079. * but the standard material would require them in Gamma space) (default is true)
  140080. */
  140081. gammaSpace: boolean;
  140082. /**
  140083. * Gets the loaded texture
  140084. */
  140085. texture: EquiRectangularCubeTexture;
  140086. /**
  140087. * Callback called when the task is successful
  140088. */
  140089. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  140090. /**
  140091. * Callback called when the task is successful
  140092. */
  140093. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  140094. /**
  140095. * Creates a new EquiRectangularCubeTextureAssetTask object
  140096. * @param name defines the name of the task
  140097. * @param url defines the location of the file to load
  140098. * @param size defines the desired size (the more it increases the longer the generation will be)
  140099. * If the size is omitted this implies you are using a preprocessed cubemap.
  140100. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140101. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  140102. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  140103. * (default is true)
  140104. */
  140105. constructor(
  140106. /**
  140107. * Defines the name of the task
  140108. */
  140109. name: string,
  140110. /**
  140111. * Defines the location of the file to load
  140112. */
  140113. url: string,
  140114. /**
  140115. * Defines the desired size (the more it increases the longer the generation will be)
  140116. */
  140117. size: number,
  140118. /**
  140119. * Defines if mipmaps should not be generated (default is false)
  140120. */
  140121. noMipmap?: boolean,
  140122. /**
  140123. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  140124. * but the standard material would require them in Gamma space) (default is true)
  140125. */
  140126. gammaSpace?: boolean);
  140127. /**
  140128. * Execute the current task
  140129. * @param scene defines the scene where you want your assets to be loaded
  140130. * @param onSuccess is a callback called when the task is successfully executed
  140131. * @param onError is a callback called if an error occurs
  140132. */
  140133. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140134. }
  140135. /**
  140136. * This class can be used to easily import assets into a scene
  140137. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  140138. */
  140139. export class AssetsManager {
  140140. private _scene;
  140141. private _isLoading;
  140142. protected _tasks: AbstractAssetTask[];
  140143. protected _waitingTasksCount: number;
  140144. protected _totalTasksCount: number;
  140145. /**
  140146. * Callback called when all tasks are processed
  140147. */
  140148. onFinish: (tasks: AbstractAssetTask[]) => void;
  140149. /**
  140150. * Callback called when a task is successful
  140151. */
  140152. onTaskSuccess: (task: AbstractAssetTask) => void;
  140153. /**
  140154. * Callback called when a task had an error
  140155. */
  140156. onTaskError: (task: AbstractAssetTask) => void;
  140157. /**
  140158. * Callback called when a task is done (whatever the result is)
  140159. */
  140160. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  140161. /**
  140162. * Observable called when all tasks are processed
  140163. */
  140164. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  140165. /**
  140166. * Observable called when a task had an error
  140167. */
  140168. onTaskErrorObservable: Observable<AbstractAssetTask>;
  140169. /**
  140170. * Observable called when all tasks were executed
  140171. */
  140172. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  140173. /**
  140174. * Observable called when a task is done (whatever the result is)
  140175. */
  140176. onProgressObservable: Observable<IAssetsProgressEvent>;
  140177. /**
  140178. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  140179. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  140180. */
  140181. useDefaultLoadingScreen: boolean;
  140182. /**
  140183. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  140184. * when all assets have been downloaded.
  140185. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  140186. */
  140187. autoHideLoadingUI: boolean;
  140188. /**
  140189. * Creates a new AssetsManager
  140190. * @param scene defines the scene to work on
  140191. */
  140192. constructor(scene: Scene);
  140193. /**
  140194. * Add a MeshAssetTask to the list of active tasks
  140195. * @param taskName defines the name of the new task
  140196. * @param meshesNames defines the name of meshes to load
  140197. * @param rootUrl defines the root url to use to locate files
  140198. * @param sceneFilename defines the filename of the scene file
  140199. * @returns a new MeshAssetTask object
  140200. */
  140201. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  140202. /**
  140203. * Add a TextFileAssetTask to the list of active tasks
  140204. * @param taskName defines the name of the new task
  140205. * @param url defines the url of the file to load
  140206. * @returns a new TextFileAssetTask object
  140207. */
  140208. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  140209. /**
  140210. * Add a BinaryFileAssetTask to the list of active tasks
  140211. * @param taskName defines the name of the new task
  140212. * @param url defines the url of the file to load
  140213. * @returns a new BinaryFileAssetTask object
  140214. */
  140215. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  140216. /**
  140217. * Add a ImageAssetTask to the list of active tasks
  140218. * @param taskName defines the name of the new task
  140219. * @param url defines the url of the file to load
  140220. * @returns a new ImageAssetTask object
  140221. */
  140222. addImageTask(taskName: string, url: string): ImageAssetTask;
  140223. /**
  140224. * Add a TextureAssetTask to the list of active tasks
  140225. * @param taskName defines the name of the new task
  140226. * @param url defines the url of the file to load
  140227. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140228. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  140229. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  140230. * @returns a new TextureAssetTask object
  140231. */
  140232. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  140233. /**
  140234. * Add a CubeTextureAssetTask to the list of active tasks
  140235. * @param taskName defines the name of the new task
  140236. * @param url defines the url of the file to load
  140237. * @param extensions defines the extension to use to load the cube map (can be null)
  140238. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140239. * @param files defines the list of files to load (can be null)
  140240. * @returns a new CubeTextureAssetTask object
  140241. */
  140242. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  140243. /**
  140244. *
  140245. * Add a HDRCubeTextureAssetTask to the list of active tasks
  140246. * @param taskName defines the name of the new task
  140247. * @param url defines the url of the file to load
  140248. * @param size defines the size you want for the cubemap (can be null)
  140249. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140250. * @param generateHarmonics defines if you want to automatically generate (true by default)
  140251. * @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)
  140252. * @param reserved Internal use only
  140253. * @returns a new HDRCubeTextureAssetTask object
  140254. */
  140255. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  140256. /**
  140257. *
  140258. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  140259. * @param taskName defines the name of the new task
  140260. * @param url defines the url of the file to load
  140261. * @param size defines the size you want for the cubemap (can be null)
  140262. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140263. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  140264. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  140265. * @returns a new EquiRectangularCubeTextureAssetTask object
  140266. */
  140267. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  140268. /**
  140269. * Remove a task from the assets manager.
  140270. * @param task the task to remove
  140271. */
  140272. removeTask(task: AbstractAssetTask): void;
  140273. private _decreaseWaitingTasksCount;
  140274. private _runTask;
  140275. /**
  140276. * Reset the AssetsManager and remove all tasks
  140277. * @return the current instance of the AssetsManager
  140278. */
  140279. reset(): AssetsManager;
  140280. /**
  140281. * Start the loading process
  140282. * @return the current instance of the AssetsManager
  140283. */
  140284. load(): AssetsManager;
  140285. /**
  140286. * Start the loading process as an async operation
  140287. * @return a promise returning the list of failed tasks
  140288. */
  140289. loadAsync(): Promise<void>;
  140290. }
  140291. }
  140292. declare module BABYLON {
  140293. /**
  140294. * Wrapper class for promise with external resolve and reject.
  140295. */
  140296. export class Deferred<T> {
  140297. /**
  140298. * The promise associated with this deferred object.
  140299. */
  140300. readonly promise: Promise<T>;
  140301. private _resolve;
  140302. private _reject;
  140303. /**
  140304. * The resolve method of the promise associated with this deferred object.
  140305. */
  140306. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  140307. /**
  140308. * The reject method of the promise associated with this deferred object.
  140309. */
  140310. get reject(): (reason?: any) => void;
  140311. /**
  140312. * Constructor for this deferred object.
  140313. */
  140314. constructor();
  140315. }
  140316. }
  140317. declare module BABYLON {
  140318. /**
  140319. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  140320. */
  140321. export class MeshExploder {
  140322. private _centerMesh;
  140323. private _meshes;
  140324. private _meshesOrigins;
  140325. private _toCenterVectors;
  140326. private _scaledDirection;
  140327. private _newPosition;
  140328. private _centerPosition;
  140329. /**
  140330. * Explodes meshes from a center mesh.
  140331. * @param meshes The meshes to explode.
  140332. * @param centerMesh The mesh to be center of explosion.
  140333. */
  140334. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  140335. private _setCenterMesh;
  140336. /**
  140337. * Get class name
  140338. * @returns "MeshExploder"
  140339. */
  140340. getClassName(): string;
  140341. /**
  140342. * "Exploded meshes"
  140343. * @returns Array of meshes with the centerMesh at index 0.
  140344. */
  140345. getMeshes(): Array<Mesh>;
  140346. /**
  140347. * Explodes meshes giving a specific direction
  140348. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  140349. */
  140350. explode(direction?: number): void;
  140351. }
  140352. }
  140353. declare module BABYLON {
  140354. /**
  140355. * Class used to help managing file picking and drag'n'drop
  140356. */
  140357. export class FilesInput {
  140358. /**
  140359. * List of files ready to be loaded
  140360. */
  140361. static get FilesToLoad(): {
  140362. [key: string]: File;
  140363. };
  140364. /**
  140365. * Callback called when a file is processed
  140366. */
  140367. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  140368. private _engine;
  140369. private _currentScene;
  140370. private _sceneLoadedCallback;
  140371. private _progressCallback;
  140372. private _additionalRenderLoopLogicCallback;
  140373. private _textureLoadingCallback;
  140374. private _startingProcessingFilesCallback;
  140375. private _onReloadCallback;
  140376. private _errorCallback;
  140377. private _elementToMonitor;
  140378. private _sceneFileToLoad;
  140379. private _filesToLoad;
  140380. /**
  140381. * Creates a new FilesInput
  140382. * @param engine defines the rendering engine
  140383. * @param scene defines the hosting scene
  140384. * @param sceneLoadedCallback callback called when scene is loaded
  140385. * @param progressCallback callback called to track progress
  140386. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  140387. * @param textureLoadingCallback callback called when a texture is loading
  140388. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  140389. * @param onReloadCallback callback called when a reload is requested
  140390. * @param errorCallback callback call if an error occurs
  140391. */
  140392. 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);
  140393. private _dragEnterHandler;
  140394. private _dragOverHandler;
  140395. private _dropHandler;
  140396. /**
  140397. * Calls this function to listen to drag'n'drop events on a specific DOM element
  140398. * @param elementToMonitor defines the DOM element to track
  140399. */
  140400. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  140401. /**
  140402. * Release all associated resources
  140403. */
  140404. dispose(): void;
  140405. private renderFunction;
  140406. private drag;
  140407. private drop;
  140408. private _traverseFolder;
  140409. private _processFiles;
  140410. /**
  140411. * Load files from a drop event
  140412. * @param event defines the drop event to use as source
  140413. */
  140414. loadFiles(event: any): void;
  140415. private _processReload;
  140416. /**
  140417. * Reload the current scene from the loaded files
  140418. */
  140419. reload(): void;
  140420. }
  140421. }
  140422. declare module BABYLON {
  140423. /**
  140424. * Defines the root class used to create scene optimization to use with SceneOptimizer
  140425. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140426. */
  140427. export class SceneOptimization {
  140428. /**
  140429. * Defines the priority of this optimization (0 by default which means first in the list)
  140430. */
  140431. priority: number;
  140432. /**
  140433. * Gets a string describing the action executed by the current optimization
  140434. * @returns description string
  140435. */
  140436. getDescription(): string;
  140437. /**
  140438. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140439. * @param scene defines the current scene where to apply this optimization
  140440. * @param optimizer defines the current optimizer
  140441. * @returns true if everything that can be done was applied
  140442. */
  140443. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140444. /**
  140445. * Creates the SceneOptimization object
  140446. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  140447. * @param desc defines the description associated with the optimization
  140448. */
  140449. constructor(
  140450. /**
  140451. * Defines the priority of this optimization (0 by default which means first in the list)
  140452. */
  140453. priority?: number);
  140454. }
  140455. /**
  140456. * Defines an optimization used to reduce the size of render target textures
  140457. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140458. */
  140459. export class TextureOptimization extends SceneOptimization {
  140460. /**
  140461. * Defines the priority of this optimization (0 by default which means first in the list)
  140462. */
  140463. priority: number;
  140464. /**
  140465. * 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
  140466. */
  140467. maximumSize: number;
  140468. /**
  140469. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  140470. */
  140471. step: number;
  140472. /**
  140473. * Gets a string describing the action executed by the current optimization
  140474. * @returns description string
  140475. */
  140476. getDescription(): string;
  140477. /**
  140478. * Creates the TextureOptimization object
  140479. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  140480. * @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
  140481. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  140482. */
  140483. constructor(
  140484. /**
  140485. * Defines the priority of this optimization (0 by default which means first in the list)
  140486. */
  140487. priority?: number,
  140488. /**
  140489. * 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
  140490. */
  140491. maximumSize?: number,
  140492. /**
  140493. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  140494. */
  140495. step?: number);
  140496. /**
  140497. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140498. * @param scene defines the current scene where to apply this optimization
  140499. * @param optimizer defines the current optimizer
  140500. * @returns true if everything that can be done was applied
  140501. */
  140502. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140503. }
  140504. /**
  140505. * Defines an optimization used to increase or decrease the rendering resolution
  140506. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140507. */
  140508. export class HardwareScalingOptimization extends SceneOptimization {
  140509. /**
  140510. * Defines the priority of this optimization (0 by default which means first in the list)
  140511. */
  140512. priority: number;
  140513. /**
  140514. * Defines the maximum scale to use (2 by default)
  140515. */
  140516. maximumScale: number;
  140517. /**
  140518. * Defines the step to use between two passes (0.5 by default)
  140519. */
  140520. step: number;
  140521. private _currentScale;
  140522. private _directionOffset;
  140523. /**
  140524. * Gets a string describing the action executed by the current optimization
  140525. * @return description string
  140526. */
  140527. getDescription(): string;
  140528. /**
  140529. * Creates the HardwareScalingOptimization object
  140530. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  140531. * @param maximumScale defines the maximum scale to use (2 by default)
  140532. * @param step defines the step to use between two passes (0.5 by default)
  140533. */
  140534. constructor(
  140535. /**
  140536. * Defines the priority of this optimization (0 by default which means first in the list)
  140537. */
  140538. priority?: number,
  140539. /**
  140540. * Defines the maximum scale to use (2 by default)
  140541. */
  140542. maximumScale?: number,
  140543. /**
  140544. * Defines the step to use between two passes (0.5 by default)
  140545. */
  140546. step?: number);
  140547. /**
  140548. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140549. * @param scene defines the current scene where to apply this optimization
  140550. * @param optimizer defines the current optimizer
  140551. * @returns true if everything that can be done was applied
  140552. */
  140553. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140554. }
  140555. /**
  140556. * Defines an optimization used to remove shadows
  140557. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140558. */
  140559. export class ShadowsOptimization extends SceneOptimization {
  140560. /**
  140561. * Gets a string describing the action executed by the current optimization
  140562. * @return description string
  140563. */
  140564. getDescription(): string;
  140565. /**
  140566. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140567. * @param scene defines the current scene where to apply this optimization
  140568. * @param optimizer defines the current optimizer
  140569. * @returns true if everything that can be done was applied
  140570. */
  140571. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140572. }
  140573. /**
  140574. * Defines an optimization used to turn post-processes off
  140575. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140576. */
  140577. export class PostProcessesOptimization extends SceneOptimization {
  140578. /**
  140579. * Gets a string describing the action executed by the current optimization
  140580. * @return description string
  140581. */
  140582. getDescription(): string;
  140583. /**
  140584. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140585. * @param scene defines the current scene where to apply this optimization
  140586. * @param optimizer defines the current optimizer
  140587. * @returns true if everything that can be done was applied
  140588. */
  140589. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140590. }
  140591. /**
  140592. * Defines an optimization used to turn lens flares off
  140593. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140594. */
  140595. export class LensFlaresOptimization extends SceneOptimization {
  140596. /**
  140597. * Gets a string describing the action executed by the current optimization
  140598. * @return description string
  140599. */
  140600. getDescription(): string;
  140601. /**
  140602. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140603. * @param scene defines the current scene where to apply this optimization
  140604. * @param optimizer defines the current optimizer
  140605. * @returns true if everything that can be done was applied
  140606. */
  140607. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140608. }
  140609. /**
  140610. * Defines an optimization based on user defined callback.
  140611. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140612. */
  140613. export class CustomOptimization extends SceneOptimization {
  140614. /**
  140615. * Callback called to apply the custom optimization.
  140616. */
  140617. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  140618. /**
  140619. * Callback called to get custom description
  140620. */
  140621. onGetDescription: () => string;
  140622. /**
  140623. * Gets a string describing the action executed by the current optimization
  140624. * @returns description string
  140625. */
  140626. getDescription(): string;
  140627. /**
  140628. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140629. * @param scene defines the current scene where to apply this optimization
  140630. * @param optimizer defines the current optimizer
  140631. * @returns true if everything that can be done was applied
  140632. */
  140633. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140634. }
  140635. /**
  140636. * Defines an optimization used to turn particles off
  140637. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140638. */
  140639. export class ParticlesOptimization extends SceneOptimization {
  140640. /**
  140641. * Gets a string describing the action executed by the current optimization
  140642. * @return description string
  140643. */
  140644. getDescription(): string;
  140645. /**
  140646. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140647. * @param scene defines the current scene where to apply this optimization
  140648. * @param optimizer defines the current optimizer
  140649. * @returns true if everything that can be done was applied
  140650. */
  140651. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140652. }
  140653. /**
  140654. * Defines an optimization used to turn render targets off
  140655. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140656. */
  140657. export class RenderTargetsOptimization extends SceneOptimization {
  140658. /**
  140659. * Gets a string describing the action executed by the current optimization
  140660. * @return description string
  140661. */
  140662. getDescription(): string;
  140663. /**
  140664. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140665. * @param scene defines the current scene where to apply this optimization
  140666. * @param optimizer defines the current optimizer
  140667. * @returns true if everything that can be done was applied
  140668. */
  140669. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  140670. }
  140671. /**
  140672. * Defines an optimization used to merge meshes with compatible materials
  140673. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140674. */
  140675. export class MergeMeshesOptimization extends SceneOptimization {
  140676. private static _UpdateSelectionTree;
  140677. /**
  140678. * Gets or sets a boolean which defines if optimization octree has to be updated
  140679. */
  140680. static get UpdateSelectionTree(): boolean;
  140681. /**
  140682. * Gets or sets a boolean which defines if optimization octree has to be updated
  140683. */
  140684. static set UpdateSelectionTree(value: boolean);
  140685. /**
  140686. * Gets a string describing the action executed by the current optimization
  140687. * @return description string
  140688. */
  140689. getDescription(): string;
  140690. private _canBeMerged;
  140691. /**
  140692. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  140693. * @param scene defines the current scene where to apply this optimization
  140694. * @param optimizer defines the current optimizer
  140695. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  140696. * @returns true if everything that can be done was applied
  140697. */
  140698. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  140699. }
  140700. /**
  140701. * Defines a list of options used by SceneOptimizer
  140702. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140703. */
  140704. export class SceneOptimizerOptions {
  140705. /**
  140706. * Defines the target frame rate to reach (60 by default)
  140707. */
  140708. targetFrameRate: number;
  140709. /**
  140710. * Defines the interval between two checkes (2000ms by default)
  140711. */
  140712. trackerDuration: number;
  140713. /**
  140714. * Gets the list of optimizations to apply
  140715. */
  140716. optimizations: SceneOptimization[];
  140717. /**
  140718. * Creates a new list of options used by SceneOptimizer
  140719. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  140720. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  140721. */
  140722. constructor(
  140723. /**
  140724. * Defines the target frame rate to reach (60 by default)
  140725. */
  140726. targetFrameRate?: number,
  140727. /**
  140728. * Defines the interval between two checkes (2000ms by default)
  140729. */
  140730. trackerDuration?: number);
  140731. /**
  140732. * Add a new optimization
  140733. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  140734. * @returns the current SceneOptimizerOptions
  140735. */
  140736. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  140737. /**
  140738. * Add a new custom optimization
  140739. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  140740. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  140741. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  140742. * @returns the current SceneOptimizerOptions
  140743. */
  140744. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  140745. /**
  140746. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  140747. * @param targetFrameRate defines the target frame rate (60 by default)
  140748. * @returns a SceneOptimizerOptions object
  140749. */
  140750. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  140751. /**
  140752. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  140753. * @param targetFrameRate defines the target frame rate (60 by default)
  140754. * @returns a SceneOptimizerOptions object
  140755. */
  140756. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  140757. /**
  140758. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  140759. * @param targetFrameRate defines the target frame rate (60 by default)
  140760. * @returns a SceneOptimizerOptions object
  140761. */
  140762. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  140763. }
  140764. /**
  140765. * Class used to run optimizations in order to reach a target frame rate
  140766. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  140767. */
  140768. export class SceneOptimizer implements IDisposable {
  140769. private _isRunning;
  140770. private _options;
  140771. private _scene;
  140772. private _currentPriorityLevel;
  140773. private _targetFrameRate;
  140774. private _trackerDuration;
  140775. private _currentFrameRate;
  140776. private _sceneDisposeObserver;
  140777. private _improvementMode;
  140778. /**
  140779. * Defines an observable called when the optimizer reaches the target frame rate
  140780. */
  140781. onSuccessObservable: Observable<SceneOptimizer>;
  140782. /**
  140783. * Defines an observable called when the optimizer enables an optimization
  140784. */
  140785. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  140786. /**
  140787. * Defines an observable called when the optimizer is not able to reach the target frame rate
  140788. */
  140789. onFailureObservable: Observable<SceneOptimizer>;
  140790. /**
  140791. * Gets a boolean indicating if the optimizer is in improvement mode
  140792. */
  140793. get isInImprovementMode(): boolean;
  140794. /**
  140795. * Gets the current priority level (0 at start)
  140796. */
  140797. get currentPriorityLevel(): number;
  140798. /**
  140799. * Gets the current frame rate checked by the SceneOptimizer
  140800. */
  140801. get currentFrameRate(): number;
  140802. /**
  140803. * Gets or sets the current target frame rate (60 by default)
  140804. */
  140805. get targetFrameRate(): number;
  140806. /**
  140807. * Gets or sets the current target frame rate (60 by default)
  140808. */
  140809. set targetFrameRate(value: number);
  140810. /**
  140811. * Gets or sets the current interval between two checks (every 2000ms by default)
  140812. */
  140813. get trackerDuration(): number;
  140814. /**
  140815. * Gets or sets the current interval between two checks (every 2000ms by default)
  140816. */
  140817. set trackerDuration(value: number);
  140818. /**
  140819. * Gets the list of active optimizations
  140820. */
  140821. get optimizations(): SceneOptimization[];
  140822. /**
  140823. * Creates a new SceneOptimizer
  140824. * @param scene defines the scene to work on
  140825. * @param options defines the options to use with the SceneOptimizer
  140826. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  140827. * @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)
  140828. */
  140829. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  140830. /**
  140831. * Stops the current optimizer
  140832. */
  140833. stop(): void;
  140834. /**
  140835. * Reset the optimizer to initial step (current priority level = 0)
  140836. */
  140837. reset(): void;
  140838. /**
  140839. * Start the optimizer. By default it will try to reach a specific framerate
  140840. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  140841. */
  140842. start(): void;
  140843. private _checkCurrentState;
  140844. /**
  140845. * Release all resources
  140846. */
  140847. dispose(): void;
  140848. /**
  140849. * Helper function to create a SceneOptimizer with one single line of code
  140850. * @param scene defines the scene to work on
  140851. * @param options defines the options to use with the SceneOptimizer
  140852. * @param onSuccess defines a callback to call on success
  140853. * @param onFailure defines a callback to call on failure
  140854. * @returns the new SceneOptimizer object
  140855. */
  140856. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  140857. }
  140858. }
  140859. declare module BABYLON {
  140860. /**
  140861. * Class used to serialize a scene into a string
  140862. */
  140863. export class SceneSerializer {
  140864. /**
  140865. * Clear cache used by a previous serialization
  140866. */
  140867. static ClearCache(): void;
  140868. /**
  140869. * Serialize a scene into a JSON compatible object
  140870. * @param scene defines the scene to serialize
  140871. * @returns a JSON compatible object
  140872. */
  140873. static Serialize(scene: Scene): any;
  140874. /**
  140875. * Serialize a mesh into a JSON compatible object
  140876. * @param toSerialize defines the mesh to serialize
  140877. * @param withParents defines if parents must be serialized as well
  140878. * @param withChildren defines if children must be serialized as well
  140879. * @returns a JSON compatible object
  140880. */
  140881. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  140882. }
  140883. }
  140884. declare module BABYLON {
  140885. /**
  140886. * Class used to host texture specific utilities
  140887. */
  140888. export class TextureTools {
  140889. /**
  140890. * Uses the GPU to create a copy texture rescaled at a given size
  140891. * @param texture Texture to copy from
  140892. * @param width defines the desired width
  140893. * @param height defines the desired height
  140894. * @param useBilinearMode defines if bilinear mode has to be used
  140895. * @return the generated texture
  140896. */
  140897. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  140898. }
  140899. }
  140900. declare module BABYLON {
  140901. /**
  140902. * This represents the different options available for the video capture.
  140903. */
  140904. export interface VideoRecorderOptions {
  140905. /** Defines the mime type of the video. */
  140906. mimeType: string;
  140907. /** Defines the FPS the video should be recorded at. */
  140908. fps: number;
  140909. /** Defines the chunk size for the recording data. */
  140910. recordChunckSize: number;
  140911. /** The audio tracks to attach to the recording. */
  140912. audioTracks?: MediaStreamTrack[];
  140913. }
  140914. /**
  140915. * This can help with recording videos from BabylonJS.
  140916. * This is based on the available WebRTC functionalities of the browser.
  140917. *
  140918. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  140919. */
  140920. export class VideoRecorder {
  140921. private static readonly _defaultOptions;
  140922. /**
  140923. * Returns whether or not the VideoRecorder is available in your browser.
  140924. * @param engine Defines the Babylon Engine.
  140925. * @returns true if supported otherwise false.
  140926. */
  140927. static IsSupported(engine: Engine): boolean;
  140928. private readonly _options;
  140929. private _canvas;
  140930. private _mediaRecorder;
  140931. private _recordedChunks;
  140932. private _fileName;
  140933. private _resolve;
  140934. private _reject;
  140935. /**
  140936. * True when a recording is already in progress.
  140937. */
  140938. get isRecording(): boolean;
  140939. /**
  140940. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  140941. * @param engine Defines the BabylonJS Engine you wish to record.
  140942. * @param options Defines options that can be used to customize the capture.
  140943. */
  140944. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  140945. /**
  140946. * Stops the current recording before the default capture timeout passed in the startRecording function.
  140947. */
  140948. stopRecording(): void;
  140949. /**
  140950. * Starts recording the canvas for a max duration specified in parameters.
  140951. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  140952. * If null no automatic download will start and you can rely on the promise to get the data back.
  140953. * @param maxDuration Defines the maximum recording time in seconds.
  140954. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  140955. * @return A promise callback at the end of the recording with the video data in Blob.
  140956. */
  140957. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  140958. /**
  140959. * Releases internal resources used during the recording.
  140960. */
  140961. dispose(): void;
  140962. private _handleDataAvailable;
  140963. private _handleError;
  140964. private _handleStop;
  140965. }
  140966. }
  140967. declare module BABYLON {
  140968. /**
  140969. * Class containing a set of static utilities functions for screenshots
  140970. */
  140971. export class ScreenshotTools {
  140972. /**
  140973. * Captures a screenshot of the current rendering
  140974. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  140975. * @param engine defines the rendering engine
  140976. * @param camera defines the source camera
  140977. * @param size This parameter can be set to a single number or to an object with the
  140978. * following (optional) properties: precision, width, height. If a single number is passed,
  140979. * it will be used for both width and height. If an object is passed, the screenshot size
  140980. * will be derived from the parameters. The precision property is a multiplier allowing
  140981. * rendering at a higher or lower resolution
  140982. * @param successCallback defines the callback receives a single parameter which contains the
  140983. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  140984. * src parameter of an <img> to display it
  140985. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  140986. * Check your browser for supported MIME types
  140987. */
  140988. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  140989. /**
  140990. * Captures a screenshot of the current rendering
  140991. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  140992. * @param engine defines the rendering engine
  140993. * @param camera defines the source camera
  140994. * @param size This parameter can be set to a single number or to an object with the
  140995. * following (optional) properties: precision, width, height. If a single number is passed,
  140996. * it will be used for both width and height. If an object is passed, the screenshot size
  140997. * will be derived from the parameters. The precision property is a multiplier allowing
  140998. * rendering at a higher or lower resolution
  140999. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  141000. * Check your browser for supported MIME types
  141001. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141002. * to the src parameter of an <img> to display it
  141003. */
  141004. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  141005. /**
  141006. * Generates an image screenshot from the specified camera.
  141007. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141008. * @param engine The engine to use for rendering
  141009. * @param camera The camera to use for rendering
  141010. * @param size This parameter can be set to a single number or to an object with the
  141011. * following (optional) properties: precision, width, height. If a single number is passed,
  141012. * it will be used for both width and height. If an object is passed, the screenshot size
  141013. * will be derived from the parameters. The precision property is a multiplier allowing
  141014. * rendering at a higher or lower resolution
  141015. * @param successCallback The callback receives a single parameter which contains the
  141016. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  141017. * src parameter of an <img> to display it
  141018. * @param mimeType The MIME type of the screenshot image (default: image/png).
  141019. * Check your browser for supported MIME types
  141020. * @param samples Texture samples (default: 1)
  141021. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  141022. * @param fileName A name for for the downloaded file.
  141023. */
  141024. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  141025. /**
  141026. * Generates an image screenshot from the specified camera.
  141027. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141028. * @param engine The engine to use for rendering
  141029. * @param camera The camera to use for rendering
  141030. * @param size This parameter can be set to a single number or to an object with the
  141031. * following (optional) properties: precision, width, height. If a single number is passed,
  141032. * it will be used for both width and height. If an object is passed, the screenshot size
  141033. * will be derived from the parameters. The precision property is a multiplier allowing
  141034. * rendering at a higher or lower resolution
  141035. * @param mimeType The MIME type of the screenshot image (default: image/png).
  141036. * Check your browser for supported MIME types
  141037. * @param samples Texture samples (default: 1)
  141038. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  141039. * @param fileName A name for for the downloaded file.
  141040. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141041. * to the src parameter of an <img> to display it
  141042. */
  141043. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  141044. /**
  141045. * Gets height and width for screenshot size
  141046. * @private
  141047. */
  141048. private static _getScreenshotSize;
  141049. }
  141050. }
  141051. declare module BABYLON {
  141052. /**
  141053. * Interface for a data buffer
  141054. */
  141055. export interface IDataBuffer {
  141056. /**
  141057. * Reads bytes from the data buffer.
  141058. * @param byteOffset The byte offset to read
  141059. * @param byteLength The byte length to read
  141060. * @returns A promise that resolves when the bytes are read
  141061. */
  141062. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  141063. /**
  141064. * The byte length of the buffer.
  141065. */
  141066. readonly byteLength: number;
  141067. }
  141068. /**
  141069. * Utility class for reading from a data buffer
  141070. */
  141071. export class DataReader {
  141072. /**
  141073. * The data buffer associated with this data reader.
  141074. */
  141075. readonly buffer: IDataBuffer;
  141076. /**
  141077. * The current byte offset from the beginning of the data buffer.
  141078. */
  141079. byteOffset: number;
  141080. private _dataView;
  141081. private _dataByteOffset;
  141082. /**
  141083. * Constructor
  141084. * @param buffer The buffer to read
  141085. */
  141086. constructor(buffer: IDataBuffer);
  141087. /**
  141088. * Loads the given byte length.
  141089. * @param byteLength The byte length to load
  141090. * @returns A promise that resolves when the load is complete
  141091. */
  141092. loadAsync(byteLength: number): Promise<void>;
  141093. /**
  141094. * Read a unsigned 32-bit integer from the currently loaded data range.
  141095. * @returns The 32-bit integer read
  141096. */
  141097. readUint32(): number;
  141098. /**
  141099. * Read a byte array from the currently loaded data range.
  141100. * @param byteLength The byte length to read
  141101. * @returns The byte array read
  141102. */
  141103. readUint8Array(byteLength: number): Uint8Array;
  141104. /**
  141105. * Read a string from the currently loaded data range.
  141106. * @param byteLength The byte length to read
  141107. * @returns The string read
  141108. */
  141109. readString(byteLength: number): string;
  141110. /**
  141111. * Skips the given byte length the currently loaded data range.
  141112. * @param byteLength The byte length to skip
  141113. */
  141114. skipBytes(byteLength: number): void;
  141115. }
  141116. }
  141117. declare module BABYLON {
  141118. /**
  141119. * Options used for hit testing
  141120. */
  141121. export interface IWebXRHitTestOptions {
  141122. /**
  141123. * Only test when user interacted with the scene. Default - hit test every frame
  141124. */
  141125. testOnPointerDownOnly?: boolean;
  141126. /**
  141127. * The node to use to transform the local results to world coordinates
  141128. */
  141129. worldParentNode?: TransformNode;
  141130. }
  141131. /**
  141132. * Interface defining the babylon result of raycasting/hit-test
  141133. */
  141134. export interface IWebXRHitResult {
  141135. /**
  141136. * The native hit test result
  141137. */
  141138. xrHitResult: XRHitResult;
  141139. /**
  141140. * Transformation matrix that can be applied to a node that will put it in the hit point location
  141141. */
  141142. transformationMatrix: Matrix;
  141143. }
  141144. /**
  141145. * The currently-working hit-test module.
  141146. * Hit test (or raycasting) is used to interact with the real world.
  141147. * For further information read here - https://github.com/immersive-web/hit-test
  141148. */
  141149. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  141150. /**
  141151. * options to use when constructing this feature
  141152. */
  141153. readonly options: IWebXRHitTestOptions;
  141154. /**
  141155. * The module's name
  141156. */
  141157. static readonly Name: string;
  141158. /**
  141159. * The (Babylon) version of this module.
  141160. * This is an integer representing the implementation version.
  141161. * This number does not correspond to the webxr specs version
  141162. */
  141163. static readonly Version: number;
  141164. /**
  141165. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  141166. * @param event the (select) event to use to select with
  141167. * @param referenceSpace the reference space to use for this hit test
  141168. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  141169. */
  141170. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  141171. /**
  141172. * execute a hit test with an XR Ray
  141173. *
  141174. * @param xrSession a native xrSession that will execute this hit test
  141175. * @param xrRay the ray (position and direction) to use for raycasting
  141176. * @param referenceSpace native XR reference space to use for the hit-test
  141177. * @param filter filter function that will filter the results
  141178. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  141179. */
  141180. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  141181. /**
  141182. * Triggered when new babylon (transformed) hit test results are available
  141183. */
  141184. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  141185. private _onSelectEnabled;
  141186. /**
  141187. * Creates a new instance of the (legacy version) hit test feature
  141188. * @param _xrSessionManager an instance of WebXRSessionManager
  141189. * @param options options to use when constructing this feature
  141190. */
  141191. constructor(_xrSessionManager: WebXRSessionManager,
  141192. /**
  141193. * options to use when constructing this feature
  141194. */
  141195. options?: IWebXRHitTestOptions);
  141196. /**
  141197. * Populated with the last native XR Hit Results
  141198. */
  141199. lastNativeXRHitResults: XRHitResult[];
  141200. /**
  141201. * attach this feature
  141202. * Will usually be called by the features manager
  141203. *
  141204. * @returns true if successful.
  141205. */
  141206. attach(): boolean;
  141207. /**
  141208. * detach this feature.
  141209. * Will usually be called by the features manager
  141210. *
  141211. * @returns true if successful.
  141212. */
  141213. detach(): boolean;
  141214. private _onHitTestResults;
  141215. private _origin;
  141216. private _direction;
  141217. private _mat;
  141218. protected _onXRFrame(frame: XRFrame): void;
  141219. private _onSelect;
  141220. /**
  141221. * Dispose this feature and all of the resources attached
  141222. */
  141223. dispose(): void;
  141224. }
  141225. }
  141226. declare module BABYLON {
  141227. /**
  141228. * Options used in the plane detector module
  141229. */
  141230. export interface IWebXRPlaneDetectorOptions {
  141231. /**
  141232. * The node to use to transform the local results to world coordinates
  141233. */
  141234. worldParentNode?: TransformNode;
  141235. }
  141236. /**
  141237. * A babylon interface for a webxr plane.
  141238. * A Plane is actually a polygon, built from N points in space
  141239. *
  141240. * Supported in chrome 79, not supported in canary 81 ATM
  141241. */
  141242. export interface IWebXRPlane {
  141243. /**
  141244. * a babylon-assigned ID for this polygon
  141245. */
  141246. id: number;
  141247. /**
  141248. * the native xr-plane object
  141249. */
  141250. xrPlane: XRPlane;
  141251. /**
  141252. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  141253. */
  141254. polygonDefinition: Array<Vector3>;
  141255. /**
  141256. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  141257. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  141258. */
  141259. transformationMatrix: Matrix;
  141260. }
  141261. /**
  141262. * The plane detector is used to detect planes in the real world when in AR
  141263. * For more information see https://github.com/immersive-web/real-world-geometry/
  141264. */
  141265. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  141266. private _options;
  141267. /**
  141268. * The module's name
  141269. */
  141270. static readonly Name: string;
  141271. /**
  141272. * The (Babylon) version of this module.
  141273. * This is an integer representing the implementation version.
  141274. * This number does not correspond to the webxr specs version
  141275. */
  141276. static readonly Version: number;
  141277. /**
  141278. * Observers registered here will be executed when a new plane was added to the session
  141279. */
  141280. onPlaneAddedObservable: Observable<IWebXRPlane>;
  141281. /**
  141282. * Observers registered here will be executed when a plane is no longer detected in the session
  141283. */
  141284. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  141285. /**
  141286. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  141287. * This can execute N times every frame
  141288. */
  141289. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  141290. private _enabled;
  141291. private _detectedPlanes;
  141292. private _lastFrameDetected;
  141293. /**
  141294. * construct a new Plane Detector
  141295. * @param _xrSessionManager an instance of xr Session manager
  141296. * @param _options configuration to use when constructing this feature
  141297. */
  141298. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  141299. private _init;
  141300. protected _onXRFrame(frame: XRFrame): void;
  141301. /**
  141302. * Dispose this feature and all of the resources attached
  141303. */
  141304. dispose(): void;
  141305. private _updatePlaneWithXRPlane;
  141306. /**
  141307. * avoiding using Array.find for global support.
  141308. * @param xrPlane the plane to find in the array
  141309. */
  141310. private findIndexInPlaneArray;
  141311. }
  141312. }
  141313. declare module BABYLON {
  141314. /**
  141315. * Configuration options of the anchor system
  141316. */
  141317. export interface IWebXRAnchorSystemOptions {
  141318. /**
  141319. * a node that will be used to convert local to world coordinates
  141320. */
  141321. worldParentNode?: TransformNode;
  141322. /**
  141323. * should the anchor system use plane detection.
  141324. * If set to true, the plane-detection feature should be set using setPlaneDetector
  141325. */
  141326. usePlaneDetection?: boolean;
  141327. /**
  141328. * Should a new anchor be added every time a select event is triggered
  141329. */
  141330. addAnchorOnSelect?: boolean;
  141331. }
  141332. /**
  141333. * A babylon container for an XR Anchor
  141334. */
  141335. export interface IWebXRAnchor {
  141336. /**
  141337. * A babylon-assigned ID for this anchor
  141338. */
  141339. id: number;
  141340. /**
  141341. * The native anchor object
  141342. */
  141343. xrAnchor: XRAnchor;
  141344. /**
  141345. * Transformation matrix to apply to an object attached to this anchor
  141346. */
  141347. transformationMatrix: Matrix;
  141348. }
  141349. /**
  141350. * An implementation of the anchor system of WebXR.
  141351. * Note that the current documented implementation is not available in any browser. Future implementations
  141352. * will use the frame to create an anchor and not the session or a detected plane
  141353. * For further information see https://github.com/immersive-web/anchors/
  141354. */
  141355. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  141356. private _options;
  141357. /**
  141358. * The module's name
  141359. */
  141360. static readonly Name: string;
  141361. /**
  141362. * The (Babylon) version of this module.
  141363. * This is an integer representing the implementation version.
  141364. * This number does not correspond to the webxr specs version
  141365. */
  141366. static readonly Version: number;
  141367. /**
  141368. * Observers registered here will be executed when a new anchor was added to the session
  141369. */
  141370. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  141371. /**
  141372. * Observers registered here will be executed when an existing anchor updates
  141373. * This can execute N times every frame
  141374. */
  141375. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  141376. /**
  141377. * Observers registered here will be executed when an anchor was removed from the session
  141378. */
  141379. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  141380. private _planeDetector;
  141381. private _hitTestModule;
  141382. private _enabled;
  141383. private _trackedAnchors;
  141384. private _lastFrameDetected;
  141385. /**
  141386. * constructs a new anchor system
  141387. * @param _xrSessionManager an instance of WebXRSessionManager
  141388. * @param _options configuration object for this feature
  141389. */
  141390. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  141391. /**
  141392. * set the plane detector to use in order to create anchors from frames
  141393. * @param planeDetector the plane-detector module to use
  141394. * @param enable enable plane-anchors. default is true
  141395. */
  141396. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  141397. /**
  141398. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  141399. * @param hitTestModule the hit-test module to use.
  141400. */
  141401. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  141402. /**
  141403. * attach this feature
  141404. * Will usually be called by the features manager
  141405. *
  141406. * @returns true if successful.
  141407. */
  141408. attach(): boolean;
  141409. /**
  141410. * detach this feature.
  141411. * Will usually be called by the features manager
  141412. *
  141413. * @returns true if successful.
  141414. */
  141415. detach(): boolean;
  141416. /**
  141417. * Dispose this feature and all of the resources attached
  141418. */
  141419. dispose(): void;
  141420. protected _onXRFrame(frame: XRFrame): void;
  141421. private _onSelect;
  141422. /**
  141423. * Add anchor at a specific XR point.
  141424. *
  141425. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  141426. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  141427. * @returns a promise the fulfills when the anchor was created
  141428. */
  141429. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  141430. private _updateAnchorWithXRFrame;
  141431. /**
  141432. * avoiding using Array.find for global support.
  141433. * @param xrAnchor the plane to find in the array
  141434. */
  141435. private _findIndexInAnchorArray;
  141436. }
  141437. }
  141438. declare module BABYLON {
  141439. /**
  141440. * Options interface for the background remover plugin
  141441. */
  141442. export interface IWebXRBackgroundRemoverOptions {
  141443. /**
  141444. * don't disable the environment helper
  141445. */
  141446. ignoreEnvironmentHelper?: boolean;
  141447. /**
  141448. * flags to configure the removal of the environment helper.
  141449. * If not set, the entire background will be removed. If set, flags should be set as well.
  141450. */
  141451. environmentHelperRemovalFlags?: {
  141452. /**
  141453. * Should the skybox be removed (default false)
  141454. */
  141455. skyBox?: boolean;
  141456. /**
  141457. * Should the ground be removed (default false)
  141458. */
  141459. ground?: boolean;
  141460. };
  141461. /**
  141462. * Further background meshes to disable when entering AR
  141463. */
  141464. backgroundMeshes?: AbstractMesh[];
  141465. }
  141466. /**
  141467. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  141468. */
  141469. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  141470. /**
  141471. * read-only options to be used in this module
  141472. */
  141473. readonly options: IWebXRBackgroundRemoverOptions;
  141474. /**
  141475. * The module's name
  141476. */
  141477. static readonly Name: string;
  141478. /**
  141479. * The (Babylon) version of this module.
  141480. * This is an integer representing the implementation version.
  141481. * This number does not correspond to the webxr specs version
  141482. */
  141483. static readonly Version: number;
  141484. /**
  141485. * registered observers will be triggered when the background state changes
  141486. */
  141487. onBackgroundStateChangedObservable: Observable<boolean>;
  141488. /**
  141489. * constructs a new background remover module
  141490. * @param _xrSessionManager the session manager for this module
  141491. * @param options read-only options to be used in this module
  141492. */
  141493. constructor(_xrSessionManager: WebXRSessionManager,
  141494. /**
  141495. * read-only options to be used in this module
  141496. */
  141497. options?: IWebXRBackgroundRemoverOptions);
  141498. /**
  141499. * attach this feature
  141500. * Will usually be called by the features manager
  141501. *
  141502. * @returns true if successful.
  141503. */
  141504. attach(): boolean;
  141505. /**
  141506. * detach this feature.
  141507. * Will usually be called by the features manager
  141508. *
  141509. * @returns true if successful.
  141510. */
  141511. detach(): boolean;
  141512. private _setBackgroundState;
  141513. /**
  141514. * Dispose this feature and all of the resources attached
  141515. */
  141516. dispose(): void;
  141517. protected _onXRFrame(_xrFrame: XRFrame): void;
  141518. }
  141519. }
  141520. declare module BABYLON {
  141521. /**
  141522. * Options for the controller physics feature
  141523. */
  141524. export class IWebXRControllerPhysicsOptions {
  141525. /**
  141526. * the xr input to use with this pointer selection
  141527. */
  141528. xrInput: WebXRInput;
  141529. /**
  141530. * The physics properties of the future impostors
  141531. */
  141532. physicsProperties?: {
  141533. /**
  141534. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  141535. * Note that this requires a physics engine that supports mesh impostors!
  141536. */
  141537. useControllerMesh?: boolean;
  141538. /**
  141539. * The type of impostor to create. Default is sphere
  141540. */
  141541. impostorType?: number;
  141542. /**
  141543. * the size of the impostor. Defaults to 10cm
  141544. */
  141545. impostorSize?: number | {
  141546. width: number;
  141547. height: number;
  141548. depth: number;
  141549. };
  141550. /**
  141551. * Friction definitions
  141552. */
  141553. friction?: number;
  141554. /**
  141555. * Restitution
  141556. */
  141557. restitution?: number;
  141558. };
  141559. }
  141560. /**
  141561. * Add physics impostor to your webxr controllers,
  141562. * including naive calculation of their linear and angular velocity
  141563. */
  141564. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  141565. private readonly _options;
  141566. /**
  141567. * The module's name
  141568. */
  141569. static readonly Name: string;
  141570. /**
  141571. * The (Babylon) version of this module.
  141572. * This is an integer representing the implementation version.
  141573. * This number does not correspond to the webxr specs version
  141574. */
  141575. static readonly Version: number;
  141576. private _lastTimestamp;
  141577. private _delta;
  141578. private _controllers;
  141579. private _tmpVector;
  141580. private _tmpQuaternion;
  141581. /**
  141582. * Construct a new Controller Physics Feature
  141583. * @param _xrSessionManager the corresponding xr session manager
  141584. * @param _options options to create this feature with
  141585. */
  141586. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  141587. /**
  141588. * Update the physics properties provided in the constructor
  141589. * @param newProperties the new properties object
  141590. */
  141591. setPhysicsProperties(newProperties: {
  141592. impostorType?: number;
  141593. impostorSize?: number | {
  141594. width: number;
  141595. height: number;
  141596. depth: number;
  141597. };
  141598. friction?: number;
  141599. restitution?: number;
  141600. }): void;
  141601. /**
  141602. * attach this feature
  141603. * Will usually be called by the features manager
  141604. *
  141605. * @returns true if successful.
  141606. */
  141607. attach(): boolean;
  141608. /**
  141609. * detach this feature.
  141610. * Will usually be called by the features manager
  141611. *
  141612. * @returns true if successful.
  141613. */
  141614. detach(): boolean;
  141615. /**
  141616. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  141617. * @param xrController the controller to add
  141618. */
  141619. addController(xrController: WebXRInputSource): void;
  141620. private _debugMode;
  141621. /**
  141622. * @hidden
  141623. * enable debugging - will show console outputs and the impostor mesh
  141624. */
  141625. _enablePhysicsDebug(): void;
  141626. private _attachController;
  141627. private _detachController;
  141628. protected _onXRFrame(_xrFrame: any): void;
  141629. }
  141630. }
  141631. declare module BABYLON {
  141632. /**
  141633. * The motion controller class for all microsoft mixed reality controllers
  141634. */
  141635. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  141636. /**
  141637. * The base url used to load the left and right controller models
  141638. */
  141639. static MODEL_BASE_URL: string;
  141640. /**
  141641. * The name of the left controller model file
  141642. */
  141643. static MODEL_LEFT_FILENAME: string;
  141644. /**
  141645. * The name of the right controller model file
  141646. */
  141647. static MODEL_RIGHT_FILENAME: string;
  141648. profileId: string;
  141649. protected readonly _mapping: {
  141650. defaultButton: {
  141651. "valueNodeName": string;
  141652. "unpressedNodeName": string;
  141653. "pressedNodeName": string;
  141654. };
  141655. defaultAxis: {
  141656. "valueNodeName": string;
  141657. "minNodeName": string;
  141658. "maxNodeName": string;
  141659. };
  141660. buttons: {
  141661. "xr-standard-trigger": {
  141662. "rootNodeName": string;
  141663. "componentProperty": string;
  141664. "states": string[];
  141665. };
  141666. "xr-standard-squeeze": {
  141667. "rootNodeName": string;
  141668. "componentProperty": string;
  141669. "states": string[];
  141670. };
  141671. "xr-standard-touchpad": {
  141672. "rootNodeName": string;
  141673. "labelAnchorNodeName": string;
  141674. "touchPointNodeName": string;
  141675. };
  141676. "xr-standard-thumbstick": {
  141677. "rootNodeName": string;
  141678. "componentProperty": string;
  141679. "states": string[];
  141680. };
  141681. };
  141682. axes: {
  141683. "xr-standard-touchpad": {
  141684. "x-axis": {
  141685. "rootNodeName": string;
  141686. };
  141687. "y-axis": {
  141688. "rootNodeName": string;
  141689. };
  141690. };
  141691. "xr-standard-thumbstick": {
  141692. "x-axis": {
  141693. "rootNodeName": string;
  141694. };
  141695. "y-axis": {
  141696. "rootNodeName": string;
  141697. };
  141698. };
  141699. };
  141700. };
  141701. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  141702. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  141703. protected _getFilenameAndPath(): {
  141704. filename: string;
  141705. path: string;
  141706. };
  141707. protected _updateModel(): void;
  141708. protected _getModelLoadingConstraints(): boolean;
  141709. protected _setRootMesh(meshes: AbstractMesh[]): void;
  141710. }
  141711. }
  141712. declare module BABYLON {
  141713. /**
  141714. * The motion controller class for oculus touch (quest, rift).
  141715. * This class supports legacy mapping as well the standard xr mapping
  141716. */
  141717. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  141718. private _forceLegacyControllers;
  141719. /**
  141720. * The base url used to load the left and right controller models
  141721. */
  141722. static MODEL_BASE_URL: string;
  141723. /**
  141724. * The name of the left controller model file
  141725. */
  141726. static MODEL_LEFT_FILENAME: string;
  141727. /**
  141728. * The name of the right controller model file
  141729. */
  141730. static MODEL_RIGHT_FILENAME: string;
  141731. /**
  141732. * Base Url for the Quest controller model.
  141733. */
  141734. static QUEST_MODEL_BASE_URL: string;
  141735. profileId: string;
  141736. private _modelRootNode;
  141737. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  141738. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  141739. protected _getFilenameAndPath(): {
  141740. filename: string;
  141741. path: string;
  141742. };
  141743. /**
  141744. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  141745. * between the touch and touch 2.
  141746. */
  141747. private _isQuest;
  141748. protected _updateModel(): void;
  141749. protected _getModelLoadingConstraints(): boolean;
  141750. protected _setRootMesh(meshes: AbstractMesh[]): void;
  141751. }
  141752. }
  141753. declare module BABYLON {
  141754. /**
  141755. * The motion controller class for the standard HTC-Vive controllers
  141756. */
  141757. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  141758. /**
  141759. * The base url used to load the left and right controller models
  141760. */
  141761. static MODEL_BASE_URL: string;
  141762. /**
  141763. * File name for the controller model.
  141764. */
  141765. static MODEL_FILENAME: string;
  141766. profileId: string;
  141767. private _modelRootNode;
  141768. /**
  141769. * Create a new Vive motion controller object
  141770. * @param scene the scene to use to create this controller
  141771. * @param gamepadObject the corresponding gamepad object
  141772. * @param handness the handness of the controller
  141773. */
  141774. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  141775. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  141776. protected _getFilenameAndPath(): {
  141777. filename: string;
  141778. path: string;
  141779. };
  141780. protected _updateModel(): void;
  141781. protected _getModelLoadingConstraints(): boolean;
  141782. protected _setRootMesh(meshes: AbstractMesh[]): void;
  141783. }
  141784. }
  141785. declare module BABYLON {
  141786. /**
  141787. * A cursor which tracks a point on a path
  141788. */
  141789. export class PathCursor {
  141790. private path;
  141791. /**
  141792. * Stores path cursor callbacks for when an onchange event is triggered
  141793. */
  141794. private _onchange;
  141795. /**
  141796. * The value of the path cursor
  141797. */
  141798. value: number;
  141799. /**
  141800. * The animation array of the path cursor
  141801. */
  141802. animations: Animation[];
  141803. /**
  141804. * Initializes the path cursor
  141805. * @param path The path to track
  141806. */
  141807. constructor(path: Path2);
  141808. /**
  141809. * Gets the cursor point on the path
  141810. * @returns A point on the path cursor at the cursor location
  141811. */
  141812. getPoint(): Vector3;
  141813. /**
  141814. * Moves the cursor ahead by the step amount
  141815. * @param step The amount to move the cursor forward
  141816. * @returns This path cursor
  141817. */
  141818. moveAhead(step?: number): PathCursor;
  141819. /**
  141820. * Moves the cursor behind by the step amount
  141821. * @param step The amount to move the cursor back
  141822. * @returns This path cursor
  141823. */
  141824. moveBack(step?: number): PathCursor;
  141825. /**
  141826. * Moves the cursor by the step amount
  141827. * If the step amount is greater than one, an exception is thrown
  141828. * @param step The amount to move the cursor
  141829. * @returns This path cursor
  141830. */
  141831. move(step: number): PathCursor;
  141832. /**
  141833. * Ensures that the value is limited between zero and one
  141834. * @returns This path cursor
  141835. */
  141836. private ensureLimits;
  141837. /**
  141838. * Runs onchange callbacks on change (used by the animation engine)
  141839. * @returns This path cursor
  141840. */
  141841. private raiseOnChange;
  141842. /**
  141843. * Executes a function on change
  141844. * @param f A path cursor onchange callback
  141845. * @returns This path cursor
  141846. */
  141847. onchange(f: (cursor: PathCursor) => void): PathCursor;
  141848. }
  141849. }
  141850. declare module BABYLON {
  141851. /** @hidden */
  141852. export var blurPixelShader: {
  141853. name: string;
  141854. shader: string;
  141855. };
  141856. }
  141857. declare module BABYLON {
  141858. /** @hidden */
  141859. export var pointCloudVertexDeclaration: {
  141860. name: string;
  141861. shader: string;
  141862. };
  141863. }
  141864. // Mixins
  141865. interface Window {
  141866. mozIndexedDB: IDBFactory;
  141867. webkitIndexedDB: IDBFactory;
  141868. msIndexedDB: IDBFactory;
  141869. webkitURL: typeof URL;
  141870. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  141871. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  141872. WebGLRenderingContext: WebGLRenderingContext;
  141873. MSGesture: MSGesture;
  141874. CANNON: any;
  141875. AudioContext: AudioContext;
  141876. webkitAudioContext: AudioContext;
  141877. PointerEvent: any;
  141878. Math: Math;
  141879. Uint8Array: Uint8ArrayConstructor;
  141880. Float32Array: Float32ArrayConstructor;
  141881. mozURL: typeof URL;
  141882. msURL: typeof URL;
  141883. VRFrameData: any; // WebVR, from specs 1.1
  141884. DracoDecoderModule: any;
  141885. setImmediate(handler: (...args: any[]) => void): number;
  141886. }
  141887. interface HTMLCanvasElement {
  141888. requestPointerLock(): void;
  141889. msRequestPointerLock?(): void;
  141890. mozRequestPointerLock?(): void;
  141891. webkitRequestPointerLock?(): void;
  141892. /** Track wether a record is in progress */
  141893. isRecording: boolean;
  141894. /** Capture Stream method defined by some browsers */
  141895. captureStream(fps?: number): MediaStream;
  141896. }
  141897. interface CanvasRenderingContext2D {
  141898. msImageSmoothingEnabled: boolean;
  141899. }
  141900. interface MouseEvent {
  141901. mozMovementX: number;
  141902. mozMovementY: number;
  141903. webkitMovementX: number;
  141904. webkitMovementY: number;
  141905. msMovementX: number;
  141906. msMovementY: number;
  141907. }
  141908. interface Navigator {
  141909. mozGetVRDevices: (any: any) => any;
  141910. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  141911. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  141912. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  141913. webkitGetGamepads(): Gamepad[];
  141914. msGetGamepads(): Gamepad[];
  141915. webkitGamepads(): Gamepad[];
  141916. }
  141917. interface HTMLVideoElement {
  141918. mozSrcObject: any;
  141919. }
  141920. interface Math {
  141921. fround(x: number): number;
  141922. imul(a: number, b: number): number;
  141923. }
  141924. interface WebGLRenderingContext {
  141925. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  141926. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  141927. vertexAttribDivisor(index: number, divisor: number): void;
  141928. createVertexArray(): any;
  141929. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  141930. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  141931. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  141932. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  141933. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  141934. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  141935. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  141936. // Queries
  141937. createQuery(): WebGLQuery;
  141938. deleteQuery(query: WebGLQuery): void;
  141939. beginQuery(target: number, query: WebGLQuery): void;
  141940. endQuery(target: number): void;
  141941. getQueryParameter(query: WebGLQuery, pname: number): any;
  141942. getQuery(target: number, pname: number): any;
  141943. MAX_SAMPLES: number;
  141944. RGBA8: number;
  141945. READ_FRAMEBUFFER: number;
  141946. DRAW_FRAMEBUFFER: number;
  141947. UNIFORM_BUFFER: number;
  141948. HALF_FLOAT_OES: number;
  141949. RGBA16F: number;
  141950. RGBA32F: number;
  141951. R32F: number;
  141952. RG32F: number;
  141953. RGB32F: number;
  141954. R16F: number;
  141955. RG16F: number;
  141956. RGB16F: number;
  141957. RED: number;
  141958. RG: number;
  141959. R8: number;
  141960. RG8: number;
  141961. UNSIGNED_INT_24_8: number;
  141962. DEPTH24_STENCIL8: number;
  141963. MIN: number;
  141964. MAX: number;
  141965. /* Multiple Render Targets */
  141966. drawBuffers(buffers: number[]): void;
  141967. readBuffer(src: number): void;
  141968. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  141969. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  141970. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  141971. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  141972. // Occlusion Query
  141973. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  141974. ANY_SAMPLES_PASSED: number;
  141975. QUERY_RESULT_AVAILABLE: number;
  141976. QUERY_RESULT: number;
  141977. }
  141978. interface WebGLProgram {
  141979. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  141980. }
  141981. interface EXT_disjoint_timer_query {
  141982. QUERY_COUNTER_BITS_EXT: number;
  141983. TIME_ELAPSED_EXT: number;
  141984. TIMESTAMP_EXT: number;
  141985. GPU_DISJOINT_EXT: number;
  141986. QUERY_RESULT_EXT: number;
  141987. QUERY_RESULT_AVAILABLE_EXT: number;
  141988. queryCounterEXT(query: WebGLQuery, target: number): void;
  141989. createQueryEXT(): WebGLQuery;
  141990. beginQueryEXT(target: number, query: WebGLQuery): void;
  141991. endQueryEXT(target: number): void;
  141992. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  141993. deleteQueryEXT(query: WebGLQuery): void;
  141994. }
  141995. interface WebGLUniformLocation {
  141996. _currentState: any;
  141997. }
  141998. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  141999. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  142000. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  142001. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  142002. interface WebGLRenderingContext {
  142003. readonly RASTERIZER_DISCARD: number;
  142004. readonly DEPTH_COMPONENT24: number;
  142005. readonly TEXTURE_3D: number;
  142006. readonly TEXTURE_2D_ARRAY: number;
  142007. readonly TEXTURE_COMPARE_FUNC: number;
  142008. readonly TEXTURE_COMPARE_MODE: number;
  142009. readonly COMPARE_REF_TO_TEXTURE: number;
  142010. readonly TEXTURE_WRAP_R: number;
  142011. readonly HALF_FLOAT: number;
  142012. readonly RGB8: number;
  142013. readonly RED_INTEGER: number;
  142014. readonly RG_INTEGER: number;
  142015. readonly RGB_INTEGER: number;
  142016. readonly RGBA_INTEGER: number;
  142017. readonly R8_SNORM: number;
  142018. readonly RG8_SNORM: number;
  142019. readonly RGB8_SNORM: number;
  142020. readonly RGBA8_SNORM: number;
  142021. readonly R8I: number;
  142022. readonly RG8I: number;
  142023. readonly RGB8I: number;
  142024. readonly RGBA8I: number;
  142025. readonly R8UI: number;
  142026. readonly RG8UI: number;
  142027. readonly RGB8UI: number;
  142028. readonly RGBA8UI: number;
  142029. readonly R16I: number;
  142030. readonly RG16I: number;
  142031. readonly RGB16I: number;
  142032. readonly RGBA16I: number;
  142033. readonly R16UI: number;
  142034. readonly RG16UI: number;
  142035. readonly RGB16UI: number;
  142036. readonly RGBA16UI: number;
  142037. readonly R32I: number;
  142038. readonly RG32I: number;
  142039. readonly RGB32I: number;
  142040. readonly RGBA32I: number;
  142041. readonly R32UI: number;
  142042. readonly RG32UI: number;
  142043. readonly RGB32UI: number;
  142044. readonly RGBA32UI: number;
  142045. readonly RGB10_A2UI: number;
  142046. readonly R11F_G11F_B10F: number;
  142047. readonly RGB9_E5: number;
  142048. readonly RGB10_A2: number;
  142049. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  142050. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  142051. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  142052. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  142053. readonly DEPTH_COMPONENT32F: number;
  142054. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  142055. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  142056. 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;
  142057. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  142058. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  142059. readonly TRANSFORM_FEEDBACK: number;
  142060. readonly INTERLEAVED_ATTRIBS: number;
  142061. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  142062. createTransformFeedback(): WebGLTransformFeedback;
  142063. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  142064. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  142065. beginTransformFeedback(primitiveMode: number): void;
  142066. endTransformFeedback(): void;
  142067. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  142068. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142069. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142070. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142071. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  142072. }
  142073. interface ImageBitmap {
  142074. readonly width: number;
  142075. readonly height: number;
  142076. close(): void;
  142077. }
  142078. interface WebGLQuery extends WebGLObject {
  142079. }
  142080. declare var WebGLQuery: {
  142081. prototype: WebGLQuery;
  142082. new(): WebGLQuery;
  142083. };
  142084. interface WebGLSampler extends WebGLObject {
  142085. }
  142086. declare var WebGLSampler: {
  142087. prototype: WebGLSampler;
  142088. new(): WebGLSampler;
  142089. };
  142090. interface WebGLSync extends WebGLObject {
  142091. }
  142092. declare var WebGLSync: {
  142093. prototype: WebGLSync;
  142094. new(): WebGLSync;
  142095. };
  142096. interface WebGLTransformFeedback extends WebGLObject {
  142097. }
  142098. declare var WebGLTransformFeedback: {
  142099. prototype: WebGLTransformFeedback;
  142100. new(): WebGLTransformFeedback;
  142101. };
  142102. interface WebGLVertexArrayObject extends WebGLObject {
  142103. }
  142104. declare var WebGLVertexArrayObject: {
  142105. prototype: WebGLVertexArrayObject;
  142106. new(): WebGLVertexArrayObject;
  142107. };
  142108. // Type definitions for WebVR API
  142109. // Project: https://w3c.github.io/webvr/
  142110. // Definitions by: six a <https://github.com/lostfictions>
  142111. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  142112. interface VRDisplay extends EventTarget {
  142113. /**
  142114. * Dictionary of capabilities describing the VRDisplay.
  142115. */
  142116. readonly capabilities: VRDisplayCapabilities;
  142117. /**
  142118. * z-depth defining the far plane of the eye view frustum
  142119. * enables mapping of values in the render target depth
  142120. * attachment to scene coordinates. Initially set to 10000.0.
  142121. */
  142122. depthFar: number;
  142123. /**
  142124. * z-depth defining the near plane of the eye view frustum
  142125. * enables mapping of values in the render target depth
  142126. * attachment to scene coordinates. Initially set to 0.01.
  142127. */
  142128. depthNear: number;
  142129. /**
  142130. * An identifier for this distinct VRDisplay. Used as an
  142131. * association point in the Gamepad API.
  142132. */
  142133. readonly displayId: number;
  142134. /**
  142135. * A display name, a user-readable name identifying it.
  142136. */
  142137. readonly displayName: string;
  142138. readonly isConnected: boolean;
  142139. readonly isPresenting: boolean;
  142140. /**
  142141. * If this VRDisplay supports room-scale experiences, the optional
  142142. * stage attribute contains details on the room-scale parameters.
  142143. */
  142144. readonly stageParameters: VRStageParameters | null;
  142145. /**
  142146. * Passing the value returned by `requestAnimationFrame` to
  142147. * `cancelAnimationFrame` will unregister the callback.
  142148. * @param handle Define the hanle of the request to cancel
  142149. */
  142150. cancelAnimationFrame(handle: number): void;
  142151. /**
  142152. * Stops presenting to the VRDisplay.
  142153. * @returns a promise to know when it stopped
  142154. */
  142155. exitPresent(): Promise<void>;
  142156. /**
  142157. * Return the current VREyeParameters for the given eye.
  142158. * @param whichEye Define the eye we want the parameter for
  142159. * @returns the eye parameters
  142160. */
  142161. getEyeParameters(whichEye: string): VREyeParameters;
  142162. /**
  142163. * Populates the passed VRFrameData with the information required to render
  142164. * the current frame.
  142165. * @param frameData Define the data structure to populate
  142166. * @returns true if ok otherwise false
  142167. */
  142168. getFrameData(frameData: VRFrameData): boolean;
  142169. /**
  142170. * Get the layers currently being presented.
  142171. * @returns the list of VR layers
  142172. */
  142173. getLayers(): VRLayer[];
  142174. /**
  142175. * Return a VRPose containing the future predicted pose of the VRDisplay
  142176. * when the current frame will be presented. The value returned will not
  142177. * change until JavaScript has returned control to the browser.
  142178. *
  142179. * The VRPose will contain the position, orientation, velocity,
  142180. * and acceleration of each of these properties.
  142181. * @returns the pose object
  142182. */
  142183. getPose(): VRPose;
  142184. /**
  142185. * Return the current instantaneous pose of the VRDisplay, with no
  142186. * prediction applied.
  142187. * @returns the current instantaneous pose
  142188. */
  142189. getImmediatePose(): VRPose;
  142190. /**
  142191. * The callback passed to `requestAnimationFrame` will be called
  142192. * any time a new frame should be rendered. When the VRDisplay is
  142193. * presenting the callback will be called at the native refresh
  142194. * rate of the HMD. When not presenting this function acts
  142195. * identically to how window.requestAnimationFrame acts. Content should
  142196. * make no assumptions of frame rate or vsync behavior as the HMD runs
  142197. * asynchronously from other displays and at differing refresh rates.
  142198. * @param callback Define the eaction to run next frame
  142199. * @returns the request handle it
  142200. */
  142201. requestAnimationFrame(callback: FrameRequestCallback): number;
  142202. /**
  142203. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  142204. * Repeat calls while already presenting will update the VRLayers being displayed.
  142205. * @param layers Define the list of layer to present
  142206. * @returns a promise to know when the request has been fulfilled
  142207. */
  142208. requestPresent(layers: VRLayer[]): Promise<void>;
  142209. /**
  142210. * Reset the pose for this display, treating its current position and
  142211. * orientation as the "origin/zero" values. VRPose.position,
  142212. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  142213. * updated when calling resetPose(). This should be called in only
  142214. * sitting-space experiences.
  142215. */
  142216. resetPose(): void;
  142217. /**
  142218. * The VRLayer provided to the VRDisplay will be captured and presented
  142219. * in the HMD. Calling this function has the same effect on the source
  142220. * canvas as any other operation that uses its source image, and canvases
  142221. * created without preserveDrawingBuffer set to true will be cleared.
  142222. * @param pose Define the pose to submit
  142223. */
  142224. submitFrame(pose?: VRPose): void;
  142225. }
  142226. declare var VRDisplay: {
  142227. prototype: VRDisplay;
  142228. new(): VRDisplay;
  142229. };
  142230. interface VRLayer {
  142231. leftBounds?: number[] | Float32Array | null;
  142232. rightBounds?: number[] | Float32Array | null;
  142233. source?: HTMLCanvasElement | null;
  142234. }
  142235. interface VRDisplayCapabilities {
  142236. readonly canPresent: boolean;
  142237. readonly hasExternalDisplay: boolean;
  142238. readonly hasOrientation: boolean;
  142239. readonly hasPosition: boolean;
  142240. readonly maxLayers: number;
  142241. }
  142242. interface VREyeParameters {
  142243. /** @deprecated */
  142244. readonly fieldOfView: VRFieldOfView;
  142245. readonly offset: Float32Array;
  142246. readonly renderHeight: number;
  142247. readonly renderWidth: number;
  142248. }
  142249. interface VRFieldOfView {
  142250. readonly downDegrees: number;
  142251. readonly leftDegrees: number;
  142252. readonly rightDegrees: number;
  142253. readonly upDegrees: number;
  142254. }
  142255. interface VRFrameData {
  142256. readonly leftProjectionMatrix: Float32Array;
  142257. readonly leftViewMatrix: Float32Array;
  142258. readonly pose: VRPose;
  142259. readonly rightProjectionMatrix: Float32Array;
  142260. readonly rightViewMatrix: Float32Array;
  142261. readonly timestamp: number;
  142262. }
  142263. interface VRPose {
  142264. readonly angularAcceleration: Float32Array | null;
  142265. readonly angularVelocity: Float32Array | null;
  142266. readonly linearAcceleration: Float32Array | null;
  142267. readonly linearVelocity: Float32Array | null;
  142268. readonly orientation: Float32Array | null;
  142269. readonly position: Float32Array | null;
  142270. readonly timestamp: number;
  142271. }
  142272. interface VRStageParameters {
  142273. sittingToStandingTransform?: Float32Array;
  142274. sizeX?: number;
  142275. sizeY?: number;
  142276. }
  142277. interface Navigator {
  142278. getVRDisplays(): Promise<VRDisplay[]>;
  142279. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  142280. }
  142281. interface Window {
  142282. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  142283. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  142284. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  142285. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  142286. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  142287. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  142288. }
  142289. interface Gamepad {
  142290. readonly displayId: number;
  142291. }
  142292. type XRSessionMode =
  142293. | "inline"
  142294. | "immersive-vr"
  142295. | "immersive-ar";
  142296. type XRReferenceSpaceType =
  142297. | "viewer"
  142298. | "local"
  142299. | "local-floor"
  142300. | "bounded-floor"
  142301. | "unbounded";
  142302. type XREnvironmentBlendMode =
  142303. | "opaque"
  142304. | "additive"
  142305. | "alpha-blend";
  142306. type XRVisibilityState =
  142307. | "visible"
  142308. | "visible-blurred"
  142309. | "hidden";
  142310. type XRHandedness =
  142311. | "none"
  142312. | "left"
  142313. | "right";
  142314. type XRTargetRayMode =
  142315. | "gaze"
  142316. | "tracked-pointer"
  142317. | "screen";
  142318. type XREye =
  142319. | "none"
  142320. | "left"
  142321. | "right";
  142322. interface XRSpace extends EventTarget {
  142323. }
  142324. interface XRRenderState {
  142325. depthNear?: number;
  142326. depthFar?: number;
  142327. inlineVerticalFieldOfView?: number;
  142328. baseLayer?: XRWebGLLayer;
  142329. }
  142330. interface XRInputSource {
  142331. handedness: XRHandedness;
  142332. targetRayMode: XRTargetRayMode;
  142333. targetRaySpace: XRSpace;
  142334. gripSpace: XRSpace | undefined;
  142335. gamepad: Gamepad | undefined;
  142336. profiles: Array<string>;
  142337. }
  142338. interface XRSessionInit {
  142339. optionalFeatures?: XRReferenceSpaceType[];
  142340. requiredFeatures?: XRReferenceSpaceType[];
  142341. }
  142342. interface XRSession extends XRAnchorCreator {
  142343. addEventListener: Function;
  142344. removeEventListener: Function;
  142345. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  142346. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  142347. requestAnimationFrame: Function;
  142348. end(): Promise<void>;
  142349. renderState: XRRenderState;
  142350. inputSources: Array<XRInputSource>;
  142351. // AR hit test
  142352. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  142353. updateWorldTrackingState(options: {
  142354. planeDetectionState?: { enabled: boolean; }
  142355. }): void;
  142356. }
  142357. interface XRReferenceSpace extends XRSpace {
  142358. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  142359. onreset: any;
  142360. }
  142361. type XRPlaneSet = Set<XRPlane>;
  142362. type XRAnchorSet = Set<XRAnchor>;
  142363. interface XRFrame {
  142364. session: XRSession;
  142365. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  142366. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  142367. // Anchors
  142368. trackedAnchors?: XRAnchorSet;
  142369. // Planes
  142370. worldInformation: {
  142371. detectedPlanes?: XRPlaneSet;
  142372. };
  142373. }
  142374. interface XRViewerPose extends XRPose {
  142375. views: Array<XRView>;
  142376. }
  142377. interface XRPose {
  142378. transform: XRRigidTransform;
  142379. emulatedPosition: boolean;
  142380. }
  142381. interface XRWebGLLayerOptions {
  142382. antialias?: boolean;
  142383. depth?: boolean;
  142384. stencil?: boolean;
  142385. alpha?: boolean;
  142386. multiview?: boolean;
  142387. framebufferScaleFactor?: number;
  142388. }
  142389. declare var XRWebGLLayer: {
  142390. prototype: XRWebGLLayer;
  142391. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  142392. };
  142393. interface XRWebGLLayer {
  142394. framebuffer: WebGLFramebuffer;
  142395. framebufferWidth: number;
  142396. framebufferHeight: number;
  142397. getViewport: Function;
  142398. }
  142399. declare class XRRigidTransform {
  142400. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  142401. position: DOMPointReadOnly;
  142402. orientation: DOMPointReadOnly;
  142403. matrix: Float32Array;
  142404. inverse: XRRigidTransform;
  142405. }
  142406. interface XRView {
  142407. eye: XREye;
  142408. projectionMatrix: Float32Array;
  142409. transform: XRRigidTransform;
  142410. }
  142411. interface XRInputSourceChangeEvent {
  142412. session: XRSession;
  142413. removed: Array<XRInputSource>;
  142414. added: Array<XRInputSource>;
  142415. }
  142416. interface XRInputSourceEvent extends Event {
  142417. readonly frame: XRFrame;
  142418. readonly inputSource: XRInputSource;
  142419. }
  142420. // Experimental(er) features
  142421. declare class XRRay {
  142422. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  142423. origin: DOMPointReadOnly;
  142424. direction: DOMPointReadOnly;
  142425. matrix: Float32Array;
  142426. }
  142427. interface XRHitResult {
  142428. hitMatrix: Float32Array;
  142429. }
  142430. interface XRAnchor {
  142431. // remove?
  142432. id?: string;
  142433. anchorSpace: XRSpace;
  142434. lastChangedTime: number;
  142435. detach(): void;
  142436. }
  142437. interface XRPlane extends XRAnchorCreator {
  142438. orientation: "Horizontal" | "Vertical";
  142439. planeSpace: XRSpace;
  142440. polygon: Array<DOMPointReadOnly>;
  142441. lastChangedTime: number;
  142442. }
  142443. interface XRAnchorCreator {
  142444. // AR Anchors
  142445. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  142446. }